On 4/25/18 1:55 PM, Daniel Borkmann wrote: >> @@ -3861,6 +4090,8 @@ sk_filter_func_proto(enum bpf_func_id func_id, const >> struct bpf_prog *prog) >> return &bpf_get_socket_cookie_proto; >> case BPF_FUNC_get_socket_uid: >> return &bpf_get_socket_uid_proto; >> + case BPF_FUNC_fib_lookup: >> + return &bpf_fib_lookup_proto; > This part doesn't belong to sk_filter_func_proto(), but to the > tc_cls_act_func_proto() instead.
oops, somewhere in all of the re-basing it got added to the wrong function. Will fix. > >> default: >> return bpf_base_func_proto(func_id); >> } >> @@ -3957,6 +4188,8 @@ xdp_func_proto(enum bpf_func_id func_id, const struct >> bpf_prog *prog) >> return &bpf_xdp_redirect_map_proto; >> case BPF_FUNC_xdp_adjust_tail: >> return &bpf_xdp_adjust_tail_proto; >> + case BPF_FUNC_fib_lookup: >> + return &bpf_fib_lookup_proto; > Basically, you're using the very same bpf_fib_lookup_proto for > both XDP and skb. In the skb case, you're reusing the two functions > bpf_ipv{4,6}_fib_lookup(), so when you get the netdev pointer for > retrieving the netns, you'll crash at dev_net(ctx->rxq->dev) since > this is XDP only and not skb meta data. > > Therefore, as mentioned, pass the netdev to bpf_ipv{4,6}_fib_lookup() > to have it generic and have bpf_xdp_fib_lookup_proto and > bpf_skb_fib_lookup_proto where both are under the case BPF_FUNC_fib_lookup > in the respective *func_proto(), but using the proper prototypes according > to their correct context. Meaning, both reuse bpf_ipv{4,6}_fib_lookup() > from each of their BPF_CALL_4() helper implementation. ok. I have been focused on the xdp program and not the tc path. Will fix.