提交 1ea2d020 编写于 作者: N Nikolay Aleksandrov 提交者: David S. Miller

bridge: vlan: flush the dynamically learned entries on port vlan delete

Add a new argument to br_fdb_delete_by_port which allows to specify a
vid to match when flushing entries and use it in nbp_vlan_delete() to
flush the dynamically learned entries of the vlan/port pair when removing
a vlan from a port. Before this patch only the local mac was being
removed and the dynamically learned ones were left to expire.
Note that the do_all argument is still respected and if specified, the
vid will be ignored.
Signed-off-by: NNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 9aa66382
...@@ -330,9 +330,11 @@ void br_fdb_flush(struct net_bridge *br) ...@@ -330,9 +330,11 @@ void br_fdb_flush(struct net_bridge *br)
/* Flush all entries referring to a specific port. /* Flush all entries referring to a specific port.
* if do_all is set also flush static entries * if do_all is set also flush static entries
* if vid is set delete all entries that match the vlan_id
*/ */
void br_fdb_delete_by_port(struct net_bridge *br, void br_fdb_delete_by_port(struct net_bridge *br,
const struct net_bridge_port *p, const struct net_bridge_port *p,
u16 vid,
int do_all) int do_all)
{ {
int i; int i;
...@@ -347,7 +349,8 @@ void br_fdb_delete_by_port(struct net_bridge *br, ...@@ -347,7 +349,8 @@ void br_fdb_delete_by_port(struct net_bridge *br,
if (f->dst != p) if (f->dst != p)
continue; continue;
if (f->is_static && !do_all) if (!do_all)
if (f->is_static || (vid && f->vlan_id != vid))
continue; continue;
if (f->is_local) if (f->is_local)
......
...@@ -249,7 +249,7 @@ static void del_nbp(struct net_bridge_port *p) ...@@ -249,7 +249,7 @@ static void del_nbp(struct net_bridge_port *p)
list_del_rcu(&p->list); list_del_rcu(&p->list);
nbp_vlan_flush(p); nbp_vlan_flush(p);
br_fdb_delete_by_port(br, p, 1); br_fdb_delete_by_port(br, p, 0, 1);
nbp_update_port_count(br); nbp_update_port_count(br);
netdev_upper_dev_unlink(dev, br->dev); netdev_upper_dev_unlink(dev, br->dev);
...@@ -278,7 +278,7 @@ void br_dev_delete(struct net_device *dev, struct list_head *head) ...@@ -278,7 +278,7 @@ void br_dev_delete(struct net_device *dev, struct list_head *head)
del_nbp(p); del_nbp(p);
} }
br_fdb_delete_by_port(br, NULL, 1); br_fdb_delete_by_port(br, NULL, 0, 1);
br_vlan_flush(br); br_vlan_flush(br);
del_timer_sync(&br->gc_timer); del_timer_sync(&br->gc_timer);
......
...@@ -387,7 +387,7 @@ void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr); ...@@ -387,7 +387,7 @@ void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr);
void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr); void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr);
void br_fdb_cleanup(unsigned long arg); void br_fdb_cleanup(unsigned long arg);
void br_fdb_delete_by_port(struct net_bridge *br, void br_fdb_delete_by_port(struct net_bridge *br,
const struct net_bridge_port *p, int do_all); const struct net_bridge_port *p, u16 vid, int do_all);
struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br, struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br,
const unsigned char *addr, __u16 vid); const unsigned char *addr, __u16 vid);
int br_fdb_test_addr(struct net_device *dev, unsigned char *addr); int br_fdb_test_addr(struct net_device *dev, unsigned char *addr);
......
...@@ -111,7 +111,7 @@ void br_stp_disable_port(struct net_bridge_port *p) ...@@ -111,7 +111,7 @@ void br_stp_disable_port(struct net_bridge_port *p)
del_timer(&p->forward_delay_timer); del_timer(&p->forward_delay_timer);
del_timer(&p->hold_timer); del_timer(&p->hold_timer);
br_fdb_delete_by_port(br, p, 0); br_fdb_delete_by_port(br, p, 0, 0);
br_multicast_disable_port(p); br_multicast_disable_port(p);
br_configuration_update(br); br_configuration_update(br);
......
...@@ -160,7 +160,7 @@ static BRPORT_ATTR(hold_timer, S_IRUGO, show_hold_timer, NULL); ...@@ -160,7 +160,7 @@ static BRPORT_ATTR(hold_timer, S_IRUGO, show_hold_timer, NULL);
static int store_flush(struct net_bridge_port *p, unsigned long v) static int store_flush(struct net_bridge_port *p, unsigned long v)
{ {
br_fdb_delete_by_port(p->br, p, 0); // Don't delete local entry br_fdb_delete_by_port(p->br, p, 0, 0); // Don't delete local entry
return 0; return 0;
} }
static BRPORT_ATTR(flush, S_IWUSR, NULL, store_flush); static BRPORT_ATTR(flush, S_IWUSR, NULL, store_flush);
......
...@@ -741,6 +741,7 @@ int nbp_vlan_delete(struct net_bridge_port *port, u16 vid) ...@@ -741,6 +741,7 @@ int nbp_vlan_delete(struct net_bridge_port *port, u16 vid)
return -EINVAL; return -EINVAL;
br_fdb_find_delete_local(port->br, port, port->dev->dev_addr, vid); br_fdb_find_delete_local(port->br, port, port->dev->dev_addr, vid);
br_fdb_delete_by_port(port->br, port, vid, 0);
return __vlan_del(pv, vid); return __vlan_del(pv, vid);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册