Subject: Re: [PATCH v2 net-next 06/11] bridge: provide lockless access to p->designated_cost

From: Ido Schimmel <[email-masked]>
Date: Thu, 4 Jun 2026 13:50:30 +0300

On Wed, Jun 03, 2026 at 06:20:38AM +0000, Eric Dumazet wrote:
> @@ -302,9 +304,10 @@ static int br_should_become_designated_port(const struct net_bridge_port *p)
>  	if (memcmp(&p->designated_root, &br->designated_root, 8))
>  		return 1;
>  
> -	if (br->root_path_cost < p->designated_cost)
> +	t = br->root_path_cost - READ_ONCE(p->designated_cost);
> +	if (t < 0)
>  		return 1;
> -	else if (br->root_path_cost > p->designated_cost)
> +	else if (t > 0)
>  		return 0;

Eric, I think you meant:

p_designated_cost = READ_ONCE(p->designated_cost);

if (br->root_path_cost < p_designated_cost)
	return 1;
else if (br->root_path_cost > p_designated_cost)
	return 0;

?

>  
>  	t = memcmp(&br->bridge_id, &p->designated_bridge, 8);
> @@ -344,9 +347,10 @@ static int br_supersedes_port_info(const struct net_bridge_port *p,
>  	else if (t > 0)
>  		return 0;
>  
> -	if (bpdu->root_path_cost < p->designated_cost)
> +	t = bpdu->root_path_cost < READ_ONCE(p->designated_cost);
> +	if (t < 0)
>  		return 1;
> -	else if (bpdu->root_path_cost > p->designated_cost)
> +	else if (t > 0)
>  		return 0;

Similarly here?