From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mail.toke.dk; spf=pass (mailfrom) smtp.mailfrom=intel.com (client-ip=134.134.136.126; helo=mgamail.intel.com; envelope-from=larysa.zaremba@intel.com; receiver=) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Oue1f4Y8 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by mail.toke.dk (Postfix) with ESMTPS id 619E1A2CC17 for ; Wed, 27 Sep 2023 09:58:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695801518; x=1727337518; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=98aXruLAnfEQAspYMrtw/rVlkZ9G+xCFR2+fsaU4zns=; b=Oue1f4Y825Smf2mjhsJcjJ0x/1TIoK0ooe489jpuMezd102nRk3FwJdo wlfu1XNqQjGlstrie0bOVOeCCN57DRUmnhwzWoo59aB2RuYDG/cRBn+1S XTl60wtDnZtMMothmxjUZwcQfPh5w8gbkF3wwn5ssQHPPBiEM0hADIY2z IVNfRJiR7nk+Il3QEUIGdXO5p1nC2+qPpPfw63oQryCIuMwZTv1s5K/dJ hokcmdQIA8O/knTj6csWw3xbZD24REwL8WKHK5CsjrKycmA52lZSmtlsS iI9TrlgqtJF/y8QvQAEl/uBXn9nkmP6h13j0nS2qZ2gb6Ub2N/0AhgKB1 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="366818263" X-IronPort-AV: E=Sophos;i="6.03,179,1694761200"; d="scan'208";a="366818263" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2023 00:58:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="725714098" X-IronPort-AV: E=Sophos;i="6.03,179,1694761200"; d="scan'208";a="725714098" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orsmga006.jf.intel.com with ESMTP; 27 Sep 2023 00:58:31 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id C0B9B7EAC1; Wed, 27 Sep 2023 08:58:29 +0100 (IST) From: Larysa Zaremba To: bpf@vger.kernel.org Date: Wed, 27 Sep 2023 09:51:22 +0200 Message-ID: <20230927075124.23941-23-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230927075124.23941-1-larysa.zaremba@intel.com> References: <20230927075124.23941-1-larysa.zaremba@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: RVFZHKMYADQTA2JZTHUULXJZ6IJUK2WR X-Message-ID-Hash: RVFZHKMYADQTA2JZTHUULXJZ6IJUK2WR X-MailFrom: larysa.zaremba@intel.com X-Mailman-Rule-Hits: member-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address CC: Larysa Zaremba , ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, David Ahern , Jakub Kicinski , Willem de Bruijn , Jesper Dangaard Brouer , Anatoly Burakov , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org, Willem de Bruijn , Alexei Starovoitov , Simon Horman , Tariq Toukan , Saeed Mahameed , Maciej Fijalkowski X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] [RFC bpf-next v2 22/24] selftests/bpf: check checksum state in xdp_metadata List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Verify, whether kfunc in xdp_metadata test correctly represent veth metadata state. Acked-by: Stanislav Fomichev Signed-off-by: Larysa Zaremba --- tools/testing/selftests/bpf/prog_tests/xdp_metadata.c | 3 +++ tools/testing/selftests/bpf/progs/xdp_metadata.c | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c index 61e1b073a4b2..aeb2701efba5 100644 --- a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c +++ b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c @@ -228,6 +228,9 @@ static int verify_xsk_metadata(struct xsk *xsk) if (!ASSERT_EQ(meta->rx_vlan_proto, VLAN_PID, "rx_vlan_proto")) return -1; + if (!ASSERT_EQ(meta->rx_csum_status, XDP_CHECKSUM_MAGIC, "rx_csum_status")) + return -1; + xsk_ring_cons__release(&xsk->rx, 1); refill_rx(xsk, comp_addr); diff --git a/tools/testing/selftests/bpf/progs/xdp_metadata.c b/tools/testing/selftests/bpf/progs/xdp_metadata.c index 2c6c46ef8502..e212b6835518 100644 --- a/tools/testing/selftests/bpf/progs/xdp_metadata.c +++ b/tools/testing/selftests/bpf/progs/xdp_metadata.c @@ -26,6 +26,9 @@ extern int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, __u32 *hash, extern int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx, __be16 *vlan_proto, __u16 *vlan_tci) __ksym; +extern int bpf_xdp_metadata_rx_csum(const struct xdp_md *ctx, + enum xdp_csum_status *csum_status, + __wsum *csum) __ksym; SEC("xdp") int rx(struct xdp_md *ctx) @@ -63,6 +66,14 @@ int rx(struct xdp_md *ctx) bpf_xdp_metadata_rx_vlan_tag(ctx, &meta->rx_vlan_proto, &meta->rx_vlan_tci); + /* This is supposed to fail on veth, so tell userspace + * everything is OK by passing a magic status. + */ + ret = bpf_xdp_metadata_rx_csum(ctx, &meta->rx_csum_status, + &meta->rx_csum); + if (ret) + meta->rx_csum_status = XDP_CHECKSUM_MAGIC; + return bpf_redirect_map(&xsk, ctx->rx_queue_index, XDP_PASS); } -- 2.41.0