From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, idosch@mellanox.com, arkadis@mellanox.com,
mlxsw@mellanox.com, roopa@cumulusnetworks.com,
stephen@networkplumber.org, ivecera@redhat.com
Subject: [patch net-next 06/19] net: bridge: Receive notification about successful FDB offload
Date: Mon, 5 Jun 2017 11:20:30 +0200 [thread overview]
Message-ID: <20170605092043.3523-7-jiri@resnulli.us> (raw)
In-Reply-To: <20170605092043.3523-1-jiri@resnulli.us>
From: Arkadi Sharshevsky <arkadis@mellanox.com>
When a new static FDB is added to the bridge a notification is sent to
the driver for offload. In case of successful offload the driver should
notify the bridge back, which in turn should mark the FDB as offloaded.
Currently, externally learned is equivalent for being offloaded which is
not correct due to the fact that FDBs which are added from user-space are
also marked as externally learned. In order to specify if an FDB was
successfully offloaded a new flag is introduced.
Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
include/net/switchdev.h | 1 +
include/uapi/linux/neighbour.h | 1 +
net/bridge/br.c | 11 ++++++++++-
net/bridge/br_fdb.c | 22 +++++++++++++++++++++-
net/bridge/br_private.h | 5 ++++-
5 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 8165ed9..c784a6a 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -159,6 +159,7 @@ enum switchdev_notifier_type {
SWITCHDEV_FDB_DEL_TO_BRIDGE,
SWITCHDEV_FDB_ADD_TO_DEVICE,
SWITCHDEV_FDB_DEL_TO_DEVICE,
+ SWITCHDEV_FDB_OFFLOADED,
};
struct switchdev_notifier_info {
diff --git a/include/uapi/linux/neighbour.h b/include/uapi/linux/neighbour.h
index f3d16db..3199d28 100644
--- a/include/uapi/linux/neighbour.h
+++ b/include/uapi/linux/neighbour.h
@@ -41,6 +41,7 @@ enum {
#define NTF_MASTER 0x04
#define NTF_PROXY 0x08 /* == ATF_PUBL */
#define NTF_EXT_LEARNED 0x10
+#define NTF_OFFLOADED 0x20
#define NTF_ROUTER 0x80
/*
diff --git a/net/bridge/br.c b/net/bridge/br.c
index 96d209c..1407d1b 100644
--- a/net/bridge/br.c
+++ b/net/bridge/br.c
@@ -142,8 +142,12 @@ static int br_switchdev_event(struct notifier_block *unused,
fdb_info = ptr;
err = br_fdb_external_learn_add(br, p, fdb_info->addr,
fdb_info->vid);
- if (err)
+ if (err) {
err = notifier_from_errno(err);
+ break;
+ }
+ br_fdb_offloaded_set(br, p, fdb_info->addr,
+ fdb_info->vid);
break;
case SWITCHDEV_FDB_DEL_TO_BRIDGE:
fdb_info = ptr;
@@ -152,6 +156,11 @@ static int br_switchdev_event(struct notifier_block *unused,
if (err)
err = notifier_from_errno(err);
break;
+ case SWITCHDEV_FDB_OFFLOADED:
+ fdb_info = ptr;
+ br_fdb_offloaded_set(br, p, fdb_info->addr,
+ fdb_info->vid);
+ break;
}
out:
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 21bf9d2..1bd3d84 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -511,6 +511,7 @@ static struct net_bridge_fdb_entry *fdb_create(struct hlist_head *head,
fdb->is_static = is_static;
fdb->added_by_user = 0;
fdb->added_by_external_learn = 0;
+ fdb->offloaded = 0;
fdb->updated = fdb->used = jiffies;
hlist_add_head_rcu(&fdb->hlist, head);
}
@@ -647,11 +648,16 @@ static int fdb_fill_info(struct sk_buff *skb, const struct net_bridge *br,
ndm->ndm_family = AF_BRIDGE;
ndm->ndm_pad1 = 0;
ndm->ndm_pad2 = 0;
- ndm->ndm_flags = fdb->added_by_external_learn ? NTF_EXT_LEARNED : 0;
+ ndm->ndm_flags = 0;
ndm->ndm_type = 0;
ndm->ndm_ifindex = fdb->dst ? fdb->dst->dev->ifindex : br->dev->ifindex;
ndm->ndm_state = fdb_to_nud(br, fdb);
+ if (fdb->offloaded)
+ ndm->ndm_flags |= NTF_OFFLOADED;
+ if (fdb->added_by_external_learn)
+ ndm->ndm_flags |= NTF_EXT_LEARNED;
+
if (nla_put(skb, NDA_LLADDR, ETH_ALEN, &fdb->addr))
goto nla_put_failure;
if (nla_put_u32(skb, NDA_MASTER, br->dev->ifindex))
@@ -1143,3 +1149,17 @@ int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
return err;
}
+
+void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p,
+ const unsigned char *addr, u16 vid)
+{
+ struct net_bridge_fdb_entry *fdb;
+
+ spin_lock_bh(&br->hash_lock);
+
+ fdb = br_fdb_find(br, addr, vid);
+ if (fdb)
+ fdb->offloaded = 1;
+
+ spin_unlock_bh(&br->hash_lock);
+}
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 5e944e9..a5db2e1 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -173,7 +173,8 @@ struct net_bridge_fdb_entry {
unsigned char is_local:1,
is_static:1,
added_by_user:1,
- added_by_external_learn:1;
+ added_by_external_learn:1,
+ offloaded:1;
/* write-heavy members should not affect lookups */
unsigned long updated ____cacheline_aligned_in_smp;
@@ -540,6 +541,8 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
const unsigned char *addr, u16 vid);
int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
const unsigned char *addr, u16 vid);
+void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p,
+ const unsigned char *addr, u16 vid);
/* br_forward.c */
enum br_pkt_type {
--
2.9.3
next prev parent reply other threads:[~2017-06-05 9:20 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-05 9:20 [patch net-next 00/19] Remove support from bridge bypass for mlxsw/rocker drivers Jiri Pirko
2017-06-05 9:20 ` [patch net-next 01/19] net: switchdev: Add support for querying supported bridge flags by hardware Jiri Pirko
2017-06-05 14:00 ` Ivan Vecera
2017-06-05 9:20 ` [patch net-next 02/19] net: bridge: Add support for offloading port attributes Jiri Pirko
2017-06-05 13:29 ` Nikolay Aleksandrov
2017-06-06 13:08 ` Arkadi Sharshevsky
2017-06-05 9:20 ` [patch net-next 03/19] net: bridge: Add support for calling FDB external learning under rcu Jiri Pirko
2017-06-05 13:36 ` Nikolay Aleksandrov
2017-06-05 9:20 ` [patch net-next 04/19] net: switchdev: Change notifier chain to be atomic Jiri Pirko
2017-06-05 13:59 ` Ivan Vecera
2017-06-05 9:20 ` [patch net-next 05/19] net: bridge: Add support for notifying devices about FDB add/del Jiri Pirko
2017-06-05 13:35 ` Nikolay Aleksandrov
2017-06-06 14:19 ` Arkadi Sharshevsky
2017-06-05 9:20 ` Jiri Pirko [this message]
2017-06-05 13:44 ` [patch net-next 06/19] net: bridge: Receive notification about successful FDB offload Nikolay Aleksandrov
2017-06-05 9:20 ` [patch net-next 07/19] mlxsw: spectrum: Remove support for bridge FDB learning sync Jiri Pirko
2017-06-05 9:20 ` [patch net-next 08/19] mlxsw: spectrum_switchdev: Add support for querying supported bridge flags Jiri Pirko
2017-06-05 9:20 ` [patch net-next 09/19] mlxsw: spectrum: Remove support for bypass bridge port attributes/vlan set Jiri Pirko
2017-06-05 9:20 ` [patch net-next 10/19] mlxsw: spectrum_switchdev: Change switchdev notifier API Jiri Pirko
2017-06-05 9:20 ` [patch net-next 11/19] mlxsw: spectrum_switchdev: Add support for learning FDB through notification Jiri Pirko
2017-06-05 9:20 ` [patch net-next 12/19] mlxsw: spectrum: Remove support for bridge bypass FDB add/del Jiri Pirko
2017-06-05 9:20 ` [patch net-next 13/19] net: Remove support for bridge bypass ndos from stacked devices Jiri Pirko
2017-06-05 9:20 ` [patch net-next 14/19] rocker: Remove support for bridge FDB learning sync Jiri Pirko
2017-06-05 9:20 ` [patch net-next 15/19] rocker: Add support for querying supported bridge flags Jiri Pirko
2017-06-05 9:20 ` [patch net-next 16/19] rocker: Change world_ops API and implementation to be switchdev independant Jiri Pirko
2017-06-05 9:20 ` [patch net-next 17/19] rocker: Add support for learning FDB through notification Jiri Pirko
2017-06-05 9:20 ` [patch net-next 18/19] rocker: Remove support for bypass bridge port attributes/vlan set Jiri Pirko
2017-06-05 9:20 ` [patch net-next 19/19] rocker: Remove support bridge bypass FDB Jiri Pirko
2017-06-05 10:07 ` [patch iproute2] bridge: Distinguish between externally learned vs offloaded FDBs Jiri Pirko
2017-06-14 16:52 ` Stephen Hemminger
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=20170605092043.3523-7-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=arkadis@mellanox.com \
--cc=davem@davemloft.net \
--cc=idosch@mellanox.com \
--cc=ivecera@redhat.com \
--cc=mlxsw@mellanox.com \
--cc=netdev@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).