From: Ido Schimmel <idosch@mellanox.com>
To: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"bridge@lists.linux-foundation.org"
<bridge@lists.linux-foundation.org>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
Jiri Pirko <jiri@mellanox.com>, Petr Machata <petrm@mellanox.com>,
"roopa@cumulusnetworks.com" <roopa@cumulusnetworks.com>,
"nikolay@cumulusnetworks.com" <nikolay@cumulusnetworks.com>,
"stephen@networkplumber.org" <stephen@networkplumber.org>,
"ivecera@redhat.com" <ivecera@redhat.com>,
mlxsw <mlxsw@mellanox.com>, Ido Schimmel <idosch@mellanox.com>
Subject: [PATCH net-next 05/16] vxlan: Add hardware FDB learning
Date: Wed, 21 Nov 2018 08:02:39 +0000 [thread overview]
Message-ID: <20181121080141.16676-6-idosch@mellanox.com> (raw)
In-Reply-To: <20181121080141.16676-1-idosch@mellanox.com>
From: Petr Machata <petrm@mellanox.com>
In order to allow devices to signal learning events to VXLAN, introduce
two new switchdev messages: SWITCHDEV_VXLAN_FDB_ADD_TO_BRIDGE and
SWITCHDEV_VXLAN_FDB_DEL_TO_BRIDGE.
Listen to these notifications in the vxlan driver. The FDB entries
learned this way have an NTF_EXT_LEARNED flag, and only entries marked
as such can be unlearned by the _DEL_ event. They are also immediately
marked as offloaded. This is the same behavior that the bridge driver
observes.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
drivers/net/vxlan.c | 73 ++++++++++++++++++++++++++++++++++++++++-
include/net/switchdev.h | 2 ++
2 files changed, 74 insertions(+), 1 deletion(-)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index b50705a50686..03ba1b56ba6d 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -3923,18 +3923,89 @@ vxlan_fdb_offloaded_set(struct net_device *dev,
spin_unlock_bh(&vxlan->hash_lock);
}
+static int
+vxlan_fdb_external_learn_add(struct net_device *dev,
+ struct switchdev_notifier_vxlan_fdb_info *fdb_info)
+{
+ struct vxlan_dev *vxlan = netdev_priv(dev);
+ int err;
+
+ spin_lock_bh(&vxlan->hash_lock);
+ err = vxlan_fdb_update(vxlan, fdb_info->eth_addr, &fdb_info->remote_ip,
+ NUD_REACHABLE,
+ NLM_F_CREATE | NLM_F_REPLACE,
+ fdb_info->remote_port,
+ fdb_info->vni,
+ fdb_info->remote_vni,
+ fdb_info->remote_ifindex,
+ NTF_USE | NTF_SELF | NTF_EXT_LEARNED,
+ false);
+ spin_unlock_bh(&vxlan->hash_lock);
+
+ return err;
+}
+
+static int
+vxlan_fdb_external_learn_del(struct net_device *dev,
+ struct switchdev_notifier_vxlan_fdb_info *fdb_info)
+{
+ struct vxlan_dev *vxlan = netdev_priv(dev);
+ struct vxlan_fdb *f;
+ int err = 0;
+
+ spin_lock_bh(&vxlan->hash_lock);
+
+ f = vxlan_find_mac(vxlan, fdb_info->eth_addr, fdb_info->vni);
+ if (!f)
+ err = -ENOENT;
+ else if (f->flags & NTF_EXT_LEARNED)
+ err = __vxlan_fdb_delete(vxlan, fdb_info->eth_addr,
+ fdb_info->remote_ip,
+ fdb_info->remote_port,
+ fdb_info->vni,
+ fdb_info->remote_vni,
+ fdb_info->remote_ifindex,
+ false);
+
+ spin_unlock_bh(&vxlan->hash_lock);
+
+ return err;
+}
+
static int vxlan_switchdev_event(struct notifier_block *unused,
unsigned long event, void *ptr)
{
struct net_device *dev = switchdev_notifier_info_to_dev(ptr);
+ struct switchdev_notifier_vxlan_fdb_info *fdb_info;
+ int err = 0;
switch (event) {
case SWITCHDEV_VXLAN_FDB_OFFLOADED:
vxlan_fdb_offloaded_set(dev, ptr);
break;
+ case SWITCHDEV_VXLAN_FDB_ADD_TO_BRIDGE:
+ fdb_info = ptr;
+ err = vxlan_fdb_external_learn_add(dev, fdb_info);
+ if (err) {
+ err = notifier_from_errno(err);
+ break;
+ }
+ fdb_info->offloaded = true;
+ vxlan_fdb_offloaded_set(dev, fdb_info);
+ break;
+ case SWITCHDEV_VXLAN_FDB_DEL_TO_BRIDGE:
+ fdb_info = ptr;
+ err = vxlan_fdb_external_learn_del(dev, fdb_info);
+ if (err) {
+ err = notifier_from_errno(err);
+ break;
+ }
+ fdb_info->offloaded = false;
+ vxlan_fdb_offloaded_set(dev, fdb_info);
+ break;
}
- return 0;
+ return err;
}
static struct notifier_block vxlan_switchdev_notifier_block __read_mostly = {
diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 881ecb1555bf..7b371e7c4bc6 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -146,6 +146,8 @@ enum switchdev_notifier_type {
SWITCHDEV_FDB_DEL_TO_DEVICE,
SWITCHDEV_FDB_OFFLOADED,
+ SWITCHDEV_VXLAN_FDB_ADD_TO_BRIDGE,
+ SWITCHDEV_VXLAN_FDB_DEL_TO_BRIDGE,
SWITCHDEV_VXLAN_FDB_ADD_TO_DEVICE,
SWITCHDEV_VXLAN_FDB_DEL_TO_DEVICE,
SWITCHDEV_VXLAN_FDB_OFFLOADED,
--
2.19.1
next prev parent reply other threads:[~2018-11-21 18:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-21 8:02 [PATCH net-next 00/16] mlxsw: Add VxLAN learning support Ido Schimmel
2018-11-21 8:02 ` [PATCH net-next 01/16] vxlan: __vxlan_fdb_delete(): Drop unused argument vid Ido Schimmel
2018-11-21 8:02 ` [PATCH net-next 02/16] vxlan: vxlan_fdb_notify(): Make switchdev notification configurable Ido Schimmel
2018-11-21 8:02 ` [PATCH net-next 03/16] vxlan: Mark user-added FDB entries Ido Schimmel
2018-11-21 8:02 ` [PATCH net-next 04/16] vxlan: Don't override user-added entries with ext-learned ones Ido Schimmel
2018-11-21 8:02 ` Ido Schimmel [this message]
2018-11-21 8:02 ` [PATCH net-next 06/16] vxlan: Allow changing ageing time Ido Schimmel
2018-11-21 8:02 ` [PATCH net-next 07/16] bridge: Allow querying bridge port flags Ido Schimmel
2018-11-21 8:02 ` [PATCH net-next 08/16] mlxsw: reg: Add definition of unicast tunnel record for SFN register Ido Schimmel
2018-11-21 8:02 ` [PATCH net-next 09/16] mlxsw: spectrum_fid: Store ifindex of NVE device in FID Ido Schimmel
2018-11-21 8:02 ` [PATCH net-next 10/16] mlxsw: spectrum_fid: Allow FID lookup by its index Ido Schimmel
2018-11-21 8:02 ` [PATCH net-next 11/16] mlxsw: spectrum_nve: Add API to resolve learned IP addresses Ido Schimmel
2018-11-21 8:02 ` [PATCH net-next 12/16] mlxsw: spectrum_switchdev: Process learned VxLAN FDB entries Ido Schimmel
2018-11-21 8:02 ` [PATCH net-next 13/16] mlxsw: spectrum_switchdev: Allow deletion of learned " Ido Schimmel
2018-11-21 8:02 ` [PATCH net-next 14/16] mlxsw: spectrum_nve: Allow VxLAN learning Ido Schimmel
2018-11-21 8:02 ` [PATCH net-next 15/16] selftests: mlxsw: Consider VxLAN learning enabled as valid Ido Schimmel
2018-11-21 8:02 ` [PATCH net-next 16/16] selftests: forwarding: vxlan_bridge_1d: Add learning test Ido Schimmel
2018-11-22 1:10 ` [PATCH net-next 00/16] mlxsw: Add VxLAN learning support David Miller
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=20181121080141.16676-6-idosch@mellanox.com \
--to=idosch@mellanox.com \
--cc=bridge@lists.linux-foundation.org \
--cc=davem@davemloft.net \
--cc=ivecera@redhat.com \
--cc=jiri@mellanox.com \
--cc=mlxsw@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=petrm@mellanox.com \
--cc=roopa@cumulusnetworks.com \
--cc=stephen@networkplumber.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