[PATCH v21 04/20] net/tls,core: export get_netdev_for_sock
Jakub Kicinski
kuba at kernel.org
Thu Dec 14 18:11:28 PST 2023
On Thu, 14 Dec 2023 13:26:07 +0000 Aurelien Aptel wrote:
> -struct net_device *netdev_sk_get_lowest_dev(struct net_device *dev,
> - struct sock *sk)
> +struct net_device *get_netdev_for_sock(struct sock *sk)
> {
> - struct net_device *lower;
> + struct dst_entry *dst = sk_dst_get(sk);
> + struct net_device *dev, *lower;
>
> - lower = netdev_sk_get_lower_dev(dev, sk);
> - while (lower) {
> + if (unlikely(!dst))
> + return NULL;
> + dev = dst->dev;
> + while ((lower = netdev_sk_get_lower_dev(dev, sk)))
> dev = lower;
> - lower = netdev_sk_get_lower_dev(dev, sk);
> - }
> -
> + dev_hold(dev);
> + dst_release(dst);
> return dev;
> }
> -EXPORT_SYMBOL(netdev_sk_get_lowest_dev);
> +EXPORT_SYMBOL_GPL(get_netdev_for_sock);
Since the use of this helper is now spreading we should
switch it to netdev_hold and have the caller pass in a
netdevice_tracker.
More information about the Linux-nvme
mailing list