diff options
author | David S. Miller <davem@davemloft.net> | 2008-03-25 22:43:59 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-03-25 22:43:59 -0400 |
commit | dfe98e9214ced45cd1a6ecd19f2627819a630f77 (patch) | |
tree | 4a229937bc32c470ebb75a51bdd39572d91ac0ce /include | |
parent | f89e6e3834035c6e8203042f3527931aa7f52496 (diff) | |
parent | 878628fbf2589eb24357e42027d5f54b1dafd3c8 (diff) |
Merge branch 'net-2.6.26-netns-20080326' of git://git.linux-ipv6.org/gitroot/yoshfuji/linux-2.6-dev
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/inetdevice.h | 6 | ||||
-rw-r--r-- | include/linux/ipv6.h | 4 | ||||
-rw-r--r-- | include/linux/netdevice.h | 25 | ||||
-rw-r--r-- | include/linux/seq_file.h | 7 | ||||
-rw-r--r-- | include/net/inet_hashtables.h | 8 | ||||
-rw-r--r-- | include/net/inet_timewait_sock.h | 18 | ||||
-rw-r--r-- | include/net/neighbour.h | 25 | ||||
-rw-r--r-- | include/net/net_namespace.h | 12 | ||||
-rw-r--r-- | include/net/route.h | 4 | ||||
-rw-r--r-- | include/net/sock.h | 24 |
10 files changed, 119 insertions, 14 deletions
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h index da05ab47ff2f..7009b0cdd06f 100644 --- a/include/linux/inetdevice.h +++ b/include/linux/inetdevice.h | |||
@@ -70,13 +70,13 @@ static inline void ipv4_devconf_setall(struct in_device *in_dev) | |||
70 | ipv4_devconf_set((in_dev), NET_IPV4_CONF_ ## attr, (val)) | 70 | ipv4_devconf_set((in_dev), NET_IPV4_CONF_ ## attr, (val)) |
71 | 71 | ||
72 | #define IN_DEV_ANDCONF(in_dev, attr) \ | 72 | #define IN_DEV_ANDCONF(in_dev, attr) \ |
73 | (IPV4_DEVCONF_ALL(in_dev->dev->nd_net, attr) && \ | 73 | (IPV4_DEVCONF_ALL(dev_net(in_dev->dev), attr) && \ |
74 | IN_DEV_CONF_GET((in_dev), attr)) | 74 | IN_DEV_CONF_GET((in_dev), attr)) |
75 | #define IN_DEV_ORCONF(in_dev, attr) \ | 75 | #define IN_DEV_ORCONF(in_dev, attr) \ |
76 | (IPV4_DEVCONF_ALL(in_dev->dev->nd_net, attr) || \ | 76 | (IPV4_DEVCONF_ALL(dev_net(in_dev->dev), attr) || \ |
77 | IN_DEV_CONF_GET((in_dev), attr)) | 77 | IN_DEV_CONF_GET((in_dev), attr)) |
78 | #define IN_DEV_MAXCONF(in_dev, attr) \ | 78 | #define IN_DEV_MAXCONF(in_dev, attr) \ |
79 | (max(IPV4_DEVCONF_ALL(in_dev->dev->nd_net, attr), \ | 79 | (max(IPV4_DEVCONF_ALL(dev_net(in_dev->dev), attr), \ |
80 | IN_DEV_CONF_GET((in_dev), attr))) | 80 | IN_DEV_CONF_GET((in_dev), attr))) |
81 | 81 | ||
82 | #define IN_DEV_FORWARD(in_dev) IN_DEV_CONF_GET((in_dev), FORWARDING) | 82 | #define IN_DEV_FORWARD(in_dev) IN_DEV_CONF_GET((in_dev), FORWARDING) |
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index c9ba0da16ce9..b90d3d461d4e 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h | |||
@@ -481,7 +481,7 @@ static inline struct raw6_sock *raw6_sk(const struct sock *sk) | |||
481 | #endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ | 481 | #endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ |
482 | 482 | ||
483 | #define INET6_MATCH(__sk, __net, __hash, __saddr, __daddr, __ports, __dif)\ | 483 | #define INET6_MATCH(__sk, __net, __hash, __saddr, __daddr, __ports, __dif)\ |
484 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ | 484 | (((__sk)->sk_hash == (__hash)) && sock_net((__sk)) == (__net) && \ |
485 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ | 485 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ |
486 | ((__sk)->sk_family == AF_INET6) && \ | 486 | ((__sk)->sk_family == AF_INET6) && \ |
487 | ipv6_addr_equal(&inet6_sk(__sk)->daddr, (__saddr)) && \ | 487 | ipv6_addr_equal(&inet6_sk(__sk)->daddr, (__saddr)) && \ |
@@ -489,7 +489,7 @@ static inline struct raw6_sock *raw6_sk(const struct sock *sk) | |||
489 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | 489 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
490 | 490 | ||
491 | #define INET6_TW_MATCH(__sk, __net, __hash, __saddr, __daddr, __ports, __dif) \ | 491 | #define INET6_TW_MATCH(__sk, __net, __hash, __saddr, __daddr, __ports, __dif) \ |
492 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ | 492 | (((__sk)->sk_hash == (__hash)) && sock_net((__sk)) == (__net) && \ |
493 | (*((__portpair *)&(inet_twsk(__sk)->tw_dport)) == (__ports)) && \ | 493 | (*((__portpair *)&(inet_twsk(__sk)->tw_dport)) == (__ports)) && \ |
494 | ((__sk)->sk_family == PF_INET6) && \ | 494 | ((__sk)->sk_family == PF_INET6) && \ |
495 | (ipv6_addr_equal(&inet6_twsk(__sk)->tw_v6_daddr, (__saddr))) && \ | 495 | (ipv6_addr_equal(&inet6_twsk(__sk)->tw_v6_daddr, (__saddr))) && \ |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index ced61f87660e..d146be40f46c 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -708,8 +708,10 @@ struct net_device | |||
708 | void (*poll_controller)(struct net_device *dev); | 708 | void (*poll_controller)(struct net_device *dev); |
709 | #endif | 709 | #endif |
710 | 710 | ||
711 | #ifdef CONFIG_NET_NS | ||
711 | /* Network namespace this network device is inside */ | 712 | /* Network namespace this network device is inside */ |
712 | struct net *nd_net; | 713 | struct net *nd_net; |
714 | #endif | ||
713 | 715 | ||
714 | /* bridge stuff */ | 716 | /* bridge stuff */ |
715 | struct net_bridge_port *br_port; | 717 | struct net_bridge_port *br_port; |
@@ -737,6 +739,27 @@ struct net_device | |||
737 | #define NETDEV_ALIGN 32 | 739 | #define NETDEV_ALIGN 32 |
738 | #define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1) | 740 | #define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1) |
739 | 741 | ||
742 | /* | ||
743 | * Net namespace inlines | ||
744 | */ | ||
745 | static inline | ||
746 | struct net *dev_net(const struct net_device *dev) | ||
747 | { | ||
748 | #ifdef CONFIG_NET_NS | ||
749 | return dev->nd_net; | ||
750 | #else | ||
751 | return &init_net; | ||
752 | #endif | ||
753 | } | ||
754 | |||
755 | static inline | ||
756 | void dev_net_set(struct net_device *dev, const struct net *net) | ||
757 | { | ||
758 | #ifdef CONFIG_NET_NS | ||
759 | dev->nd_dev = net; | ||
760 | #endif | ||
761 | } | ||
762 | |||
740 | /** | 763 | /** |
741 | * netdev_priv - access network device private data | 764 | * netdev_priv - access network device private data |
742 | * @dev: network device | 765 | * @dev: network device |
@@ -813,7 +836,7 @@ static inline struct net_device *next_net_device(struct net_device *dev) | |||
813 | struct list_head *lh; | 836 | struct list_head *lh; |
814 | struct net *net; | 837 | struct net *net; |
815 | 838 | ||
816 | net = dev->nd_net; | 839 | net = dev_net(dev); |
817 | lh = dev->dev_list.next; | 840 | lh = dev->dev_list.next; |
818 | return lh == &net->dev_base_head ? NULL : net_device_entry(lh); | 841 | return lh == &net->dev_base_head ? NULL : net_device_entry(lh); |
819 | } | 842 | } |
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index 67c2563961f3..d870a8253769 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
6 | #include <linux/string.h> | 6 | #include <linux/string.h> |
7 | #include <linux/mutex.h> | 7 | #include <linux/mutex.h> |
8 | #include <net/net_namespace.h> | ||
8 | 9 | ||
9 | struct seq_operations; | 10 | struct seq_operations; |
10 | struct file; | 11 | struct file; |
@@ -64,7 +65,9 @@ extern struct list_head *seq_list_next(void *v, struct list_head *head, | |||
64 | 65 | ||
65 | struct net; | 66 | struct net; |
66 | struct seq_net_private { | 67 | struct seq_net_private { |
68 | #ifdef CONFIG_NET_NS | ||
67 | struct net *net; | 69 | struct net *net; |
70 | #endif | ||
68 | }; | 71 | }; |
69 | 72 | ||
70 | int seq_open_net(struct inode *, struct file *, | 73 | int seq_open_net(struct inode *, struct file *, |
@@ -72,7 +75,11 @@ int seq_open_net(struct inode *, struct file *, | |||
72 | int seq_release_net(struct inode *, struct file *); | 75 | int seq_release_net(struct inode *, struct file *); |
73 | static inline struct net *seq_file_net(struct seq_file *seq) | 76 | static inline struct net *seq_file_net(struct seq_file *seq) |
74 | { | 77 | { |
78 | #ifdef CONFIG_NET_NS | ||
75 | return ((struct seq_net_private *)seq->private)->net; | 79 | return ((struct seq_net_private *)seq->private)->net; |
80 | #else | ||
81 | return &init_net; | ||
82 | #endif | ||
76 | } | 83 | } |
77 | 84 | ||
78 | #endif | 85 | #endif |
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index d99c1ba2ece0..5525227c5e92 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h | |||
@@ -314,25 +314,25 @@ typedef __u64 __bitwise __addrpair; | |||
314 | ((__force __u64)(__be32)(__saddr))); | 314 | ((__force __u64)(__be32)(__saddr))); |
315 | #endif /* __BIG_ENDIAN */ | 315 | #endif /* __BIG_ENDIAN */ |
316 | #define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ | 316 | #define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ |
317 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ | 317 | (((__sk)->sk_hash == (__hash)) && sock_net((__sk)) == (__net) && \ |
318 | ((*((__addrpair *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \ | 318 | ((*((__addrpair *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \ |
319 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ | 319 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ |
320 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | 320 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
321 | #define INET_TW_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ | 321 | #define INET_TW_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ |
322 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ | 322 | (((__sk)->sk_hash == (__hash)) && sock_net((__sk)) == (__net) && \ |
323 | ((*((__addrpair *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \ | 323 | ((*((__addrpair *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \ |
324 | ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ | 324 | ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ |
325 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | 325 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
326 | #else /* 32-bit arch */ | 326 | #else /* 32-bit arch */ |
327 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) | 327 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) |
328 | #define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif) \ | 328 | #define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif) \ |
329 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ | 329 | (((__sk)->sk_hash == (__hash)) && sock_net((__sk)) == (__net) && \ |
330 | (inet_sk(__sk)->daddr == (__saddr)) && \ | 330 | (inet_sk(__sk)->daddr == (__saddr)) && \ |
331 | (inet_sk(__sk)->rcv_saddr == (__daddr)) && \ | 331 | (inet_sk(__sk)->rcv_saddr == (__daddr)) && \ |
332 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ | 332 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ |
333 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | 333 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
334 | #define INET_TW_MATCH(__sk, __net, __hash,__cookie, __saddr, __daddr, __ports, __dif) \ | 334 | #define INET_TW_MATCH(__sk, __net, __hash,__cookie, __saddr, __daddr, __ports, __dif) \ |
335 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ | 335 | (((__sk)->sk_hash == (__hash)) && sock_net((__sk)) == (__net) && \ |
336 | (inet_twsk(__sk)->tw_daddr == (__saddr)) && \ | 336 | (inet_twsk(__sk)->tw_daddr == (__saddr)) && \ |
337 | (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \ | 337 | (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \ |
338 | ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ | 338 | ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ |
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, | |||
207 | const int timeo, const int timewait_len); | 207 | const int timeo, const int timewait_len); |
208 | extern void inet_twsk_deschedule(struct inet_timewait_sock *tw, | 208 | extern void inet_twsk_deschedule(struct inet_timewait_sock *tw, |
209 | struct inet_timewait_death_row *twdr); | 209 | struct inet_timewait_death_row *twdr); |
210 | |||
211 | static inline | ||
212 | struct net *twsk_net(const struct inet_timewait_sock *twsk) | ||
213 | { | ||
214 | #ifdef CONFIG_NET_NS | ||
215 | return twsk->tw_net; | ||
216 | #else | ||
217 | return &init_net; | ||
218 | #endif | ||
219 | } | ||
220 | |||
221 | static inline | ||
222 | void twsk_net_set(struct inet_timewait_sock *twsk, const struct net *net) | ||
223 | { | ||
224 | #ifdef CONFIG_NET_NS | ||
225 | twsk->tw_net = net; | ||
226 | #endif | ||
227 | } | ||
210 | #endif /* _INET_TIMEWAIT_SOCK_ */ | 228 | #endif /* _INET_TIMEWAIT_SOCK_ */ |
diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 062281872064..8bec0d69b270 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h | |||
@@ -38,7 +38,9 @@ struct neighbour; | |||
38 | 38 | ||
39 | struct neigh_parms | 39 | struct neigh_parms |
40 | { | 40 | { |
41 | #ifdef CONFIG_NET_NS | ||
41 | struct net *net; | 42 | struct net *net; |
43 | #endif | ||
42 | struct net_device *dev; | 44 | struct net_device *dev; |
43 | struct neigh_parms *next; | 45 | struct neigh_parms *next; |
44 | int (*neigh_setup)(struct neighbour *); | 46 | int (*neigh_setup)(struct neighbour *); |
@@ -131,7 +133,9 @@ struct neigh_ops | |||
131 | struct pneigh_entry | 133 | struct pneigh_entry |
132 | { | 134 | { |
133 | struct pneigh_entry *next; | 135 | struct pneigh_entry *next; |
136 | #ifdef CONFIG_NET_NS | ||
134 | struct net *net; | 137 | struct net *net; |
138 | #endif | ||
135 | struct net_device *dev; | 139 | struct net_device *dev; |
136 | u8 flags; | 140 | u8 flags; |
137 | u8 key[0]; | 141 | u8 key[0]; |
@@ -213,6 +217,17 @@ extern struct neighbour *neigh_event_ns(struct neigh_table *tbl, | |||
213 | 217 | ||
214 | extern struct neigh_parms *neigh_parms_alloc(struct net_device *dev, struct neigh_table *tbl); | 218 | extern struct neigh_parms *neigh_parms_alloc(struct net_device *dev, struct neigh_table *tbl); |
215 | extern void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms); | 219 | extern void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms); |
220 | |||
221 | static inline | ||
222 | struct net *neigh_parms_net(const struct neigh_parms *parms) | ||
223 | { | ||
224 | #ifdef CONFIG_NET_NS | ||
225 | return parms->net; | ||
226 | #else | ||
227 | return &init_net; | ||
228 | #endif | ||
229 | } | ||
230 | |||
216 | extern unsigned long neigh_rand_reach_time(unsigned long base); | 231 | extern unsigned long neigh_rand_reach_time(unsigned long base); |
217 | 232 | ||
218 | extern void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p, | 233 | extern void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p, |
@@ -220,6 +235,16 @@ extern void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p, | |||
220 | extern struct pneigh_entry *pneigh_lookup(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev, int creat); | 235 | extern struct pneigh_entry *pneigh_lookup(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev, int creat); |
221 | extern int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev); | 236 | extern int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev); |
222 | 237 | ||
238 | static inline | ||
239 | struct net *pneigh_net(const struct pneigh_entry *pneigh) | ||
240 | { | ||
241 | #ifdef CONFIG_NET_NS | ||
242 | return pneigh->net; | ||
243 | #else | ||
244 | return &init_net; | ||
245 | #endif | ||
246 | } | ||
247 | |||
223 | extern void neigh_app_ns(struct neighbour *n); | 248 | extern void neigh_app_ns(struct neighbour *n); |
224 | extern void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie); | 249 | extern void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie); |
225 | extern void __neigh_for_each_release(struct neigh_table *tbl, int (*cb)(struct neighbour *)); | 250 | extern void __neigh_for_each_release(struct neigh_table *tbl, int (*cb)(struct neighbour *)); |
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 923f2b8b9096..f8f3d1a5fc35 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
@@ -118,6 +118,12 @@ static inline void release_net(struct net *net) | |||
118 | { | 118 | { |
119 | atomic_dec(&net->use_count); | 119 | atomic_dec(&net->use_count); |
120 | } | 120 | } |
121 | |||
122 | static inline | ||
123 | int net_eq(const struct net *net1, const struct net *net2) | ||
124 | { | ||
125 | return net1 == net2; | ||
126 | } | ||
121 | #else | 127 | #else |
122 | static inline struct net *get_net(struct net *net) | 128 | static inline struct net *get_net(struct net *net) |
123 | { | 129 | { |
@@ -141,6 +147,12 @@ static inline struct net *maybe_get_net(struct net *net) | |||
141 | { | 147 | { |
142 | return net; | 148 | return net; |
143 | } | 149 | } |
150 | |||
151 | static inline | ||
152 | int net_eq(const struct net *net1, const struct net *net2) | ||
153 | { | ||
154 | return 1; | ||
155 | } | ||
144 | #endif | 156 | #endif |
145 | 157 | ||
146 | #define for_each_net(VAR) \ | 158 | #define for_each_net(VAR) \ |
diff --git a/include/net/route.h b/include/net/route.h index 28dba925663c..c6338802e8f1 100644 --- a/include/net/route.h +++ b/include/net/route.h | |||
@@ -160,7 +160,7 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst, | |||
160 | .dport = dport } } }; | 160 | .dport = dport } } }; |
161 | 161 | ||
162 | int err; | 162 | int err; |
163 | struct net *net = sk->sk_net; | 163 | struct net *net = sock_net(sk); |
164 | if (!dst || !src) { | 164 | if (!dst || !src) { |
165 | err = __ip_route_output_key(net, rp, &fl); | 165 | err = __ip_route_output_key(net, rp, &fl); |
166 | if (err) | 166 | if (err) |
@@ -188,7 +188,7 @@ static inline int ip_route_newports(struct rtable **rp, u8 protocol, | |||
188 | ip_rt_put(*rp); | 188 | ip_rt_put(*rp); |
189 | *rp = NULL; | 189 | *rp = NULL; |
190 | security_sk_classify_flow(sk, &fl); | 190 | security_sk_classify_flow(sk, &fl); |
191 | return ip_route_output_flow(sk->sk_net, rp, &fl, sk, 0); | 191 | return ip_route_output_flow(sock_net(sk), rp, &fl, sk, 0); |
192 | } | 192 | } |
193 | return 0; | 193 | return 0; |
194 | } | 194 | } |
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); |