From 5a3e759bd03cd42fdfb7927684ea0b29e086a308 Mon Sep 17 00:00:00 2001 From: Gregor Herburger Date: Wed, 12 Jun 2024 14:05:09 +0200 Subject: [PATCH] networkctl: add support to display learned fdb entries 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 networkctl for the netlink bridge attributes IFLA_BR_FDB_MAX_LEARNED and IFLA_BR_FDB_N_LEARNED. [1] https://lore.kernel.org/all/20231016-fdb_limit-v5-0-32cddff87758@avm.de/ Signed-off-by: Gregor Herburger --- src/libsystemd/sd-netlink/netlink-types-rtnl.c | 1 + src/network/networkctl.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/libsystemd/sd-netlink/netlink-types-rtnl.c b/src/libsystemd/sd-netlink/netlink-types-rtnl.c index 4cd54a3df55..a85b4b16c3c 100644 --- a/src/libsystemd/sd-netlink/netlink-types-rtnl.c +++ b/src/libsystemd/sd-netlink/netlink-types-rtnl.c @@ -173,6 +173,7 @@ static const NLAPolicy rtnl_link_info_data_bridge_policies[] = { [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_N_LEARNED] = BUILD_POLICY(U32), [IFLA_BR_FDB_MAX_LEARNED] = BUILD_POLICY(U32), }; diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 69e5ca869d2..b51c7aa7e59 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -415,6 +415,9 @@ typedef struct LinkInfo { uint16_t priority; uint8_t mcast_igmp_version; uint8_t port_state; + uint32_t fdb_max_learned; + uint32_t fdb_n_learned; + bool has_fdb_learned; /* vxlan info */ VxLanInfo vxlan_info; @@ -522,6 +525,9 @@ static int decode_netdev(sd_netlink_message *m, LinkInfo *info) { (void) sd_netlink_message_read_u16(m, IFLA_BR_PRIORITY, &info->priority); (void) sd_netlink_message_read_u8(m, IFLA_BR_MCAST_IGMP_VERSION, &info->mcast_igmp_version); (void) sd_netlink_message_read_u8(m, IFLA_BRPORT_STATE, &info->port_state); + if (sd_netlink_message_read_u32(m, IFLA_BR_FDB_MAX_LEARNED, &info->fdb_max_learned) >= 0 && + sd_netlink_message_read_u32(m, IFLA_BR_FDB_N_LEARNED, &info->fdb_n_learned) >= 0) + info->has_fdb_learned = true; } if (streq(info->netdev_kind, "bond")) { (void) sd_netlink_message_read_u8(m, IFLA_BOND_MODE, &info->mode); (void) sd_netlink_message_read_u32(m, IFLA_BOND_MIIMON, &info->miimon); @@ -1910,6 +1916,16 @@ static int link_status_one( if (r < 0) return table_log_add_error(r); + if (info->has_fdb_learned) { + r = table_add_many(table, + TABLE_FIELD, "FDB Learned", + TABLE_UINT32, info->fdb_n_learned, + TABLE_FIELD, "FDB Max Learned", + TABLE_UINT32, info->fdb_max_learned); + if (r < 0) + return table_log_add_error(r); + } + if (info->port_state <= BR_STATE_BLOCKING) { r = table_add_many(table, TABLE_FIELD, "Port State",