Skip to content

Commit c62987b

Browse files
scottfeldmandavem330
authored andcommitted
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 <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 464314e commit c62987b

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

net/bridge/br_ioctl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
200200
if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
201201
return -EPERM;
202202

203-
br->ageing_time = clock_t_to_jiffies(args[1]);
204-
return 0;
203+
return br_set_ageing_time(br, args[1]);
205204

206205
case BRCTL_GET_PORT_INFO:
207206
{

net/bridge/br_netlink.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,9 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
870870
}
871871

872872
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;
876876
}
877877

878878
if (data[IFLA_BR_STP_STATE]) {

net/bridge/br_private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ void __br_set_forward_delay(struct net_bridge *br, unsigned long t);
882882
int br_set_forward_delay(struct net_bridge *br, unsigned long x);
883883
int br_set_hello_time(struct net_bridge *br, unsigned long x);
884884
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);
885886

886887

887888
/* br_stp_if.c */

net/bridge/br_stp.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,29 @@ int br_set_max_age(struct net_bridge *br, unsigned long val)
566566

567567
}
568568

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+
569592
void __br_set_forward_delay(struct net_bridge *br, unsigned long t)
570593
{
571594
br->bridge_forward_delay = t;

net/bridge/br_sysfs_br.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ static ssize_t ageing_time_show(struct device *d,
102102

103103
static int set_ageing_time(struct net_bridge *br, unsigned long val)
104104
{
105-
br->ageing_time = clock_t_to_jiffies(val);
106-
return 0;
105+
return br_set_ageing_time(br, val);
107106
}
108107

109108
static ssize_t ageing_time_store(struct device *d,

0 commit comments

Comments
 (0)