Commit 6f5f68d0 authored by David Ahern's avatar David Ahern Committed by David S. Miller

bpf: Handle ipv6 gateway in bpf_ipv4_fib_lookup

Update bpf_ipv4_fib_lookup to handle an ipv6 gateway.
Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5c9f7c1d
...@@ -4639,15 +4639,26 @@ static int bpf_ipv4_fib_lookup(struct net *net, struct bpf_fib_lookup *params, ...@@ -4639,15 +4639,26 @@ static int bpf_ipv4_fib_lookup(struct net *net, struct bpf_fib_lookup *params,
return BPF_FIB_LKUP_RET_UNSUPP_LWT; return BPF_FIB_LKUP_RET_UNSUPP_LWT;
dev = nhc->nhc_dev; dev = nhc->nhc_dev;
if (nhc->nhc_gw_family)
params->ipv4_dst = nhc->nhc_gw.ipv4;
params->rt_metric = res.fi->fib_priority; params->rt_metric = res.fi->fib_priority;
/* xdp and cls_bpf programs are run in RCU-bh so /* xdp and cls_bpf programs are run in RCU-bh so
* rcu_read_lock_bh is not needed here * rcu_read_lock_bh is not needed here
*/ */
neigh = __ipv4_neigh_lookup_noref(dev, (__force u32)params->ipv4_dst); if (likely(nhc->nhc_gw_family != AF_INET6)) {
if (nhc->nhc_gw_family)
params->ipv4_dst = nhc->nhc_gw.ipv4;
neigh = __ipv4_neigh_lookup_noref(dev,
(__force u32)params->ipv4_dst);
} else {
struct in6_addr *dst = (struct in6_addr *)params->ipv6_dst;
params->family = AF_INET6;
*dst = nhc->nhc_gw.ipv6;
neigh = __ipv6_neigh_lookup_noref_stub(dev, dst);
}
if (!neigh) if (!neigh)
return BPF_FIB_LKUP_RET_NO_NEIGH; return BPF_FIB_LKUP_RET_NO_NEIGH;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment