Commit fdb5fd7f authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

tcp: sk->sk_bound_dev_if once in inet_request_bound_dev_if()

inet_request_bound_dev_if() reads sk->sk_bound_dev_if twice
while listener socket is not locked.

Another cpu could change this field under us.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a20ea298
...@@ -116,14 +116,15 @@ static inline u32 inet_request_mark(const struct sock *sk, struct sk_buff *skb) ...@@ -116,14 +116,15 @@ static inline u32 inet_request_mark(const struct sock *sk, struct sk_buff *skb)
static inline int inet_request_bound_dev_if(const struct sock *sk, static inline int inet_request_bound_dev_if(const struct sock *sk,
struct sk_buff *skb) struct sk_buff *skb)
{ {
int bound_dev_if = READ_ONCE(sk->sk_bound_dev_if);
#ifdef CONFIG_NET_L3_MASTER_DEV #ifdef CONFIG_NET_L3_MASTER_DEV
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
if (!sk->sk_bound_dev_if && net->ipv4.sysctl_tcp_l3mdev_accept) if (!bound_dev_if && net->ipv4.sysctl_tcp_l3mdev_accept)
return l3mdev_master_ifindex_by_index(net, skb->skb_iif); return l3mdev_master_ifindex_by_index(net, skb->skb_iif);
#endif #endif
return sk->sk_bound_dev_if; return bound_dev_if;
} }
static inline int inet_sk_bound_l3mdev(const struct sock *sk) static inline int inet_sk_bound_l3mdev(const struct sock *sk)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment