OSDN Git Service

bpf: Change bpf_fib_lookup to return -EAFNOSUPPORT for unsupported address families
authorDavid Ahern <dsahern@gmail.com>
Wed, 30 May 2018 19:24:17 +0000 (12:24 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 30 May 2018 21:17:18 +0000 (14:17 -0700)
Update bpf_fib_lookup to return -EAFNOSUPPORT for unsupported address
families. Allows userspace to probe for support as more are added
(e.g., AF_MPLS).

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
net/core/filter.c

index 81bd2e9..885fb0e 100644 (file)
@@ -4285,7 +4285,7 @@ BPF_CALL_4(bpf_xdp_fib_lookup, struct xdp_buff *, ctx,
                                           flags, true);
 #endif
        }
-       return 0;
+       return -EAFNOSUPPORT;
 }
 
 static const struct bpf_func_proto bpf_xdp_fib_lookup_proto = {
@@ -4302,7 +4302,7 @@ BPF_CALL_4(bpf_skb_fib_lookup, struct sk_buff *, skb,
           struct bpf_fib_lookup *, params, int, plen, u32, flags)
 {
        struct net *net = dev_net(skb->dev);
-       int index = 0;
+       int index = -EAFNOSUPPORT;
 
        if (plen < sizeof(*params))
                return -EINVAL;