提交 5812521b 编写于 作者: G Gu Zheng 提交者: David S. Miller

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: NGu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 431a9124
......@@ -2252,8 +2252,12 @@ 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));
sock_net_set(sk, hold_net(net));
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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册