Re: [PATCH RFC net-next] net: Add dev_getbyhwaddr_rtnl() helper
From: Jakub Kicinski
Date: Fri Feb 07 2025 - 19:28:16 EST
On Fri, 07 Feb 2025 04:11:34 -0800 Breno Leitao wrote:
> +static bool dev_comp_addr(struct net_device *dev,
> + unsigned short type,
> + const char *ha)
Weird indentation.
static bool
dev_comp_addr(struct net_device *dev, unsigned short type, const char *ha)
or
static bool dev_comp_addr(struct net_device *dev, unsigned short type,
const char *ha)
> +{
> + if (dev->type == type && !memcmp(dev->dev_addr, ha, dev->addr_len))
> + return true;
> +
> + return false;
return dev->type == type && !memcmp(dev->dev_addr, ha, dev->addr_len);
> +}
> +/**
> + * dev_getbyhwaddr_rtnl - find a device by its hardware address
I guess Eric suggested the _rtnl() suffix, tho it's quite uncommon.
Most function are either function() or function_rcu() in networking.
> + * @net: the applicable net namespace
> + * @type: media type of device
> + * @ha: hardware address
> + *
> + * Similar to dev_getbyhwaddr_rcu(), but, the owner needs to hold
unnecessary , after but
> + * RTNL.
rtnl_lock. RTNL is short for RTNetLink
> + *
document the return value kdoc style:
Return: pointer to the net_device, or NULL if not found
> + */
> +struct net_device *dev_getbyhwaddr_rtnl(struct net *net, unsigned short type,
> + const char *ha)
You missed adding this to a header file?