[NET] NETNS: Omit sock->sk_net without CONFIG_NET_NS.
Introduce per-sock inlines: sock_net(), sock_net_set() and per-inet_timewait_sock inlines: twsk_net(), twsk_net_set(). Without CONFIG_NET_NS, no namespace other than &init_net exists. Let's explicitly define them to help compiler optimizations. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
This commit is contained in:
@@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(struct net *net, struct sock *sk,
|
||||
sk_for_each_from(sk, node) {
|
||||
struct inet_sock *inet = inet_sk(sk);
|
||||
|
||||
if (sk->sk_net == net && inet->num == num &&
|
||||
if (sock_net(sk) == net && inet->num == num &&
|
||||
!(inet->daddr && inet->daddr != raddr) &&
|
||||
!(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
|
||||
!(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
|
||||
@@ -499,7 +499,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
|
||||
ipc.oif = sk->sk_bound_dev_if;
|
||||
|
||||
if (msg->msg_controllen) {
|
||||
err = ip_cmsg_send(sk->sk_net, msg, &ipc);
|
||||
err = ip_cmsg_send(sock_net(sk), msg, &ipc);
|
||||
if (err)
|
||||
goto out;
|
||||
if (ipc.opt)
|
||||
@@ -553,7 +553,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
|
||||
}
|
||||
|
||||
security_sk_classify_flow(sk, &fl);
|
||||
err = ip_route_output_flow(sk->sk_net, &rt, &fl, sk, 1);
|
||||
err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
|
||||
}
|
||||
if (err)
|
||||
goto done;
|
||||
@@ -620,7 +620,7 @@ static int raw_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
|
||||
|
||||
if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
|
||||
goto out;
|
||||
chk_addr_ret = inet_addr_type(sk->sk_net, addr->sin_addr.s_addr);
|
||||
chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
|
||||
ret = -EADDRNOTAVAIL;
|
||||
if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
|
||||
chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
|
||||
@@ -856,7 +856,7 @@ static struct sock *raw_get_first(struct seq_file *seq)
|
||||
struct hlist_node *node;
|
||||
|
||||
sk_for_each(sk, node, &state->h->ht[state->bucket])
|
||||
if (sk->sk_net == state->p.net)
|
||||
if (sock_net(sk) == state->p.net)
|
||||
goto found;
|
||||
}
|
||||
sk = NULL;
|
||||
@@ -872,7 +872,7 @@ static struct sock *raw_get_next(struct seq_file *seq, struct sock *sk)
|
||||
sk = sk_next(sk);
|
||||
try_again:
|
||||
;
|
||||
} while (sk && sk->sk_net != state->p.net);
|
||||
} while (sk && sock_net(sk) != state->p.net);
|
||||
|
||||
if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
|
||||
sk = sk_head(&state->h->ht[state->bucket]);
|
||||
|
Reference in New Issue
Block a user