Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5ff4b19 authored by Petr Machata's avatar Petr Machata Committed by David S. Miller
Browse files

vxlan: Add vxlan_fdb_clear_offload()



When a driver unoffloads all FDB entries en bloc, it's inefficient to
send the switchdev notification one by one. Add a helper that walks the
FDB table, unsetting the offload flag on RDST with a given VNI.

Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4f89f5b5
Loading
Loading
Loading
Loading
+22 −0
Original line number Original line Diff line number Diff line
@@ -599,6 +599,28 @@ int vxlan_fdb_replay(const struct net_device *dev, __be32 vni,
}
}
EXPORT_SYMBOL_GPL(vxlan_fdb_replay);
EXPORT_SYMBOL_GPL(vxlan_fdb_replay);


void vxlan_fdb_clear_offload(const struct net_device *dev, __be32 vni)
{
	struct vxlan_dev *vxlan;
	struct vxlan_rdst *rdst;
	struct vxlan_fdb *f;
	unsigned int h;

	if (!netif_is_vxlan(dev))
		return;
	vxlan = netdev_priv(dev);

	spin_lock_bh(&vxlan->hash_lock);
	for (h = 0; h < FDB_HASH_SIZE; ++h) {
		hlist_for_each_entry(f, &vxlan->fdb_head[h], hlist)
			if (f->vni == vni)
				list_for_each_entry(rdst, &f->remotes, list)
					rdst->offloaded = false;
	}
	spin_unlock_bh(&vxlan->hash_lock);
}
EXPORT_SYMBOL_GPL(vxlan_fdb_clear_offload);

/* Replace destination of unicast mac */
/* Replace destination of unicast mac */
static int vxlan_fdb_replace(struct vxlan_fdb *f,
static int vxlan_fdb_replace(struct vxlan_fdb *f,
			     union vxlan_addr *ip, __be16 port, __be32 vni,
			     union vxlan_addr *ip, __be16 port, __be32 vni,
+6 −0
Original line number Original line Diff line number Diff line
@@ -429,6 +429,7 @@ int vxlan_fdb_find_uc(struct net_device *dev, const u8 *mac, __be32 vni,
		      struct switchdev_notifier_vxlan_fdb_info *fdb_info);
		      struct switchdev_notifier_vxlan_fdb_info *fdb_info);
int vxlan_fdb_replay(const struct net_device *dev, __be32 vni,
int vxlan_fdb_replay(const struct net_device *dev, __be32 vni,
		     struct notifier_block *nb);
		     struct notifier_block *nb);
void vxlan_fdb_clear_offload(const struct net_device *dev, __be32 vni);


#else
#else
static inline int
static inline int
@@ -443,6 +444,11 @@ static inline int vxlan_fdb_replay(const struct net_device *dev, __be32 vni,
{
{
	return -EOPNOTSUPP;
	return -EOPNOTSUPP;
}
}

static inline void
vxlan_fdb_clear_offload(const struct net_device *dev, __be32 vni)
{
}
#endif
#endif


#endif
#endif