* [Bridge] [PATCH iproute2-next v3] iplink: bridge: Add support for bridge FDB learning limits
@ 2023-09-05 11:47 ` Johannes Nixdorf
0 siblings, 0 replies; 4+ messages in thread
From: Johannes Nixdorf @ 2023-09-05 11:47 UTC (permalink / raw)
To: David S. Miller, Andrew Lunn, David Ahern, Eric Dumazet,
Florian Fainelli, Ido Schimmel, Jakub Kicinski,
Nikolay Aleksandrov, Oleksij Rempel, Paolo Abeni, Roopa Prabhu,
Shuah Khan, Vladimir Oltean
Cc: netdev, bridge, Johannes Nixdorf, linux-kernel, linux-kselftest
Support setting the FDB limit through ip link. The arguments is:
- fdb_max_learned_entries: 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_entries: 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_entries": 2,
"fdb_max_learned_entries": 0,
...
}
},
...
} ]
# ip link set br0 type bridge fdb_max_learned_entries 1024
# ip -d -j -p link show br0
[ {
...
"linkinfo": {
"info_kind": "bridge",
"info_data": {
...
"fdb_n_learned_entries": 2,
"fdb_max_learned_entries": 1024,
...
}
},
...
} ]
Signed-off-by: Johannes Nixdorf <jnixdorf-oss@avm.de>
---
Changes since v2:
- 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)
Changes since v1:
- Sent out the first corresponding iproute2 patches.
net-next v3: https://lore.kernel.org/netdev/20230905-fdb_limit-v3-0-7597cd500a82@avm.de/
v2: https://lore.kernel.org/netdev/20230619071444.14625-1-jnixdorf-oss@avm.de/
v1: https://lore.kernel.org/netdev/20230515085046.4457-1-jnixdorf-oss@avm.de/
---
include/uapi/linux/if_link.h | 2 ++
ip/iplink_bridge.c | 21 +++++++++++++++++++++
man/man8/ip-link.8.in | 10 ++++++++++
3 files changed, 33 insertions(+)
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index c2ca7a6add0e..51cf58e3171c 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -508,6 +508,8 @@ enum {
IFLA_BR_VLAN_STATS_PER_PORT,
IFLA_BR_MULTI_BOOLOPT,
IFLA_BR_MCAST_QUERIER_STATE,
+ IFLA_BR_FDB_N_LEARNED_ENTRIES,
+ IFLA_BR_FDB_MAX_LEARNED_ENTRIES,
__IFLA_BR_MAX,
};
diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
index 7e4e62c81c0c..f08754618e0f 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_entries FDB_MAX_LEARNED_ENTRIES ]\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_entries") == 0) {
+ __u32 fdb_max_learned_entries;
+
+ NEXT_ARG();
+ if (get_u32(&fdb_max_learned_entries, *argv, 0))
+ invarg("invalid fdb_max_learned_entries", *argv);
+
+ addattr32(n, 1024, IFLA_BR_FDB_MAX_LEARNED_ENTRIES, fdb_max_learned_entries);
} 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_ENTRIES])
+ print_uint(PRINT_ANY,
+ "fdb_n_learned_entries",
+ "fdb_n_learned_entries %u ",
+ rta_getattr_u32(tb[IFLA_BR_FDB_N_LEARNED_ENTRIES]));
+
+ if (tb[IFLA_BR_FDB_MAX_LEARNED_ENTRIES])
+ print_uint(PRINT_ANY,
+ "fdb_max_learned_entries",
+ "fdb_max_learned_entries %u ",
+ rta_getattr_u32(tb[IFLA_BR_FDB_MAX_LEARNED_ENTRIES]));
+
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..184ae9183712 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_entries " FDB_MAX_LEARNED_ENTRIES "
+] [
.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_entries " FDB_MAX_LEARNED_ENTRIES "
+- set the maximum number of learned FDB entries. If
+.RI ( FDB_MAX_LEARNED_ENTRIES " == 0) "
+the feature is disabled. Default is
+.BR 0 .
+.I FDB_MAX_LEARNED_ENTRIES
+is a 32bit unsigned integer.
+
.BI vlan_filtering " VLAN_FILTERING "
- turn VLAN filtering on
.RI ( VLAN_FILTERING " > 0) "
---
base-commit: 865dd3ab1580092221c73317a844ee65f032c9e8
change-id: 20230905-fdb_limit-ace1467c6a84
Best regards,
--
Johannes Nixdorf <jnixdorf-oss@avm.de>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH iproute2-next v3] iplink: bridge: Add support for bridge FDB learning limits
@ 2023-09-05 11:47 ` Johannes Nixdorf
0 siblings, 0 replies; 4+ messages in thread
From: Johannes Nixdorf @ 2023-09-05 11:47 UTC (permalink / raw)
To: David S. Miller, Andrew Lunn, David Ahern, Eric Dumazet,
Florian Fainelli, Ido Schimmel, Jakub Kicinski,
Nikolay Aleksandrov, Oleksij Rempel, Paolo Abeni, Roopa Prabhu,
Shuah Khan, Vladimir Oltean
Cc: bridge, netdev, linux-kernel, linux-kselftest, Johannes Nixdorf
Support setting the FDB limit through ip link. The arguments is:
- fdb_max_learned_entries: 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_entries: 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_entries": 2,
"fdb_max_learned_entries": 0,
...
}
},
...
} ]
# ip link set br0 type bridge fdb_max_learned_entries 1024
# ip -d -j -p link show br0
[ {
...
"linkinfo": {
"info_kind": "bridge",
"info_data": {
...
"fdb_n_learned_entries": 2,
"fdb_max_learned_entries": 1024,
...
}
},
...
} ]
Signed-off-by: Johannes Nixdorf <jnixdorf-oss@avm.de>
---
Changes since v2:
- 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)
Changes since v1:
- Sent out the first corresponding iproute2 patches.
net-next v3: https://lore.kernel.org/netdev/20230905-fdb_limit-v3-0-7597cd500a82@avm.de/
v2: https://lore.kernel.org/netdev/20230619071444.14625-1-jnixdorf-oss@avm.de/
v1: https://lore.kernel.org/netdev/20230515085046.4457-1-jnixdorf-oss@avm.de/
---
include/uapi/linux/if_link.h | 2 ++
ip/iplink_bridge.c | 21 +++++++++++++++++++++
man/man8/ip-link.8.in | 10 ++++++++++
3 files changed, 33 insertions(+)
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index c2ca7a6add0e..51cf58e3171c 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -508,6 +508,8 @@ enum {
IFLA_BR_VLAN_STATS_PER_PORT,
IFLA_BR_MULTI_BOOLOPT,
IFLA_BR_MCAST_QUERIER_STATE,
+ IFLA_BR_FDB_N_LEARNED_ENTRIES,
+ IFLA_BR_FDB_MAX_LEARNED_ENTRIES,
__IFLA_BR_MAX,
};
diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
index 7e4e62c81c0c..f08754618e0f 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_entries FDB_MAX_LEARNED_ENTRIES ]\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_entries") == 0) {
+ __u32 fdb_max_learned_entries;
+
+ NEXT_ARG();
+ if (get_u32(&fdb_max_learned_entries, *argv, 0))
+ invarg("invalid fdb_max_learned_entries", *argv);
+
+ addattr32(n, 1024, IFLA_BR_FDB_MAX_LEARNED_ENTRIES, fdb_max_learned_entries);
} 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_ENTRIES])
+ print_uint(PRINT_ANY,
+ "fdb_n_learned_entries",
+ "fdb_n_learned_entries %u ",
+ rta_getattr_u32(tb[IFLA_BR_FDB_N_LEARNED_ENTRIES]));
+
+ if (tb[IFLA_BR_FDB_MAX_LEARNED_ENTRIES])
+ print_uint(PRINT_ANY,
+ "fdb_max_learned_entries",
+ "fdb_max_learned_entries %u ",
+ rta_getattr_u32(tb[IFLA_BR_FDB_MAX_LEARNED_ENTRIES]));
+
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..184ae9183712 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_entries " FDB_MAX_LEARNED_ENTRIES "
+] [
.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_entries " FDB_MAX_LEARNED_ENTRIES "
+- set the maximum number of learned FDB entries. If
+.RI ( FDB_MAX_LEARNED_ENTRIES " == 0) "
+the feature is disabled. Default is
+.BR 0 .
+.I FDB_MAX_LEARNED_ENTRIES
+is a 32bit unsigned integer.
+
.BI vlan_filtering " VLAN_FILTERING "
- turn VLAN filtering on
.RI ( VLAN_FILTERING " > 0) "
---
base-commit: 865dd3ab1580092221c73317a844ee65f032c9e8
change-id: 20230905-fdb_limit-ace1467c6a84
Best regards,
--
Johannes Nixdorf <jnixdorf-oss@avm.de>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Bridge] [PATCH iproute2-next v3] iplink: bridge: Add support for bridge FDB learning limits
2023-09-05 11:47 ` Johannes Nixdorf
@ 2023-09-06 10:32 ` Petr Machata
-1 siblings, 0 replies; 4+ messages in thread
From: Petr Machata @ 2023-09-06 10:32 UTC (permalink / raw)
To: Johannes Nixdorf
Cc: David Ahern, Ido Schimmel, Nikolay Aleksandrov, bridge, netdev,
Roopa Prabhu
(I pruned the CC list, hopefully I didn't leave out anybody who cares.)
Johannes Nixdorf via Bridge <bridge@lists.linux-foundation.org> writes:
> Support setting the FDB limit through ip link. The arguments is:
> - fdb_max_learned_entries: A 32-bit unsigned integer specifying the
> maximum number of learned FDB entries, with 0
> disabling the limit.
...
> Signed-off-by: Johannes Nixdorf <jnixdorf-oss@avm.de>
Code looks good to me. A couple points though:
- The corresponding kernel changes have not yet been merged, have they?
This patch should obviously only be merged after that happens.
- The UAPI changes should not be part of the patch, the maintainers will
update themselves.
- The names fdb_n_learned_entries, fdb_max_learned_entries... they are
somewhat unwieldy IMHO. Just for consideration, I don't feel strongly
about this:
Your kconfig option is named BRIDGE_DEFAULT_FDB_MAX_LEARNED, and that
makes sense to me, because yeah, given the word "learned" in context
of FDB, "entries" is the obvious continuation, so why mention it
explicitly. Consider following suit with the other source artifacts --
the attribute names, struct fields, keywords in this patch.
"fdb_n_learned", "fdb_max_learned" is IMHO just as understandable and
will be easier to type.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Bridge] [PATCH iproute2-next v3] iplink: bridge: Add support for bridge FDB learning limits
@ 2023-09-06 10:32 ` Petr Machata
0 siblings, 0 replies; 4+ messages in thread
From: Petr Machata @ 2023-09-06 10:32 UTC (permalink / raw)
To: Johannes Nixdorf
Cc: David Ahern, Ido Schimmel, Nikolay Aleksandrov, Roopa Prabhu,
netdev, bridge
(I pruned the CC list, hopefully I didn't leave out anybody who cares.)
Johannes Nixdorf via Bridge <bridge@lists.linux-foundation.org> writes:
> Support setting the FDB limit through ip link. The arguments is:
> - fdb_max_learned_entries: A 32-bit unsigned integer specifying the
> maximum number of learned FDB entries, with 0
> disabling the limit.
...
> Signed-off-by: Johannes Nixdorf <jnixdorf-oss@avm.de>
Code looks good to me. A couple points though:
- The corresponding kernel changes have not yet been merged, have they?
This patch should obviously only be merged after that happens.
- The UAPI changes should not be part of the patch, the maintainers will
update themselves.
- The names fdb_n_learned_entries, fdb_max_learned_entries... they are
somewhat unwieldy IMHO. Just for consideration, I don't feel strongly
about this:
Your kconfig option is named BRIDGE_DEFAULT_FDB_MAX_LEARNED, and that
makes sense to me, because yeah, given the word "learned" in context
of FDB, "entries" is the obvious continuation, so why mention it
explicitly. Consider following suit with the other source artifacts --
the attribute names, struct fields, keywords in this patch.
"fdb_n_learned", "fdb_max_learned" is IMHO just as understandable and
will be easier to type.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-09-06 10:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-05 11:47 [Bridge] [PATCH iproute2-next v3] iplink: bridge: Add support for bridge FDB learning limits Johannes Nixdorf
2023-09-05 11:47 ` Johannes Nixdorf
2023-09-06 10:32 ` [Bridge] " Petr Machata
2023-09-06 10:32 ` Petr Machata
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.