Johannes Nixdorf
2023-Oct-18 07:04 UTC
[Bridge] [PATCH iproute2-next v5] iplink: bridge: Add support for bridge FDB learning limits
Support setting the FDB limit through ip link. The arguments is:
- fdb_max_learned: A 32-bit unsigned integer specifying the maximum
number of learned FDB entries, with 0 disabling
the limit.
Also support reading back the current number of learned FDB entries in
the bridge by this count. The returned value's name is:
- fdb_n_learned: A 32-bit unsigned integer specifying the current number
of learned FDB entries.
Example:
# ip -d -j -p link show br0
[ {
...
"linkinfo": {
"info_kind": "bridge",
"info_data": {
...
"fdb_n_learned": 2,
"fdb_max_learned": 0,
...
}
},
...
} ]
# ip link set br0 type bridge fdb_max_learned 1024
# ip -d -j -p link show br0
[ {
...
"linkinfo": {
"info_kind": "bridge",
"info_data": {
...
"fdb_n_learned": 2,
"fdb_max_learned": 1024,
...
}
},
...
} ]
Signed-off-by: Johannes Nixdorf <jnixdorf-oss at avm.de>
---
The corresponding kernel changes are in net-next.git as commit
ddd1ad68826d ("net: bridge: Add netlink knobs for number / max learned
FDB entries").
---
Changes in v5:
- Removed the RFC status again, as the kernel changes landed.
- Link to v4: https://lore.kernel.org/r/20230919-fdb_limit-v4-1-b4d2dc4df30f at
avm.de
Changes in v4:
- Removed _entries from the names. (from review)
- Removed the UAPI change, to be synced from linux separately by the
maintainer. (from review)
For local testing e.g. `make CCOPTS="-O2 -pipe
-I${path_to_dev_kernel_headers}"` works as a workaround.
- Downgraded to an RFC until the kernel changes land.
- Link to v3:
https://lore.kernel.org/netdev/20230905-fdb_limit-v3-1-34bb124556d8 at avm.de/
Changes in v3:
- Properly split the net-next and iproute2-next threads. (from review)
- Changed to *_n_* instead of *_cur_*. (from review)
- Use strcmp() instead of matches(). (from review)
- Made names in code and documentation consistent. (from review)
- Various documentation fixes. (from review)
- Link to v2:
https://lore.kernel.org/netdev/20230619071444.14625-1-jnixdorf-oss at avm.de/
Changes in v2:
- Sent out the first corresponding iproute2 patches.
- Link to v1: https://lore.kernel.org/netdev/20230515085046.4457-1-jnixdorf-oss
at avm.de/
---
ip/iplink_bridge.c | 21 +++++++++++++++++++++
man/man8/ip-link.8.in | 10 ++++++++++
2 files changed, 31 insertions(+)
diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
index 462075295308..6b70ffbb6f5f 100644
--- a/ip/iplink_bridge.c
+++ b/ip/iplink_bridge.c
@@ -34,6 +34,7 @@ static void print_explain(FILE *f)
" [ group_fwd_mask MASK ]\n"
" [ group_address ADDRESS ]\n"
" [ no_linklocal_learn NO_LINKLOCAL_LEARN ]\n"
+ " [ fdb_max_learned FDB_MAX_LEARNED ]\n"
" [ vlan_filtering VLAN_FILTERING ]\n"
" [ vlan_protocol VLAN_PROTOCOL ]\n"
" [ vlan_default_pvid VLAN_DEFAULT_PVID ]\n"
@@ -168,6 +169,14 @@ static int bridge_parse_opt(struct link_util *lu, int argc,
char **argv,
bm.optval |= no_ll_learn_bit;
else
bm.optval &= ~no_ll_learn_bit;
+ } else if (strcmp(*argv, "fdb_max_learned") == 0) {
+ __u32 fdb_max_learned;
+
+ NEXT_ARG();
+ if (get_u32(&fdb_max_learned, *argv, 0))
+ invarg("invalid fdb_max_learned", *argv);
+
+ addattr32(n, 1024, IFLA_BR_FDB_MAX_LEARNED, fdb_max_learned);
} else if (matches(*argv, "fdb_flush") == 0) {
addattr(n, 1024, IFLA_BR_FDB_FLUSH);
} else if (matches(*argv, "vlan_default_pvid") == 0) {
@@ -544,6 +553,18 @@ static void bridge_print_opt(struct link_util *lu, FILE *f,
struct rtattr *tb[])
if (tb[IFLA_BR_GC_TIMER])
_bridge_print_timer(f, "gc_timer", tb[IFLA_BR_GC_TIMER]);
+ if (tb[IFLA_BR_FDB_N_LEARNED])
+ print_uint(PRINT_ANY,
+ "fdb_n_learned",
+ "fdb_n_learned %u ",
+ rta_getattr_u32(tb[IFLA_BR_FDB_N_LEARNED]));
+
+ if (tb[IFLA_BR_FDB_MAX_LEARNED])
+ print_uint(PRINT_ANY,
+ "fdb_max_learned",
+ "fdb_max_learned %u ",
+ rta_getattr_u32(tb[IFLA_BR_FDB_MAX_LEARNED]));
+
if (tb[IFLA_BR_VLAN_DEFAULT_PVID])
print_uint(PRINT_ANY,
"vlan_default_pvid",
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index 7365d0c6b14f..e82b2dbb0070 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -1630,6 +1630,8 @@ the following additional arguments are supported:
] [
.BI no_linklocal_learn " NO_LINKLOCAL_LEARN "
] [
+.BI fdb_max_learned " FDB_MAX_LEARNED "
+] [
.BI vlan_filtering " VLAN_FILTERING "
] [
.BI vlan_protocol " VLAN_PROTOCOL "
@@ -1741,6 +1743,14 @@ or off
When disabled, the bridge will not learn from link-local frames (default:
enabled).
+.BI fdb_max_learned " FDB_MAX_LEARNED "
+- set the maximum number of learned FDB entries. If
+.RI ( FDB_MAX_LEARNED " == 0) "
+the feature is disabled. Default is
+.BR 0 .
+.I FDB_MAX_LEARNED
+is a 32bit unsigned integer.
+
.BI vlan_filtering " VLAN_FILTERING "
- turn VLAN filtering on
.RI ( VLAN_FILTERING " > 0) "
---
base-commit: 582453de1b65e9eada669d9aea4aca88509e7658
change-id: 20230905-fdb_limit-ace1467c6a84
Best regards,
--
Johannes Nixdorf <jnixdorf-oss at avm.de>
Petr Machata
2023-Oct-19 09:50 UTC
[Bridge] [PATCH iproute2-next v5] iplink: bridge: Add support for bridge FDB learning limits
Johannes Nixdorf <jnixdorf-oss at avm.de> writes:> Support setting the FDB limit through ip link. The arguments is: > - fdb_max_learned: A 32-bit unsigned integer specifying the maximum > number of learned FDB entries, with 0 disabling > the limit. > > Also support reading back the current number of learned FDB entries in > the bridge by this count. The returned value's name is: > - fdb_n_learned: A 32-bit unsigned integer specifying the current number > of learned FDB entries. > > Example: > > # ip -d -j -p link show br0 > [ { > ... > "linkinfo": { > "info_kind": "bridge", > "info_data": { > ... > "fdb_n_learned": 2, > "fdb_max_learned": 0, > ... > } > }, > ... > } ] > # ip link set br0 type bridge fdb_max_learned 1024 > # ip -d -j -p link show br0 > [ { > ... > "linkinfo": { > "info_kind": "bridge", > "info_data": { > ... > "fdb_n_learned": 2, > "fdb_max_learned": 1024, > ... > } > }, > ... > } ] > > Signed-off-by: Johannes Nixdorf <jnixdorf-oss at avm.de>Reviewed-by: Petr Machata <petrm at nvidia.com>
Nikolay Aleksandrov
2023-Oct-19 13:12 UTC
[Bridge] [PATCH iproute2-next v5] iplink: bridge: Add support for bridge FDB learning limits
On 10/18/23 10:04, Johannes Nixdorf wrote:> Support setting the FDB limit through ip link. The arguments is: > - fdb_max_learned: A 32-bit unsigned integer specifying the maximum > number of learned FDB entries, with 0 disabling > the limit. > > Also support reading back the current number of learned FDB entries in > the bridge by this count. The returned value's name is: > - fdb_n_learned: A 32-bit unsigned integer specifying the current number > of learned FDB entries. > > Example: > > # ip -d -j -p link show br0 > [ { > ... > "linkinfo": { > "info_kind": "bridge", > "info_data": { > ... > "fdb_n_learned": 2, > "fdb_max_learned": 0, > ... > } > }, > ... > } ] > # ip link set br0 type bridge fdb_max_learned 1024 > # ip -d -j -p link show br0 > [ { > ... > "linkinfo": { > "info_kind": "bridge", > "info_data": { > ... > "fdb_n_learned": 2, > "fdb_max_learned": 1024, > ... > } > }, > ... > } ] > > Signed-off-by: Johannes Nixdorf <jnixdorf-oss at avm.de> > --- > The corresponding kernel changes are in net-next.git as commit > ddd1ad68826d ("net: bridge: Add netlink knobs for number / max learned > FDB entries"). > --- > Changes in v5: > - Removed the RFC status again, as the kernel changes landed. > - Link to v4: https://lore.kernel.org/r/20230919-fdb_limit-v4-1-b4d2dc4df30f at avm.de > > Changes in v4: > - Removed _entries from the names. (from review) > - Removed the UAPI change, to be synced from linux separately by the > maintainer. (from review) > For local testing e.g. `make CCOPTS="-O2 -pipe > -I${path_to_dev_kernel_headers}"` works as a workaround. > - Downgraded to an RFC until the kernel changes land. > - Link to v3: https://lore.kernel.org/netdev/20230905-fdb_limit-v3-1-34bb124556d8 at avm.de/ > > Changes in v3: > - Properly split the net-next and iproute2-next threads. (from review) > - Changed to *_n_* instead of *_cur_*. (from review) > - Use strcmp() instead of matches(). (from review) > - Made names in code and documentation consistent. (from review) > - Various documentation fixes. (from review) > - Link to v2: https://lore.kernel.org/netdev/20230619071444.14625-1-jnixdorf-oss at avm.de/ > > Changes in v2: > - Sent out the first corresponding iproute2 patches. > - Link to v1: https://lore.kernel.org/netdev/20230515085046.4457-1-jnixdorf-oss at avm.de/ > --- > ip/iplink_bridge.c | 21 +++++++++++++++++++++ > man/man8/ip-link.8.in | 10 ++++++++++ > 2 files changed, 31 insertions(+) >Acked-by: Nikolay Aleksandrov <razor at blackwall.org>
patchwork-bot+netdevbpf at kernel.org
2023-Oct-19 15:40 UTC
[Bridge] [PATCH iproute2-next v5] iplink: bridge: Add support for bridge FDB learning limits
Hello: This patch was applied to iproute2/iproute2-next.git (main) by David Ahern <dsahern at kernel.org>: On Wed, 18 Oct 2023 09:04:43 +0200 you wrote:> Support setting the FDB limit through ip link. The arguments is: > - fdb_max_learned: A 32-bit unsigned integer specifying the maximum > number of learned FDB entries, with 0 disabling > the limit. > > Also support reading back the current number of learned FDB entries in > the bridge by this count. The returned value's name is: > - fdb_n_learned: A 32-bit unsigned integer specifying the current number > of learned FDB entries. > > [...]Here is the summary with links: - [iproute2-next,v5] iplink: bridge: Add support for bridge FDB learning limits https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=48cb4320487a You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Apparently Analagous Threads
- [Bridge] [PATCH iproute2-next v3] iplink: bridge: Add support for bridge FDB learning limits
- [Bridge] [PATCH iproute2-next 1/1] iplink: bridge: Add support for bridge FDB learning limits
- [Bridge] [PATCH net-next v2 0/3, iproute2-next 0/1] bridge: Add a limit on learned FDB entries
- Re: KVM-Docker-Networking using TAP and MACVLAN
- KVM-Docker-Networking using TAP and MACVLAN