Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10467116rwr; Fri, 12 May 2023 08:29:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ70moC4Uj7LF3SlJP3dFqCTccPBebwosPqul8epcwtTHN7sKyYEbP2a63tr8JbGmF1aLyDi X-Received: by 2002:a05:6a20:9148:b0:103:bad9:1254 with SMTP id x8-20020a056a20914800b00103bad91254mr8889134pzc.6.1683905395996; Fri, 12 May 2023 08:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683905395; cv=none; d=google.com; s=arc-20160816; b=UyRMRyUBSp8hTzpfZcwrAg2GlCpL48EzSS2ox9dwY/n9nq5KuZa2Jay14mM0XeJd/1 LMNmmwyZcHGOSlfuz3gunX7xWsoOtdMS5lVSBmdlIxoWhBTWYj9duWtKrNeVelHowAEl cZvBQ5LEqJuemBkqwXhitF+4HqlGc1GprJjb5ioNLwExBXcpTJeCFW1ZDw7kz1JKTxNk es3fBSJO6iXOqV1olHqKujD/80cqO7fc5v8vZYJDvSr3I+kL8fynfZdLr5B0+bqy+Upj rISete4AMgfNJJCrfVcWM/kIr4j358k8qFBX6wAUKItpykJ+B7qa5mylZaZCt/p9qdJ0 xNFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tBkMpd78HeZFcevFDNwN3sMqXCL9g4VmVIh14jOC5hs=; b=GuymBuMNKT8VvSM6gjt5KcKpsO3fjadKU9c6sACPwhFGLiInGsHd8hb6MmnLteQO2G lcITzcVtrgi8y+4SD0N3NdZJhun80U3zYobkjtvkXj1uk4E/XJDjLnSaD6avh7KXMxQL khm3NBs5ZlJxq8hg2n4GY1fHnQ4BsvFsOB0bIZ4aDT7vRrWH0EMYZJTcPNRG7gHg4nK8 eTPngqX+mc51M+d/lEM4xLJdkg/wAIvUQYKzfdYy7NSW8GJZLX2t0kanDj5gIO8+XhUw 7KL5kE5fbWBJdE3lCxGC5tpFP13jfFFr1TifWAG3snhV61sL+0Qll8NFgCFBW9P4Oi2c uw3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=enKUeuui; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a28-20020a637f1c000000b005194eaa611csi9220641pgd.397.2023.05.12.08.29.43; Fri, 12 May 2023 08:29:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=enKUeuui; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241801AbjELPW2 (ORCPT + 99 others); Fri, 12 May 2023 11:22:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241805AbjELPWS (ORCPT ); Fri, 12 May 2023 11:22:18 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A55435A2; Fri, 12 May 2023 08:21:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683904908; x=1715440908; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ju9PvqXqCCJFMNbWyzPaBdJfLC40q1RU30A9+HNOEsU=; b=enKUeuuiDK1hPjeU2zcSqoZC/5/iT3dO5DjYWIPo6PasaJWrKAe0+6Gf pQrsUh4vqpc9z7hDPeH6ThxPvixYdMEp0q40wY3R7eSArrSy2ITK/XC6U EK/I1i6ySpKSk1YiRN1Vk4msl4wSW5pNYW1Rc53XY5fvFtGFrQ1c+C4Hv 60F824c10llV24swnoyOnBr91g3s25OJJRcewrB/E7oEk9XAAGXQSWNpS pC4hQxgZDFvjHJHi6iW7PdHBHifcYbjCO7LkLoBaNiTVVZvXN4R93Dq45 +efMJkoolG/Gorn6zEvhSVtFuokhOho+RWqRJUiV3Hhe7AKLwddBUYdSV w==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="353061253" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="353061253" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 08:20:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="812114587" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="812114587" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmsmga002.fm.intel.com with ESMTP; 12 May 2023 08:20:48 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id AC6653635B; Fri, 12 May 2023 16:20:43 +0100 (IST) From: Larysa Zaremba To: bpf@vger.kernel.org Cc: Larysa Zaremba , Stanislav Fomichev , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Jakub Kicinski , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Jiri Olsa , Jesse Brandeburg , Tony Nguyen , Anatoly Burakov , Jesper Dangaard Brouer , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/15] selftests/bpf: Allow VLAN packets in xdp_hw_metadata Date: Fri, 12 May 2023 17:16:37 +0200 Message-Id: <20230512151639.992033-14-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230512151639.992033-1-larysa.zaremba@intel.com> References: <20230512151639.992033-1-larysa.zaremba@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make VLAN c-tag and s-tag XDP hint testing more convenient by not skipping VLAN-ed packets. Allow both 802.1ad and 802.1Q headers. Signed-off-by: Larysa Zaremba --- tools/testing/selftests/bpf/progs/xdp_hw_metadata.c | 9 ++++++++- tools/testing/selftests/bpf/xdp_metadata.h | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c index b2dfd7066c6e..f95f82a8b449 100644 --- a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c +++ b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c @@ -26,15 +26,22 @@ int rx(struct xdp_md *ctx) { void *data, *data_meta, *data_end; struct ipv6hdr *ip6h = NULL; - struct ethhdr *eth = NULL; struct udphdr *udp = NULL; struct iphdr *iph = NULL; struct xdp_meta *meta; + struct ethhdr *eth; int err; data = (void *)(long)ctx->data; data_end = (void *)(long)ctx->data_end; eth = data; + + if (eth + 1 < data_end && eth->h_proto == bpf_htons(ETH_P_8021AD)) + eth = (void *)eth + sizeof(struct vlan_hdr); + + if (eth + 1 < data_end && eth->h_proto == bpf_htons(ETH_P_8021Q)) + eth = (void *)eth + sizeof(struct vlan_hdr); + if (eth + 1 < data_end) { if (eth->h_proto == bpf_htons(ETH_P_IP)) { iph = (void *)(eth + 1); diff --git a/tools/testing/selftests/bpf/xdp_metadata.h b/tools/testing/selftests/bpf/xdp_metadata.h index 938a729bd307..6664893c2c77 100644 --- a/tools/testing/selftests/bpf/xdp_metadata.h +++ b/tools/testing/selftests/bpf/xdp_metadata.h @@ -9,6 +9,14 @@ #define ETH_P_IPV6 0x86DD #endif +#ifndef ETH_P_8021Q +#define ETH_P_8021Q 0x8100 +#endif + +#ifndef ETH_P_8021AD +#define ETH_P_8021AD 0x88A8 +#endif + struct xdp_meta { __u64 rx_timestamp; __u64 xdp_timestamp; -- 2.35.3