On 03/09/2026 09:56, Zhiling Zou wrote:
CFM and MRP register a global br_frame_type whose hlist_node is linked into the per-bridge frame_type_list when the first MEP/MRP instance is created. Enabling the protocol on multiple bridges therefore inserts the same node into multiple lists. Unregistering it on one bridge then corrupts list state belonging to another.These handlers can only be installed once per bridge, and they are uncommon. Track their per-bridge enable state with net_bridge option bits, which already live on the Rx hot cache line, and dispatch the matching handler directly from the receive path. Check both bits together first as an unlikely case. Remove the generic frame_type_list and br_frame_type helpers, which have had no other users since CFM and MRP were added. That shrinks struct net_bridge by 8 bytes and drops the list walk from the fast path. When neither protocol is compiled in, BR_CFM_MRP_OPTS is 0 and the compiler prunes the branch. Fixes: 90c628dd47ff ("net: bridge: extend the process of special frames") Fixes: dc32cbb3dbd7 ("bridge: cfm: Kernel space implementation of CFM. CCM frame RX added.") Cc: [email protected] Reported-by: Vega <[email protected]> Suggested-by: Nikolay Aleksandrov <[email protected]> Co-developed-by: Yilin Zhu <[email protected]> Signed-off-by: Yilin Zhu <[email protected]> Signed-off-by: Zhiling Zou <[email protected]> --- changes in v3: - Always define BR_CFM_MRP_OPTS and keep the fast-path check unconditional. Read br->options with READ_ONCE(). - Drop CONFIG ifdefs around CFM/MRP dispatch. Provide header no-ops when the protocols are not compiled in so the compiler can prune them. - v2 Link: https://lore.kernel.org/all/a43fdd12ad2fbb708c090dc4ead60f3e4aa8c0ac.1788159904.git.zhil...@nebusec.ai/ changes in v2: - Replace the per-bridge br_frame_type object with net_bridge option bits. - Dispatch CFM/MRP handlers from the receive path. Check both option bits together first as an unlikely case. - Cover MRP, which has the same shared hlist_node bug. - Remove frame_type_list so CFM/MRP do not affect the fast path when they are disabled in .config. - v1 Link: https://lore.kernel.org/all/7198fe2845c30c60c6b3833dd78cead8c5966931.1778378864.git.zylzyl2...@gmail.com/ net/bridge/br_cfm.c | 11 +++-------- net/bridge/br_device.c | 1 - net/bridge/br_input.c | 35 ++++++++++++++--------------------- net/bridge/br_mrp.c | 13 +++---------- net/bridge/br_private.h | 26 +++++++++++++++----------- 5 files changed, 35 insertions(+), 51 deletions(-)
Thank you for following up on this, the patch looks good to me. Acked-by: Nikolay Aleksandrov <[email protected]>
