Ethernet Bridge development
 help / color / mirror / Atom feed
From: Amit Cohen <amcohen@nvidia.com>
To: netdev@vger.kernel.org
Cc: Petr Machata <petrm@nvidia.com>,
	razor@blackwall.org, Amit Cohen <amcohen@nvidia.com>,
	mlxsw@nvidia.com, dsahern@kernel.org,
	bridge@lists.linux-foundation.org, idosch@nvidia.com,
	linux-kselftest@vger.kernel.org, roopa@nvidia.com,
	kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org,
	davem@davemloft.net
Subject: [Bridge] [PATCH net-next 03/11] vxlan: vxlan_core: Do not skip default entry in vxlan_flush() by default
Date: Mon, 9 Oct 2023 13:06:10 +0300	[thread overview]
Message-ID: <20231009100618.2911374-4-amcohen@nvidia.com> (raw)
In-Reply-To: <20231009100618.2911374-1-amcohen@nvidia.com>

Currently, the function vxlan_flush() does not flush the default FDB entry
(an entry with all_zeros_mac and default VNI), as it is deleted at
vxlan_uninit(). When this function will be used for flushing FDB entries
from user space, it will have to flush also the default entry in case that
other parameters match (e.g., VNI, flags).

Extend 'struct vxlan_fdb_flush_desc' to include an indication whether
the default entry should be flushed or not. The default value (false)
indicates to flush it, adjust all the existing callers to set
'.ignore_default_entry' to true, so the current behavior will not be
changed.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
 drivers/net/vxlan/vxlan_core.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 1c58fddb7df4..958960fdc011 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -3023,16 +3023,27 @@ static int vxlan_open(struct net_device *dev)
 }
 
 struct vxlan_fdb_flush_desc {
+	bool				ignore_default_entry;
 	unsigned long                   state;
 	unsigned long			state_mask;
 };
 
+static bool vxlan_fdb_is_default_entry(const struct vxlan_fdb *f,
+				       const struct vxlan_dev *vxlan)
+{
+	return is_zero_ether_addr(f->eth_addr) && f->vni == vxlan->cfg.vni;
+}
+
 static bool vxlan_fdb_flush_matches(const struct vxlan_fdb *f,
+				    const struct vxlan_dev *vxlan,
 				    const struct vxlan_fdb_flush_desc *desc)
 {
 	if (desc->state_mask && (f->state & desc->state_mask) != desc->state)
 		return false;
 
+	if (desc->ignore_default_entry && vxlan_fdb_is_default_entry(f, vxlan))
+		return false;
+
 	return true;
 }
 
@@ -3050,13 +3061,9 @@ static void vxlan_flush(struct vxlan_dev *vxlan,
 			struct vxlan_fdb *f
 				= container_of(p, struct vxlan_fdb, hlist);
 
-			if (!vxlan_fdb_flush_matches(f, desc))
+			if (!vxlan_fdb_flush_matches(f, vxlan, desc))
 				continue;
 
-			/* the all_zeros_mac entry is deleted at vxlan_uninit */
-			if (is_zero_ether_addr(f->eth_addr) &&
-			    f->vni == vxlan->cfg.vni)
-				continue;
 			vxlan_fdb_destroy(vxlan, f, true, true);
 		}
 		spin_unlock_bh(&vxlan->hash_lock[h]);
@@ -3068,6 +3075,8 @@ static int vxlan_stop(struct net_device *dev)
 {
 	struct vxlan_dev *vxlan = netdev_priv(dev);
 	struct vxlan_fdb_flush_desc desc = {
+		/* Default entry is deleted at vxlan_uninit. */
+		.ignore_default_entry = true,
 		.state = 0,
 		.state_mask = NUD_PERMANENT | NUD_NOARP,
 	};
@@ -4315,7 +4324,10 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
 static void vxlan_dellink(struct net_device *dev, struct list_head *head)
 {
 	struct vxlan_dev *vxlan = netdev_priv(dev);
-	struct vxlan_fdb_flush_desc desc = {};
+	struct vxlan_fdb_flush_desc desc = {
+		/* Default entry is deleted at vxlan_uninit. */
+		.ignore_default_entry = true,
+	};
 
 	vxlan_flush(vxlan, &desc);
 
-- 
2.40.1


  parent reply	other threads:[~2023-10-09 10:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09 10:06 [Bridge] [PATCH net-next 00/11] Extend VXLAN driver to support FDB flushing Amit Cohen
2023-10-09 10:06 ` [Bridge] [PATCH net-next 01/11] net: Handle bulk delete policy in bridge driver Amit Cohen
2023-10-09 10:06 ` [Bridge] [PATCH net-next 02/11] vxlan: vxlan_core: Make vxlan_flush() more generic for future use Amit Cohen
2023-10-09 10:06 ` Amit Cohen [this message]
2023-10-09 10:06 ` [Bridge] [PATCH net-next 04/11] vxlan: vxlan_core: Add support for FDB flush Amit Cohen
2023-10-09 10:06 ` [Bridge] [PATCH net-next 05/11] vxlan: vxlan_core: Support FDB flushing by source VNI Amit Cohen
2023-10-09 10:06 ` [Bridge] [PATCH net-next 06/11] vxlan: vxlan_core: Support FDB flushing by nexthop ID Amit Cohen
2023-10-09 10:06 ` [Bridge] [PATCH net-next 07/11] vxlan: vxlan_core: Support FDB flushing by destination VNI Amit Cohen
2023-10-09 10:06 ` [Bridge] [PATCH net-next 08/11] vxlan: vxlan_core: Support FDB flushing by destination port Amit Cohen
2023-10-09 10:06 ` [Bridge] [PATCH net-next 09/11] vxlan: vxlan_core: Support FDB flushing by destination IP Amit Cohen
2023-10-09 10:06 ` [Bridge] [PATCH net-next 10/11] selftests: Add test cases for FDB flush with VXLAN device Amit Cohen
2023-10-09 10:06 ` [Bridge] [PATCH net-next 11/11] selftests: fdb_flush: Add test cases for FDB flush with bridge device Amit Cohen
2023-10-10 19:11   ` Scott Wadkins
2023-10-10 18:50 ` [Bridge] [PATCH net-next 00/11] Extend VXLAN driver to support FDB flushing Nikolay Aleksandrov
2023-10-13  9:10 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231009100618.2911374-4-amcohen@nvidia.com \
    --to=amcohen@nvidia.com \
    --cc=bridge@lists.linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mlxsw@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=razor@blackwall.org \
    --cc=roopa@nvidia.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox