From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by mail.toke.dk (Postfix) with ESMTPS id 16C3EA24BF2 for ; Thu, 24 Aug 2023 21:34:39 +0200 (CEST) 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=Og7GVNki DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692905680; x=1724441680; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bhCltMc6p9RLjAFsmeSC85cRm/N9MGOGrgAJApfZ+jw=; b=Og7GVNkipJh+AiyoBkxtW4ubhdj24bX25KLX/kiozs1knXnfSzpEdsIV 1kJqDOFILa19YT5SHIsYkSCoZLF5qpZjhvveKhh6msBQj1Aq1H7YnzPRt TZ8Oa1GCh/VFo4GLXLnWKcIz/SufDi/9QiIqTEMCEmRKXO70nigVjwLWw IIhucw07yOmSKJ6Rqmqa59cwrIEd2lwD0os8yzbs9P3sp7ck/bkOnC9WF gmZvLs6+U1q5MVB+3K/oe+i4Kcv3V7QMjNS9e08nEx+2E+5C5+XPYKXRl mOsMWqpEadEQ9rvwRThfpcaIb5ecmF4cP0H+oHLVqpeSFY+BQjuafVTR0 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10812"; a="354865500" X-IronPort-AV: E=Sophos;i="6.02,195,1688454000"; d="scan'208";a="354865500" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2023 12:34:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10812"; a="860830587" X-IronPort-AV: E=Sophos;i="6.02,195,1688454000"; d="scan'208";a="860830587" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orsmga004.jf.intel.com with ESMTP; 24 Aug 2023 12:34:33 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id D3C4234914; Thu, 24 Aug 2023 20:34:31 +0100 (IST) From: Larysa Zaremba To: bpf@vger.kernel.org Date: Thu, 24 Aug 2023 21:27:00 +0200 Message-ID: <20230824192703.712881-22-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824192703.712881-1-larysa.zaremba@intel.com> References: <20230824192703.712881-1-larysa.zaremba@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: N7I6B5L5QHYKEF72VQPDZB7Q3QHWU7XM X-Message-ID-Hash: N7I6B5L5QHYKEF72VQPDZB7Q3QHWU7XM 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 X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] [RFC bpf-next 21/23] 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. 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 f3db5cef4726..766477e0a31d 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, __u16 *vlan_tci, __be16 *vlan_proto) __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_tci, &meta->rx_vlan_proto); + /* 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