netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Martin KaFai Lau <kafai@fb.com>
Cc: netdev@vger.kernel.org, borkmann@iogearbox.net, ast@kernel.org,
	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: Fri, 27 Apr 2018 10:49:35 -0600	[thread overview]
Message-ID: <c5cf74c1-fae0-f8ff-4679-df0e6cf4d334@gmail.com> (raw)
In-Reply-To: <20180427164303.qxodjc63i6pf75q6@kafai-mbp>

On 4/27/18 10:43 AM, Martin KaFai Lau wrote:
>> +#if IS_ENABLED(CONFIG_IPV6)
>> +static int bpf_ipv6_fib_lookup(struct xdp_buff *ctx,
>> +			       struct bpf_fib_lookup *params, u32 flags)
>> +{
>> +	struct net *net = dev_net(ctx->rxq->dev);
>> +	struct neighbour *neigh;
>> +	struct net_device *dev;
>> +	struct fib6_info *f6i;
>> +	struct flowi6 fl6;
>> +	int strict = 0;
>> +	int oif;
>> +
>> +	/* link local addresses are never forwarded */
>> +	if (rt6_need_strict(&params->ipv6_dst) ||
>> +	    rt6_need_strict(&params->ipv6_src))
>> +		return 0;
>> +
>> +	dev = dev_get_by_index_rcu(net, params->ifindex);
>> +	if (unlikely(!dev))
>> +		return -ENODEV;
>> +
>> +	if (flags & BPF_FIB_LOOKUP_OUTPUT) {
>> +		fl6.flowi6_iif = 1;
> 1 is for LOOPBACK_IFINDEX?

yes. The intention is to mirror the flow struct created by full stack so
that routing in bpf == routing in IPv6 stack. ip6_route_output_flags
sets flowi6_iif to 1, so I repeated it here.

> 
>> +		oif = fl6.flowi6_oif = params->ifindex;
>> +	} else {
>> +		oif = fl6.flowi6_iif = params->ifindex;
>> +		fl6.flowi6_oif = 0;
>> +		strict = RT6_LOOKUP_F_HAS_SADDR;
>> +	}

  reply	other threads:[~2018-04-27 16:49 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
2018-04-27 16:43   ` Martin KaFai Lau
2018-04-27 16:49     ` David Ahern [this message]
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=c5cf74c1-fae0-f8ff-4679-df0e6cf4d334@gmail.com \
    --to=dsahern@gmail.com \
    --cc=ast@kernel.org \
    --cc=borkmann@iogearbox.net \
    --cc=brouer@redhat.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.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).