aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/sock.c
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-25 13:26:21 -0400
committerYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-25 15:39:55 -0400
commit3b1e0a655f8eba44ab1ee2a1068d169ccfb853b9 (patch)
tree09edb35f32ebcfb1b4dad904425128a110ef16ee /net/core/sock.c
parentc346dca10840a874240c78efe3f39acf4312a1f2 (diff)
[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>
Diffstat (limited to 'net/core/sock.c')
-rw-r--r--net/core/sock.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index b1a6ed4d33c1..3ee95060dbd0 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -372,7 +372,7 @@ static int sock_bindtodevice(struct sock *sk, char __user *optval, int optlen)
372{ 372{
373 int ret = -ENOPROTOOPT; 373 int ret = -ENOPROTOOPT;
374#ifdef CONFIG_NETDEVICES 374#ifdef CONFIG_NETDEVICES
375 struct net *net = sk->sk_net; 375 struct net *net = sock_net(sk);
376 char devname[IFNAMSIZ]; 376 char devname[IFNAMSIZ];
377 int index; 377 int index;
378 378
@@ -958,7 +958,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
958 */ 958 */
959 sk->sk_prot = sk->sk_prot_creator = prot; 959 sk->sk_prot = sk->sk_prot_creator = prot;
960 sock_lock_init(sk); 960 sock_lock_init(sk);
961 sk->sk_net = get_net(net); 961 sock_net_set(sk, get_net(net));
962 } 962 }
963 963
964 return sk; 964 return sk;
@@ -983,7 +983,7 @@ void sk_free(struct sock *sk)
983 printk(KERN_DEBUG "%s: optmem leakage (%d bytes) detected.\n", 983 printk(KERN_DEBUG "%s: optmem leakage (%d bytes) detected.\n",
984 __func__, atomic_read(&sk->sk_omem_alloc)); 984 __func__, atomic_read(&sk->sk_omem_alloc));
985 985
986 put_net(sk->sk_net); 986 put_net(sock_net(sk));
987 sk_prot_free(sk->sk_prot_creator, sk); 987 sk_prot_free(sk->sk_prot_creator, sk);
988} 988}
989 989
@@ -1001,7 +1001,7 @@ void sk_release_kernel(struct sock *sk)
1001 1001
1002 sock_hold(sk); 1002 sock_hold(sk);
1003 sock_release(sk->sk_socket); 1003 sock_release(sk->sk_socket);
1004 sk->sk_net = get_net(&init_net); 1004 sock_net_set(sk, get_net(&init_net));
1005 sock_put(sk); 1005 sock_put(sk);
1006} 1006}
1007EXPORT_SYMBOL(sk_release_kernel); 1007EXPORT_SYMBOL(sk_release_kernel);
@@ -1017,7 +1017,7 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority)
1017 sock_copy(newsk, sk); 1017 sock_copy(newsk, sk);
1018 1018
1019 /* SANITY */ 1019 /* SANITY */
1020 get_net(newsk->sk_net); 1020 get_net(sock_net(newsk));
1021 sk_node_init(&newsk->sk_node); 1021 sk_node_init(&newsk->sk_node);
1022 sock_lock_init(newsk); 1022 sock_lock_init(newsk);
1023 bh_lock_sock(newsk); 1023 bh_lock_sock(newsk);