Re: Backporting "net: ipv6_stub: use ip6_dst_lookup_flow instead of ip6_dst_lookup"

Ben Hutchings <ben.hutchings@...>

On Fri, 2020-03-13 at 22:03 +0100, Pavel Machek wrote:

Here's backport of `subj` to 4.19. ip6_dst_lookup_flow() prototype
changed between 4.19 and mainline, files were moved around, and I
could not find some instances to update. Fun!
I also had a go at this before catching up on cip-dev and finding you
had also done so. So I've compared this with my version.

I did minimal compile testing, I'll need to run it behind gitlab ci;
but... if you are using IPv6 and can test this, it would be nice.
I haven't done real testing yet either.

Best regards,

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 46b855a42884..e3c948617c73 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -415,9 +415,9 @@ static int addr6_resolve(struct sockaddr_in6 *src_in,
fl6.saddr = src_in->sin6_addr;
fl6.flowi6_oif = addr->bound_dev_if;

- ret = ipv6_stub->ipv6_dst_lookup(addr->net, NULL, &dst, &fl6);
- if (ret < 0)
- return ret;
+ dst = ipv6_stub->ipv6_dst_lookup_flow(addr->net, NULL, &fl6, NULL);
+ if (IS_ERR(dst))
+ return PTR_ERR(dst);
This leaves the ret variable unused, so I deleted it.

diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index ff33f498c137..035cd7dc3836 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -961,6 +961,13 @@ int ip6_dst_lookup(struct net *net, struct sock *sk, struct dst_entry **dst,
struct flowi6 *fl6);
struct dst_entry *ip6_dst_lookup_flow(const struct sock *sk, struct flowi6 *fl6,
const struct in6_addr *final_dst);
+static inline struct dst_entry *ip6_dst_lookup_flow_net(struct net *ign, const struct sock *sk, struct flowi6 *fl6,
+ const struct in6_addr *final_dst)
+ return ip6_dst_lookup_flow(sk, fl6, final_dst);
I think we should pick commit c4e85f73afb6 "net: ipv6: add net argument
to ip6_dst_lookup_flow" first instead of adding this adapter. It is
explicitly described as preparation for this fix.

--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -190,6 +190,14 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
.saddr = src->ipv6,
.flowi6_proto = IPPROTO_UDP
+ ndst = ipv6_stub->ipv6_dst_lookup_flow(net,
+ ub->ubsock->sk,
+ &fl6, NULL);
+ if (IS_ERR(ndst)) {
+ err = PTR_ERR(ndst);
+ goto tx_error;
+ }
err = ipv6_stub->ipv6_dst_lookup(net, ub->ubsock->sk, &ndst,
if (err)
You've not deleted the call to the old ipv6_dst_lookup operation here.

The mlx5_en driver *does* use the ipv6_dst_lookup operation in 4.19 so
it should be converted to ipv6_dst_lookup_flow. The relevant code is
in drivers/net/ethernet/mellanox/mlx5/core/en_tc.c.


Ben Hutchings, Software Developer Codethink Ltd Dale House, 35 Dale Street
Manchester, M1 2HF, United Kingdom

Join to automatically receive all group messages.