Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipv6: change ipv6_stub_impl.ipv6_dst_lookup to take net argument

This patch adds net argument to ipv6_stub_impl.ipv6_dst_lookup
for use cases where sk is not available (like mpls).
sk appears to be needed to get the namespace 'net' and is optional
otherwise. This patch series changes ipv6_stub_impl.ipv6_dst_lookup
to take net argument. sk remains optional.

All callers of ipv6_stub_impl.ipv6_dst_lookup have been modified
to pass net. I have modified them to use already available
'net' in the scope of the call. I can change them to
sock_net(sk) to avoid any unintended change in behaviour if sock
namespace is different. They dont seem to be from code inspection.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Roopa Prabhu and committed by
David S. Miller
343d60aa d3aa45ce

+26 -15
+1 -1
drivers/net/vxlan.c
··· 2034 2034 fl6.flowi6_mark = skb->mark; 2035 2035 fl6.flowi6_proto = IPPROTO_UDP; 2036 2036 2037 - if (ipv6_stub->ipv6_dst_lookup(sk, &ndst, &fl6)) { 2037 + if (ipv6_stub->ipv6_dst_lookup(vxlan->net, sk, &ndst, &fl6)) { 2038 2038 netdev_dbg(dev, "no route to %pI6\n", 2039 2039 &dst->sin6.sin6_addr); 2040 2040 dev->stats.tx_carrier_errors++;
+2 -2
include/net/addrconf.h
··· 158 158 const struct in6_addr *addr); 159 159 int (*ipv6_sock_mc_drop)(struct sock *sk, int ifindex, 160 160 const struct in6_addr *addr); 161 - int (*ipv6_dst_lookup)(struct sock *sk, struct dst_entry **dst, 162 - struct flowi6 *fl6); 161 + int (*ipv6_dst_lookup)(struct net *net, struct sock *sk, 162 + struct dst_entry **dst, struct flowi6 *fl6); 163 163 void (*udpv6_encap_enable)(void); 164 164 void (*ndisc_send_na)(struct net_device *dev, struct neighbour *neigh, 165 165 const struct in6_addr *daddr,
+2 -1
include/net/ipv6.h
··· 813 813 &inet6_sk(sk)->cork); 814 814 } 815 815 816 - int ip6_dst_lookup(struct sock *sk, struct dst_entry **dst, struct flowi6 *fl6); 816 + int ip6_dst_lookup(struct net *net, struct sock *sk, struct dst_entry **dst, 817 + struct flowi6 *fl6); 817 818 struct dst_entry *ip6_dst_lookup_flow(struct sock *sk, struct flowi6 *fl6, 818 819 const struct in6_addr *final_dst); 819 820 struct dst_entry *ip6_sk_dst_lookup_flow(struct sock *sk, struct flowi6 *fl6,
+10 -1
net/ipv6/addrconf_core.c
··· 107 107 } 108 108 EXPORT_SYMBOL(inet6addr_notifier_call_chain); 109 109 110 - const struct ipv6_stub *ipv6_stub __read_mostly; 110 + static int eafnosupport_ipv6_dst_lookup(struct net *net, struct sock *u1, 111 + struct dst_entry **u2, 112 + struct flowi6 *u3) 113 + { 114 + return -EAFNOSUPPORT; 115 + } 116 + 117 + const struct ipv6_stub *ipv6_stub __read_mostly = &(struct ipv6_stub) { 118 + .ipv6_dst_lookup = eafnosupport_ipv6_dst_lookup, 119 + }; 111 120 EXPORT_SYMBOL_GPL(ipv6_stub); 112 121 113 122 /* IPv6 Wildcard Address and Loopback Address defined by RFC2553 */
+3 -3
net/ipv6/icmp.c
··· 329 329 struct flowi6 fl2; 330 330 int err; 331 331 332 - err = ip6_dst_lookup(sk, &dst, fl6); 332 + err = ip6_dst_lookup(net, sk, &dst, fl6); 333 333 if (err) 334 334 return ERR_PTR(err); 335 335 ··· 361 361 if (err) 362 362 goto relookup_failed; 363 363 364 - err = ip6_dst_lookup(sk, &dst2, &fl2); 364 + err = ip6_dst_lookup(net, sk, &dst2, &fl2); 365 365 if (err) 366 366 goto relookup_failed; 367 367 ··· 591 591 else if (!fl6.flowi6_oif) 592 592 fl6.flowi6_oif = np->ucast_oif; 593 593 594 - err = ip6_dst_lookup(sk, &dst, &fl6); 594 + err = ip6_dst_lookup(net, sk, &dst, &fl6); 595 595 if (err) 596 596 goto out; 597 597 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), sk, 0);
+6 -6
net/ipv6/ip6_output.c
··· 881 881 return dst; 882 882 } 883 883 884 - static int ip6_dst_lookup_tail(struct sock *sk, 884 + static int ip6_dst_lookup_tail(struct net *net, struct sock *sk, 885 885 struct dst_entry **dst, struct flowi6 *fl6) 886 886 { 887 - struct net *net = sock_net(sk); 888 887 #ifdef CONFIG_IPV6_OPTIMISTIC_DAD 889 888 struct neighbour *n; 890 889 struct rt6_info *rt; ··· 993 994 * 994 995 * It returns zero on success, or a standard errno code on error. 995 996 */ 996 - int ip6_dst_lookup(struct sock *sk, struct dst_entry **dst, struct flowi6 *fl6) 997 + int ip6_dst_lookup(struct net *net, struct sock *sk, struct dst_entry **dst, 998 + struct flowi6 *fl6) 997 999 { 998 1000 *dst = NULL; 999 - return ip6_dst_lookup_tail(sk, dst, fl6); 1001 + return ip6_dst_lookup_tail(net, sk, dst, fl6); 1000 1002 } 1001 1003 EXPORT_SYMBOL_GPL(ip6_dst_lookup); 1002 1004 ··· 1018 1018 struct dst_entry *dst = NULL; 1019 1019 int err; 1020 1020 1021 - err = ip6_dst_lookup_tail(sk, &dst, fl6); 1021 + err = ip6_dst_lookup_tail(sock_net(sk), sk, &dst, fl6); 1022 1022 if (err) 1023 1023 return ERR_PTR(err); 1024 1024 if (final_dst) ··· 1052 1052 1053 1053 dst = ip6_sk_dst_check(sk, dst, fl6); 1054 1054 1055 - err = ip6_dst_lookup_tail(sk, &dst, fl6); 1055 + err = ip6_dst_lookup_tail(sock_net(sk), sk, &dst, fl6); 1056 1056 if (err) 1057 1057 return ERR_PTR(err); 1058 1058 if (final_dst)
+2 -1
net/tipc/udp_media.c
··· 194 194 .saddr = src->ipv6, 195 195 .flowi6_proto = IPPROTO_UDP 196 196 }; 197 - err = ipv6_stub->ipv6_dst_lookup(ub->ubsock->sk, &ndst, &fl6); 197 + err = ipv6_stub->ipv6_dst_lookup(net, ub->ubsock->sk, &ndst, 198 + &fl6); 198 199 if (err) 199 200 goto tx_error; 200 201 ttl = ip6_dst_hoplimit(ndst);