]> git.baikalelectronics.ru Git - kernel.git/commitdiff
bridge: mrp: Fix the usage of br_mrp_port_switchdev_set_state
authorHoratiu Vultur <horatiu.vultur@microchip.com>
Sat, 6 Feb 2021 21:47:33 +0000 (22:47 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 9 Feb 2021 00:20:57 +0000 (16:20 -0800)
The function br_mrp_port_switchdev_set_state was called both with MRP
port state and STP port state, which is an issue because they don't
match exactly.

Therefore, update the function to be used only with STP port state and
use the id SWITCHDEV_ATTR_ID_PORT_STP_STATE.

The choice of using STP over MRP is that the drivers already implement
SWITCHDEV_ATTR_ID_PORT_STP_STATE and already in SW we update the port
STP state.

Fixes: 3bb98758960608 ("bridge: mrp: Connect MRP API with the switchdev API")
Fixes: 7f15633558c1f2 ("bridge: switchdev: mrp: Implement MRP API for switchdev")
Fixes: 4d7917e59f25fd ("bridge: mrp: Add MRP interface.")
Reported-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_mrp.c
net/bridge/br_mrp_switchdev.c
net/bridge/br_private_mrp.h

index cec2c4e4561d06540a31a47ca6ae1a8f47c168b2..5aeae6ad17b37d8beac099bfd7db44b841941516 100644 (file)
@@ -557,19 +557,22 @@ int br_mrp_del(struct net_bridge *br, struct br_mrp_instance *instance)
 int br_mrp_set_port_state(struct net_bridge_port *p,
                          enum br_mrp_port_state_type state)
 {
+       u32 port_state;
+
        if (!p || !(p->flags & BR_MRP_AWARE))
                return -EINVAL;
 
        spin_lock_bh(&p->br->lock);
 
        if (state == BR_MRP_PORT_STATE_FORWARDING)
-               p->state = BR_STATE_FORWARDING;
+               port_state = BR_STATE_FORWARDING;
        else
-               p->state = BR_STATE_BLOCKING;
+               port_state = BR_STATE_BLOCKING;
 
+       p->state = port_state;
        spin_unlock_bh(&p->br->lock);
 
-       br_mrp_port_switchdev_set_state(p, state);
+       br_mrp_port_switchdev_set_state(p, port_state);
 
        return 0;
 }
index ed547e03ace173565b3ceaaf9d371bf40197931a..75a7e8d0a26853a2f5f167f89b4255915b0c26f3 100644 (file)
@@ -169,13 +169,12 @@ int br_mrp_switchdev_send_in_test(struct net_bridge *br, struct br_mrp *mrp,
        return err;
 }
 
-int br_mrp_port_switchdev_set_state(struct net_bridge_port *p,
-                                   enum br_mrp_port_state_type state)
+int br_mrp_port_switchdev_set_state(struct net_bridge_port *p, u32 state)
 {
        struct switchdev_attr attr = {
                .orig_dev = p->dev,
-               .id = SWITCHDEV_ATTR_ID_MRP_PORT_STATE,
-               .u.mrp_port_state = state,
+               .id = SWITCHDEV_ATTR_ID_PORT_STP_STATE,
+               .u.stp_state = state,
        };
        int err;
 
index 32a48e5418dac67af8daf4dcf9b4312ab89c321f..2514954c14316c00c5cb2a1e2dd0f49f3ccadc25 100644 (file)
@@ -72,8 +72,7 @@ int br_mrp_switchdev_set_ring_state(struct net_bridge *br, struct br_mrp *mrp,
 int br_mrp_switchdev_send_ring_test(struct net_bridge *br, struct br_mrp *mrp,
                                    u32 interval, u8 max_miss, u32 period,
                                    bool monitor);
-int br_mrp_port_switchdev_set_state(struct net_bridge_port *p,
-                                   enum br_mrp_port_state_type state);
+int br_mrp_port_switchdev_set_state(struct net_bridge_port *p, u32 state);
 int br_mrp_port_switchdev_set_role(struct net_bridge_port *p,
                                   enum br_mrp_port_role_type role);
 int br_mrp_switchdev_set_in_role(struct net_bridge *br, struct br_mrp *mrp,