netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>,
	netdev@vger.kernel.org, ast@kernel.org
Cc: shm@cumulusnetworks.com, roopa@cumulusnetworks.com,
	brouer@redhat.com, toke@toke.dk, john.fastabend@gmail.com
Subject: Re: [RFC bpf-next 8/9] bpf: Provide helper to do lookups in kernel FIB table
Date: Wed, 25 Apr 2018 17:24:45 -0600	[thread overview]
Message-ID: <f602eefc-20b5-b742-128b-7d1aae749a01@gmail.com> (raw)
In-Reply-To: <9488a57d-5559-b69f-631e-71cada1c1d2d@iogearbox.net>

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.

  reply	other threads:[~2018-04-25 23:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-25 18:34 [RFC bpf-next 0/9] bpf: Add helper to do FIB lookups David Ahern
2018-04-25 18:34 ` [RFC bpf-next 1/9] net/ipv6: Rename fib6_lookup to fib6_node_lookup David Ahern
2018-04-25 18:34 ` [RFC bpf-next 2/9] net/ipv6: Rename rt6_multipath_select David Ahern
2018-04-25 18:34 ` [RFC bpf-next 3/9] net/ipv6: Extract table lookup from ip6_pol_route David Ahern
2018-04-25 18:34 ` [RFC bpf-next 4/9] net/ipv6: Refactor fib6_rule_action David Ahern
2018-04-25 18:34 ` [RFC bpf-next 5/9] net/ipv6: Add fib6_lookup David Ahern
2018-04-25 18:34 ` [RFC bpf-next 6/9] net/ipv6: Update fib6 tracepoint to take fib6_info David Ahern
2018-04-25 18:34 ` [RFC bpf-next 7/9] net/ipv6: Add fib lookup stubs for use in bpf helper David Ahern
2018-04-25 18:34 ` [RFC bpf-next 8/9] bpf: Provide helper to do lookups in kernel FIB table David Ahern
2018-04-25 19:55   ` Daniel Borkmann
2018-04-25 23:24     ` David Ahern [this message]
2018-04-27 16:43   ` Martin KaFai Lau
2018-04-27 16:49     ` David Ahern
2018-04-25 18:34 ` [RFC bpf-next 9/9] samples/bpf: Add examples of ipv4 and ipv6 forwarding in XDP David Ahern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f602eefc-20b5-b742-128b-7d1aae749a01@gmail.com \
    --to=dsahern@gmail.com \
    --cc=ast@kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=roopa@cumulusnetworks.com \
    --cc=shm@cumulusnetworks.com \
    --cc=toke@toke.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).