Merge branch 'bridge-mrp-Update-MRP_PORT_ROLE'

Horatiu Vultur says:

====================
bridge: mrp: Update MRP_PORT_ROLE

This patch series does the following:
- fixes the enum br_mrp_port_role_type. It removes the port role none(0x2)
  because this is in conflict with the standard. The standard defines the
  interconnect port role as value 0x2.
- adds checks regarding current defined port roles: primary(0x0) and
  secondary(0x1).

v2:
 - add the validation code when setting the port role.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David S. Miller 2020-06-23 14:38:05 -07:00
commit f7fb92acd9
2 changed files with 8 additions and 3 deletions

View File

@ -36,7 +36,6 @@ enum br_mrp_port_state_type {
enum br_mrp_port_role_type { enum br_mrp_port_role_type {
BR_MRP_PORT_ROLE_PRIMARY, BR_MRP_PORT_ROLE_PRIMARY,
BR_MRP_PORT_ROLE_SECONDARY, BR_MRP_PORT_ROLE_SECONDARY,
BR_MRP_PORT_ROLE_NONE,
}; };
enum br_mrp_tlv_header_type { enum br_mrp_tlv_header_type {

View File

@ -411,10 +411,16 @@ int br_mrp_set_port_role(struct net_bridge_port *p,
if (!mrp) if (!mrp)
return -EINVAL; return -EINVAL;
if (role == BR_MRP_PORT_ROLE_PRIMARY) switch (role) {
case BR_MRP_PORT_ROLE_PRIMARY:
rcu_assign_pointer(mrp->p_port, p); rcu_assign_pointer(mrp->p_port, p);
else break;
case BR_MRP_PORT_ROLE_SECONDARY:
rcu_assign_pointer(mrp->s_port, p); rcu_assign_pointer(mrp->s_port, p);
break;
default:
return -EINVAL;
}
br_mrp_port_switchdev_set_role(p, role); br_mrp_port_switchdev_set_role(p, role);