From: Boris Pismenny <[email protected]>
Date: Sun, 22 Apr 2018 18:19:49 +0300
> +/* We assume that the socket is already connected */
> +static struct net_device *get_netdev_for_sock(struct sock *sk)
> +{
> + struct inet_sock *inet = inet_sk(sk);
> + struct net_device *netdev = NULL;
> +
> + netdev = dev_get_by_index(sock_net(sk), inet->cork.fl.flowi_oif);
> +
> + return netdev;
> +}
Please do this more directly by looking at sk->sk_dst_cache and taking
the device from dst->dev if non-NULL.
That avoids the dev_get_by_index() demux work, and also if
sk->sk_dst_cache is non-NULL then the socket is indeed connected.
Thanks.