From: Nikolay Aleksandrov <razor@blackwall.org>
To: netdev@vger.kernel.org
Cc: kuba@kernel.org, Nikolay Aleksandrov <razor@blackwall.org>,
bridge@lists.linux-foundation.org, davem@davemloft.net,
roopa@nvidia.com
Subject: [Bridge] [PATCH net-next 1/6] net: bridge: add a generic flush operation
Date: Sat, 9 Apr 2022 13:58:52 +0300 [thread overview]
Message-ID: <20220409105857.803667-2-razor@blackwall.org> (raw)
In-Reply-To: <20220409105857.803667-1-razor@blackwall.org>
Add a new bridge attribute (IFLA_BRIDGE_FLUSH) which will have embedded
attributes describing the object types that will be flushed. It will
allow fine-grained object flushing. Only a single flush attribute is
allowed per call since it can be a very load heavy operation. Also it is
allowed only with setlink command (similar to changelink flush). A nice
side-effect of using an af spec attribute is that it avoids making the
bridge link attribute options list longer.
An example structure for fdbs:
[ IFLA_BRIDGE_FLUSH ]
`[ BRIDGE_FDB_FLUSH ]
`[ FDB_FLUSH_NDM_STATE ]
`[ FDB_FLUSH_NDM_FLAGS ]
Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
---
include/uapi/linux/if_bridge.h | 8 +++++++
net/bridge/br_netlink.c | 42 +++++++++++++++++++++++++++++++++-
2 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h
index a86a7e7b811f..221a4256808f 100644
--- a/include/uapi/linux/if_bridge.h
+++ b/include/uapi/linux/if_bridge.h
@@ -123,6 +123,7 @@ enum {
IFLA_BRIDGE_MRP,
IFLA_BRIDGE_CFM,
IFLA_BRIDGE_MST,
+ IFLA_BRIDGE_FLUSH,
__IFLA_BRIDGE_MAX,
};
#define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
@@ -802,4 +803,11 @@ enum {
__BRIDGE_QUERIER_MAX
};
#define BRIDGE_QUERIER_MAX (__BRIDGE_QUERIER_MAX - 1)
+
+/* embedded in IFLA_BRIDGE_FLUSH */
+enum {
+ BRIDGE_FLUSH_UNSPEC,
+ __BRIDGE_FLUSH_MAX
+};
+#define BRIDGE_FLUSH_MAX (__BRIDGE_FLUSH_MAX - 1)
#endif /* _UAPI_LINUX_IF_BRIDGE_H */
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 200ad05b296f..fe2211d4c0c7 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -779,6 +779,34 @@ int br_process_vlan_info(struct net_bridge *br,
return err;
}
+static const struct nla_policy br_flush_policy[BRIDGE_FLUSH_MAX + 1] = {
+ [BRIDGE_FLUSH_UNSPEC] = { .type = NLA_REJECT },
+};
+
+static int br_flush(struct net_bridge *br, int cmd,
+ struct nlattr *flush_attr,
+ struct netlink_ext_ack *extack)
+{
+ struct nlattr *flush_tb[BRIDGE_FLUSH_MAX + 1];
+ int err;
+
+ switch (cmd) {
+ case RTM_SETLINK:
+ break;
+ default:
+ NL_SET_ERR_MSG_MOD(extack,
+ "Bridge flush attribute is allowed only with RTM_SETLINK");
+ return -EINVAL;
+ }
+
+ err = nla_parse_nested(flush_tb, BRIDGE_FLUSH_MAX, flush_attr,
+ br_flush_policy, extack);
+ if (err)
+ return err;
+
+ return 0;
+}
+
static int br_afspec(struct net_bridge *br,
struct net_bridge_port *p,
struct nlattr *af_spec,
@@ -787,9 +815,10 @@ static int br_afspec(struct net_bridge *br,
{
struct bridge_vlan_info *vinfo_curr = NULL;
struct bridge_vlan_info *vinfo_last = NULL;
- struct nlattr *attr;
struct vtunnel_info tinfo_last = {};
struct vtunnel_info tinfo_curr = {};
+ bool flushed = false;
+ struct nlattr *attr;
int err = 0, rem;
nla_for_each_nested(attr, af_spec, rem) {
@@ -845,6 +874,17 @@ static int br_afspec(struct net_bridge *br,
if (err)
return err;
break;
+ case IFLA_BRIDGE_FLUSH:
+ if (flushed) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Multiple bridge flush attributes are not allowed");
+ return -EINVAL;
+ }
+ err = br_flush(br, cmd, attr, extack);
+ if (err)
+ return err;
+ flushed = true;
+ break;
}
}
--
2.35.1
next prev parent reply other threads:[~2022-04-09 10:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-09 10:58 [Bridge] [PATCH net-next 0/6] net: bridge: add flush filtering support Nikolay Aleksandrov
2022-04-09 10:58 ` Nikolay Aleksandrov [this message]
2022-04-09 10:58 ` [Bridge] [PATCH net-next 2/6] net: bridge: fdb: add support for fine-grained flushing Nikolay Aleksandrov
2022-04-11 8:20 ` Ido Schimmel
2022-04-11 8:54 ` Nikolay Aleksandrov
2022-04-09 10:58 ` [Bridge] [PATCH net-next 3/6] net: bridge: fdb: add new nl attribute-based flush call Nikolay Aleksandrov
2022-04-11 8:33 ` Ido Schimmel
2022-04-11 9:01 ` Nikolay Aleksandrov
2022-04-11 8:41 ` Ido Schimmel
2022-04-11 9:05 ` Nikolay Aleksandrov
2022-04-09 10:58 ` [Bridge] [PATCH net-next 4/6] net: bridge: fdb: add support for flush filtering based on ndm flags and state Nikolay Aleksandrov
2022-04-11 8:47 ` Ido Schimmel
2022-04-11 9:07 ` Nikolay Aleksandrov
2022-04-09 10:58 ` [Bridge] [PATCH net-next 5/6] net: bridge: fdb: add support for flush filtering based on ifindex Nikolay Aleksandrov
2022-04-11 8:57 ` Ido Schimmel
2022-04-11 9:03 ` Nikolay Aleksandrov
2022-04-09 10:58 ` [Bridge] [PATCH net-next 6/6] net: bridge: fdb: add support for flush filtering based on vlan id Nikolay Aleksandrov
2022-04-09 12:36 ` [Bridge] [PATCH net-next 0/6] net: bridge: add flush filtering support Nikolay Aleksandrov
2022-04-10 20:43 ` Nikolay Aleksandrov
2022-04-11 7:47 ` Ido Schimmel
2022-04-11 8:53 ` Nikolay Aleksandrov
2022-04-11 8:54 ` Ido Schimmel
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=20220409105857.803667-2-razor@blackwall.org \
--to=razor@blackwall.org \
--cc=bridge@lists.linux-foundation.org \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=roopa@nvidia.com \
/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