Since Linux commit
ddd1ad68826d ("net: bridge: Add netlink knobs for number
/ max learned FDB entries") [1] it is possible to limit to number of
dynamically learned fdb entries per bridge.
Add support to the systemd netdev bridge for the new netlink attribute
IFLA_BR_FDB_MAX_LEARNED.
[1] https://lore.kernel.org/all/
20231016-fdb_limit-v5-0-
32cddff87758@avm.de/
Signed-off-by: Gregor Herburger <gregor.herburger@ew.tq-group.com>
<xi:include href="version-info.xml" xpointer="v243"/>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><varname>FDBMaxLearned=</varname></term>
+ <listitem>
+ <para>Specifies the maximum number of learned Ethernet addresses for the bridge. When the limit is
+ reached, no more addresses are learned. When unset, the kernel's default will be used. 0 disables the limit.
+ </para>
+
+ <xi:include href="version-info.xml" xpointer="v257"/>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
[IFLA_BR_MCAST_MLD_VERSION] = BUILD_POLICY(U8),
[IFLA_BR_VLAN_STATS_PER_PORT] = BUILD_POLICY(U8),
[IFLA_BR_MULTI_BOOLOPT] = BUILD_POLICY_WITH_SIZE(BINARY, sizeof(struct br_boolopt_multi)),
+ [IFLA_BR_FDB_MAX_LEARNED] = BUILD_POLICY(U32),
};
static const NLAPolicy rtnl_link_info_data_can_policies[] = {
return r;
}
+ if (b->fdb_max_learned_set) {
+ r = sd_netlink_message_append_u32(req, IFLA_BR_FDB_MAX_LEARNED, b->fdb_max_learned);
+ if (r < 0)
+ return r;
+ }
+
r = sd_netlink_message_close_container(req);
if (r < 0)
return r;
prio);
}
+int config_parse_bridge_fdb_max_learned(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ Bridge *b = ASSERT_PTR(userdata);
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ if (isempty(rvalue)) {
+ b->fdb_max_learned_set = false;
+ return 0;
+ }
+
+ r = config_parse_uint32_bounded(unit, filename, line, section, section_line, lvalue, rvalue,
+ 0, UINT32_MAX, true, &b->fdb_max_learned);
+ if (r <= 0)
+ return r;
+
+ b->fdb_max_learned_set = true;
+ return 1;
+}
+
static void bridge_init(NetDev *netdev) {
Bridge *b = BRIDGE(netdev);
uint16_t group_fwd_mask;
uint16_t default_pvid;
uint8_t igmp_version;
+ uint32_t fdb_max_learned;
+ bool fdb_max_learned_set;
usec_t forward_delay;
usec_t hello_time;
CONFIG_PARSER_PROTOTYPE(config_parse_multicast_router);
CONFIG_PARSER_PROTOTYPE(config_parse_bridge_igmp_version);
CONFIG_PARSER_PROTOTYPE(config_parse_bridge_port_priority);
+CONFIG_PARSER_PROTOTYPE(config_parse_bridge_fdb_max_learned);
Bridge.VLANProtocol, config_parse_vlanprotocol, 0, offsetof(Bridge, vlan_protocol)
Bridge.STP, config_parse_tristate, 0, offsetof(Bridge, stp)
Bridge.MulticastIGMPVersion, config_parse_uint8, 0, offsetof(Bridge, igmp_version)
+Bridge.FDBMaxLearned, config_parse_bridge_fdb_max_learned, 0, offsetof(Bridge, fdb_max_learned)
VRF.TableId, config_parse_uint32, 0, offsetof(Vrf, table) /* deprecated */
VRF.Table, config_parse_uint32, 0, offsetof(Vrf, table)
BareUDP.DestinationPort, config_parse_ip_port, 0, offsetof(BareUDP, dest_port)