Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5812521b authored by Gu Zheng's avatar Gu Zheng Committed by David S. Miller
Browse files

net: add a pre-check of net_ns in sk_change_net()



We do not need to switch the net_ns if the target net_ns the same
as the current one, so here we add a pre-check of net_ns to avoid
this as David suggested.

Signed-off-by: default avatarGu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 431a9124
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -2252,9 +2252,13 @@ void sock_net_set(struct sock *sk, struct net *net)
 */
static inline void sk_change_net(struct sock *sk, struct net *net)
{
	put_net(sock_net(sk));
	struct net *current_net = sock_net(sk);

	if (!net_eq(current_net, net)) {
		put_net(current_net);
		sock_net_set(sk, hold_net(net));
	}
}

static inline struct sock *skb_steal_sock(struct sk_buff *skb)
{