system-linux: get rid of SIOCSDEVPRIVATE
authorHans Dedecker <dedeckeh@gmail.com>
Thu, 13 Dec 2018 15:13:06 +0000 (16:13 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Thu, 13 Dec 2018 16:22:14 +0000 (17:22 +0100)
Use sysfs to configure the bridge settings stp/forward_delay/priority
ageing_time/hello_time and max_age as the SIOCDEVPRIVATE bridge ioctl
has no compat ioctl support which makes it impossible to set the above
mentioned bridge paramaters if the kernel is compiled in 64 bit mode
and user_space in 32 bit mode.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
system-linux.c

index 9694c6f68d1f5ceda63dcfcc9928ac6df86115e8..ea16ed5aede732104bfb17f40f0d0a1c59dca3c8 100644 (file)
@@ -403,6 +403,36 @@ 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)
+{
+       system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/stp_state", dev->ifname, val);
+}
+
+static void system_bridge_set_forward_delay(struct device *dev, const char *val)
+{
+       system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/forward_delay", dev->ifname, val);
+}
+
+static void system_bridge_set_priority(struct device *dev, const char *val)
+{
+       system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/priority", dev->ifname, val);
+}
+
+static void system_bridge_set_ageing_time(struct device *dev, const char *val)
+{
+       system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/ageing_time", dev->ifname, val);
+}
+
+static void system_bridge_set_hello_time(struct device *dev, const char *val)
+{
+       system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/hello_time", dev->ifname, val);
+}
+
+static void system_bridge_set_max_age(struct device *dev, const char *val)
+{
+       system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/max_age", dev->ifname, val);
+}
+
 static void system_bridge_set_learning(struct device *dev, const char *val)
 {
        system_set_dev_sysctl("/sys/class/net/%s/brport/learning", dev->ifname, val);
@@ -1061,41 +1091,33 @@ static void system_bridge_conf_multicast(struct device *bridge,
 int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg)
 {
        char buf[64];
-       unsigned long args[4] = {};
 
        if (ioctl(sock_ioctl, SIOCBRADDBR, bridge->ifname) < 0)
                return -1;
 
-       args[0] = BRCTL_SET_BRIDGE_STP_STATE;
-       args[1] = !!cfg->stp;
-       system_bridge_if(bridge->ifname, NULL, SIOCDEVPRIVATE, &args);
+       system_bridge_set_stp_state(bridge, cfg->stp ? "1" : "0");
 
-       args[0] = BRCTL_SET_BRIDGE_FORWARD_DELAY;
-       args[1] = sec_to_jiffies(cfg->forward_delay);
-       system_bridge_if(bridge->ifname, NULL, SIOCDEVPRIVATE, &args);
+       snprintf(buf, sizeof(buf), "%lu", sec_to_jiffies(cfg->forward_delay));
+       system_bridge_set_forward_delay(bridge, buf);
 
        system_bridge_conf_multicast(bridge, cfg, buf, sizeof(buf));
 
-       args[0] = BRCTL_SET_BRIDGE_PRIORITY;
-       args[1] = cfg->priority;
-       system_bridge_if(bridge->ifname, NULL, SIOCDEVPRIVATE, &args);
+       snprintf(buf, sizeof(buf), "%d", cfg->priority);
+       system_bridge_set_priority(bridge, buf);
 
        if (cfg->flags & BRIDGE_OPT_AGEING_TIME) {
-               args[0] = BRCTL_SET_AGEING_TIME;
-               args[1] = sec_to_jiffies(cfg->ageing_time);
-               system_bridge_if(bridge->ifname, NULL, SIOCDEVPRIVATE, &args);
+               snprintf(buf, sizeof(buf), "%lu", sec_to_jiffies(cfg->ageing_time));
+               system_bridge_set_ageing_time(bridge, buf);
        }
 
        if (cfg->flags & BRIDGE_OPT_HELLO_TIME) {
-               args[0] = BRCTL_SET_BRIDGE_HELLO_TIME;
-               args[1] = sec_to_jiffies(cfg->hello_time);
-               system_bridge_if(bridge->ifname, NULL, SIOCDEVPRIVATE, &args);
+               snprintf(buf, sizeof(buf), "%lu", sec_to_jiffies(cfg->hello_time));
+               system_bridge_set_hello_time(bridge, buf);
        }
 
        if (cfg->flags & BRIDGE_OPT_MAX_AGE) {
-               args[0] = BRCTL_SET_BRIDGE_MAX_AGE;
-               args[1] = sec_to_jiffies(cfg->max_age);
-               system_bridge_if(bridge->ifname, NULL, SIOCDEVPRIVATE, &args);
+               snprintf(buf, sizeof(buf), "%lu", sec_to_jiffies(cfg->max_age));
+               system_bridge_set_max_age(bridge, buf);
        }
 
        return 0;