On Friday, 4 January 2019 01.39.54 CET Linus Lüssing wrote:
On Fri, Dec 07, 2018 at 02:58:30PM +0100, Sven Eckelmann wrote: [...]
+/**
- batadv_get_hardif_from_info() - Retrieve hardif from genl attributes
- @bat_priv: the bat priv with all the soft interface information
- @net: the applicable net namespace
- @info: receiver information
- Return: Pointer to hard interface on success, error pointer on error
- */
+static struct batadv_hard_iface * +batadv_get_hardif_from_info(struct batadv_priv *bat_priv, struct net
*net,
struct genl_info *info)
+{
- struct batadv_hard_iface *hard_iface;
- struct net_device *hard_dev;
- unsigned int hardif_index;
- if (!info->attrs[BATADV_ATTR_HARD_IFINDEX])
return ERR_PTR(-EINVAL);
- hardif_index = nla_get_u32(info->attrs[BATADV_ATTR_HARD_IFINDEX]);
- hard_dev = dev_get_by_index(net, hardif_index);
- if (!hard_dev)
return ERR_PTR(-ENODEV);
- hard_iface = batadv_hardif_get_by_netdev(hard_dev);
- if (!hard_iface)
goto err_put_harddev;
- if (hard_iface->soft_iface != bat_priv->soft_iface)
goto err_put_hardif;
When would this case above happen?
When you ask for a hard interface from a different mesh interface or a hard interface without a mesh interface.
It seems unnecessary to keep holding a reference to hard_dev on successful return here (and releasing it in post_doit).
[...]
Ok.
often with these net_device reference counters...) Same for batadv_get_softif_from_info().
No, no, no, no, no, no, no and again no. The net_device is the only thing with a refcounter here. The bat_priv doesn't have a refcounter because it is just a memory region in the net_device.
Kind regards, Sven