From 3b1e0a655f8eba44ab1ee2a1068d169ccfb853b9 Mon Sep 17 00:00:00 2001 From: YOSHIFUJI Hideaki Date: Wed, 26 Mar 2008 02:26:21 +0900 Subject: [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 --- include/net/inet_timewait_sock.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'include/net/inet_timewait_sock.h') diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h index 296547bfb0b7..07fe0d1a4f03 100644 --- a/include/net/inet_timewait_sock.h +++ b/include/net/inet_timewait_sock.h @@ -207,4 +207,22 @@ extern void inet_twsk_schedule(struct inet_timewait_sock *tw, const int timeo, const int timewait_len); extern void inet_twsk_deschedule(struct inet_timewait_sock *tw, struct inet_timewait_death_row *twdr); + +static inline +struct net *twsk_net(const struct inet_timewait_sock *twsk) +{ +#ifdef CONFIG_NET_NS + return twsk->tw_net; +#else + return &init_net; +#endif +} + +static inline +void twsk_net_set(struct inet_timewait_sock *twsk, const struct net *net) +{ +#ifdef CONFIG_NET_NS + twsk->tw_net = net; +#endif +} #endif /* _INET_TIMEWAIT_SOCK_ */ -- cgit v1.2.3-59-g8ed1b From f5aa23fd49063745f85644dd7a9330acd706add6 Mon Sep 17 00:00:00 2001 From: "Denis V. Lunev" Date: Wed, 26 Mar 2008 00:48:17 -0700 Subject: [NETNS]: Compilation warnings under CONFIG_NET_NS. Recent commits from YOSHIFUJI Hideaki have been introduced a several compilation warnings 'assignment discards qualifiers from pointer target type' due to extra const modifier in the inline call parameters of {dev|sock|twsk}_net_set. Drop it. Signed-off-by: Denis V. Lunev Signed-off-by: David S. Miller --- include/linux/netdevice.h | 2 +- include/net/inet_timewait_sock.h | 2 +- include/net/sock.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include/net/inet_timewait_sock.h') diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 06ca84d71db4..15fa84a15c27 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -753,7 +753,7 @@ struct net *dev_net(const struct net_device *dev) } static inline -void dev_net_set(struct net_device *dev, const struct net *net) +void dev_net_set(struct net_device *dev, struct net *net) { #ifdef CONFIG_NET_NS dev->nd_net = net; diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h index 07fe0d1a4f03..95c660c9719b 100644 --- a/include/net/inet_timewait_sock.h +++ b/include/net/inet_timewait_sock.h @@ -219,7 +219,7 @@ struct net *twsk_net(const struct inet_timewait_sock *twsk) } static inline -void twsk_net_set(struct inet_timewait_sock *twsk, const struct net *net) +void twsk_net_set(struct inet_timewait_sock *twsk, struct net *net) { #ifdef CONFIG_NET_NS twsk->tw_net = net; diff --git a/include/net/sock.h b/include/net/sock.h index 7e0d4a0c4d12..1c9d059223ee 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1358,7 +1358,7 @@ struct net *sock_net(const struct sock *sk) } static inline -void sock_net_set(struct sock *sk, const struct net *net) +void sock_net_set(struct sock *sk, struct net *net) { #ifdef CONFIG_NET_NS sk->sk_net = net; -- cgit v1.2.3-59-g8ed1b