summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDimitri John Ledkov <xnox@ubuntu.com>2017-04-11 22:17:31 +0100
committerMartin Pitt <martinpitt@users.noreply.github.com>2017-04-11 23:17:31 +0200
commitb56be2966a8a8bcc2432e37370bad5381498a819 (patch)
tree79083431600346ae3c1910f142b60d1948d40f7a /src
parentc618423a5aacb0378985f6d49d31be65866ab79a (diff)
networkd: Add bridge port priority setting (#5545)
Allow setting bridge port priority in the Bridge section of the network file, similar to e.g. port path cost setting. Set the default to an invalid value of 128, and only set the port priority when it's not 128. Unlike e.g. path cost, zero is a valid priority value. Add a networkd-test.py to check that bridge port priority is correctly set. Incidently, fix bridge port cost type and document valid ranges.
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-link.c5
-rw-r--r--src/network/networkd-link.h2
-rw-r--r--src/network/networkd-network-gperf.gperf3
-rw-r--r--src/network/networkd-network.c1
-rw-r--r--src/network/networkd-network.h3
5 files changed, 12 insertions, 2 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 0c1229336b..1797f144b6 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1325,6 +1325,11 @@ static int link_set_bridge(Link *link) {
if (r < 0)
return log_link_error_errno(link, r, "Could not append IFLA_BRPORT_COST attribute: %m");
}
+ if (link->network->priority != LINK_BRIDGE_PORT_PRIORITY_INVALID) {
+ r = sd_netlink_message_append_u16(req, IFLA_BRPORT_PRIORITY, link->network->priority);
+ if (r < 0)
+ return log_link_error_errno(link, r, "Could not append IFLA_BRPORT_PRIORITY attribute: %m");
+ }
r = sd_netlink_message_close_container(req);
if (r < 0)
diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
index e6190fbe57..010b38248a 100644
--- a/src/network/networkd-link.h
+++ b/src/network/networkd-link.h
@@ -33,6 +33,8 @@
#include "list.h"
#include "set.h"
+#define LINK_BRIDGE_PORT_PRIORITY_INVALID 128
+
typedef enum LinkState {
LINK_STATE_PENDING,
LINK_STATE_ENSLAVING,
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index 68052ba544..9658978651 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -119,12 +119,13 @@ DHCPServer.EmitTimezone, config_parse_bool,
DHCPServer.Timezone, config_parse_timezone, 0, offsetof(Network, dhcp_server_timezone)
DHCPServer.PoolOffset, config_parse_uint32, 0, offsetof(Network, dhcp_server_pool_offset)
DHCPServer.PoolSize, config_parse_uint32, 0, offsetof(Network, dhcp_server_pool_size)
-Bridge.Cost, config_parse_unsigned, 0, offsetof(Network, cost)
+Bridge.Cost, config_parse_uint32, 0, offsetof(Network, cost)
Bridge.UseBPDU, config_parse_bool, 0, offsetof(Network, use_bpdu)
Bridge.HairPin, config_parse_bool, 0, offsetof(Network, hairpin)
Bridge.FastLeave, config_parse_bool, 0, offsetof(Network, fast_leave)
Bridge.AllowPortToBeRoot, config_parse_bool, 0, offsetof(Network, allow_port_to_be_root)
Bridge.UnicastFlood, config_parse_bool, 0, offsetof(Network, unicast_flood)
+Bridge.Priority, config_parse_uint16, 0, offsetof(Network, priority)
BridgeFDB.MACAddress, config_parse_fdb_hwaddr, 0, 0
BridgeFDB.VLANId, config_parse_fdb_vlan_id, 0, 0
BridgeVLAN.PVID, config_parse_brvlan_pvid, 0, 0
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index fac42d8478..dd29b4ca48 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -165,6 +165,7 @@ static int network_load_one(Manager *manager, const char *filename) {
network->use_bpdu = true;
network->allow_port_to_be_root = true;
network->unicast_flood = true;
+ network->priority = LINK_BRIDGE_PORT_PRIORITY_INVALID;
network->lldp_mode = LLDP_MODE_ROUTERS_ONLY;
diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h
index 4ce066a764..d6f418d521 100644
--- a/src/network/networkd-network.h
+++ b/src/network/networkd-network.h
@@ -163,7 +163,8 @@ struct Network {
bool fast_leave;
bool allow_port_to_be_root;
bool unicast_flood;
- unsigned cost;
+ uint32_t cost;
+ uint16_t priority;
bool use_br_vlan;
uint16_t pvid;