Skip to contentSkip to conversation

switchdev: support stp updates on stacked netdevices

PATCH In review [email protected] 4 participants 14 messages Mar 13, 2015 – Mar 16, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover switchdev: support stp updates on stacked netdevices

From: Roopa Prabhu <[email protected]>

This series moves bridge stp update api to follow the setlink/dellink apis to propagate stp state updates to switch ports on stacked netdevs

v1 -> v2:
fix comment
add CONFIG_NET_SWITCHDEV checks

Roopa Prabhu (3):
switchdev: fix stp update API to work with layered netdevices
bond: add support for ndo_switch_port_stp_update when bond is a
bridge port
team: add support for ndo_switch_port_stp_update when team dev is a
bridge port

 drivers/net/bonding/bond_main.c |    3 +++
 drivers/net/team/team.c         |    3 +++
 include/net/switchdev.h         |    4 ++++
 net/switchdev/switchdev.c       |   30 +++++++++++++++++++++++++++++-
 4 files changed, 39 insertions(+), 1 deletion(-)
Signature · 1 line
1.7.10.4
maintainer
#1 lore raw

From: [email protected]
Date: Thu, 12 Mar 2015 17:29:55 -0700

Quoted 10 lines

From: Roopa Prabhu <[email protected]>

This series moves bridge stp update api to follow the setlink/dellink apis to propagate stp state updates to switch ports on stacked netdevs

v1 -> v2:
fix comment
add CONFIG_NET_SWITCHDEV checks

Can't we just do this stacked device traveral transparently?

That seems much cleaner to me.

author
#2 lore raw
Quoted 8 lines · David Miller

From: [email protected]
Date: Thu, 12 Mar 2015 17:29:55 -0700

Quoted 5 lines

From: Roopa Prabhu <[email protected]>

This series moves bridge stp update api to follow the setlink/dellink apis to propagate stp state updates to switch ports on stacked netdevs

Quoted 8 lines
Quoted 5 lines

v1 -> v2:
fix comment
add CONFIG_NET_SWITCHDEV checks

Can't we just do this stacked device traveral transparently?

That seems much cleaner to me.

David, if you mean not touch bond and team but have the switchdev api do it transparently, yes, i had it that way initially.
And i do liked it that way as well. But the feedback i received (during the initial introduction of this for setlink/dellink) was to make it explicit for each master.

Thanks,
Roopa

maintainer
#3 lore raw

From: roopa <[email protected]>
Date: Fri, 13 Mar 2015 06:25:24 -0700

Quoted 5 lines

David, if you mean not touch bond and team but have the switchdev api do it transparently, yes, i had it that way initially. And i do liked it that way as well. But the feedback i received (during the initial introduction of this for setlink/dellink) was to make it explicit for each master.

I think the concern is that we only want to do this for devices for which it is safe to "traverse" down like this.

But frankly I cannot think of any layered device where we would not want to do this.

Let's go back to the simple scheme where we unconditionally traverse and if we hit a problem case we'll figure out how to deal with it then, ok?

author
#4 lore raw
Quoted 11 lines · David Miller

From: roopa <[email protected]>
Date: Fri, 13 Mar 2015 06:25:24 -0700

Quoted 5 lines

David, if you mean not touch bond and team but have the switchdev api do it transparently, yes, i had it that way initially. And i do liked it that way as well. But the feedback i received (during the initial introduction of this for setlink/dellink) was to make it explicit for each master.

I think the concern is that we only want to do this for devices for which it is safe to "traverse" down like this.

Quoted 6 lines

But frankly I cannot think of any layered device where we would not want to do this.

Let's go back to the simple scheme where we unconditionally traverse and if we hit a problem case we'll figure out how to deal with it then, ok?

ok, sounds great. I will respin. Thanks!.

I wanted to move all three ops setlink/dellink/stpupdate initially, but now realize that for something like the below to work, you will need the setlink/dellink support in the bond and team driver because the call goes into the 'dev' driver directly without calling into the switchdev api.

