Commit 4591db4f37618f37a9f1f25d291c3c7a43a15a21

Authored by Daniel Lezcano
Committed by David S. Miller
1 parent 6fda735005

[NETNS][IPV6] route6 - add netns parameter to ip6_route_output

Add an netns parameter to ip6_route_output. That will allow to access
to the right routing table for outgoing traffic.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 11 changed files with 17 additions and 15 deletions Side-by-side Diff

include/net/ip6_route.h
... ... @@ -43,7 +43,8 @@
43 43  
44 44 extern void ip6_route_input(struct sk_buff *skb);
45 45  
46   -extern struct dst_entry * ip6_route_output(struct sock *sk,
  46 +extern struct dst_entry * ip6_route_output(struct net *net,
  47 + struct sock *sk,
47 48 struct flowi *fl);
48 49  
49 50 extern int ip6_route_init(void);
... ... @@ -178,7 +178,7 @@
178 178 * XXX: perhaps the expire for routing entries cloned by
179 179 * this lookup should be more aggressive (not longer than timeout).
180 180 */
181   - dst = ip6_route_output(sk, fl);
  181 + dst = ip6_route_output(&init_net, sk, fl);
182 182 if (dst->error) {
183 183 IP6_INC_STATS(ip6_dst_idev(dst),
184 184 IPSTATS_MIB_OUTNOROUTES);
net/ipv6/ip6_output.c
... ... @@ -913,7 +913,7 @@
913 913 int err;
914 914  
915 915 if (*dst == NULL)
916   - *dst = ip6_route_output(sk, fl);
  916 + *dst = ip6_route_output(&init_net, sk, fl);
917 917  
918 918 if ((err = (*dst)->error))
919 919 goto out_err_release;
... ... @@ -954,7 +954,7 @@
954 954 dst_release(*dst);
955 955 memcpy(&fl_gw, fl, sizeof(struct flowi));
956 956 memset(&fl_gw.fl6_dst, 0, sizeof(struct in6_addr));
957   - *dst = ip6_route_output(sk, &fl_gw);
  957 + *dst = ip6_route_output(&init_net, sk, &fl_gw);
958 958 if ((err = (*dst)->error))
959 959 goto out_err_release;
960 960 }
net/ipv6/ip6_tunnel.c
... ... @@ -847,7 +847,7 @@
847 847 if ((dst = ip6_tnl_dst_check(t)) != NULL)
848 848 dst_hold(dst);
849 849 else {
850   - dst = ip6_route_output(NULL, fl);
  850 + dst = ip6_route_output(&init_net, NULL, fl);
851 851  
852 852 if (dst->error || xfrm_lookup(&dst, fl, NULL, 0) < 0)
853 853 goto tx_err_link_failure;
... ... @@ -1427,7 +1427,7 @@
1427 1427 icmpv6_flow_init(ndisc_socket->sk, &fl, NDISC_REDIRECT,
1428 1428 &saddr_buf, &ipv6_hdr(skb)->saddr, dev->ifindex);
1429 1429  
1430   - dst = ip6_route_output(NULL, &fl);
  1430 + dst = ip6_route_output(&init_net, NULL, &fl);
1431 1431 if (dst == NULL)
1432 1432 return;
1433 1433  
net/ipv6/netfilter.c
... ... @@ -23,7 +23,7 @@
23 23 .saddr = iph->saddr, } },
24 24 };
25 25  
26   - dst = ip6_route_output(skb->sk, &fl);
  26 + dst = ip6_route_output(&init_net, skb->sk, &fl);
27 27  
28 28 #ifdef CONFIG_XFRM
29 29 if (!(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) &&
... ... @@ -86,7 +86,7 @@
86 86  
87 87 static int nf_ip6_route(struct dst_entry **dst, struct flowi *fl)
88 88 {
89   - *dst = ip6_route_output(NULL, fl);
  89 + *dst = ip6_route_output(&init_net, NULL, fl);
90 90 return (*dst)->error;
91 91 }
92 92  
net/ipv6/netfilter/ip6t_REJECT.c
... ... @@ -93,7 +93,7 @@
93 93 fl.fl_ip_sport = otcph.dest;
94 94 fl.fl_ip_dport = otcph.source;
95 95 security_skb_classify_flow(oldskb, &fl);
96   - dst = ip6_route_output(NULL, &fl);
  96 + dst = ip6_route_output(&init_net, NULL, &fl);
97 97 if (dst == NULL)
98 98 return;
99 99 if (dst->error || xfrm_lookup(&dst, &fl, NULL, 0))
... ... @@ -772,7 +772,8 @@
772 772 return ip6_pol_route(net, table, fl->oif, fl, flags);
773 773 }
774 774  
775   -struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)
  775 +struct dst_entry * ip6_route_output(struct net *net, struct sock *sk,
  776 + struct flowi *fl)
776 777 {
777 778 int flags = 0;
778 779  
... ... @@ -782,7 +783,7 @@
782 783 if (!ipv6_addr_any(&fl->fl6_src))
783 784 flags |= RT6_LOOKUP_F_HAS_SADDR;
784 785  
785   - return fib6_rule_lookup(&init_net, fl, flags, ip6_pol_route_output);
  786 + return fib6_rule_lookup(net, fl, flags, ip6_pol_route_output);
786 787 }
787 788  
788 789 EXPORT_SYMBOL(ip6_route_output);
... ... @@ -2260,7 +2261,7 @@
2260 2261 skb_reset_mac_header(skb);
2261 2262 skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr));
2262 2263  
2263   - rt = (struct rt6_info*) ip6_route_output(NULL, &fl);
  2264 + rt = (struct rt6_info*) ip6_route_output(&init_net, NULL, &fl);
2264 2265 skb->dst = &rt->u.dst;
2265 2266  
2266 2267 err = rt6_fill_node(skb, rt, &fl.fl6_dst, &fl.fl6_src, iif,
... ... @@ -393,7 +393,7 @@
393 393 fl.oif = dev->ifindex;
394 394 security_skb_classify_flow(skb, &fl);
395 395  
396   - dst = ip6_route_output(NULL, &fl);
  396 + dst = ip6_route_output(&init_net, NULL, &fl);
397 397 if (!dst->error && (dst->dev == dev) && (neigh = dst->neighbour)) {
398 398  
399 399 addr6 = (struct in6_addr*)&neigh->primary_key;
net/ipv6/xfrm6_policy.c
... ... @@ -38,7 +38,7 @@
38 38 if (saddr)
39 39 memcpy(&fl.fl6_src, saddr, sizeof(fl.fl6_src));
40 40  
41   - dst = ip6_route_output(NULL, &fl);
  41 + dst = ip6_route_output(&init_net, NULL, &fl);
42 42  
43 43 err = dst->error;
44 44 if (dst->error) {
... ... @@ -257,7 +257,7 @@
257 257 NIP6(fl.fl6_src));
258 258 }
259 259  
260   - dst = ip6_route_output(NULL, &fl);
  260 + dst = ip6_route_output(&init_net, NULL, &fl);
261 261 if (!dst->error) {
262 262 struct rt6_info *rt;
263 263 rt = (struct rt6_info *)dst;