From: Nikolay Aleksandrov <razor@blackwall.org>
To: Yilin Zhu <zylzyl2333@gmail.com>
Cc: Ren Wei <n05ec@lzu.edu.cn>,
bridge@lists.linux.dev, netdev@vger.kernel.org,
idosch@nvidia.com, horatiu.vultur@microchip.com, kuba@kernel.org,
henrik.bjoernlund@microchip.com, yuantan098@gmail.com,
yifanwucs@gmail.com, tomapufckgml@gmail.com, bird@lzu.edu.cn,
ronbogo@outlook.com
Subject: Re: [PATCH net 1/1] net: bridge: cfm: use a per-bridge frame type
Date: Fri, 28 Aug 2026 13:23:03 +0300 [thread overview]
Message-ID: <6c1c6972-c212-4139-b629-4603a8801cbb@blackwall.org> (raw)
In-Reply-To: <7ffc7cdc-8140-4ea2-b3bd-c86abe6e6cff@blackwall.org>
On 12/05/2026 11:09, Nikolay Aleksandrov wrote:
> On 12/05/2026 08:21, Yilin Zhu wrote:
>> On Sun, 10 May 2026 at 04:40, Nikolay Aleksandrov <razor@blackwall.org> wrote:
>>>
>>> On 10/05/2026 13:05, Nikolay Aleksandrov wrote:
>>>> On 10/05/2026 12:15, Ren Wei wrote:
>>>>> From: Yilin Zhu <zylzyl2333@gmail.com>
>>>>>
>>>>> CFM registers a bridge frame handler when the first MEP is created and
>>>>> unregisters it when the last MEP is deleted. The registered object also
>>>>> contains the hlist_node used by the bridge-local frame_type_list.
>>>>>
>>>>> The CFM frame type is currently global, so enabling CFM on multiple
>>>>> bridges links the same hlist_node into multiple bridge-local lists. A
>>>>> later unregister on one bridge can then operate on list state belonging
>>>>> to another bridge.
>>>>>
>>>>> Move the CFM frame type into struct net_bridge and register/unregister
>>>>> the bridge-owned object. This keeps frame handler list membership local
>>>>> to the bridge while preserving the existing first-MEP/last-MEP lifetime.
>>>>>
>>>>> Fixes: dc32cbb3dbd7 ("bridge: cfm: Kernel space implementation of CFM. CCM
>>>>> frame RX added.")
>>>>> Cc: stable@kernel.org
>>>>> Reported-by: Yuan Tan <yuantan098@gmail.com>
>>>>> Reported-by: Yifan Wu <yifanwucs@gmail.com>
>>>>> Reported-by: Juefei Pu <tomapufckgml@gmail.com>
>>>>> Reported-by: Xin Liu <bird@lzu.edu.cn>
>>>>> Co-developed-by: Peihan Liu <ronbogo@outlook.com>
>>>>> Signed-off-by: Peihan Liu <ronbogo@outlook.com>
>>>>> Signed-off-by: Yilin Zhu <zylzyl2333@gmail.com>
>>>>> Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
>>>>> ---
>>>>> net/bridge/br_cfm.c | 14 ++++++--------
>>>>> net/bridge/br_private.h | 18 +++++++++++-------
>>>>> 2 files changed, 17 insertions(+), 15 deletions(-)
>>>>>
>>>>
>>>> I think MRP suffers from the same bug, but I also think we can contain the
>>>> fix within the packet type structure instead of making the already huge
>>>> struct net_bridge even bigger. Also, linking a struct within net_bridge
>>>> to a list within the same net_bridge looks weird.
>>>>
>>>> IMO br_add_frame should take a type & a frame_handler, allocate a br_frame_type
>>>> dynamically and link it, then br_del_frame should take a type instead of a ptr
>>>> and remove that frame type and free it with kfree_rcu. That would require
>>>> br_add_frame return value to be checked in the respective cfm/mrp functions.
>>>> Warnings for already existing types on add or missing types on del should be
>>>> added.
>>>>
>>>
>>> Actually I have a better idea since these handlers can be added only once per
>>> bridge, we can do away with a simple bitmask (e.g. use net_bridge's options
>>> which is in a Rx hot cache line) and even reduce net_bridge size while fixing
>>> these bugs, and also remove a conditional from the fast-path when CFM/MRP are
>>> not compiled in. Would you like me to prepare it or do you want to give it a go?
>>>
>>
>> Hi Nik,
>>
>> Thanks for the suggestion.
>>
>> I'll give it a go. IIUC, the idea is to remove the shared
>> br_frame_type list entries for CFM/MRP, track their per-bridge enable
>> state with bridge option bits, and dispatch the CFM/MRP handlers directly
>> from the receive path when the corresponding EtherType and option bit
>> match.
>>
>> I'll include MRP in v2.
>>
>> Thanks,
>> Yilin
>>
>
> Great, thank you. That should simplify the code and give us 8 bytes of Rx hot
> cache line back. The important point is that there haven't been any new
> handlers since these were added back in 2020, and also these are not
> common, so making their impact on the fast-path as small as possible
> while fixing the bug sounds good.
>
> A quick & dirty sketch of the fixes gives me:
> 5 files changed, 47 insertions(+), 66 deletions(-)
>
> That can probably be improved (i.e. more deletions).
>
> Just please make sure that if CFM/MRP are not enabled in .config, they
> would not affect the fast-path at all.
>
> Cheers,
> Nik
>
Hi Yilin,
Are you still considering fixing these problems? A few months passed since
we last spoke.
Cheers,
Nik
next prev parent reply other threads:[~2026-08-28 10:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1778378864.git.zylzyl2333@gmail.com>
2026-05-10 9:15 ` [PATCH net 1/1] net: bridge: cfm: use a per-bridge frame type Ren Wei
2026-05-10 10:05 ` Nikolay Aleksandrov
2026-05-10 11:40 ` Nikolay Aleksandrov
2026-05-12 5:21 ` Yilin Zhu
2026-05-12 8:09 ` Nikolay Aleksandrov
2026-08-28 10:23 ` Nikolay Aleksandrov [this message]
2026-08-28 19:44 ` Yuan Tan
2026-08-30 8:29 ` Nikolay Aleksandrov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6c1c6972-c212-4139-b629-4603a8801cbb@blackwall.org \
--to=razor@blackwall.org \
--cc=bird@lzu.edu.cn \
--cc=bridge@lists.linux.dev \
--cc=henrik.bjoernlund@microchip.com \
--cc=horatiu.vultur@microchip.com \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=n05ec@lzu.edu.cn \
--cc=netdev@vger.kernel.org \
--cc=ronbogo@outlook.com \
--cc=tomapufckgml@gmail.com \
--cc=yifanwucs@gmail.com \
--cc=yuantan098@gmail.com \
--cc=zylzyl2333@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox