diff options
author | Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> | 2014-02-07 02:48:19 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-02-10 17:34:33 -0500 |
commit | 2836882fe07718fe3263745b1aa07284ec71871c (patch) | |
tree | c9fd17f8842c7093cd3c6cc2bfb66876abc1cdb0 /net/bridge/br_fdb.c | |
parent | a5642ab4744bc8c5a8c7ce7c6e30c01bd6bbc691 (diff) |
bridge: Fix the way to insert new local fdb entries in br_fdb_changeaddr
Since commit bc9a25d21ef8 ("bridge: Add vlan support for local fdb entries"),
br_fdb_changeaddr() has inserted a new local fdb entry only if it can
find old one. But if we have two ports where they have the same address
or user has deleted a local entry, there will be no entry for one of the
ports.
Example of problematic case:
ip link set eth0 address aa:bb:cc:dd:ee:ff
ip link set eth1 address aa:bb:cc:dd:ee:ff
brctl addif br0 eth0
brctl addif br0 eth1 # eth1 will not have a local entry due to dup.
ip link set eth1 address 12:34:56:78:90:ab
Then, the new entry for the address 12:34:56:78:90:ab will not be
created, and the bridge device will not be able to communicate.
Insert new entries regardless of whether we can find old entries or not.
Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Acked-by: Vlad Yasevich <vyasevic@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge/br_fdb.c')
-rw-r--r-- | net/bridge/br_fdb.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index ce5411995a63..96ab1d1748d0 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c | |||
@@ -92,8 +92,10 @@ static void fdb_delete(struct net_bridge *br, struct net_bridge_fdb_entry *f) | |||
92 | void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr) | 92 | void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr) |
93 | { | 93 | { |
94 | struct net_bridge *br = p->br; | 94 | struct net_bridge *br = p->br; |
95 | bool no_vlan = (nbp_get_vlan_info(p) == NULL) ? true : false; | 95 | struct net_port_vlans *pv = nbp_get_vlan_info(p); |
96 | bool no_vlan = !pv; | ||
96 | int i; | 97 | int i; |
98 | u16 vid; | ||
97 | 99 | ||
98 | spin_lock_bh(&br->hash_lock); | 100 | spin_lock_bh(&br->hash_lock); |
99 | 101 | ||
@@ -114,28 +116,37 @@ void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr) | |||
114 | f->addr.addr) && | 116 | f->addr.addr) && |
115 | nbp_vlan_find(op, vid)) { | 117 | nbp_vlan_find(op, vid)) { |
116 | f->dst = op; | 118 | f->dst = op; |
117 | goto insert; | 119 | goto skip_delete; |
118 | } | 120 | } |
119 | } | 121 | } |
120 | 122 | ||
121 | /* delete old one */ | 123 | /* delete old one */ |
122 | fdb_delete(br, f); | 124 | fdb_delete(br, f); |
123 | insert: | 125 | skip_delete: |
124 | /* insert new address, may fail if invalid | ||
125 | * address or dup. | ||
126 | */ | ||
127 | fdb_insert(br, p, newaddr, vid); | ||
128 | |||
129 | /* if this port has no vlan information | 126 | /* if this port has no vlan information |
130 | * configured, we can safely be done at | 127 | * configured, we can safely be done at |
131 | * this point. | 128 | * this point. |
132 | */ | 129 | */ |
133 | if (no_vlan) | 130 | if (no_vlan) |
134 | goto done; | 131 | goto insert; |
135 | } | 132 | } |
136 | } | 133 | } |
137 | } | 134 | } |
138 | 135 | ||
136 | insert: | ||
137 | /* insert new address, may fail if invalid address or dup. */ | ||
138 | fdb_insert(br, p, newaddr, 0); | ||
139 | |||
140 | if (no_vlan) | ||
141 | goto done; | ||
142 | |||
143 | /* Now add entries for every VLAN configured on the port. | ||
144 | * This function runs under RTNL so the bitmap will not change | ||
145 | * from under us. | ||
146 | */ | ||
147 | for_each_set_bit(vid, pv->vlan_bitmap, VLAN_N_VID) | ||
148 | fdb_insert(br, p, newaddr, vid); | ||
149 | |||
139 | done: | 150 | done: |
140 | spin_unlock_bh(&br->hash_lock); | 151 | spin_unlock_bh(&br->hash_lock); |
141 | } | 152 | } |