diff options
author | Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> | 2014-02-07 02:48:18 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-02-10 17:34:33 -0500 |
commit | a5642ab4744bc8c5a8c7ce7c6e30c01bd6bbc691 (patch) | |
tree | 5ede15fbe48d33f5620de09ac5e5514a9ea5bf44 /net/bridge/br_private.h | |
parent | b10bd54c05a6c3c96549f4642d7de23c99b9853b (diff) |
bridge: Fix the way to find old local fdb entries in br_fdb_changeaddr
br_fdb_changeaddr() assumes that there is at most one local entry per port
per vlan. It used to be true, but since commit 36fd2b63e3b4 ("bridge: allow
creating/deleting fdb entries via netlink"), it has not been so.
Therefore, the function might fail to search a correct previous address
to be deleted and delete an arbitrary local entry if user has added local
entries manually.
Example of problematic case:
ip link set eth0 address ee:ff:12:34:56:78
brctl addif br0 eth0
bridge fdb add 12:34:56:78:90:ab dev eth0 master
ip link set eth0 address aa:bb:cc:dd:ee:ff
Then, the address 12:34:56:78:90:ab might be deleted instead of
ee:ff:12:34:56:78, the original mac address of eth0.
Address this issue by introducing a new flag, added_by_user, to struct
net_bridge_fdb_entry.
Note that br_fdb_delete_by_port() has to set added_by_user to 0 in cases
like:
ip link set eth0 address 12:34:56:78:90:ab
ip link set eth1 address aa:bb:cc:dd:ee:ff
brctl addif br0 eth0
bridge fdb add aa:bb:cc:dd:ee:ff dev eth0 master
brctl addif br0 eth1
brctl delif br0 eth0
In this case, kernel should delete the user-added entry aa:bb:cc:dd:ee:ff,
but it also should have been added by "brctl addif br0 eth1" originally,
so we don't delete it and treat it a new kernel-created entry.
Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge/br_private.h')
-rw-r--r-- | net/bridge/br_private.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index fcd12333c59b..939a59e15036 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h | |||
@@ -104,6 +104,7 @@ struct net_bridge_fdb_entry | |||
104 | mac_addr addr; | 104 | mac_addr addr; |
105 | unsigned char is_local; | 105 | unsigned char is_local; |
106 | unsigned char is_static; | 106 | unsigned char is_static; |
107 | unsigned char added_by_user; | ||
107 | __u16 vlan_id; | 108 | __u16 vlan_id; |
108 | }; | 109 | }; |
109 | 110 | ||
@@ -383,7 +384,7 @@ int br_fdb_fillbuf(struct net_bridge *br, void *buf, unsigned long count, | |||
383 | int br_fdb_insert(struct net_bridge *br, struct net_bridge_port *source, | 384 | int br_fdb_insert(struct net_bridge *br, struct net_bridge_port *source, |
384 | const unsigned char *addr, u16 vid); | 385 | const unsigned char *addr, u16 vid); |
385 | void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source, | 386 | void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source, |
386 | const unsigned char *addr, u16 vid); | 387 | const unsigned char *addr, u16 vid, bool added_by_user); |
387 | int fdb_delete_by_addr(struct net_bridge *br, const u8 *addr, u16 vid); | 388 | int fdb_delete_by_addr(struct net_bridge *br, const u8 *addr, u16 vid); |
388 | 389 | ||
389 | int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[], | 390 | int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[], |