]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: ipv6_stub: use ip6_dst_lookup_flow instead of ip6_dst_lookup
authorSabrina Dubroca <sd@queasysnail.net>
Wed, 4 Dec 2019 14:35:53 +0000 (15:35 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 28 Apr 2020 18:03:39 +0000 (19:03 +0100)
commit 6c8991f41546c3c472503dff1ea9daaddf9331c2 upstream.

ipv6_stub uses the ip6_dst_lookup function to allow other modules to
perform IPv6 lookups. However, this function skips the XFRM layer
entirely.

All users of ipv6_stub->ip6_dst_lookup use ip_route_output_flow (via the
ip_route_output_key and ip_route_output helpers) for their IPv4 lookups,
which calls xfrm_lookup_route(). This patch fixes this inconsistent
behavior by switching the stub to ip6_dst_lookup_flow, which also calls
xfrm_lookup_route().

This requires some changes in all the callers, as these two functions
take different arguments and have different return types.

Fixes: 5f81bd2e5d80 ("ipv6: export a stub for IPv6 symbols used by vxlan")
Reported-by: Xiumei Mu <xmu@redhat.com>
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.16:
 - Only vxlan uses this operation
 - Neither ip6_dst_lookup() nor ip6_dst_lookup_flow() takes a struct net
   pointer argument here
 - Adjust filename, context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/net/vxlan.c
include/net/addrconf.h
net/ipv6/af_inet6.c

index 11736ad7c835435888dc51c8d5ca6e74256e8765..78f3e8612bab5698ec4a86947709fc6151f633cc 100644 (file)
@@ -1929,7 +1929,8 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
                fl6.saddr = vxlan->saddr.sin6.sin6_addr;
                fl6.flowi6_proto = IPPROTO_UDP;
 
-               if (ipv6_stub->ipv6_dst_lookup(sk, &ndst, &fl6)) {
+               ndst = ipv6_stub->ipv6_dst_lookup_flow(sk, &fl6, NULL);
+               if (unlikely(IS_ERR(ndst))) {
                        netdev_dbg(dev, "no route to %pI6\n",
                                   &dst->sin6.sin6_addr);
                        dev->stats.tx_carrier_errors++;
index c9766ab9c87c0ad1fe50b0c07464ae65583125b3..19d0e56375f7c47d5fb6b366ae1af8e24a1c0a72 100644 (file)
@@ -156,8 +156,9 @@ struct ipv6_stub {
                                 const struct in6_addr *addr);
        int (*ipv6_sock_mc_drop)(struct sock *sk, int ifindex,
                                 const struct in6_addr *addr);
-       int (*ipv6_dst_lookup)(struct sock *sk, struct dst_entry **dst,
-                               struct flowi6 *fl6);
+       struct dst_entry *(*ipv6_dst_lookup_flow)(struct sock *sk,
+                                                 struct flowi6 *fl6,
+                                                 const struct in6_addr *final_dst);
        void (*udpv6_encap_enable)(void);
        void (*ndisc_send_na)(struct net_device *dev, struct neighbour *neigh,
                              const struct in6_addr *daddr,
index d5db3ce7b46360db17f6d7627d0a761e3ca698be..afe2766351633cd0abe684ac42a747aa422c1144 100644 (file)
@@ -820,7 +820,7 @@ static struct pernet_operations inet6_net_ops = {
 static const struct ipv6_stub ipv6_stub_impl = {
        .ipv6_sock_mc_join = ipv6_sock_mc_join,
        .ipv6_sock_mc_drop = ipv6_sock_mc_drop,
-       .ipv6_dst_lookup = ip6_dst_lookup,
+       .ipv6_dst_lookup_flow = ip6_dst_lookup_flow,
        .udpv6_encap_enable = udpv6_encap_enable,
        .ndisc_send_na = ndisc_send_na,
        .nd_tbl = &nd_tbl,