Commit bfe36bf7 authored by Amit Cohen's avatar Amit Cohen Committed by David S. Miller

vxlan: vxlan_core: Make vxlan_flush() more generic for future use

The function vxlan_flush() gets a boolean called 'do_all' and in case
that it is false, it does not flush entries with state 'NUD_PERMANENT'
or 'NUD_NOARP'. The following patches will add support for FDB flush
with parameters from user space. Make the function more generic, so it
can be used later.
Signed-off-by: default avatarAmit Cohen <amcohen@nvidia.com>
Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 38985e8c
...@@ -3022,8 +3022,23 @@ static int vxlan_open(struct net_device *dev) ...@@ -3022,8 +3022,23 @@ static int vxlan_open(struct net_device *dev)
return ret; return ret;
} }
struct vxlan_fdb_flush_desc {
unsigned long state;
unsigned long state_mask;
};
static bool vxlan_fdb_flush_matches(const struct vxlan_fdb *f,
const struct vxlan_fdb_flush_desc *desc)
{
if (desc->state_mask && (f->state & desc->state_mask) != desc->state)
return false;
return true;
}
/* Purge the forwarding table */ /* Purge the forwarding table */
static void vxlan_flush(struct vxlan_dev *vxlan, bool do_all) static void vxlan_flush(struct vxlan_dev *vxlan,
const struct vxlan_fdb_flush_desc *desc)
{ {
unsigned int h; unsigned int h;
...@@ -3034,8 +3049,10 @@ static void vxlan_flush(struct vxlan_dev *vxlan, bool do_all) ...@@ -3034,8 +3049,10 @@ static void vxlan_flush(struct vxlan_dev *vxlan, bool do_all)
hlist_for_each_safe(p, n, &vxlan->fdb_head[h]) { hlist_for_each_safe(p, n, &vxlan->fdb_head[h]) {
struct vxlan_fdb *f struct vxlan_fdb *f
= container_of(p, struct vxlan_fdb, hlist); = container_of(p, struct vxlan_fdb, hlist);
if (!do_all && (f->state & (NUD_PERMANENT | NUD_NOARP)))
if (!vxlan_fdb_flush_matches(f, desc))
continue; continue;
/* the all_zeros_mac entry is deleted at vxlan_uninit */ /* the all_zeros_mac entry is deleted at vxlan_uninit */
if (is_zero_ether_addr(f->eth_addr) && if (is_zero_ether_addr(f->eth_addr) &&
f->vni == vxlan->cfg.vni) f->vni == vxlan->cfg.vni)
...@@ -3050,12 +3067,16 @@ static void vxlan_flush(struct vxlan_dev *vxlan, bool do_all) ...@@ -3050,12 +3067,16 @@ static void vxlan_flush(struct vxlan_dev *vxlan, bool do_all)
static int vxlan_stop(struct net_device *dev) static int vxlan_stop(struct net_device *dev)
{ {
struct vxlan_dev *vxlan = netdev_priv(dev); struct vxlan_dev *vxlan = netdev_priv(dev);
struct vxlan_fdb_flush_desc desc = {
.state = 0,
.state_mask = NUD_PERMANENT | NUD_NOARP,
};
vxlan_multicast_leave(vxlan); vxlan_multicast_leave(vxlan);
del_timer_sync(&vxlan->age_timer); del_timer_sync(&vxlan->age_timer);
vxlan_flush(vxlan, false); vxlan_flush(vxlan, &desc);
vxlan_sock_release(vxlan); vxlan_sock_release(vxlan);
return 0; return 0;
...@@ -4294,8 +4315,9 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], ...@@ -4294,8 +4315,9 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
static void vxlan_dellink(struct net_device *dev, struct list_head *head) static void vxlan_dellink(struct net_device *dev, struct list_head *head)
{ {
struct vxlan_dev *vxlan = netdev_priv(dev); struct vxlan_dev *vxlan = netdev_priv(dev);
struct vxlan_fdb_flush_desc desc = {};
vxlan_flush(vxlan, true); vxlan_flush(vxlan, &desc);
list_del(&vxlan->next); list_del(&vxlan->next);
unregister_netdevice_queue(dev, head); unregister_netdevice_queue(dev, head);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment