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

net: bridge: add helper to offload ageing time

The SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME switchdev attr is actually set
when initializing a bridge port, and when configuring the bridge ageing
time from ioctl/netlink/sysfs.

Add a __set_ageing_time helper to offload the ageing time to physical
switches, and add the SWITCHDEV_F_DEFER flag since it can be called
under bridge lock.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vivien Didelot and committed by
David S. Miller
82dd4332 bfd8d977

+24 -17
+1
net/bridge/br_private.h
··· 999 999 int br_set_forward_delay(struct net_bridge *br, unsigned long x); 1000 1000 int br_set_hello_time(struct net_bridge *br, unsigned long x); 1001 1001 int br_set_max_age(struct net_bridge *br, unsigned long x); 1002 + int __set_ageing_time(struct net_device *dev, unsigned long t); 1002 1003 int br_set_ageing_time(struct net_bridge *br, clock_t ageing_time); 1003 1004 1004 1005
+20 -8
net/bridge/br_stp.c
··· 562 562 563 563 } 564 564 565 + /* called under bridge lock */ 566 + int __set_ageing_time(struct net_device *dev, unsigned long t) 567 + { 568 + struct switchdev_attr attr = { 569 + .orig_dev = dev, 570 + .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME, 571 + .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP | SWITCHDEV_F_DEFER, 572 + .u.ageing_time = jiffies_to_clock_t(t), 573 + }; 574 + int err; 575 + 576 + err = switchdev_port_attr_set(dev, &attr); 577 + if (err && err != -EOPNOTSUPP) 578 + return err; 579 + 580 + return 0; 581 + } 582 + 565 583 /* Set time interval that dynamic forwarding entries live 566 584 * For pure software bridge, allow values outside the 802.1 567 585 * standard specification for special cases: ··· 590 572 */ 591 573 int br_set_ageing_time(struct net_bridge *br, clock_t ageing_time) 592 574 { 593 - struct switchdev_attr attr = { 594 - .orig_dev = br->dev, 595 - .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME, 596 - .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP, 597 - .u.ageing_time = ageing_time, 598 - }; 599 575 unsigned long t = clock_t_to_jiffies(ageing_time); 600 576 int err; 601 577 602 - err = switchdev_port_attr_set(br->dev, &attr); 603 - if (err && err != -EOPNOTSUPP) 578 + err = __set_ageing_time(br->dev, t); 579 + if (err) 604 580 return err; 605 581 606 582 br->ageing_time = t;
+3 -9
net/bridge/br_stp_if.c
··· 36 36 /* called under bridge lock */ 37 37 void br_init_port(struct net_bridge_port *p) 38 38 { 39 - struct switchdev_attr attr = { 40 - .orig_dev = p->dev, 41 - .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME, 42 - .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP | SWITCHDEV_F_DEFER, 43 - .u.ageing_time = jiffies_to_clock_t(p->br->ageing_time), 44 - }; 45 39 int err; 46 40 47 41 p->port_id = br_make_port_id(p->priority, p->port_no); ··· 44 50 p->topology_change_ack = 0; 45 51 p->config_pending = 0; 46 52 47 - err = switchdev_port_attr_set(p->dev, &attr); 48 - if (err && err != -EOPNOTSUPP) 49 - netdev_err(p->dev, "failed to set HW ageing time\n"); 53 + err = __set_ageing_time(p->dev, p->br->ageing_time); 54 + if (err) 55 + netdev_err(p->dev, "failed to offload ageing time\n"); 50 56 } 51 57 52 58 /* NO locks held */