Subject: Re: [PATCH net v2 1/4] bonding: add bond_ether_setup helper

From: Michal Kubiak <[email-masked]>
Date: Tue, 14 Mar 2023 15:58:06 +0100

On Tue, Mar 14, 2023 at 01:14:23PM +0200, Nikolay Aleksandrov wrote:
> Add bond_ether_setup helper which will be used in the following patches
> to fix all ether_setup() calls in the bonding driver. It takes care of both
> IFF_MASTER and IFF_SLAVE flags, the former is always restored and the
> latter only if it was set.
> 
> Fixes: e36b9d16c6a6d ("bonding: clean muticast addresses when device changes type")
> Fixes: 7d5cd2ce5292 ("bonding: correctly handle bonding type change on enslave failure")
> Signed-off-by: Nikolay Aleksandrov <[email-masked]>
> ---
>  drivers/net/bonding/bond_main.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 00646aa315c3..d41024ad2c18 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -1775,6 +1775,18 @@ void bond_lower_state_changed(struct slave *slave)
>  		slave_err(bond_dev, slave_dev, "Error: %s\n", errmsg);	\
>  } while (0)
>  
> +/* ether_setup() resets bond_dev's flags so we always have to restore
> + * IFF_MASTER, and only restore IFF_SLAVE if it was set
> + */

I would suggest using the kernel pattern for function documentation.
At first glance, the name "ether_setup" at the beginning is easy to be
confused with the function name (bond_ether_setup).

> +static void bond_ether_setup(struct net_device *bond_dev)
> +{
> +	unsigned int slave_flag = bond_dev->flags & IFF_SLAVE;
> +
> +	ether_setup(bond_dev);
> +	bond_dev->flags |= IFF_MASTER | slave_flag;
> +	bond_dev->priv_flags &= ~IFF_TX_SKB_SHARING;
> +}
> +
>  /* enslave device <slave> to bond device <master> */
>  int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
>  		 struct netlink_ext_ack *extack)

It seems you never call this newly added helper in the current patch. I
think it creates a compilation warning ("defined but not used").
Please add your function in the patch where you actually use it.

> -- 
> 2.39.2

Thanks,
Michal