Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: bridge: explicitly convert between mdb entry state and port group flags

When creating a new multicast port group, there is implicit conversion
between the __u8 state member of struct br_mdb_entry and the unsigned
char flags member of struct net_bridge_port_group. This implicit
conversion relies on the fact that MDB_PERMANENT is equal to
MDB_PG_FLAGS_PERMANENT.

Let's be more explicit and convert the state to flags manually.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://lore.kernel.org/r/20201028234815.613226-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vladimir Oltean and committed by
Jakub Kicinski
0e761ac0 955062b0

+5 -1
+5 -1
net/bridge/br_mdb.c
··· 846 846 struct net_bridge_port_group __rcu **pp; 847 847 struct br_ip group, star_group; 848 848 unsigned long now = jiffies; 849 + unsigned char flags = 0; 849 850 u8 filter_mode; 850 851 int err; 851 852 ··· 905 904 filter_mode = br_multicast_is_star_g(&group) ? MCAST_EXCLUDE : 906 905 MCAST_INCLUDE; 907 906 908 - p = br_multicast_new_port_group(port, &group, *pp, entry->state, NULL, 907 + if (entry->state == MDB_PERMANENT) 908 + flags |= MDB_PG_FLAGS_PERMANENT; 909 + 910 + p = br_multicast_new_port_group(port, &group, *pp, flags, NULL, 909 911 filter_mode, RTPROT_STATIC); 910 912 if (unlikely(!p)) { 911 913 NL_SET_ERR_MSG_MOD(extack, "Couldn't allocate new port group");