bridge link set dev bond0 learning off self

This case can be fixed too, however, it needs some more work in rtnetlink.c handling of 'self'. The stp update api does not have this problem. I will respin the current stp update series first.

#5 lore raw
In reply to David Miller
Quoted 11 lines · Fri, Mar 13, 2015 at 05:31:56PM CET, [email protected] wrote:

From: roopa <[email protected]>
Date: Fri, 13 Mar 2015 06:25:24 -0700

Quoted 5 lines

David, if you mean not touch bond and team but have the switchdev api do it transparently, yes, i had it that way initially. And i do liked it that way as well. But the feedback i received (during the initial introduction of this for setlink/dellink) was to make it explicit for each master.

I think the concern is that we only want to do this for devices for which it is safe to "traverse" down like this.

Yes, that was my point. Also, some layered drivers might want to do some individual magic, propagate on condition, etc. I think it is clearer architecture. And also, you can see right away what is happening. By doing the travelsal directly in switchdev code, that is in the shadow :/

Quoted 7 lines

But frankly I cannot think of any layered device where we would not want to do this.

Let's go back to the simple scheme where we unconditionally traverse and if we hit a problem case we'll figure out how to deal with it then, ok?

maintainer
#6 lore raw

From: Jiri Pirko <[email protected]>
Date: Sun, 15 Mar 2015 17:56:32 +0100

Quoted 10 lines
Quoted 9 lines · Fri, Mar 13, 2015 at 05:31:56PM CET, [email protected] wrote:

From: roopa <[email protected]>
Date: Fri, 13 Mar 2015 06:25:24 -0700

Quoted 5 lines

David, if you mean not touch bond and team but have the switchdev api do it transparently, yes, i had it that way initially. And i do liked it that way as well. But the feedback i received (during the initial introduction of this for setlink/dellink) was to make it explicit for each master.

Quoted 7 lines
Quoted 2 lines

I think the concern is that we only want to do this for devices for which it is safe to "traverse" down like this.

Yes, that was my point. Also, some layered drivers might want to do some individual magic, propagate on condition, etc. I think it is clearer architecture. And also, you can see right away what is happening. By doing the travelsal directly in switchdev code, that is in the shadow :/

I think special behavior would be the exception rather than the norm, and we should code our interfaces for the common case.

This means we can add a per-device flag to avoid this logic if necessary.

Notice how you use lots of words like "might", and I hate designing interfaces without hard explicit real word examples of the actual precise need.

So don't use open ended reasons like that for justifying the design of our interfaces.

#7 lore raw
In reply to David Miller
Quoted 12 lines · David Miller

From: roopa <[email protected]>
Date: Fri, 13 Mar 2015 06:25:24 -0700

Quoted 5 lines

David, if you mean not touch bond and team but have the switchdev api do it transparently, yes, i had it that way initially. And i do liked it that way as well. But the feedback i received (during the initial introduction of this for setlink/dellink) was to make it explicit for each master.

I think the concern is that we only want to do this for devices for which it is safe to "traverse" down like this.

Quoted 6 lines

But frankly I cannot think of any layered device where we would not want to do this.

Let's go back to the simple scheme where we unconditionally traverse and if we hit a problem case we'll figure out how to deal with it then, ok?

Here's a way to do it without touching team/bonding/vlan drivers, but also giving us flexibility to down the road to intercept the call in the team/bonding/vlan driver and change the behavior by implementing swdev_port_stp_update in the middle driver.

I would prefer this approach not only for STP updates but also for port attr set/get calls.

/**
* netdev_switch_port_stp_update - Notify switch device port of STP
* state change
* @dev: bridge port device
* @state: bridge port STP state
*
* Notify switch device port of bridge port STP state change.
*/
int netdev_switch_port_stp_update(struct net_device *dev, u8 state)

