Skip to content

Commit 4591db4

Browse files
Daniel Lezcanodavem330
authored andcommitted
[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>
1 parent 6fda735 commit 4591db4

File tree

11 files changed

+17
-15
lines changed

11 files changed

+17
-15
lines changed

include/net/ip6_route.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ extern struct rt6_info *ip6_blk_hole_entry;
4343

4444
extern void ip6_route_input(struct sk_buff *skb);
4545

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,
4748
struct flowi *fl);
4849

4950
extern int ip6_route_init(void);

net/ipv6/icmp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static inline int icmpv6_xrlim_allow(struct sock *sk, int type,
178178
* XXX: perhaps the expire for routing entries cloned by
179179
* this lookup should be more aggressive (not longer than timeout).
180180
*/
181-
dst = ip6_route_output(sk, fl);
181+
dst = ip6_route_output(&init_net, sk, fl);
182182
if (dst->error) {
183183
IP6_INC_STATS(ip6_dst_idev(dst),
184184
IPSTATS_MIB_OUTNOROUTES);

net/ipv6/ip6_output.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ static int ip6_dst_lookup_tail(struct sock *sk,
913913
int err;
914914

915915
if (*dst == NULL)
916-
*dst = ip6_route_output(sk, fl);
916+
*dst = ip6_route_output(&init_net, sk, fl);
917917

918918
if ((err = (*dst)->error))
919919
goto out_err_release;
@@ -954,7 +954,7 @@ static int ip6_dst_lookup_tail(struct sock *sk,
954954
dst_release(*dst);
955955
memcpy(&fl_gw, fl, sizeof(struct flowi));
956956
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);
958958
if ((err = (*dst)->error))
959959
goto out_err_release;
960960
}

net/ipv6/ip6_tunnel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
847847
if ((dst = ip6_tnl_dst_check(t)) != NULL)
848848
dst_hold(dst);
849849
else {
850-
dst = ip6_route_output(NULL, fl);
850+
dst = ip6_route_output(&init_net, NULL, fl);
851851

852852
if (dst->error || xfrm_lookup(&dst, fl, NULL, 0) < 0)
853853
goto tx_err_link_failure;

net/ipv6/ndisc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
14271427
icmpv6_flow_init(ndisc_socket->sk, &fl, NDISC_REDIRECT,
14281428
&saddr_buf, &ipv6_hdr(skb)->saddr, dev->ifindex);
14291429

1430-
dst = ip6_route_output(NULL, &fl);
1430+
dst = ip6_route_output(&init_net, NULL, &fl);
14311431
if (dst == NULL)
14321432
return;
14331433

net/ipv6/netfilter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ int ip6_route_me_harder(struct sk_buff *skb)
2323
.saddr = iph->saddr, } },
2424
};
2525

26-
dst = ip6_route_output(skb->sk, &fl);
26+
dst = ip6_route_output(&init_net, skb->sk, &fl);
2727

2828
#ifdef CONFIG_XFRM
2929
if (!(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) &&
@@ -86,7 +86,7 @@ static int nf_ip6_reroute(struct sk_buff *skb,
8686

8787
static int nf_ip6_route(struct dst_entry **dst, struct flowi *fl)
8888
{
89-
*dst = ip6_route_output(NULL, fl);
89+
*dst = ip6_route_output(&init_net, NULL, fl);
9090
return (*dst)->error;
9191
}
9292

net/ipv6/netfilter/ip6t_REJECT.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static void send_reset(struct sk_buff *oldskb)
9393
fl.fl_ip_sport = otcph.dest;
9494
fl.fl_ip_dport = otcph.source;
9595
security_skb_classify_flow(oldskb, &fl);
96-
dst = ip6_route_output(NULL, &fl);
96+
dst = ip6_route_output(&init_net, NULL, &fl);
9797
if (dst == NULL)
9898
return;
9999
if (dst->error || xfrm_lookup(&dst, &fl, NULL, 0))

net/ipv6/route.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,8 @@ static struct rt6_info *ip6_pol_route_output(struct net *net, struct fib6_table
772772
return ip6_pol_route(net, table, fl->oif, fl, flags);
773773
}
774774

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)
776777
{
777778
int flags = 0;
778779

@@ -782,7 +783,7 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)
782783
if (!ipv6_addr_any(&fl->fl6_src))
783784
flags |= RT6_LOOKUP_F_HAS_SADDR;
784785

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);
786787
}
787788

788789
EXPORT_SYMBOL(ip6_route_output);
@@ -2260,7 +2261,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
22602261
skb_reset_mac_header(skb);
22612262
skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr));
22622263

2263-
rt = (struct rt6_info*) ip6_route_output(NULL, &fl);
2264+
rt = (struct rt6_info*) ip6_route_output(&init_net, NULL, &fl);
22642265
skb->dst = &rt->u.dst;
22652266

22662267
err = rt6_fill_node(skb, rt, &fl.fl6_dst, &fl.fl6_src, iif,

net/ipv6/sit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ isatap_srcok(struct sk_buff *skb, struct iphdr *iph, struct net_device *dev)
393393
fl.oif = dev->ifindex;
394394
security_skb_classify_flow(skb, &fl);
395395

396-
dst = ip6_route_output(NULL, &fl);
396+
dst = ip6_route_output(&init_net, NULL, &fl);
397397
if (!dst->error && (dst->dev == dev) && (neigh = dst->neighbour)) {
398398

399399
addr6 = (struct in6_addr*)&neigh->primary_key;

net/ipv6/xfrm6_policy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static struct dst_entry *xfrm6_dst_lookup(int tos, xfrm_address_t *saddr,
3838
if (saddr)
3939
memcpy(&fl.fl6_src, saddr, sizeof(fl.fl6_src));
4040

41-
dst = ip6_route_output(NULL, &fl);
41+
dst = ip6_route_output(&init_net, NULL, &fl);
4242

4343
err = dst->error;
4444
if (dst->error) {

0 commit comments

Comments
 (0)