Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bridge: push bridge setting ageing_time down to switchdev

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>

authored by

Scott Feldman and committed by
David S. Miller
c62987bb 464314ea

+29 -7
+1 -2
net/bridge/br_ioctl.c
··· 200 200 if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN)) 201 201 return -EPERM; 202 202 203 - br->ageing_time = clock_t_to_jiffies(args[1]); 204 - return 0; 203 + return br_set_ageing_time(br, args[1]); 205 204 206 205 case BRCTL_GET_PORT_INFO: 207 206 {
+3 -3
net/bridge/br_netlink.c
··· 870 870 } 871 871 872 872 if (data[IFLA_BR_AGEING_TIME]) { 873 - u32 ageing_time = nla_get_u32(data[IFLA_BR_AGEING_TIME]); 874 - 875 - br->ageing_time = clock_t_to_jiffies(ageing_time); 873 + err = br_set_ageing_time(br, nla_get_u32(data[IFLA_BR_AGEING_TIME])); 874 + if (err) 875 + return err; 876 876 } 877 877 878 878 if (data[IFLA_BR_STP_STATE]) {
+1
net/bridge/br_private.h
··· 882 882 int br_set_forward_delay(struct net_bridge *br, unsigned long x); 883 883 int br_set_hello_time(struct net_bridge *br, unsigned long x); 884 884 int br_set_max_age(struct net_bridge *br, unsigned long x); 885 + int br_set_ageing_time(struct net_bridge *br, u32 ageing_time); 885 886 886 887 887 888 /* br_stp_if.c */
+23
net/bridge/br_stp.c
··· 566 566 567 567 } 568 568 569 + int br_set_ageing_time(struct net_bridge *br, u32 ageing_time) 570 + { 571 + struct switchdev_attr attr = { 572 + .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME, 573 + .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP, 574 + .u.ageing_time = ageing_time, 575 + }; 576 + unsigned long t = clock_t_to_jiffies(ageing_time); 577 + int err; 578 + 579 + if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME) 580 + return -ERANGE; 581 + 582 + err = switchdev_port_attr_set(br->dev, &attr); 583 + if (err) 584 + return err; 585 + 586 + br->ageing_time = t; 587 + mod_timer(&br->gc_timer, jiffies); 588 + 589 + return 0; 590 + } 591 + 569 592 void __br_set_forward_delay(struct net_bridge *br, unsigned long t) 570 593 { 571 594 br->bridge_forward_delay = t;
+1 -2
net/bridge/br_sysfs_br.c
··· 102 102 103 103 static int set_ageing_time(struct net_bridge *br, unsigned long val) 104 104 { 105 - br->ageing_time = clock_t_to_jiffies(val); 106 - return 0; 105 + return br_set_ageing_time(br, val); 107 106 } 108 107 109 108 static ssize_t ageing_time_store(struct device *d,