Skip to content

Commit 6c8991f

Browse files
qsndavem330
authored andcommitted
net: ipv6_stub: use ip6_dst_lookup_flow instead of ip6_dst_lookup
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: 5f81bd2 ("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>
1 parent c4e85f7 commit 6c8991f

11 files changed

Lines changed: 39 additions & 35 deletions

File tree

‎drivers/infiniband/core/addr.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,16 +421,15 @@ static int addr6_resolve(struct sockaddr *src_sock,
421421
(const struct sockaddr_in6 *)dst_sock;
422422
struct flowi6 fl6;
423423
struct dst_entry *dst;
424-
int ret;
425424

426425
memset(&fl6, 0, sizeof fl6);
427426
fl6.daddr = dst_in->sin6_addr;
428427
fl6.saddr = src_in->sin6_addr;
429428
fl6.flowi6_oif = addr->bound_dev_if;
430429

431-
ret = ipv6_stub->ipv6_dst_lookup(addr->net, NULL, &dst, &fl6);
432-
if (ret < 0)
433-
return ret;
430+
dst = ipv6_stub->ipv6_dst_lookup_flow(addr->net, NULL, &fl6, NULL);
431+
if (IS_ERR(dst))
432+
return PTR_ERR(dst);
434433

435434
if (ipv6_addr_any(&src_in->sin6_addr))
436435
src_in->sin6_addr = fl6.saddr;

‎drivers/infiniband/sw/rxe/rxe_net.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ static struct dst_entry *rxe_find_route6(struct net_device *ndev,
117117
memcpy(&fl6.daddr, daddr, sizeof(*daddr));
118118
fl6.flowi6_proto = IPPROTO_UDP;
119119

120-
if (unlikely(ipv6_stub->ipv6_dst_lookup(sock_net(recv_sockets.sk6->sk),
121-
recv_sockets.sk6->sk, &ndst, &fl6))) {
120+
ndst = ipv6_stub->ipv6_dst_lookup_flow(sock_net(recv_sockets.sk6->sk),
121+
recv_sockets.sk6->sk, &fl6,
122+
NULL);
123+
if (unlikely(IS_ERR(ndst))) {
122124
pr_err_ratelimited("no route to %pI6\n", daddr);
123-
goto put;
125+
return NULL;
124126
}
125127

126128
if (unlikely(ndst->error)) {

‎drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,10 @@ static int mlx5e_route_lookup_ipv6(struct mlx5e_priv *priv,
297297

298298
int ret;
299299

300-
ret = ipv6_stub->ipv6_dst_lookup(dev_net(mirred_dev), NULL, &dst,
301-
fl6);
302-
if (ret < 0)
303-
return ret;
300+
dst = ipv6_stub->ipv6_dst_lookup_flow(dev_net(mirred_dev), NULL, fl6,
301+
NULL);
302+
if (IS_ERR(dst))
303+
return PTR_ERR(dst);
304304

305305
if (!(*out_ttl))
306306
*out_ttl = ip6_dst_hoplimit(dst);

‎drivers/net/geneve.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,9 @@ static struct dst_entry *geneve_get_v6_dst(struct sk_buff *skb,
853853
if (dst)
854854
return dst;
855855
}
856-
if (ipv6_stub->ipv6_dst_lookup(geneve->net, gs6->sock->sk, &dst, fl6)) {
856+
dst = ipv6_stub->ipv6_dst_lookup_flow(geneve->net, gs6->sock->sk, fl6,
857+
NULL);
858+
if (IS_ERR(dst)) {
857859
netdev_dbg(dev, "no route to %pI6\n", &fl6->daddr);
858860
return ERR_PTR(-ENETUNREACH);
859861
}

‎drivers/net/vxlan.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,7 +2275,6 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan,
22752275
bool use_cache = ip_tunnel_dst_cache_usable(skb, info);
22762276
struct dst_entry *ndst;
22772277
struct flowi6 fl6;
2278-
int err;
22792278

22802279
if (!sock6)
22812280
return ERR_PTR(-EIO);
@@ -2298,10 +2297,9 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan,
22982297
fl6.fl6_dport = dport;
22992298
fl6.fl6_sport = sport;
23002299

2301-
err = ipv6_stub->ipv6_dst_lookup(vxlan->net,
2302-
sock6->sock->sk,
2303-
&ndst, &fl6);
2304-
if (unlikely(err < 0)) {
2300+
ndst = ipv6_stub->ipv6_dst_lookup_flow(vxlan->net, sock6->sock->sk,
2301+
&fl6, NULL);
2302+
if (unlikely(IS_ERR(ndst))) {
23052303
netdev_dbg(dev, "no route to %pI6\n", daddr);
23062304
return ERR_PTR(-ENETUNREACH);
23072305
}

‎include/net/ipv6_stubs.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ struct ipv6_stub {
2424
const struct in6_addr *addr);
2525
int (*ipv6_sock_mc_drop)(struct sock *sk, int ifindex,
2626
const struct in6_addr *addr);
27-
int (*ipv6_dst_lookup)(struct net *net, struct sock *sk,
28-
struct dst_entry **dst, struct flowi6 *fl6);
27+
struct dst_entry *(*ipv6_dst_lookup_flow)(struct net *net,
28+
const struct sock *sk,
29+
struct flowi6 *fl6,
30+
const struct in6_addr *final_dst);
2931
int (*ipv6_route_input)(struct sk_buff *skb);
3032

3133
struct fib6_table *(*fib6_get_table)(struct net *net, u32 id);

‎net/core/lwt_bpf.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,7 @@ static int bpf_lwt_xmit_reroute(struct sk_buff *skb)
230230
fl6.daddr = iph6->daddr;
231231
fl6.saddr = iph6->saddr;
232232

233-
err = ipv6_stub->ipv6_dst_lookup(net, skb->sk, &dst, &fl6);
234-
if (unlikely(err))
235-
goto err;
233+
dst = ipv6_stub->ipv6_dst_lookup_flow(net, skb->sk, &fl6, NULL);
236234
if (IS_ERR(dst)) {
237235
err = PTR_ERR(dst);
238236
goto err;

‎net/ipv6/addrconf_core.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,12 @@ int inet6addr_validator_notifier_call_chain(unsigned long val, void *v)
129129
}
130130
EXPORT_SYMBOL(inet6addr_validator_notifier_call_chain);
131131

132-
static int eafnosupport_ipv6_dst_lookup(struct net *net, struct sock *u1,
133-
struct dst_entry **u2,
134-
struct flowi6 *u3)
132+
static struct dst_entry *eafnosupport_ipv6_dst_lookup_flow(struct net *net,
133+
const struct sock *sk,
134+
struct flowi6 *fl6,
135+
const struct in6_addr *final_dst)
135136
{
136-
return -EAFNOSUPPORT;
137+
return ERR_PTR(-EAFNOSUPPORT);
137138
}
138139

139140
static int eafnosupport_ipv6_route_input(struct sk_buff *skb)
@@ -190,7 +191,7 @@ static int eafnosupport_ip6_del_rt(struct net *net, struct fib6_info *rt)
190191
}
191192

192193
const struct ipv6_stub *ipv6_stub __read_mostly = &(struct ipv6_stub) {
193-
.ipv6_dst_lookup = eafnosupport_ipv6_dst_lookup,
194+
.ipv6_dst_lookup_flow = eafnosupport_ipv6_dst_lookup_flow,
194195
.ipv6_route_input = eafnosupport_ipv6_route_input,
195196
.fib6_get_table = eafnosupport_fib6_get_table,
196197
.fib6_table_lookup = eafnosupport_fib6_table_lookup,

‎net/ipv6/af_inet6.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ static int ipv6_route_input(struct sk_buff *skb)
946946
static const struct ipv6_stub ipv6_stub_impl = {
947947
.ipv6_sock_mc_join = ipv6_sock_mc_join,
948948
.ipv6_sock_mc_drop = ipv6_sock_mc_drop,
949-
.ipv6_dst_lookup = ip6_dst_lookup,
949+
.ipv6_dst_lookup_flow = ip6_dst_lookup_flow,
950950
.ipv6_route_input = ipv6_route_input,
951951
.fib6_get_table = fib6_get_table,
952952
.fib6_table_lookup = fib6_table_lookup,

‎net/mpls/af_mpls.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,16 +617,15 @@ static struct net_device *inet6_fib_lookup_dev(struct net *net,
617617
struct net_device *dev;
618618
struct dst_entry *dst;
619619
struct flowi6 fl6;
620-
int err;
621620

622621
if (!ipv6_stub)
623622
return ERR_PTR(-EAFNOSUPPORT);
624623

625624
memset(&fl6, 0, sizeof(fl6));
626625
memcpy(&fl6.daddr, addr, sizeof(struct in6_addr));
627-
err = ipv6_stub->ipv6_dst_lookup(net, NULL, &dst, &fl6);
628-
if (err)
629-
return ERR_PTR(err);
626+
dst = ipv6_stub->ipv6_dst_lookup_flow(net, NULL, &fl6, NULL);
627+
if (IS_ERR(dst))
628+
return ERR_CAST(dst);
630629

631630
dev = dst->dev;
632631
dev_hold(dev);

0 commit comments

Comments
 (0)