Skip to content

Commit

Permalink
Merge branch 'bridge-mrp'
Browse files Browse the repository at this point in the history
Horatiu Vultur says:

====================
bridge: mrp: Fix br_mrp_port_switchdev_set_state

Based on the discussion here[1], there was a problem with the function
br_mrp_port_switchdev_set_state. The problem was that it was called
both with BR_STATE* and BR_MRP_PORT_STATE* types. This patch series
fixes this issue and removes SWITCHDEV_ATTR_ID_MRP_PORT_STAT because
is not used anymore.

[1] https://www.spinics.net/lists/netdev/msg714816.html
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Feb 9, 2021
2 parents 3aa6bce + 059d2a1 commit 6bbc088
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 0 additions & 2 deletions include/net/switchdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ enum switchdev_attr_id {
SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED,
SWITCHDEV_ATTR_ID_BRIDGE_MROUTER,
#if IS_ENABLED(CONFIG_BRIDGE_MRP)
SWITCHDEV_ATTR_ID_MRP_PORT_STATE,
SWITCHDEV_ATTR_ID_MRP_PORT_ROLE,
#endif
};
Expand All @@ -62,7 +61,6 @@ struct switchdev_attr {
u16 vlan_protocol; /* BRIDGE_VLAN_PROTOCOL */
bool mc_disabled; /* MC_DISABLED */
#if IS_ENABLED(CONFIG_BRIDGE_MRP)
u8 mrp_port_state; /* MRP_PORT_STATE */
u8 mrp_port_role; /* MRP_PORT_ROLE */
#endif
} u;
Expand Down
9 changes: 6 additions & 3 deletions net/bridge/br_mrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 3 additions & 4 deletions net/bridge/br_mrp_switchdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions net/bridge/br_private_mrp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6bbc088

Please sign in to comment.