diff options
author | Denis V. Lunev <den@openvz.org> | 2008-03-24 18:31:00 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-03-24 18:31:00 -0400 |
commit | cb84663e4d239f23f0d872bc6463c272e74daad8 (patch) | |
tree | f3153fbf15585870f98f261606df014b8780a548 /net | |
parent | 7a6adb92fe301c10ca4dbd0d9f2422f5880595e7 (diff) |
[NETNS]: Process IP layer in the context of the correct namespace.
Replace all the rest of the init_net with a proper net on the IP layer.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/ip_fragment.c | 5 | ||||
-rw-r--r-- | net/ipv4/ip_input.c | 6 | ||||
-rw-r--r-- | net/ipv4/ip_options.c | 2 | ||||
-rw-r--r-- | net/ipv4/ip_output.c | 2 | ||||
-rw-r--r-- | net/ipv4/ip_sockglue.c | 7 |
5 files changed, 14 insertions, 8 deletions
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 3b2e5adca838..8b448c4b9080 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c | |||
@@ -204,8 +204,11 @@ static void ip_expire(unsigned long arg) | |||
204 | 204 | ||
205 | if ((qp->q.last_in&FIRST_IN) && qp->q.fragments != NULL) { | 205 | if ((qp->q.last_in&FIRST_IN) && qp->q.fragments != NULL) { |
206 | struct sk_buff *head = qp->q.fragments; | 206 | struct sk_buff *head = qp->q.fragments; |
207 | struct net *net; | ||
208 | |||
209 | net = container_of(qp->q.net, struct net, ipv4.frags); | ||
207 | /* Send an ICMP "Fragment Reassembly Timeout" message. */ | 210 | /* Send an ICMP "Fragment Reassembly Timeout" message. */ |
208 | if ((head->dev = dev_get_by_index(&init_net, qp->iif)) != NULL) { | 211 | if ((head->dev = dev_get_by_index(net, qp->iif)) != NULL) { |
209 | icmp_send(head, ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, 0); | 212 | icmp_send(head, ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, 0); |
210 | dev_put(head->dev); | 213 | dev_put(head->dev); |
211 | } | 214 | } |
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index f3a7a08a463f..eb1fa27dc0c4 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c | |||
@@ -160,6 +160,7 @@ int ip_call_ra_chain(struct sk_buff *skb) | |||
160 | struct ip_ra_chain *ra; | 160 | struct ip_ra_chain *ra; |
161 | u8 protocol = ip_hdr(skb)->protocol; | 161 | u8 protocol = ip_hdr(skb)->protocol; |
162 | struct sock *last = NULL; | 162 | struct sock *last = NULL; |
163 | struct net_device *dev = skb->dev; | ||
163 | 164 | ||
164 | read_lock(&ip_ra_lock); | 165 | read_lock(&ip_ra_lock); |
165 | for (ra = ip_ra_chain; ra; ra = ra->next) { | 166 | for (ra = ip_ra_chain; ra; ra = ra->next) { |
@@ -170,7 +171,8 @@ int ip_call_ra_chain(struct sk_buff *skb) | |||
170 | */ | 171 | */ |
171 | if (sk && inet_sk(sk)->num == protocol && | 172 | if (sk && inet_sk(sk)->num == protocol && |
172 | (!sk->sk_bound_dev_if || | 173 | (!sk->sk_bound_dev_if || |
173 | sk->sk_bound_dev_if == skb->dev->ifindex)) { | 174 | sk->sk_bound_dev_if == dev->ifindex) && |
175 | sk->sk_net == dev->nd_net) { | ||
174 | if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) { | 176 | if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) { |
175 | if (ip_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN)) { | 177 | if (ip_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN)) { |
176 | read_unlock(&ip_ra_lock); | 178 | read_unlock(&ip_ra_lock); |
@@ -286,7 +288,7 @@ static inline int ip_rcv_options(struct sk_buff *skb) | |||
286 | opt = &(IPCB(skb)->opt); | 288 | opt = &(IPCB(skb)->opt); |
287 | opt->optlen = iph->ihl*4 - sizeof(struct iphdr); | 289 | opt->optlen = iph->ihl*4 - sizeof(struct iphdr); |
288 | 290 | ||
289 | if (ip_options_compile(&init_net, opt, skb)) { | 291 | if (ip_options_compile(dev->nd_net, opt, skb)) { |
290 | IP_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); | 292 | IP_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); |
291 | goto drop; | 293 | goto drop; |
292 | } | 294 | } |
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index 59f7ddfb29bf..87cc1222c600 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c | |||
@@ -145,7 +145,7 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb) | |||
145 | __be32 addr; | 145 | __be32 addr; |
146 | 146 | ||
147 | memcpy(&addr, sptr+soffset-1, 4); | 147 | memcpy(&addr, sptr+soffset-1, 4); |
148 | if (inet_addr_type(&init_net, addr) != RTN_LOCAL) { | 148 | if (inet_addr_type(skb->dst->dev->nd_net, addr) != RTN_LOCAL) { |
149 | dopt->ts_needtime = 1; | 149 | dopt->ts_needtime = 1; |
150 | soffset += 8; | 150 | soffset += 8; |
151 | } | 151 | } |
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index dc494ea594a7..349fae58c1a3 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
@@ -351,7 +351,7 @@ int ip_queue_xmit(struct sk_buff *skb, int ipfragok) | |||
351 | * itself out. | 351 | * itself out. |
352 | */ | 352 | */ |
353 | security_sk_classify_flow(sk, &fl); | 353 | security_sk_classify_flow(sk, &fl); |
354 | if (ip_route_output_flow(&init_net, &rt, &fl, sk, 0)) | 354 | if (ip_route_output_flow(sk->sk_net, &rt, &fl, sk, 0)) |
355 | goto no_route; | 355 | goto no_route; |
356 | } | 356 | } |
357 | sk_setup_caps(sk, &rt->u.dst); | 357 | sk_setup_caps(sk, &rt->u.dst); |
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 0857f2d042cd..b854431047a4 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c | |||
@@ -449,7 +449,8 @@ static int do_ip_setsockopt(struct sock *sk, int level, | |||
449 | struct ip_options * opt = NULL; | 449 | struct ip_options * opt = NULL; |
450 | if (optlen > 40 || optlen < 0) | 450 | if (optlen > 40 || optlen < 0) |
451 | goto e_inval; | 451 | goto e_inval; |
452 | err = ip_options_get_from_user(&init_net, &opt, optval, optlen); | 452 | err = ip_options_get_from_user(sk->sk_net, &opt, |
453 | optval, optlen); | ||
453 | if (err) | 454 | if (err) |
454 | break; | 455 | break; |
455 | if (inet->is_icsk) { | 456 | if (inet->is_icsk) { |
@@ -589,13 +590,13 @@ static int do_ip_setsockopt(struct sock *sk, int level, | |||
589 | err = 0; | 590 | err = 0; |
590 | break; | 591 | break; |
591 | } | 592 | } |
592 | dev = ip_dev_find(&init_net, mreq.imr_address.s_addr); | 593 | dev = ip_dev_find(sk->sk_net, mreq.imr_address.s_addr); |
593 | if (dev) { | 594 | if (dev) { |
594 | mreq.imr_ifindex = dev->ifindex; | 595 | mreq.imr_ifindex = dev->ifindex; |
595 | dev_put(dev); | 596 | dev_put(dev); |
596 | } | 597 | } |
597 | } else | 598 | } else |
598 | dev = __dev_get_by_index(&init_net, mreq.imr_ifindex); | 599 | dev = __dev_get_by_index(sk->sk_net, mreq.imr_ifindex); |
599 | 600 | ||
600 | 601 | ||
601 | err = -EADDRNOTAVAIL; | 602 | err = -EADDRNOTAVAIL; |