diff options
author | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | 2008-03-25 13:26:21 -0400 |
---|---|---|
committer | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | 2008-03-25 15:39:55 -0400 |
commit | 3b1e0a655f8eba44ab1ee2a1068d169ccfb853b9 (patch) | |
tree | 09edb35f32ebcfb1b4dad904425128a110ef16ee /include/net/sock.h | |
parent | c346dca10840a874240c78efe3f39acf4312a1f2 (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 'include/net/sock.h')
-rw-r--r-- | include/net/sock.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index b433b1ed203d..7e0d4a0c4d12 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -126,7 +126,9 @@ struct sock_common { | |||
126 | atomic_t skc_refcnt; | 126 | atomic_t skc_refcnt; |
127 | unsigned int skc_hash; | 127 | unsigned int skc_hash; |
128 | struct proto *skc_prot; | 128 | struct proto *skc_prot; |
129 | #ifdef CONFIG_NET_NS | ||
129 | struct net *skc_net; | 130 | struct net *skc_net; |
131 | #endif | ||
130 | }; | 132 | }; |
131 | 133 | ||
132 | /** | 134 | /** |
@@ -1345,6 +1347,24 @@ static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_e | |||
1345 | } | 1347 | } |
1346 | #endif | 1348 | #endif |
1347 | 1349 | ||
1350 | static inline | ||
1351 | struct net *sock_net(const struct sock *sk) | ||
1352 | { | ||
1353 | #ifdef CONFIG_NET_NS | ||
1354 | return sk->sk_net; | ||
1355 | #else | ||
1356 | return &init_net; | ||
1357 | #endif | ||
1358 | } | ||
1359 | |||
1360 | static inline | ||
1361 | void sock_net_set(struct sock *sk, const struct net *net) | ||
1362 | { | ||
1363 | #ifdef CONFIG_NET_NS | ||
1364 | sk->sk_net = net; | ||
1365 | #endif | ||
1366 | } | ||
1367 | |||
1348 | /* | 1368 | /* |
1349 | * Kernel sockets, f.e. rtnl or icmp_socket, are a part of a namespace. | 1369 | * Kernel sockets, f.e. rtnl or icmp_socket, are a part of a namespace. |
1350 | * They should not hold a referrence to a namespace in order to allow | 1370 | * They should not hold a referrence to a namespace in order to allow |
@@ -1353,8 +1373,8 @@ static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_e | |||
1353 | */ | 1373 | */ |
1354 | static inline void sk_change_net(struct sock *sk, struct net *net) | 1374 | static inline void sk_change_net(struct sock *sk, struct net *net) |
1355 | { | 1375 | { |
1356 | put_net(sk->sk_net); | 1376 | put_net(sock_net(sk)); |
1357 | sk->sk_net = net; | 1377 | sock_net_set(sk, net); |
1358 | } | 1378 | } |
1359 | 1379 | ||
1360 | extern void sock_enable_timestamp(struct sock *sk); | 1380 | extern void sock_enable_timestamp(struct sock *sk); |