bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Willi <martin@strongswan.org>
To: "Toke Høiland-Jørgensen" <toke@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Jesper Dangaard Brouer" <hawk@kernel.org>,
	"John Fastabend" <john.fastabend@gmail.com>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH net-next] net: xdp: Update pkt_type if generic XDP changes unicast MAC
Date: Tue, 20 Apr 2021 07:15:00 +0200	[thread overview]
Message-ID: <f14da35f8cfa4b8f888dadfe4c9ebcd031d8e870.camel@strongswan.org> (raw)
In-Reply-To: <87tuo2gwbj.fsf@toke.dk>

Hi,

Thanks for your comments.

> >  	eth = (struct ethhdr *)xdp->data;
> > +	orig_host = ether_addr_equal_64bits(eth->h_dest, skb->dev->dev_addr);
> 
> ether_addr_equal_64bits() seems to assume that the addresses passed to 
> it are padded to be 8 bytes long, which is not the case for eth->h_dest.
> AFAICT the only reason the _64bits variant works for multicast is that
> it happens to be only checking the top-most bit, but unless I'm missing
> something you'll have to use the boring old ether_addr_equal() here, no?

This is what eth_type_trans() uses below, so I assumed it is safe to
use. Isn't that working on the same data?

Also, the destination address in Ethernet is followed by the source
address, so two extra bytes in the source are used as padding. These
are then shifted out by ether_addr_equal_64bits(), no?

> > +		skb->pkt_type = PACKET_HOST;
> >  		skb->protocol = eth_type_trans(skb, skb->dev);
> >  	}
> 
> Okay, so this was a bit confusing to me at fist glance:
> eth_type_trans() will reset the type, but not back to PACKET_HOST. So
> this works, just a bit confusing :)

Indeed. I considered changing eth_type_trans() to always reset
pkt_type, but I didn't want to take the risk for any side effects.

Thanks!
Martin


  reply	other threads:[~2021-04-20  5:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19 14:15 [PATCH net-next] net: xdp: Update pkt_type if generic XDP changes unicast MAC Martin Willi
2021-04-19 14:53 ` Toke Høiland-Jørgensen
2021-04-20  5:15   ` Martin Willi [this message]
2021-04-20  9:35     ` Toke Høiland-Jørgensen
2021-04-22 21:30 ` patchwork-bot+netdevbpf

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=f14da35f8cfa4b8f888dadfe4c9ebcd031d8e870.camel@strongswan.org \
    --to=martin@strongswan.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=hawk@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=toke@redhat.com \
    /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).