{
        const struct swdev_ops *ops = dev->swdev_ops;
        struct net_device *lower_dev;
        struct list_head *iter;
        int err = -EOPNOTSUPP;

        if (ops && ops->swdev_port_stp_update)
                return ops->swdev_port_stp_update(dev, state);

        /* Bridged switch device port(s) may be stacked under
         * bond/team/vlan dev, so recurse down to stp-update
         * them one at a time.
         */

        netdev_for_each_lower_dev(dev, lower_dev, iter) {
                err = netdev_switch_port_stp_update(lower_dev, state);
                if (err && err != -EOPNOTSUPP)
                        return err;
        }

        return err;
}

EXPORT_SYMBOL_GPL(netdev_switch_port_stp_update);

#8 lore raw
Quoted 49 lines · Sun, Mar 15, 2015 at 07:08:02PM CET, [email protected] wrote:
Quoted 12 lines · David Miller

From: roopa <[email protected]>
Date: Fri, 13 Mar 2015 06:25:24 -0700

Quoted 5 lines

David, if you mean not touch bond and team but have the switchdev api do it transparently, yes, i had it that way initially. And i do liked it that way as well. But the feedback i received (during the initial introduction of this for setlink/dellink) was to make it explicit for each master.

I think the concern is that we only want to do this for devices for which it is safe to "traverse" down like this.

Quoted 6 lines

But frankly I cannot think of any layered device where we would not want to do this.

Let's go back to the simple scheme where we unconditionally traverse and if we hit a problem case we'll figure out how to deal with it then, ok?

Here's a way to do it without touching team/bonding/vlan drivers, but also giving us flexibility to down the road to intercept the call in the team/bonding/vlan driver and change the behavior by implementing swdev_port_stp_update in the middle driver.

I would prefer this approach not only for STP updates but also for port attr set/get calls.

/**
* netdev_switch_port_stp_update - Notify switch device port of STP
* state change
* @dev: bridge port device
* @state: bridge port STP state
*
* Notify switch device port of bridge port STP state change.
*/
int netdev_switch_port_stp_update(struct net_device *dev, u8 state)

