* [PATCH net-next v2 0/3] net: bridge: cfm: notify userspace on CFM config changes
@ 2026-10-05 4:38 Abdul Wasey
2026-10-05 4:38 ` [PATCH net-next v2 1/3] net: bridge: cfm: count CFM config attributes in the link message size Abdul Wasey
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Abdul Wasey @ 2026-10-05 4:38 UTC (permalink / raw)
To: netdev
Cc: razor, idosch, davem, edumazet, kuba, pabeni, horms,
horatiu.vultur, bridge, linux-kernel
CFM status changes are sent to userspace, config changes are not, so
the only way to see a MEP being created, a peer added or CCM
transmission started is to poll RTM_GETLINK. Patch 3 adds the
notification. Patches 1 and 2 fix the two problems the AI review found
in v1.
Patch 1 makes br_get_link_af_size_filtered() count the CFM config
attributes. Without it the notification overflows its skb once a MEP
has about 32 peers, and br_info_notify() hits its WARN_ON. Patch 2 puts
an empty IFLA_BRIDGE_CFM nest in the message when the bridge has no
MEPs, so deleting the last MEP is visible to a listener.
Tested with virtme-ng on net-next: 300 peer MEPs and config changes
give one notification each (6248 byte CFM payload) and no warning;
deleting the last MEP gives a notification with an empty
IFLA_BRIDGE_CFM; a request that fails before changing anything sends
nothing, one that fails half way still sends one. Also built with
CONFIG_BRIDGE_CFM off.
v2:
- new patch 1, count the config attributes in the message size
- new patch 2, empty CFM nest for a bridge with no MEPs
- patch 3: unchanged, rebased on current net-next
v1: https://lore.kernel.org/netdev/20261004041320.2684045-1-w453y.me@gmail.com/
Abdul Wasey (3):
net: bridge: cfm: count CFM config attributes in the link message size
net: bridge: cfm: send an empty CFM nest when a bridge has no MEPs
net: bridge: cfm: notify userspace on CFM config changes
net/bridge/br_cfm_netlink.c | 32 ++++++++++++++++++-------
net/bridge/br_netlink.c | 47 ++++++++++++++++++++++++++++++++++---
2 files changed, 67 insertions(+), 12 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v2 1/3] net: bridge: cfm: count CFM config attributes in the link message size
2026-10-05 4:38 [PATCH net-next v2 0/3] net: bridge: cfm: notify userspace on CFM config changes Abdul Wasey
@ 2026-10-05 4:38 ` Abdul Wasey
2026-10-05 4:38 ` [PATCH net-next v2 2/3] net: bridge: cfm: send an empty CFM nest when a bridge has no MEPs Abdul Wasey
2026-10-05 4:38 ` [PATCH net-next v2 3/3] net: bridge: cfm: notify userspace on CFM config changes Abdul Wasey
2 siblings, 0 replies; 4+ messages in thread
From: Abdul Wasey @ 2026-10-05 4:38 UTC (permalink / raw)
To: netdev
Cc: razor, idosch, davem, edumazet, kuba, pabeni, horms,
horatiu.vultur, bridge, linux-kernel
br_get_link_af_size_filtered() only counts the CFM attributes when
RTEXT_FILTER_CFM_STATUS is set. With RTEXT_FILTER_CFM_CONFIG alone it
returns before counting anything, while br_fill_ifinfo() still writes
the whole config, about 250 bytes per MEP and 20 per peer MEP.
Dumps cope with that, they just get a bigger buffer. A message built by
br_info_notify() can't, it fails with -EMSGSIZE and hits the WARN_ON
there. No notification asks for the CFM config today, but the next
patch adds one.
Count the config attributes when RTEXT_FILTER_CFM_CONFIG is set.
Signed-off-by: Abdul Wasey <w453y.me@gmail.com>
---
net/bridge/br_netlink.c | 42 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-)
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index f65b8b6ca..5160e801d 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -90,6 +90,36 @@ static int br_get_num_vlan_infos(struct net_bridge_vlan_group *vg,
return num_vlans;
}
+static size_t br_cfm_config_info_size(u32 num_meps, u32 num_peer_meps)
+{
+ size_t mep_sz, peer_sz;
+
+ /* IFLA_BRIDGE_CFM_MEP_CREATE_INFO: instance, domain, direction,
+ * ifindex
+ */
+ mep_sz = nla_total_size(4 * nla_total_size(sizeof(u32)));
+ /* IFLA_BRIDGE_CFM_MEP_CONFIG_INFO: instance, unicast mac, mdlevel,
+ * mepid
+ */
+ mep_sz += nla_total_size(3 * nla_total_size(sizeof(u32)) +
+ nla_total_size(ETH_ALEN));
+ /* IFLA_BRIDGE_CFM_CC_CONFIG_INFO: instance, enable, interval, maid */
+ mep_sz += nla_total_size(3 * nla_total_size(sizeof(u32)) +
+ nla_total_size(CFM_MAID_LENGTH));
+ /* IFLA_BRIDGE_CFM_CC_RDI_INFO: instance, rdi */
+ mep_sz += nla_total_size(2 * nla_total_size(sizeof(u32)));
+ /* IFLA_BRIDGE_CFM_CC_CCM_TX_INFO: instance, dmac, seq no update,
+ * period, if tlv, if tlv value, port tlv, port tlv value
+ */
+ mep_sz += nla_total_size(5 * nla_total_size(sizeof(u32)) +
+ nla_total_size(ETH_ALEN) +
+ 2 * nla_total_size(sizeof(u8)));
+ /* IFLA_BRIDGE_CFM_CC_PEER_MEP_INFO: instance, peer mepid */
+ peer_sz = nla_total_size(2 * nla_total_size(sizeof(u32)));
+
+ return num_meps * mep_sz + num_peer_meps * peer_sz;
+}
+
static size_t br_get_link_af_size_filtered(const struct net_device *dev,
u32 filter_mask)
{
@@ -122,17 +152,25 @@ static size_t br_get_link_af_size_filtered(const struct net_device *dev,
if (p && vg && (filter_mask & RTEXT_FILTER_MST))
vinfo_sz += br_mst_info_size(vg);
- if (!(filter_mask & RTEXT_FILTER_CFM_STATUS))
+ if (!(filter_mask & (RTEXT_FILTER_CFM_CONFIG | RTEXT_FILTER_CFM_STATUS)))
return vinfo_sz;
if (!br)
return vinfo_sz;
- /* CFM status info must be added */
br_cfm_mep_count(br, &num_cfm_mep_infos);
br_cfm_peer_mep_count(br, &num_cfm_peer_mep_infos);
vinfo_sz += nla_total_size(0); /* IFLA_BRIDGE_CFM */
+
+ if (filter_mask & RTEXT_FILTER_CFM_CONFIG)
+ vinfo_sz += br_cfm_config_info_size(num_cfm_mep_infos,
+ num_cfm_peer_mep_infos);
+
+ if (!(filter_mask & RTEXT_FILTER_CFM_STATUS))
+ return vinfo_sz;
+
+ /* CFM status info must be added */
/* For each status struct the MEP instance (u32) is added */
/* MEP instance (u32) + br_cfm_mep_status */
vinfo_sz += num_cfm_mep_infos *
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v2 2/3] net: bridge: cfm: send an empty CFM nest when a bridge has no MEPs
2026-10-05 4:38 [PATCH net-next v2 0/3] net: bridge: cfm: notify userspace on CFM config changes Abdul Wasey
2026-10-05 4:38 ` [PATCH net-next v2 1/3] net: bridge: cfm: count CFM config attributes in the link message size Abdul Wasey
@ 2026-10-05 4:38 ` Abdul Wasey
2026-10-05 4:38 ` [PATCH net-next v2 3/3] net: bridge: cfm: notify userspace on CFM config changes Abdul Wasey
2 siblings, 0 replies; 4+ messages in thread
From: Abdul Wasey @ 2026-10-05 4:38 UTC (permalink / raw)
To: netdev
Cc: razor, idosch, davem, edumazet, kuba, pabeni, horms,
horatiu.vultur, bridge, linux-kernel
br_fill_ifinfo() leaves IFLA_BRIDGE_CFM out when the bridge has no
MEPs. For a dump that is fine, but a notification sent after the last
MEP is deleted then looks like any other RTM_NEWLINK for the bridge,
and a listener can't tell that the CFM config is now empty.
Put an empty IFLA_BRIDGE_CFM nest in the message instead when CFM is
asked for and the bridge has no MEPs. Ports still get none, as before.
Signed-off-by: Abdul Wasey <w453y.me@gmail.com>
---
net/bridge/br_netlink.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 5160e801d..68ec4529f 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -603,7 +603,10 @@ static int br_fill_ifinfo(struct sk_buff *skb,
struct nlattr *cfm_nest = NULL;
int err;
- if (!br_cfm_created(br) || port)
+ /* A bridge with no MEPs gets an empty IFLA_BRIDGE_CFM, so a
+ * listener can tell that the last MEP is gone.
+ */
+ if (!IS_ENABLED(CONFIG_BRIDGE_CFM) || port)
goto done;
cfm_nest = nla_nest_start(skb, IFLA_BRIDGE_CFM);
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v2 3/3] net: bridge: cfm: notify userspace on CFM config changes
2026-10-05 4:38 [PATCH net-next v2 0/3] net: bridge: cfm: notify userspace on CFM config changes Abdul Wasey
2026-10-05 4:38 ` [PATCH net-next v2 1/3] net: bridge: cfm: count CFM config attributes in the link message size Abdul Wasey
2026-10-05 4:38 ` [PATCH net-next v2 2/3] net: bridge: cfm: send an empty CFM nest when a bridge has no MEPs Abdul Wasey
@ 2026-10-05 4:38 ` Abdul Wasey
2 siblings, 0 replies; 4+ messages in thread
From: Abdul Wasey @ 2026-10-05 4:38 UTC (permalink / raw)
To: netdev
Cc: razor, idosch, davem, edumazet, kuba, pabeni, horms,
horatiu.vultur, bridge, linux-kernel
CFM status changes are sent to userspace by br_cfm_notify(), but config
changes are not. br_afspec() calls br_cfm_parse() without the "changed"
pointer, so creating a MEP, adding a peer or starting CCM transmission
never sends an RTM_NEWLINK. Today the only way to see these changes is
to poll RTM_GETLINK with RTEXT_FILTER_CFM_CONFIG.
Send one RTM_NEWLINK with RTEXT_FILTER_CFM_CONFIG from br_cfm_parse()
once any group in the request has been applied. If a later group in the
same request fails, still send it, since the earlier groups already
changed the config.
br_ifinfo_notify() is not used because it asks for
RTEXT_FILTER_BRVLAN_COMPRESSED, so the message would not carry the CFM
attributes. This calls br_info_notify() the same way br_cfm_notify()
does for status.
Signed-off-by: Abdul Wasey <w453y.me@gmail.com>
---
net/bridge/br_cfm_netlink.c | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/net/bridge/br_cfm_netlink.c b/net/bridge/br_cfm_netlink.c
index 91b9922dc..56309e6f4 100644
--- a/net/bridge/br_cfm_netlink.c
+++ b/net/bridge/br_cfm_netlink.c
@@ -382,6 +382,7 @@ int br_cfm_parse(struct net_bridge *br, struct net_bridge_port *p,
struct nlattr *attr, int cmd, struct netlink_ext_ack *extack)
{
struct nlattr *tb[IFLA_BRIDGE_CFM_MAX + 1];
+ bool changed = false;
int err;
/* When this function is called for a port then the br pointer is
@@ -399,59 +400,72 @@ int br_cfm_parse(struct net_bridge *br, struct net_bridge_port *p,
err = br_mep_create_parse(br, tb[IFLA_BRIDGE_CFM_MEP_CREATE],
extack);
if (err)
- return err;
+ goto out;
+ changed = true;
}
if (tb[IFLA_BRIDGE_CFM_MEP_DELETE]) {
err = br_mep_delete_parse(br, tb[IFLA_BRIDGE_CFM_MEP_DELETE],
extack);
if (err)
- return err;
+ goto out;
+ changed = true;
}
if (tb[IFLA_BRIDGE_CFM_MEP_CONFIG]) {
err = br_mep_config_parse(br, tb[IFLA_BRIDGE_CFM_MEP_CONFIG],
extack);
if (err)
- return err;
+ goto out;
+ changed = true;
}
if (tb[IFLA_BRIDGE_CFM_CC_CONFIG]) {
err = br_cc_config_parse(br, tb[IFLA_BRIDGE_CFM_CC_CONFIG],
extack);
if (err)
- return err;
+ goto out;
+ changed = true;
}
if (tb[IFLA_BRIDGE_CFM_CC_PEER_MEP_ADD]) {
err = br_cc_peer_mep_add_parse(br, tb[IFLA_BRIDGE_CFM_CC_PEER_MEP_ADD],
extack);
if (err)
- return err;
+ goto out;
+ changed = true;
}
if (tb[IFLA_BRIDGE_CFM_CC_PEER_MEP_REMOVE]) {
err = br_cc_peer_mep_remove_parse(br, tb[IFLA_BRIDGE_CFM_CC_PEER_MEP_REMOVE],
extack);
if (err)
- return err;
+ goto out;
+ changed = true;
}
if (tb[IFLA_BRIDGE_CFM_CC_RDI]) {
err = br_cc_rdi_parse(br, tb[IFLA_BRIDGE_CFM_CC_RDI],
extack);
if (err)
- return err;
+ goto out;
+ changed = true;
}
if (tb[IFLA_BRIDGE_CFM_CC_CCM_TX]) {
err = br_cc_ccm_tx_parse(br, tb[IFLA_BRIDGE_CFM_CC_CCM_TX],
extack);
if (err)
- return err;
+ goto out;
+ changed = true;
}
- return 0;
+out:
+ /* Earlier groups may have been applied even if a later one failed */
+ if (changed)
+ br_info_notify(RTM_NEWLINK, br, NULL, RTEXT_FILTER_CFM_CONFIG);
+
+ return err;
}
int br_cfm_config_fill_info(struct sk_buff *skb, struct net_bridge *br)
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-05 4:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-05 4:38 [PATCH net-next v2 0/3] net: bridge: cfm: notify userspace on CFM config changes Abdul Wasey
2026-10-05 4:38 ` [PATCH net-next v2 1/3] net: bridge: cfm: count CFM config attributes in the link message size Abdul Wasey
2026-10-05 4:38 ` [PATCH net-next v2 2/3] net: bridge: cfm: send an empty CFM nest when a bridge has no MEPs Abdul Wasey
2026-10-05 4:38 ` [PATCH net-next v2 3/3] net: bridge: cfm: notify userspace on CFM config changes Abdul Wasey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®