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

bridge: fix seq check in br_mdb_dump()

In case of rehashing, introduce a global variable 'br_mdb_rehash_seq'
which gets increased every time when rehashing, and assign
net->dev_base_seq + br_mdb_rehash_seq to cb->seq.

In theory cb->seq could be wrapped to zero, but this is not
easy to fix, as net->dev_base_seq is not visible inside
br_mdb_rehash(). In practice, this is rare.

Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Stephen Hemminger <shemminger@vyatta.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Graf <tgraf@suug.ch>
Cc: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Cong Wang <amwang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Cong Wang and committed by
David S. Miller
2ce297fc 2925f6c0

+5 -4
+2 -4
net/bridge/br_mdb.c
··· 117 117 118 118 rcu_read_lock(); 119 119 120 - /* TODO: in case of rehashing, we need to check 121 - * consistency for dumping. 122 - */ 123 - cb->seq = net->dev_base_seq; 120 + /* In theory this could be wrapped to 0... */ 121 + cb->seq = net->dev_base_seq + br_mdb_rehash_seq; 124 122 125 123 for_each_netdev_rcu(net, dev) { 126 124 if (dev->priv_flags & IFF_EBRIDGE) {
+2
net/bridge/br_multicast.c
··· 37 37 rcu_dereference_protected(X, lockdep_is_held(&br->multicast_lock)) 38 38 39 39 static void br_multicast_start_querier(struct net_bridge *br); 40 + unsigned int br_mdb_rehash_seq; 40 41 41 42 #if IS_ENABLED(CONFIG_IPV6) 42 43 static inline int ipv6_is_transient_multicast(const struct in6_addr *addr) ··· 339 338 return err; 340 339 } 341 340 341 + br_mdb_rehash_seq++; 342 342 call_rcu_bh(&mdb->rcu, br_mdb_free); 343 343 344 344 out:
+1
net/bridge/br_private.h
··· 411 411 412 412 /* br_multicast.c */ 413 413 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING 414 + extern unsigned int br_mdb_rehash_seq; 414 415 extern int br_multicast_rcv(struct net_bridge *br, 415 416 struct net_bridge_port *port, 416 417 struct sk_buff *skb);