]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
bridge: push bridge setting ageing_time down to switchdev
authorScott Feldman <sfeldma@gmail.com>
Fri, 9 Oct 2015 02:23:19 +0000 (19:23 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 12 Oct 2015 12:20:20 +0000 (05:20 -0700)
Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge that don't
support setting ageing_time (or setting bridge attrs in general).

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now to
recalabrate when to run gc_timer next, based on new ageing_time.

Signed-off-by: Scott Feldman <sfeldma@gmail.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_ioctl.c
net/bridge/br_netlink.c
net/bridge/br_private.h
net/bridge/br_stp.c
net/bridge/br_sysfs_br.c

index 8d423bc649b9c4a2829499dffb0ba88d952af128..263b4de4de57ccf4beddbfc48e62967236450b9b 100644 (file)
@@ -200,8 +200,7 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
                if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
                        return -EPERM;
 
-               br->ageing_time = clock_t_to_jiffies(args[1]);
-               return 0;
+               return br_set_ageing_time(br, args[1]);
 
        case BRCTL_GET_PORT_INFO:
        {
index d78b4429505a98898ceb4f4f30e5cbf9ebd89876..544ab966d47704639bf3def6addb36bf44f15e8a 100644 (file)
@@ -870,9 +870,9 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
        }
 
        if (data[IFLA_BR_AGEING_TIME]) {
-               u32 ageing_time = nla_get_u32(data[IFLA_BR_AGEING_TIME]);
-
-               br->ageing_time = clock_t_to_jiffies(ageing_time);
+               err = br_set_ageing_time(br, nla_get_u32(data[IFLA_BR_AGEING_TIME]));
+               if (err)
+                       return err;
        }
 
        if (data[IFLA_BR_STP_STATE]) {
index 09d3ecbcb4f02046430788e4c885aa49acbeb219..ba0c67b2159a59a277d8142d7871f3af91578c83 100644 (file)
@@ -882,6 +882,7 @@ void __br_set_forward_delay(struct net_bridge *br, unsigned long t);
 int br_set_forward_delay(struct net_bridge *br, unsigned long x);
 int br_set_hello_time(struct net_bridge *br, unsigned long x);
 int br_set_max_age(struct net_bridge *br, unsigned long x);
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time);
 
 
 /* br_stp_if.c */
index 3a982c02599ab4dc2d02d3023aeda299c617bad5..db6d243defb2dd0154887c273e4eb718ffab14b0 100644 (file)
@@ -566,6 +566,29 @@ int br_set_max_age(struct net_bridge *br, unsigned long val)
 
 }
 
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
+{
+       struct switchdev_attr attr = {
+               .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
+               .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
+               .u.ageing_time = ageing_time,
+       };
+       unsigned long t = clock_t_to_jiffies(ageing_time);
+       int err;
+
+       if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
+               return -ERANGE;
+
+       err = switchdev_port_attr_set(br->dev, &attr);
+       if (err)
+               return err;
+
+       br->ageing_time = t;
+       mod_timer(&br->gc_timer, jiffies);
+
+       return 0;
+}
+
 void __br_set_forward_delay(struct net_bridge *br, unsigned long t)
 {
        br->bridge_forward_delay = t;
index 4c97fc50fb704265bd2f51d96527cf3227a65118..04ef1926ee7eea204756c258e9b0689316ef5f15 100644 (file)
@@ -102,8 +102,7 @@ static ssize_t ageing_time_show(struct device *d,
 
 static int set_ageing_time(struct net_bridge *br, unsigned long val)
 {
-       br->ageing_time = clock_t_to_jiffies(val);
-       return 0;
+       return br_set_ageing_time(br, val);
 }
 
 static ssize_t ageing_time_store(struct device *d,