Igor Mitsyanko
2018-Mar-10 03:03 UTC
[Bridge] [PATCH net-next 2/5] bridge: propagate BR_ flags updates through sysfs to switchdev
sysfs interface to configure bridge flags only updates SW copy but does not notify hardware through switchdev interface. Make sure it is. Signed-off-by: Igor Mitsyanko <igor.mitsyanko.os at quantenna.com> --- net/bridge/br_sysfs_if.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c index 126a8ea..9bdd177 100644 --- a/net/bridge/br_sysfs_if.c +++ b/net/bridge/br_sysfs_if.c @@ -51,6 +51,7 @@ static int store_flag(struct net_bridge_port *p, unsigned long v, unsigned long mask) { unsigned long flags; + int err; flags = p->flags; @@ -59,10 +60,16 @@ static int store_flag(struct net_bridge_port *p, unsigned long v, else flags &= ~mask; - if (flags != p->flags) { - p->flags = flags; - br_port_flags_change(p, mask); - } + if (flags == p->flags) + return 0; + + err = br_switchdev_set_port_flag(p, flags, mask); + if (err) + return err; + + p->flags = flags; + br_port_flags_change(p, mask); + return 0; } -- 2.9.5
Andrew Lunn
2018-Mar-10 16:38 UTC
[Bridge] [PATCH net-next 2/5] bridge: propagate BR_ flags updates through sysfs to switchdev
On Fri, Mar 09, 2018 at 07:03:05PM -0800, Igor Mitsyanko wrote:> sysfs interface to configure bridge flags only updates SW copy but does > not notify hardware through switchdev interface. Make sure it is. > > Signed-off-by: Igor Mitsyanko <igor.mitsyanko.os at quantenna.com> > --- > net/bridge/br_sysfs_if.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c > index 126a8ea..9bdd177 100644 > --- a/net/bridge/br_sysfs_if.c > +++ b/net/bridge/br_sysfs_if.c > @@ -51,6 +51,7 @@ static int store_flag(struct net_bridge_port *p, unsigned long v, > unsigned long mask) > { > unsigned long flags; > + int err; > > flags = p->flags; > > @@ -59,10 +60,16 @@ static int store_flag(struct net_bridge_port *p, unsigned long v, > else > flags &= ~mask; > > - if (flags != p->flags) { > - p->flags = flags; > - br_port_flags_change(p, mask); > - } > + if (flags == p->flags) > + return 0; > + > + err = br_switchdev_set_port_flag(p, flags, mask); > + if (err) > + return err;You might want to consider the br_warn() in br_switchdev_set_port_flag(). Do we want to spam the kernel log? Or should store_flag() do some validation before calling br_switchdev_set_port_flag()? Andrew