XDP-Newbies Archive mirror
 help / color / mirror / Atom feed
From: Konrad Zemek <konrad@zemek.io>
To: xdp-newbies@vger.kernel.org
Subject: bpf_fib_lookup VLAN
Date: Fri, 16 Apr 2021 12:03:42 +0000	[thread overview]
Message-ID: <007301d732b8$8b0f5c90$a12e15b0$@zemek.io> (raw)

Hi everyone,

I've been bitten today by bpf_fib_lookup, which I use to lookup a new
neighbor after pushing some tunnel headers in XDP. Some of the tunneled
packets have to go through a specific VLAN or they get lost - and debugging
an issue today it looks like all my generated packets have no VLAN header at
all! Digging through the kernel code, both the ipv4 and ipv6 lookup routines
end with a `return bpf_fib_set_fwd_params`, which is defined as:

static int bpf_fib_set_fwd_params(struct bpf_fib_lookup *params,
				  const struct neighbour *neigh,
				  const struct net_device *dev, u32 mtu)
{
	memcpy(params->dmac, neigh->ha, ETH_ALEN);
	memcpy(params->smac, dev->dev_addr, ETH_ALEN);
	params->h_vlan_TCI = 0;
	params->h_vlan_proto = 0;
	if (mtu)
		params->mtu_result = mtu; /* union with tot_len */

	return 0;
}

So both vlan fields in the output struct bpf_fib_lookup are always zero. I
haven't seen this commented on anywhere, including the discussion around
introducing bpf_fib_lookup, so I assume it's an accidental oversight.

Do you have any proposals for a workaround? Right now I'm thinking of
creating a BPF map that would map ifindex->vlan, populated in the userspace
- but that assumes the output (struct bpf_fib_lookup*)->ifindex will be an
index of the vlan device and not the physical device the vlan is attached
on, which I'm not sure is the case yet.

Thanks,
Konrad Zemek



             reply	other threads:[~2021-04-16 12:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16 12:03 Konrad Zemek [this message]
2021-04-16 15:15 ` bpf_fib_lookup VLAN Konrad Zemek
2021-04-16 15:35 ` David Ahern
2021-04-16 16:12   ` Konrad Zemek
2021-04-18 17:11     ` 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='007301d732b8$8b0f5c90$a12e15b0$@zemek.io' \
    --to=konrad@zemek.io \
    --cc=xdp-newbies@vger.kernel.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).