From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AADB6C433B4 for ; Tue, 20 Apr 2021 05:15:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 54E7060FEE for ; Tue, 20 Apr 2021 05:15:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229593AbhDTFPd (ORCPT ); Tue, 20 Apr 2021 01:15:33 -0400 Received: from sitav-80046.hsr.ch ([152.96.80.46]:43264 "EHLO mail.strongswan.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbhDTFPd (ORCPT ); Tue, 20 Apr 2021 01:15:33 -0400 Received: from think.home (224.110.78.83.dynamic.wline.res.cust.swisscom.ch [83.78.110.224]) by mail.strongswan.org (Postfix) with ESMTPSA id EF823401B1; Tue, 20 Apr 2021 07:15:00 +0200 (CEST) Message-ID: Subject: Re: [PATCH net-next] net: xdp: Update pkt_type if generic XDP changes unicast MAC From: Martin Willi To: Toke =?ISO-8859-1?Q?H=F8iland-J=F8rgensen?= , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend Cc: netdev@vger.kernel.org, bpf@vger.kernel.org Date: Tue, 20 Apr 2021 07:15:00 +0200 In-Reply-To: <87tuo2gwbj.fsf@toke.dk> References: <20210419141559.8611-1-martin@strongswan.org> <87tuo2gwbj.fsf@toke.dk> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.4-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org 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