summaryrefslogtreecommitdiff
path: root/system-linux.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2021-08-22 08:00:18 +0200
committerFelix Fietkau <nbd@nbd.name>2021-08-24 12:58:57 +0200
commit6519cf31e4b033fd4a03c031ad882166be84fa6d (patch)
tree78f2fa0ef9bb0f59994b5c404edf76026fbbdba2 /system-linux.c
parented84473b7af96f4fc4d161bf60eeaa51bed7077b (diff)
downloadnetifd-6519cf31e4b033fd4a03c031ad882166be84fa6d.tar.gz
bridge: add support for an external STP daemon
netifd notifies the stp daemon through the network.device object and sends STP related configuration parameters. The daemon can also trigger a STP restart in order to close the race on init Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'system-linux.c')
-rw-r--r--system-linux.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/system-linux.c b/system-linux.c
index c0ba279..e9a19f7 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -460,9 +460,11 @@ static void system_bridge_set_startup_query_interval(struct device *dev, const c
dev->ifname, val);
}
-static void system_bridge_set_stp_state(struct device *dev, const char *val)
+void system_bridge_set_stp_state(struct device *dev, bool val)
{
- system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/stp_state", dev->ifname, val);
+ const char *valstr = val ? "1" : "0";
+
+ system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/stp_state", dev->ifname, valstr);
}
static void system_bridge_set_forward_delay(struct device *dev, const char *val)
@@ -1263,7 +1265,7 @@ int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg)
if (ioctl(sock_ioctl, SIOCBRADDBR, bridge->ifname) < 0)
return -1;
- system_bridge_set_stp_state(bridge, cfg->stp ? "1" : "0");
+ system_bridge_set_stp_state(bridge, cfg->stp);
snprintf(buf, sizeof(buf), "%lu", sec_to_jiffies(cfg->forward_delay));
system_bridge_set_forward_delay(bridge, buf);