{
       const struct swdev_ops *ops = dev->swdev_ops;
       struct net_device *lower_dev;
       struct list_head *iter;
       int err = -EOPNOTSUPP;

       if (ops && ops->swdev_port_stp_update)
               return ops->swdev_port_stp_update(dev, state);

       /* Bridged switch device port(s) may be stacked under
        * bond/team/vlan dev, so recurse down to stp-update
Quoted 8 lines
        * them one at a time.
        */

       netdev_for_each_lower_dev(dev, lower_dev, iter) {
               err = netdev_switch_port_stp_update(lower_dev, state);
               if (err && err != -EOPNOTSUPP)
                       return err;
       }

I don't like this blind approach. Note that with this, you enable this for lower devices of:
bond
ipvlan
macvlan
team
vlan
batman-adv

Does that make sense? I think it is better just pick what we want to support now and implement it there. That makes things clearer and confusion-prone.

Jiri

#9 lore raw
Quoted 60 lines · Jiri Pirko
Quoted 49 lines · Sun, Mar 15, 2015 at 07:08:02PM CET, [email protected] wrote:
Quoted 12 lines · David Miller

From: roopa <[email protected]>
Date: Fri, 13 Mar 2015 06:25:24 -0700

Quoted 5 lines

David, if you mean not touch bond and team but have the switchdev api do it transparently, yes, i had it that way initially. And i do liked it that way as well. But the feedback i received (during the initial introduction of this for setlink/dellink) was to make it explicit for each master.

I think the concern is that we only want to do this for devices for which it is safe to "traverse" down like this.

Quoted 6 lines

But frankly I cannot think of any layered device where we would not want to do this.

Let's go back to the simple scheme where we unconditionally traverse and if we hit a problem case we'll figure out how to deal with it then, ok?

Here's a way to do it without touching team/bonding/vlan drivers, but also giving us flexibility to down the road to intercept the call in the team/bonding/vlan driver and change the behavior by implementing swdev_port_stp_update in the middle driver.

I would prefer this approach not only for STP updates but also for port attr set/get calls.

/**
* netdev_switch_port_stp_update - Notify switch device port of STP
* state change
* @dev: bridge port device
* @state: bridge port STP state
*
* Notify switch device port of bridge port STP state change.
*/
int netdev_switch_port_stp_update(struct net_device *dev, u8 state)

{
       const struct swdev_ops *ops = dev->swdev_ops;
       struct net_device *lower_dev;
       struct list_head *iter;
       int err = -EOPNOTSUPP;

       if (ops && ops->swdev_port_stp_update)
               return ops->swdev_port_stp_update(dev, state);

       /* Bridged switch device port(s) may be stacked under
        * bond/team/vlan dev, so recurse down to stp-update
Quoted 8 lines
        * them one at a time.
        */

       netdev_for_each_lower_dev(dev, lower_dev, iter) {
               err = netdev_switch_port_stp_update(lower_dev, state);
               if (err && err != -EOPNOTSUPP)
                       return err;
       }
Quoted 8 lines

I don't like this blind approach. Note that with this, you enable this for lower devices of:
bond
ipvlan
macvlan
team
vlan
batman-adv

Only when they're used under a bridge because netdev_switch_port_stp_update() is currently only called from the bridge. So this is what we want, to propagate the stp state change down to the base port, regardless of middle drivers. If you want to exclude a middle driver from propagating stp down to the base port, or otherwise change the default propagation, add stub swdev_port_stp_update to middle driver.

Quoted 3 lines

Does that make sense? I think it is better just pick what we want to support now and implement it there. That makes things clearer and confusion-prone.

I'm proposing a simple, permissive solution, with a provision for an out on a case-by-case basis. Right now I don't see any reason to special case any middle driver; just let STP state propagate down to the port device.

-scott

maintainer
#10 lore raw

From: Scott Feldman <[email protected]>
Date: Sun, 15 Mar 2015 13:03:06 -0700

Quoted 4 lines

I'm proposing a simple, permissive solution, with a provision for an out on a case-by-case basis. Right now I don't see any reason to special case any middle driver; just let STP state propagate down to the port device.

+1

author
#11 lore raw
Quoted 8 lines · David Miller

From: Scott Feldman <[email protected]>
Date: Sun, 15 Mar 2015 13:03:06 -0700

Quoted 4 lines

I'm proposing a simple, permissive solution, with a provision for an out on a case-by-case basis. Right now I don't see any reason to special case any middle driver; just let STP state propagate down to the port device.

+1

ok. That was the path i had taken initially (see for getlink/setlink):
http://www.spinics.net/lists/netdev/msg313436.html

I have resubmitted the patch with rollback to transparently following lowerdevs. My version also does not follow lowerdevs if NETIF_F_HW_SWITCH_OFFLOAD is not set. And this is set on bonds and teams if any one of their lowerdevs have it currently.

thanks.

maintainer
#12 lore raw
In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>
Date: Sun, 15 Mar 2015 20:17:22 +0100

Quoted 3 lines

Does that make sense? I think it is better just pick what we want to support now and implement it there. That makes things clearer and confusion-prone.

You can't even say whether it makes sense or not, you yourself even have to ask.

Again, I don't want to design our interfaces for potential needs, I want to design them for actually known needs.

We'll deal with the discovered exceptions on an as-needed basis, not from the beginning.

#13 lore raw
Quoted 7 lines · Sun, Mar 15, 2015 at 11:32:13PM CET, [email protected] wrote:

From: Jiri Pirko <[email protected]>
Date: Sun, 15 Mar 2015 20:17:22 +0100

Quoted 3 lines

Does that make sense? I think it is better just pick what we want to support now and implement it there. That makes things clearer and confusion-prone.

Quoted 8 lines

You can't even say whether it makes sense or not, you yourself even have to ask.

Again, I don't want to design our interfaces for potential needs, I want to design them for actually known needs.

We'll deal with the discovered exceptions on an as-needed basis, not from the beginning.

Fair enough...