From patchwork Wed Nov 22 18:20:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Xu X-Patchwork-Id: 168502 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1522779vqb; Wed, 22 Nov 2023 10:21:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IEmaTVd6JLzZT5U7qNAc0WjM35FPKJuBVfVPFFmU5SPzX0T1xM+uaTQ/iSDDhccXs+GVwqE X-Received: by 2002:a17:90b:4c0d:b0:280:e858:2fdf with SMTP id na13-20020a17090b4c0d00b00280e8582fdfmr3359726pjb.41.1700677302278; Wed, 22 Nov 2023 10:21:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700677302; cv=none; d=google.com; s=arc-20160816; b=AxqELmuVvGnnRgHuqCL1gvbGtL6WZKm9XM6WXwkaM6D5EKESBnhH51PIDUxuBKPtdA loz6sIQdF9jQx88lTc2rEYX5dCwcXpRAPri/bI5J/GBtnzjob9pCwCsQ9Jt4iwDenss6 Bcu2Gt4R+X7WoxB528gR/5LymJU6ZinRTDBCNKjgo1739YKftNDobc+vSewd1k0JsoX6 ldJ5w+9PTIQICd9vycP4BOYMVi8UrCuDi2UWEitgQY1xSNbY0cCq+8YjFYjZsyv4rZps F6gfzhvdmiTXov8lZsSUIoKB30G7wKM4qsX/5ytORubDzdweX8gNOvNvfeapLg69LDnT yelw== 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 :feedback-id:dkim-signature:dkim-signature; bh=yqAG0TxWayCfT0SshEmax5raPV3GZo8DBJH6hzfFuE0=; fh=//S8LPLGcZXP9QhmaZk0YUTszmgMFs6JeACLrFbLrB8=; b=RjVC2vN4YtI0oVf9AKKR6jxmrM4/TaSzXpYAz0tzKEWfuIBdtLQjsNCwSlo5gJNSry zGyYqvPh1Nvc8QcLY4XH2jkN6gV+siukGKuA3/w43peO51jM9laefTDcB0FvZtW71SDm iARMunUD1cScBTvP4t+5ZJqu5iZbXlta12T/zGk3Vo67TpkxDy5kqaqKNfwacp55BFta habWtjb9P0v6snTLGplTlsS5jbSy3c3b89Sci4u3OYmSuyo1ATsAYR97GxlBbMMamfZI FK2WdaBhXCnZyQqyeaqHxdoU/xjN/buzNRcHE4FOLMVVLLVpsfTuCXPDkP2lGuj/vqM2 9/+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=fwL2y6R4; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=w7WAza6a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id k3-20020a17090ad08300b0027717627cf6si151938pju.41.2023.11.22.10.21.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 10:21:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=fwL2y6R4; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=w7WAza6a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 05BCD8341C16; Wed, 22 Nov 2023 10:21:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234945AbjKVSVK (ORCPT + 99 others); Wed, 22 Nov 2023 13:21:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230510AbjKVSVJ (ORCPT ); Wed, 22 Nov 2023 13:21:09 -0500 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4467D101; Wed, 22 Nov 2023 10:21:02 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 5F0055C00AC; Wed, 22 Nov 2023 13:21:01 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 22 Nov 2023 13:21:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1700677261; x= 1700763661; bh=yqAG0TxWayCfT0SshEmax5raPV3GZo8DBJH6hzfFuE0=; b=f wL2y6R4tiqNfld/eFxqI76ByEaGVtEh6nzFGqmLhN4a47BRbUe9JRcNxXRJOoOpk MgobS5Iv1PQGYVoGZykzcsHTrJiZXvMMEodsxBBT2aLSlG1HkvqEAu5GHDvtE5Hn 9VsxmYqKTISsKoXzT4YzbDA1dgLgLZ8IkLxRWIcm1arO5yLIPnfsEyNdPPAlNg71 R/z4ZeV5eoeUBLuJoRWlgfmFZvTHnQPWRJ1Tj/Wf51Bk7U+Wi30/OcpCBznA39i2 Q2Zuk/Y+NAXKngbchASUwuRku832p5Alc63l9WwvSCp4424y1/JV5IBheC0oR39G l6Te7YXZR3rA1IBvXr9fw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1700677261; x= 1700763661; bh=yqAG0TxWayCfT0SshEmax5raPV3GZo8DBJH6hzfFuE0=; b=w 7WAza6aQgzaGkgn4zmpYYDxSFjrrjqT5RiF2kSB30LWRQXtEzz25Uz+HttpclnSS 3NJxtU6ZuJtNYNUjbuiLrPUTNhNg4wFxJWeMfV6RzL9RPSsX8hkGHbqLhL8PHsFi 6Hqtcek2V+G9sTvW1OjDGVhSAmiDag9lQUwP1hzv2ERq9DoJJxROoSlIZ5rJ0/pN JR0+taUUvRFSbG3PqTdh3vBXyoRFLk6/5WjHArXobGyFbmOiz6enwGywQkZafDrd /LvzShDpncIq97j+NLRQUL73jWKDX6NIrFQxdetA2NO5LOv5UAPBzEh/SmsY3GvV CvgSEAGaibX2UaYvFGy7w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehuddguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enfghrlhcuvffnffculdefhedmnecujfgurhephffvvefufffkofgjfhgggfestdekredt redttdenucfhrhhomhepffgrnhhivghlucgiuhcuoegugihusegugihuuhhurdighiiiqe enucggtffrrghtthgvrhhnpefgfefggeejhfduieekvdeuteffleeifeeuvdfhheejleej jeekgfffgefhtddtteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpegugihusegugihuuhhurdighiii X-ME-Proxy: Feedback-ID: i6a694271:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Nov 2023 13:20:59 -0500 (EST) From: Daniel Xu To: john.fastabend@gmail.com, Herbert Xu , davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, pabeni@redhat.com, hawk@kernel.org, kuba@kernel.org, edumazet@google.com, steffen.klassert@secunet.com, antony.antony@secunet.com, alexei.starovoitov@gmail.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, devel@linux-ipsec.org Subject: [PATCH ipsec-next v1 1/7] bpf: xfrm: Add bpf_xdp_get_xfrm_state() kfunc Date: Wed, 22 Nov 2023 11:20:22 -0700 Message-ID: <2443b6093691c7ae9dace98b0257f61ff2ff30ec.1700676682.git.dxu@dxuuu.xyz> X-Mailer: git-send-email 2.42.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 22 Nov 2023 10:21:22 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783289402399453087 X-GMAIL-MSGID: 1783289402399453087 This commit adds an unstable kfunc helper to access internal xfrm_state associated with an SA. This is intended to be used for the upcoming IPsec pcpu work to assign special pcpu SAs to a particular CPU. In other words: for custom software RSS. That being said, the function that this kfunc wraps is fairly generic and used for a lot of xfrm tasks. I'm sure people will find uses elsewhere over time. Co-developed-by: Antony Antony Signed-off-by: Antony Antony Signed-off-by: Daniel Xu --- include/net/xfrm.h | 9 ++++ net/xfrm/Makefile | 1 + net/xfrm/xfrm_policy.c | 2 + net/xfrm/xfrm_state_bpf.c | 111 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 123 insertions(+) create mode 100644 net/xfrm/xfrm_state_bpf.c diff --git a/include/net/xfrm.h b/include/net/xfrm.h index c9bb0f892f55..1d107241b901 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -2190,4 +2190,13 @@ static inline int register_xfrm_interface_bpf(void) #endif +#if IS_ENABLED(CONFIG_DEBUG_INFO_BTF) +int register_xfrm_state_bpf(void); +#else +static inline int register_xfrm_state_bpf(void) +{ + return 0; +} +#endif + #endif /* _NET_XFRM_H */ diff --git a/net/xfrm/Makefile b/net/xfrm/Makefile index cd47f88921f5..547cec77ba03 100644 --- a/net/xfrm/Makefile +++ b/net/xfrm/Makefile @@ -21,3 +21,4 @@ obj-$(CONFIG_XFRM_USER_COMPAT) += xfrm_compat.o obj-$(CONFIG_XFRM_IPCOMP) += xfrm_ipcomp.o obj-$(CONFIG_XFRM_INTERFACE) += xfrm_interface.o obj-$(CONFIG_XFRM_ESPINTCP) += espintcp.o +obj-$(CONFIG_DEBUG_INFO_BTF) += xfrm_state_bpf.o diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index c13dc3ef7910..1b7e75159727 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -4218,6 +4218,8 @@ void __init xfrm_init(void) #ifdef CONFIG_XFRM_ESPINTCP espintcp_init(); #endif + + register_xfrm_state_bpf(); } #ifdef CONFIG_AUDITSYSCALL diff --git a/net/xfrm/xfrm_state_bpf.c b/net/xfrm/xfrm_state_bpf.c new file mode 100644 index 000000000000..0c1f2f91125c --- /dev/null +++ b/net/xfrm/xfrm_state_bpf.c @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Unstable XFRM state BPF helpers. + * + * Note that it is allowed to break compatibility for these functions since the + * interface they are exposed through to BPF programs is explicitly unstable. + */ + +#include +#include +#include +#include + +/* bpf_xfrm_state_opts - Options for XFRM state lookup helpers + * + * Members: + * @error - Out parameter, set for any errors encountered + * Values: + * -EINVAL - netns_id is less than -1 + * -EINVAL - Passed NULL for opts + * -EINVAL - opts__sz isn't BPF_XFRM_STATE_OPTS_SZ + * -ENONET - No network namespace found for netns_id + * @netns_id - Specify the network namespace for lookup + * Values: + * BPF_F_CURRENT_NETNS (-1) + * Use namespace associated with ctx + * [0, S32_MAX] + * Network Namespace ID + * @mark - XFRM mark to match on + * @daddr - Destination address to match on + * @spi - Security parameter index to match on + * @proto - L3 protocol to match on + * @family - L3 protocol family to match on + */ +struct bpf_xfrm_state_opts { + s32 error; + s32 netns_id; + u32 mark; + xfrm_address_t daddr; + __be32 spi; + u8 proto; + u16 family; +}; + +enum { + BPF_XFRM_STATE_OPTS_SZ = sizeof(struct bpf_xfrm_state_opts), +}; + +__diag_push(); +__diag_ignore_all("-Wmissing-prototypes", + "Global functions as their definitions will be in xfrm_state BTF"); + +/* bpf_xdp_get_xfrm_state - Get XFRM state + * + * Parameters: + * @ctx - Pointer to ctx (xdp_md) in XDP program + * Cannot be NULL + * @opts - Options for lookup (documented above) + * Cannot be NULL + * @opts__sz - Length of the bpf_xfrm_state_opts structure + * Must be BPF_XFRM_STATE_OPTS_SZ + */ +__bpf_kfunc struct xfrm_state * +bpf_xdp_get_xfrm_state(struct xdp_md *ctx, struct bpf_xfrm_state_opts *opts, u32 opts__sz) +{ + struct xdp_buff *xdp = (struct xdp_buff *)ctx; + struct net *net = dev_net(xdp->rxq->dev); + struct xfrm_state *x; + + if (!opts || opts__sz != BPF_XFRM_STATE_OPTS_SZ) { + opts->error = -EINVAL; + return NULL; + } + + if (unlikely(opts->netns_id < BPF_F_CURRENT_NETNS)) { + opts->error = -EINVAL; + return NULL; + } + + if (opts->netns_id >= 0) { + net = get_net_ns_by_id(net, opts->netns_id); + if (unlikely(!net)) { + opts->error = -ENONET; + return NULL; + } + } + + x = xfrm_state_lookup(net, opts->mark, &opts->daddr, opts->spi, + opts->proto, opts->family); + + if (opts->netns_id >= 0) + put_net(net); + + return x; +} + +__diag_pop() + +BTF_SET8_START(xfrm_state_kfunc_set) +BTF_ID_FLAGS(func, bpf_xdp_get_xfrm_state, KF_RET_NULL | KF_ACQUIRE) +BTF_SET8_END(xfrm_state_kfunc_set) + +static const struct btf_kfunc_id_set xfrm_state_xdp_kfunc_set = { + .owner = THIS_MODULE, + .set = &xfrm_state_kfunc_set, +}; + +int __init register_xfrm_state_bpf(void) +{ + return register_btf_kfunc_id_set(BPF_PROG_TYPE_XDP, + &xfrm_state_xdp_kfunc_set); +} From patchwork Wed Nov 22 18:20:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Xu X-Patchwork-Id: 168507 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1523882vqb; Wed, 22 Nov 2023 10:23:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRhpuYJsntQUNnz+StIESxuWzmZIsAINysXMU7znuUOvLpDu3btHLrJPVMsRJQJekWAfEc X-Received: by 2002:a05:6a21:198:b0:188:28b:86e5 with SMTP id le24-20020a056a21019800b00188028b86e5mr3651405pzb.10.1700677419313; Wed, 22 Nov 2023 10:23:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700677419; cv=none; d=google.com; s=arc-20160816; b=tUWEvI7yzoR7D058IIzgo/F7l8kJZ0OQkAWVr+jAhibeTQI7n0Su0n25RGw02gkQc8 by72/wpbUM+QOv7u6WaauVJsOh8WTYSdJgMcM1+QgEk0zSw8JqW1ZBCprUbpnIZckhYW f7pqB3mHpdYiC/jk7hYJoiSRtpLKcifRCEp+dnyaE9rRJHOs7Xj1yGFjhSFSUUOJuJIA O58wDU4iBGxDFsZZe9PeGy6L12I1o8sqgWpRtvM/wuOnxmKxRZX3B9nvQDWdN53FolNW q5NC6D8b5nc0YWjTsX76GggBuIIspiOev0pSyvRhlajezhJTMOq65E4DYbLGNj46eR3+ Q+TA== 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 :feedback-id:dkim-signature:dkim-signature; bh=1dQDEOh8HTBoY0VDz9uX6NM7X39IZ5Fcq3iL98Lsjko=; fh=TaXR4wp7/UDjyzuk+aBQf/CuCi5lRAU9dT0mcEyVE8I=; b=X1aDNN2KORh82P/g2542AEqMB6bhgW7J1zNi/AFqpo9sdV93VqJWXM9ob/sIrzbr4O jMqL/Ekz/RBDjmtCPgTSQjF/cLqfuC/+GDtihgjvOQ4aB1oG7VON3e943z/GYNMcAUAa YqTuIa0Ra+FTK+TaYr1xTyVnax2dSe7LKa2tf2D4/CsMHGfSa7tPH7PLGnNxS6YgmoDH h5JxBPkjZjLFFtQlGLDCjkarYvyfoTx1SiB02sBoJlLejJuYoKMXkg+NkZ0mkahFkmGk 0jOdErKUboQ2HsHjOa6PqvQvpqHkc+kyfpyoTjUJ4A2feS7lNic88HOja04U+SS5tTgV 8Tlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=WbEIaFB5; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=1Q9Mov8Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id 196-20020a6301cd000000b00589fcc39ef1si13142163pgb.365.2023.11.22.10.23.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 10:23:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=WbEIaFB5; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=1Q9Mov8Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0909C809639C; Wed, 22 Nov 2023 10:21:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344163AbjKVSVU (ORCPT + 99 others); Wed, 22 Nov 2023 13:21:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232178AbjKVSVJ (ORCPT ); Wed, 22 Nov 2023 13:21:09 -0500 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6133D1AB; Wed, 22 Nov 2023 10:21:03 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id CD3C35C0150; Wed, 22 Nov 2023 13:21:02 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 22 Nov 2023 13:21:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1700677262; x= 1700763662; bh=1dQDEOh8HTBoY0VDz9uX6NM7X39IZ5Fcq3iL98Lsjko=; b=W bEIaFB5RMblwglobGDqjQZJgQNdzxHC4uLbYHHPbbwYVAtJBNI4xSjlJ7Oa4Es8X yjPYJG1S+qdaoJ0dQYpv5Bm00UC5sIrDgjPDHHYuYu8QDIG1iekzscBLDMalXrWZ RdPFItbBo6F663rAnwSpYP1BA10Z6LvW0DCx0m0HTuvFNthGazCNjzAO7V9jmgjv 6z76wOQp9Qyjz0xhTQX8Yw02n5GitAninYKeLBqR7t+Js+DN3HlW8QvA+N/89Mbg U4NakqMumSFfRj85vpAW06FnNGR8A2q/J45N25LE7dhweaFElnDeiDkGPtFEaPbz Ln4SMq6BGuV+kCRGf4jbg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1700677262; x= 1700763662; bh=1dQDEOh8HTBoY0VDz9uX6NM7X39IZ5Fcq3iL98Lsjko=; b=1 Q9Mov8YxcEZsHKUjAR6PUL+qQNc0RYCYLfSsjgRJ5k79mgnV/e3oepx7n2D5i03b fjwUlNn+SJ4NSyTWfD2Glp9QOO7w2R39fB82PLA2uVM9/Ed+utYKoHv1MYhGX2pD cs/TBJilUT3ff3n0Fne8wQsA0UKaSAPLYfIUaqCWL0lStm/+moh2gLxnhRxJydVM tKa7WksFokIyt9mBVXk0GLuHrR1EqeXh7Z/vlQ+JwlLnPjxHvFZA28lnqgZAQR/p wTL8KAQzCpYF2g0VD9ahWaQxuUAq/47GUz8XZWL6C56RuqLATv3icnoPEE6TUhUG PBVgeaNzzR7dnqKQkrSeA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehuddguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enfghrlhcuvffnffculdefhedmnecujfgurhephffvvefufffkofgjfhgggfestdekredt redttdenucfhrhhomhepffgrnhhivghlucgiuhcuoegugihusegugihuuhhurdighiiiqe enucggtffrrghtthgvrhhnpefgfefggeejhfduieekvdeuteffleeifeeuvdfhheejleej jeekgfffgefhtddtteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpegugihusegugihuuhhurdighiii X-ME-Proxy: Feedback-ID: i6a694271:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Nov 2023 13:21:01 -0500 (EST) From: Daniel Xu To: john.fastabend@gmail.com, Herbert Xu , davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, pabeni@redhat.com, hawk@kernel.org, kuba@kernel.org, edumazet@google.com, steffen.klassert@secunet.com, antony.antony@secunet.com, alexei.starovoitov@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devel@linux-ipsec.org Subject: [PATCH ipsec-next v1 2/7] bpf: xfrm: Add bpf_xdp_xfrm_state_release() kfunc Date: Wed, 22 Nov 2023 11:20:23 -0700 Message-ID: X-Mailer: git-send-email 2.42.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 22 Nov 2023 10:21:29 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783289525578855027 X-GMAIL-MSGID: 1783289525578855027 This kfunc releases a previously acquired xfrm_state from bpf_xdp_get_xfrm_state(). Co-developed-by: Antony Antony Signed-off-by: Antony Antony Signed-off-by: Daniel Xu --- net/xfrm/xfrm_state_bpf.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/xfrm/xfrm_state_bpf.c b/net/xfrm/xfrm_state_bpf.c index 0c1f2f91125c..33d1b00fedbd 100644 --- a/net/xfrm/xfrm_state_bpf.c +++ b/net/xfrm/xfrm_state_bpf.c @@ -93,10 +93,26 @@ bpf_xdp_get_xfrm_state(struct xdp_md *ctx, struct bpf_xfrm_state_opts *opts, u32 return x; } +/* bpf_xdp_xfrm_state_release - Release acquired xfrm_state object + * + * This must be invoked for referenced PTR_TO_BTF_ID, and the verifier rejects + * the program if any references remain in the program in all of the explored + * states. + * + * Parameters: + * @x - Pointer to referenced xfrm_state object, obtained using + * bpf_xdp_get_xfrm_state. + */ +__bpf_kfunc void bpf_xdp_xfrm_state_release(struct xfrm_state *x) +{ + xfrm_state_put(x); +} + __diag_pop() BTF_SET8_START(xfrm_state_kfunc_set) BTF_ID_FLAGS(func, bpf_xdp_get_xfrm_state, KF_RET_NULL | KF_ACQUIRE) +BTF_ID_FLAGS(func, bpf_xdp_xfrm_state_release, KF_RELEASE) BTF_SET8_END(xfrm_state_kfunc_set) static const struct btf_kfunc_id_set xfrm_state_xdp_kfunc_set = { From patchwork Wed Nov 22 18:20:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Xu X-Patchwork-Id: 168503 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1523320vqb; Wed, 22 Nov 2023 10:22:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFScVt2kpilGgz576r6d1s3gur1OxZxR6yZh9kIWcfudrb271+wIFGMMF79IUAh0L+FoPAC X-Received: by 2002:a05:6a20:9187:b0:187:3b1f:219c with SMTP id v7-20020a056a20918700b001873b1f219cmr3310712pzd.10.1700677357546; Wed, 22 Nov 2023 10:22:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700677357; cv=none; d=google.com; s=arc-20160816; b=ZxRRWSBnaM8109M11UO5pxGr4SoNwuks+Z+r40NgCM2OT4akmzkSq3OvGeko4HDLhy HUaGUP8wc4vdOpN2YtZz3cuLj0RAxK84MLLZJsGumggg6/G2dsHIi5DVU2tSA+MRmRGM e6TX3wRGFUKQ+radDlYIBNcKZxMvt/wo6hak98c4ql6cmufSSzRMQ3PCTlu1cuZnMfGX JeTSYYdp0/cmPBuo3jw4YXGap/MPRYVzopasDS6OP6ff83mkvGLMXynuKSKSbD1eRznR /pFvUREj20HWYgFTFFhU0R7/2dIQniepzUxZ9tWa0eiK2ZN7o8l7+XTS+Tb77M9BuJRw HrXw== 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 :feedback-id:dkim-signature:dkim-signature; bh=pAXMuw36t4A5a6iy5D+iXmBn9GlBmIUIyg5Iqf95p7I=; fh=p6/jJmH8ymaPPPkPkGCoAO+quO2RGUs+oNx5YU3+VPA=; b=RdXaVi0GGLTJsOWXYPVes74IuSVCRv/NyxGFwx92UluMdrtRhX1AxPlRuzh2dHs1bW L2/ZSGfmc55Fy1iDT2HAlqrsKtKdeSiRl1PJuSxapwGarCFwgGxZ0Vw3kG5ln06LwHf4 X/pJKExlpBdpeIz7Bq3Fnh1tmNbEdh+D1HB0m0c+U/iegF2RNJvRuY3aD1zWymMywWqn 3C7qrv8snJ43vzY82ZB6/WtQCMx4UBpshhzbcY/hgrcf1d2A+Pc4krdmUZ/AZTrk3Ieg sMS1wIM0KLpiPEhV/X57uZVIW14yaytjlnzemL5FEezkhxT4vAZK0UivCFsnUUfYsBrk oPRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=fWMKENtY; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="BOUl/rwQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id c16-20020aa79530000000b006cba621ba41si63264pfp.80.2023.11.22.10.22.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 10:22:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=fWMKENtY; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="BOUl/rwQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0A73081B5AA5; Wed, 22 Nov 2023 10:21:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235123AbjKVSVR (ORCPT + 99 others); Wed, 22 Nov 2023 13:21:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231744AbjKVSVJ (ORCPT ); Wed, 22 Nov 2023 13:21:09 -0500 Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DBF41B9; Wed, 22 Nov 2023 10:21:05 -0800 (PST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 87DA158034F; Wed, 22 Nov 2023 13:21:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 22 Nov 2023 13:21:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1700677264; x= 1700684464; bh=pAXMuw36t4A5a6iy5D+iXmBn9GlBmIUIyg5Iqf95p7I=; b=f WMKENtYhXbTeI2PbKCiatC9Tzw91bHej/Dcc5zPpOUTJtwujIzZI38FTSVynRHQZ wvSlgXN1cWJK5vFYohWU0Xd8HGsILYeCsSqYRy0NSjxMjNdQMOYa5RWuzV9wfVsD /diMeZLGKhEv+DFyd+mK4Jcj2k4fpWAx8as99zf9FXISiWle+0zufWAxK/h4rjhM A2O6S/Q+yrmX7wtzx+qb6i3CM8nmIQaQYG8H+XU3BkzlCGWdjpTCC5qay8qBYgh/ O3XP9z1N8e0dKGYe2iutqH46kRpKr9wgIe8VMNPGbjOzaWl5kjrphEhpa/92BVTs DVFfgqFUU761A6veKvLRA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1700677264; x= 1700684464; bh=pAXMuw36t4A5a6iy5D+iXmBn9GlBmIUIyg5Iqf95p7I=; b=B OUl/rwQ71o6LTPAGfnbdb7yt2tzHLcVY+feh/mbDVlTzinAGZO14hjxHEf2whgGb Jjv70ovgUvzyuHgb3Afo/67RlSm+riohjlSdhF0VCyxTSv8u4E0FZJkmK2rr0muD bEX8ab1Wig+Vf9N0/3mgJFqcqAMkLQxPvsoEH8DBwTKbLfS4jsrekfkP7/v39GfS l+VfqI3TjRluZhcPai1iaw69lMiX0OJTsumNqcrqb2/7evD5Jppi0zRCZq52G5Sl qcTtA+v3y2hwCM45LIdLBSxavaxSkeRmVs25/zFAluABAdTeDaM35lrnRQHqAZIF IO9e2RLzIy9npIcb/Jd7w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehuddguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdefhedmnecujfgurhephf fvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepffgrnhhivghlucgiuhcu oegugihusegugihuuhhurdighiiiqeenucggtffrrghtthgvrhhnpeevtdekjeffkefgfe fhvefffeetgfeuueeutdetjeduudehheeiffdvgefhhfevhfenucffohhmrghinhepghhi thhhuhgsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepugiguhesugiguhhuuhdrgiihii X-ME-Proxy: Feedback-ID: i6a694271:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Nov 2023 13:21:02 -0500 (EST) From: Daniel Xu To: shuah@kernel.org, daniel@iogearbox.net, andrii@kernel.org, ast@kernel.org, steffen.klassert@secunet.com, antony.antony@secunet.com, alexei.starovoitov@gmail.com Cc: mykolal@fb.com, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, devel@linux-ipsec.org, netdev@vger.kernel.org Subject: [PATCH ipsec-next v1 3/7] bpf: selftests: test_tunnel: Use ping -6 over ping6 Date: Wed, 22 Nov 2023 11:20:24 -0700 Message-ID: <4c6de574f5de959ca5af77f4463e119186ac3202.1700676682.git.dxu@dxuuu.xyz> X-Mailer: git-send-email 2.42.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 22 Nov 2023 10:21:22 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783289460485321237 X-GMAIL-MSGID: 1783289460485321237 The ping6 binary went away over 7 years ago [0]. [0]: https://github.com/iputils/iputils/commit/ebad35fee3de851b809c7b72ccc654a72b6af61d Co-developed-by: Antony Antony Signed-off-by: Antony Antony Signed-off-by: Daniel Xu --- tools/testing/selftests/bpf/test_tunnel.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/bpf/test_tunnel.sh b/tools/testing/selftests/bpf/test_tunnel.sh index 2dec7dbf29a2..85ba39992461 100755 --- a/tools/testing/selftests/bpf/test_tunnel.sh +++ b/tools/testing/selftests/bpf/test_tunnel.sh @@ -295,13 +295,13 @@ test_ip6gre() add_ip6gretap_tunnel attach_bpf $DEV ip6gretap_set_tunnel ip6gretap_get_tunnel # underlay - ping6 $PING_ARG ::11 + ping -6 $PING_ARG ::11 # overlay: ipv4 over ipv6 ip netns exec at_ns0 ping $PING_ARG 10.1.1.200 ping $PING_ARG 10.1.1.100 check_err $? # overlay: ipv6 over ipv6 - ip netns exec at_ns0 ping6 $PING_ARG fc80::200 + ip netns exec at_ns0 ping -6 $PING_ARG fc80::200 check_err $? cleanup @@ -324,13 +324,13 @@ test_ip6gretap() add_ip6gretap_tunnel attach_bpf $DEV ip6gretap_set_tunnel ip6gretap_get_tunnel # underlay - ping6 $PING_ARG ::11 + ping -6 $PING_ARG ::11 # overlay: ipv4 over ipv6 ip netns exec at_ns0 ping $PING_ARG 10.1.1.200 ping $PING_ARG 10.1.1.100 check_err $? # overlay: ipv6 over ipv6 - ip netns exec at_ns0 ping6 $PING_ARG fc80::200 + ip netns exec at_ns0 ping -6 $PING_ARG fc80::200 check_err $? cleanup @@ -376,7 +376,7 @@ test_ip6erspan() config_device add_ip6erspan_tunnel $1 attach_bpf $DEV ip4ip6erspan_set_tunnel ip4ip6erspan_get_tunnel - ping6 $PING_ARG ::11 + ping -6 $PING_ARG ::11 ip netns exec at_ns0 ping $PING_ARG 10.1.1.200 check_err $? cleanup @@ -474,7 +474,7 @@ test_ipip6() ip link set dev veth1 mtu 1500 attach_bpf $DEV ipip6_set_tunnel ipip6_get_tunnel # underlay - ping6 $PING_ARG ::11 + ping -6 $PING_ARG ::11 # ip4 over ip6 ping $PING_ARG 10.1.1.100 check_err $? @@ -502,11 +502,11 @@ test_ip6ip6() ip link set dev veth1 mtu 1500 attach_bpf $DEV ip6ip6_set_tunnel ip6ip6_get_tunnel # underlay - ping6 $PING_ARG ::11 + ping -6 $PING_ARG ::11 # ip6 over ip6 - ping6 $PING_ARG 1::11 + ping -6 $PING_ARG 1::11 check_err $? - ip netns exec at_ns0 ping6 $PING_ARG 1::22 + ip netns exec at_ns0 ping -6 $PING_ARG 1::22 check_err $? cleanup From patchwork Wed Nov 22 18:20:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Xu X-Patchwork-Id: 168505 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1523466vqb; Wed, 22 Nov 2023 10:22:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3uFTKgxlbHcWMQC9L2DvN0QTDxIhTOf4oXvDLbeKBI56EEivnGytFpY9RQHn+iZEDT4Tz X-Received: by 2002:a17:902:e5c3:b0:1cf:7ce5:e6e8 with SMTP id u3-20020a170902e5c300b001cf7ce5e6e8mr1774116plf.12.1700677371079; Wed, 22 Nov 2023 10:22:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700677371; cv=none; d=google.com; s=arc-20160816; b=XpKmRdGZV/n6xshCx7VAEbbtxZEIhbKM4l96BHnUVI5+lWE8FXfxfAl8BJT255C6BN /R2fMIsw0XhXLq8UA61MF9+aOiaVLEd4bdtVKMxtAcfQV8EwW0jrhQEcTCGDy5HaDxN5 V2ihTcocz/KRZqYYGt2OfEIgZ6SAhHbud0Y/gD6nquhUq60iIjJutjbw/ALPlDUSib4X 47iQkctXsqOcrxrNBqzJug6fJKn26aBYr4PUWDA67+dWFXHXR51Y3tXVKqIbJPJtVT4J 99BorfM1rFZyRDA6ejj4vZQOJBC0M0+jqB89HYSx3RxS7q0Xzllq8pq02HmLThYBCeKX v0Qw== 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 :feedback-id:dkim-signature:dkim-signature; bh=JJhVdczU7V+MRWD9pKXDtWWzYuthdE42AK0YbBKT7ow=; fh=bSe5cdEN+P+2fvCtPCosCUnajpPrbPpqatKpSlJy86A=; b=IFTux6ZikfYsnxeWxxKWYS1doRp09wRYBZ08BeF64VKOP+aN44is+s9NKl1VMn9Gou KZod7gJ2O8FiDTQRL1nmZrptYKglOhZDckA9BCB+iMqGRExKPhA+K9BhMmjhHZC8BIql Q/aBF3X6SUT8bchgDZsS34rkmMaffEGPdKdu2gwtZk3jhsFYp2fIc35DKjJGS0b8YIFa 04wNXD6J3VW25Oj28FGEg7HXliruN/2PjoOcL2SUe4fp/k/fLMwap6Hn3/FSEjjYYfnQ eNKifAjKfNdOvco2WUlt9N41rjyz6kvuw8kzFFYWrwfVIEA8HYU10xAyP6W9eTc9nmqy XwFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=dF50PVdg; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="OF/BwjXR"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bj12-20020a170902850c00b001cc3473657bsi12386879plb.215.2023.11.22.10.22.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 10:22:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=dF50PVdg; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="OF/BwjXR"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8258F81EB0C8; Wed, 22 Nov 2023 10:22:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344178AbjKVSVX (ORCPT + 99 others); Wed, 22 Nov 2023 13:21:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232380AbjKVSVK (ORCPT ); Wed, 22 Nov 2023 13:21:10 -0500 Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04E201B3; Wed, 22 Nov 2023 10:21:06 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 4FDFA580452; Wed, 22 Nov 2023 13:21:06 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 22 Nov 2023 13:21:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1700677266; x= 1700684466; bh=JJhVdczU7V+MRWD9pKXDtWWzYuthdE42AK0YbBKT7ow=; b=d F50PVdgUTy+lowMWaJEiGE3zPZujRZVyTjo9FyOYpxRymzz4dCbUUyRQnC+9ixPu Ae5cUXNfOseMZ8hVjTJNbpYTPWlFFxD9u+4V4lYmGxwdJogtnVogAqxN+I6Yr3L0 nbCusAT9W91OPwOkF2WNX37MmDWweQrljYEajhG220IW9l/pc3/D2hFuhbryFXi3 F/e77zoKzP9ENJzVOYeaeqf+D1RvLLQ4ATfqvXCnen++OvLFZSAPlHsmLlDxBqlv nFCsZ8BYEVgCiNCUZqj3WccxcQ5oayYjE36dlYcvlluZtj3d9OAp0byVVDRDtdJX Rs7r8KHChg32URIzIFFSA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1700677266; x= 1700684466; bh=JJhVdczU7V+MRWD9pKXDtWWzYuthdE42AK0YbBKT7ow=; b=O F/BwjXRZNdD+dOpCFVX0WjjU5Ya1eFqTyNpSal68q2Ksaq3CaRLdnhqcUwLbkkk8 KdiKQSO0YHLJt/IR1HsTjPQDUCac9D8wR+eP2WoMR2f7Pvmx5xHhYU8wDKzl40v6 vGNnUb8Pg1kzowjwpikMTz2R4llSCYlHFL8D5dkxQTKNRoF7DNEDlI77Ce2Qw684 upgjQI9uMGukASuzT5p4xHY1+TNN73IiAfPQ9qCbW9nEraK8WA2ukqcmeX2J3c3K J0Aq+qKVPBGr5Goo4gMn9H4Wou9TN3kEBxY5So4WQMuelPVMvFzFX3643h49LSfg c97guHywmX8hpDuznn/7A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehuddguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdefhedmnecujfgurhephf fvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepffgrnhhivghlucgiuhcu oegugihusegugihuuhhurdighiiiqeenucggtffrrghtthgvrhhnpefgfefggeejhfduie ekvdeuteffleeifeeuvdfhheejleejjeekgfffgefhtddtteenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegugihusegugihuuhhurdighiii X-ME-Proxy: Feedback-ID: i6a694271:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Nov 2023 13:21:04 -0500 (EST) From: Daniel Xu To: shuah@kernel.org, daniel@iogearbox.net, andrii@kernel.org, ast@kernel.org, steffen.klassert@secunet.com, antony.antony@secunet.com, alexei.starovoitov@gmail.com Cc: martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, mykolal@fb.com, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, devel@linux-ipsec.org, netdev@vger.kernel.org Subject: [PATCH ipsec-next v1 4/7] bpf: selftests: test_tunnel: Mount bpffs if necessary Date: Wed, 22 Nov 2023 11:20:25 -0700 Message-ID: X-Mailer: git-send-email 2.42.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 22 Nov 2023 10:22:08 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783289475140724777 X-GMAIL-MSGID: 1783289475140724777 Previously, if bpffs was not already mounted, then the test suite would fail during object file pinning steps. Fix by mounting bpffs if necessary. Co-developed-by: Antony Antony Signed-off-by: Antony Antony Signed-off-by: Daniel Xu --- tools/testing/selftests/bpf/test_tunnel.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_tunnel.sh b/tools/testing/selftests/bpf/test_tunnel.sh index 85ba39992461..dd3c79129e87 100755 --- a/tools/testing/selftests/bpf/test_tunnel.sh +++ b/tools/testing/selftests/bpf/test_tunnel.sh @@ -46,7 +46,8 @@ # 6) Forward the packet to the overlay tnl dev BPF_FILE="test_tunnel_kern.bpf.o" -BPF_PIN_TUNNEL_DIR="/sys/fs/bpf/tc/tunnel" +BPF_FS="/sys/fs/bpf" +BPF_PIN_TUNNEL_DIR="${BPF_FS}/tc/tunnel" PING_ARG="-c 3 -w 10 -q" ret=0 GREEN='\033[0;92m' @@ -668,10 +669,20 @@ check_err() fi } +mount_bpffs() +{ + if ! mount | grep "bpf on /sys/fs/bpf" &>/dev/null; then + mount -t bpf bpf "$BPF_FS" + fi +} + bpf_tunnel_test() { local errors=0 + echo "Mounting bpffs..." + mount_bpffs + echo "Testing GRE tunnel..." test_gre errors=$(( $errors + $? )) From patchwork Wed Nov 22 18:20:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Xu X-Patchwork-Id: 168504 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1523382vqb; Wed, 22 Nov 2023 10:22:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhjEpS/WqfT9BjCva2LYuKyKODPOZT2EXA616fuqTF+6Za0w648qbEE+bk47SwiDtL+ewI X-Received: by 2002:a17:902:830a:b0:1c5:befa:d81d with SMTP id bd10-20020a170902830a00b001c5befad81dmr2883525plb.10.1700677363290; Wed, 22 Nov 2023 10:22:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700677363; cv=none; d=google.com; s=arc-20160816; b=asHdcicQ4LnZQL2CbP/NEIvHS7yzc5EQznGKaP4lq+AXrOjTYy79yAPBZAiKNx181N bzMECZVhGzdEvPdcD5jPcrYSZx5DC8xkSBOXEKxNM7M91tNIQO6gI21hzj4hwXYuLjDC gHEOBe+eSvubcOPOBUfcu0K2SgHOrggBZu+Juv4hrpvOwkomFCd80HTRhTVpMcHs67bm TNTek6qKxTsat5BYcfJP1gSDm//5zapCkZlRT4jD9gvHIGUVtS/0IcNoweVdyaFNMEQd pcfu59Ws+FVO+I5sFFHWNMIrHuSrFfY6986ATqgTYy1Lzycb0cJP+GT9IIPKTJz9zmmi Phsw== 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 :feedback-id:dkim-signature:dkim-signature; bh=WA5yo16lMwft5CPh1GKorx1eBd7zIhQykMs+an4tdPA=; fh=p6/jJmH8ymaPPPkPkGCoAO+quO2RGUs+oNx5YU3+VPA=; b=LHhziQw/a1MEKvtqLa0yBY5FFh9BNk7OFrCZf/GlE09i/9fh8h9UQjaI6wZybcmjAH R7ONg2UWYHIg2rlIJketWyBgNKndibTv8StNHsad0I9/4pWQTiPRJ0OCEzSy3MJAbgox +cWuAUIAz9x0j5p+C4418ALa4MYSipLUt6IHUVEMQ1iPFPhL4PG0rkOs07FZ39tFqMR/ QDYIeH5T05gUIdftq7bbIimAkg+5I/qB02uXMi9MmM5WrX75F+eR2IYKkW+52FCfQaA+ 3LgYvox4idJ6RbWT0OqZ3302bvmx1+iaGlRGrpwBD/8+9e9mMTYNvflQionHsTBnF78d YrIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b="BFalt9Z/"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=KRc5j5oI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id n11-20020a170902d2cb00b001ca1bd194b4si3986930plc.416.2023.11.22.10.22.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 10:22:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b="BFalt9Z/"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=KRc5j5oI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 239EB81B4AFA; Wed, 22 Nov 2023 10:21:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344162AbjKVSV2 (ORCPT + 99 others); Wed, 22 Nov 2023 13:21:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344081AbjKVSVN (ORCPT ); Wed, 22 Nov 2023 13:21:13 -0500 Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94DD8A4; Wed, 22 Nov 2023 10:21:08 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id EAAFC58055A; Wed, 22 Nov 2023 13:21:07 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 22 Nov 2023 13:21:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1700677267; x= 1700684467; bh=WA5yo16lMwft5CPh1GKorx1eBd7zIhQykMs+an4tdPA=; b=B Falt9Z/i6QDvEudBODypdblGWf4C34f3e4zwjOAQAJYvtG3NBAW/lttl0hmKGUeG sNezz1XKkZ/AIymaW2ZFOfEkh4f18HNcUlXP8z1IW3mu40BXMl5gIqMnFisWpei5 wCQzNtoPT9vhlBlv2zb22siDC1cy6H5QHW/6pmizxoUcxHx/sJaFWoxH/A5+XY6L BM9dL0enMkHhEhq3vtgYM1/BL4KdboEhM+yhErOu/H5eSMiAWBlv5cf33JMpwLlc kOc3Pvm1NSFrywV7RPM7Ckd6tBDjlVwVlrRPpbCF/hcpJ8ysFSRZDpSL7yZheKg/ cNbCN7/tvbAhYzsZfa/kQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1700677267; x= 1700684467; bh=WA5yo16lMwft5CPh1GKorx1eBd7zIhQykMs+an4tdPA=; b=K Rc5j5oIkr3tswv0HQiFshjicajn2sHsLWPsKJGIMQAJDgz2B1m2TsFTyzCNiPxI1 9QLbTpjgW2vFhfRa5COk6mDiGCwTMrMBT+qc2amMJkpk4cXIfdabLJ2X2rIL3UKG cz3VlgBpHATCeysbLosMdm8hnV4JJpdOzAp4/kqKY0GIYHqyeMz2CQaid3OQkTH8 RaDYAYcgaTaECpH0/l09+rok7/sg5A4a7OiWjjR7kcplE+cTZNOGTDRTWOT9Xgvm TwJR12Qn7tqtMW4nWNHJbS8bCrwbC8ZZccg8lf0SSUnCxs9IJLgIg5j80zFSt+5/ nAERvz0dCSY6Huo37VJpQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehuddguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdefhedmnecujfgurhephf fvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepffgrnhhivghlucgiuhcu oegugihusegugihuuhhurdighiiiqeenucggtffrrghtthgvrhhnpefgfefggeejhfduie ekvdeuteffleeifeeuvdfhheejleejjeekgfffgefhtddtteenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegugihusegugihuuhhurdighiii X-ME-Proxy: Feedback-ID: i6a694271:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Nov 2023 13:21:06 -0500 (EST) From: Daniel Xu To: shuah@kernel.org, daniel@iogearbox.net, andrii@kernel.org, ast@kernel.org, steffen.klassert@secunet.com, antony.antony@secunet.com, alexei.starovoitov@gmail.com Cc: mykolal@fb.com, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, devel@linux-ipsec.org, netdev@vger.kernel.org Subject: [PATCH ipsec-next v1 5/7] bpf: selftests: test_tunnel: Use vmlinux.h declarations Date: Wed, 22 Nov 2023 11:20:26 -0700 Message-ID: X-Mailer: git-send-email 2.42.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 22 Nov 2023 10:21:49 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783289466851066446 X-GMAIL-MSGID: 1783289466851066446 vmlinux.h declarations are more ergnomic, especially when working with kfuncs. The uapi headers are often incomplete for kfunc definitions. Co-developed-by: Antony Antony Signed-off-by: Antony Antony Signed-off-by: Daniel Xu --- .../selftests/bpf/progs/bpf_tracing_net.h | 1 + .../selftests/bpf/progs/test_tunnel_kern.c | 48 ++++--------------- 2 files changed, 9 insertions(+), 40 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/bpf_tracing_net.h b/tools/testing/selftests/bpf/progs/bpf_tracing_net.h index 0b793a102791..1bdc680b0e0e 100644 --- a/tools/testing/selftests/bpf/progs/bpf_tracing_net.h +++ b/tools/testing/selftests/bpf/progs/bpf_tracing_net.h @@ -26,6 +26,7 @@ #define IPV6_AUTOFLOWLABEL 70 #define TC_ACT_UNSPEC (-1) +#define TC_ACT_OK 0 #define TC_ACT_SHOT 2 #define SOL_TCP 6 diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c index f66af753bbbb..3065a716544d 100644 --- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c +++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c @@ -6,62 +6,30 @@ * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "vmlinux.h" #include #include +#include "bpf_kfuncs.h" +#include "bpf_tracing_net.h" #define log_err(__ret) bpf_printk("ERROR line:%d ret:%d\n", __LINE__, __ret) -#define VXLAN_UDP_PORT 4789 +#define VXLAN_UDP_PORT 4789 +#define ETH_P_IP 0x0800 +#define PACKET_HOST 0 +#define TUNNEL_CSUM bpf_htons(0x01) +#define TUNNEL_KEY bpf_htons(0x04) /* Only IPv4 address assigned to veth1. * 172.16.1.200 */ #define ASSIGNED_ADDR_VETH1 0xac1001c8 -struct geneve_opt { - __be16 opt_class; - __u8 type; - __u8 length:5; - __u8 r3:1; - __u8 r2:1; - __u8 r1:1; - __u8 opt_data[8]; /* hard-coded to 8 byte */ -}; - struct vxlanhdr { __be32 vx_flags; __be32 vx_vni; } __attribute__((packed)); -struct vxlan_metadata { - __u32 gbp; -}; - -struct bpf_fou_encap { - __be16 sport; - __be16 dport; -}; - -enum bpf_fou_encap_type { - FOU_BPF_ENCAP_FOU, - FOU_BPF_ENCAP_GUE, -}; - int bpf_skb_set_fou_encap(struct __sk_buff *skb_ctx, struct bpf_fou_encap *encap, int type) __ksym; int bpf_skb_get_fou_encap(struct __sk_buff *skb_ctx, From patchwork Wed Nov 22 18:20:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Xu X-Patchwork-Id: 168506 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1523810vqb; Wed, 22 Nov 2023 10:23:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQOEWRWvxBNuKOQAhz7zhyyCztsClD/InepBEItVVPoHPdTTsBXXbiQ9XQodnvbK4kDXBd X-Received: by 2002:a05:6808:1453:b0:3b2:dd7d:fc5e with SMTP id x19-20020a056808145300b003b2dd7dfc5emr4054322oiv.10.1700677411928; Wed, 22 Nov 2023 10:23:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700677411; cv=none; d=google.com; s=arc-20160816; b=Tx1SD6Ko3KN4BcelirZFmO7yE3ZrOLah/WzlUtLEVMQO+UOlXJr4F0izmfNvaxlH/t yF8WNsfyXzNr4SXobzkDxCnNww0abkQh2dHGZfCBT9M6XpI+zUlF1rTIOhd31sWJALJi Tea4KjuyxNS+x/qgfZfK0Fahm3LodiW5LCRjj6KJ2+DrmdOQqP+nQ/cXvptAGcXupxk1 4mxfNoZ4iaEYojjXSleQADzB+lhww5avohKPHZWFDM9nJs5OO+Pk/9yjM/nesuUvDPD6 6wILoGb+Nf7mb9/Wa+LUA+g7eMva4QeAUHw7LV0lKtn4PyQSYQ3F064X/nZXMixltxaN QYXg== 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 :feedback-id:dkim-signature:dkim-signature; bh=FuK4bS9tTFjezD3GdPwdW0QDdO9NNWltDhOsenLHkyk=; fh=p6/jJmH8ymaPPPkPkGCoAO+quO2RGUs+oNx5YU3+VPA=; b=UQotw6VXSSwgD2ENprUoxTlty/W0Jmu6wgsaKHmGrjcdndJEYLNlh+DLPDuIEdrPar zooaNDsvOL9RUf5St3wYtqVgcQOw/VZlwuILABd0z53BZhaYm5pk9vpt6y2cIeLsNCTX RfmIhOk+FyoeO/LVyUem9ghXH38oIfJEKrAOD7CFqgSOUIOptdhC/mWm8Qq3xLzwMkl6 MEboD0v5ewqdfJaHJRNvTcwyBxIJIccyJtWpCr/lZmsLO36rtRpchMbqZfo/I+jZFhjA lMg6w8zB0PAM0iYg9lOTNZ0xp2zJJws/rvYielzz0u+ON0Qx6VGYLb0AWiMi+Y29Le5J JgzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=B+X9C77J; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=XxsmaB38; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id q63-20020a632a42000000b005c1b2b1b555si5314pgq.160.2023.11.22.10.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 10:23:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=B+X9C77J; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=XxsmaB38; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id BFEFB8092D9F; Wed, 22 Nov 2023 10:21:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344244AbjKVSVZ (ORCPT + 99 others); Wed, 22 Nov 2023 13:21:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344079AbjKVSVN (ORCPT ); Wed, 22 Nov 2023 13:21:13 -0500 Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47BD4A2; Wed, 22 Nov 2023 10:21:10 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 9102758071C; Wed, 22 Nov 2023 13:21:09 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 22 Nov 2023 13:21:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1700677269; x= 1700684469; bh=FuK4bS9tTFjezD3GdPwdW0QDdO9NNWltDhOsenLHkyk=; b=B +X9C77JGH3b1jTsp6qm22PCvhJHboU5I/AIyQsdtB9+1Qy66Kd6gmgDVGi7QCjg8 axDkALIr3THvEO4neF5rzKw6uMDZ+HCdRTIk12UDDj3CYdpy8LSBdCoIHGmKS4I+ e+A2CLmQvixxmunJaeu9vvvDaI+A9jTFxXv3bPqKexp+SGalgRnoFDyS2YOIETkM czdl1wVDn0fKAcd6wA5gj/9qr47QVFBYZrdHNQSmv+cfQU2ez7Pni2BB2JRsY6/u ZcItv7XBi2p7w1HAlzXDgHWnlZgS98dh3zYYu0sKY4xgzZXzQqk0dtLDXjVUmP/A LdqTfaSIc3Zp5/amSXLKQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1700677269; x= 1700684469; bh=FuK4bS9tTFjezD3GdPwdW0QDdO9NNWltDhOsenLHkyk=; b=X xsmaB38ivKpsZWBP+/F0rQNi4Hd/4NUJJFChk5ZSYlKyu92A6/13jn09nEJX652p o2uw33xx1iMo81dEUOLGFX+jUzA4dPEmaTRkz/M/YQSCR4+gOmSzHmnoZgQWZ8bH 9i55uwqFLhi1MPrTAyCpVwiGxha8ysPuonbBcv3OY4GoxCMftxcYP6HBNa9fxuEP 4SJN2B3dx7471qBk4NH/O9SNYHJY0x6klCWQLW/VKM40OPvD5sQc3jKvBaTY8zr8 CzKeiHOUwcyduJpvpPAm7I6vLaGRsQD0EkWD9nN4klnnUTi78Avd2HqvxEFkJMkW EkGFIbKEWhxuN3SPuB5sg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehuddguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdefhedmnecujfgurhephf fvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepffgrnhhivghlucgiuhcu oegugihusegugihuuhhurdighiiiqeenucggtffrrghtthgvrhhnpefgfefggeejhfduie ekvdeuteffleeifeeuvdfhheejleejjeekgfffgefhtddtteenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegugihusegugihuuhhurdighiii X-ME-Proxy: Feedback-ID: i6a694271:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Nov 2023 13:21:08 -0500 (EST) From: Daniel Xu To: shuah@kernel.org, daniel@iogearbox.net, andrii@kernel.org, ast@kernel.org, steffen.klassert@secunet.com, antony.antony@secunet.com, alexei.starovoitov@gmail.com Cc: mykolal@fb.com, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, devel@linux-ipsec.org, netdev@vger.kernel.org Subject: [PATCH ipsec-next v1 6/7] bpf: selftests: test_tunnel: Disable CO-RE relocations Date: Wed, 22 Nov 2023 11:20:27 -0700 Message-ID: <391d524c496acc97a8801d8bea80976f58485810.1700676682.git.dxu@dxuuu.xyz> X-Mailer: git-send-email 2.42.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 10:21:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783289517818381421 X-GMAIL-MSGID: 1783289517818381421 Switching to vmlinux.h definitions seems to make the verifier very unhappy with bitfield accesses. The error is: ; md.u.md2.dir = direction; 33: (69) r1 = *(u16 *)(r2 +11) misaligned stack access off (0x0; 0x0)+-64+11 size 2 It looks like disabling CO-RE relocations seem to make the error go away. Co-developed-by: Antony Antony Signed-off-by: Antony Antony Signed-off-by: Daniel Xu --- tools/testing/selftests/bpf/progs/test_tunnel_kern.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c index 3065a716544d..ec7e04e012ae 100644 --- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c +++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c @@ -6,6 +6,7 @@ * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. */ +#define BPF_NO_PRESERVE_ACCESS_INDEX #include "vmlinux.h" #include #include From patchwork Wed Nov 22 18:20:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Xu X-Patchwork-Id: 168508 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1523936vqb; Wed, 22 Nov 2023 10:23:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgpsJUG7ShFSxH9uqJkkbNXdfbeA4WjNFadcshKZLQ1TS27L44yN1255vCTxJ3eVlulxxW X-Received: by 2002:a05:6a20:1610:b0:18b:386a:46a4 with SMTP id l16-20020a056a20161000b0018b386a46a4mr3231607pzj.18.1700677423986; Wed, 22 Nov 2023 10:23:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700677423; cv=none; d=google.com; s=arc-20160816; b=I5+/gXmJJpx8PX4W49fhcyAy3q0K2EItISfqr4ybV1k7Q1Ybfl3fOUmVZ42Fpn3pUd Z0BtcKY1CBCC8kN82PtCNdcHw/FHDtOTikpiGeze17CLd/Dt++5XNkaObfmD/uW0Z4nY FtP32uFfFQMgf6QnYVqeybWDwfKid6cpK+wS2hsR8AOFJtbfHZinVgZmGH1hy3LGo46H uD7d5wlxYqHT3deOBQNSwXyxH9sdEpfVQSoS4ixxqBK28K5HK02RQm1+B6cfkZJ44baa IU2liVB2y8pIYuc45Wo0pZWT0NdfpB1jGGjLH50dUO8Jsepfi0Zopc4Zli0cK0FYiLCC Q2HA== 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 :feedback-id:dkim-signature:dkim-signature; bh=MkiWZ7hndeUKcl/hIWbjV8IQ3kJNfZ+yq9JosgeOxnU=; fh=LM5vYfQHVqrelxivUB3ArrHPHwknSV97PocLfKCCv4c=; b=LXACxtjwNdebbFhz2KbePrxJCQU1j/l4bcaBc+xeN6tjqSTbL2zEmGiD+el9e/Ej1G tkyiPFu3QhGijTjhswUWvjLXIXHwQ9/CyEPut8oYQgQl5287YDdver/Pj1omFUO+wmJQ QD+8dXIK3F/CHVOTUt/aUuOroHwVg0FtxoUxsRnZl6HJK/cgrDm4Fp/kBQXXdgYqz+DK eISZ9c6AG6xeSoTtJcvIvmBpRERt3ia07/JLuW9jabgy5QZKXEcTyG6uZMdrgWpSKPw2 iTKsEXx/sV6vUrwssZUFsN6r9MBpU3xYpS//6vxQAovhVnALLtsj/rI5utIQvhhtgPuY MADA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=rC5vATeK; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Om7uyCE+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bw12-20020a056a02048c00b005893a7c438esi14340934pgb.689.2023.11.22.10.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 10:23:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=rC5vATeK; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Om7uyCE+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 29DF78096388; Wed, 22 Nov 2023 10:22:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344362AbjKVSVb (ORCPT + 99 others); Wed, 22 Nov 2023 13:21:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235092AbjKVSVQ (ORCPT ); Wed, 22 Nov 2023 13:21:16 -0500 Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45BD51AB; Wed, 22 Nov 2023 10:21:12 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 7333258071E; Wed, 22 Nov 2023 13:21:11 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 22 Nov 2023 13:21:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1700677271; x= 1700684471; bh=MkiWZ7hndeUKcl/hIWbjV8IQ3kJNfZ+yq9JosgeOxnU=; b=r C5vATeKuhOW93dtcUKH8UClKCfjzF9Xl4bA1RFgGxj4x2Z/V0laY/04WwqJPq6Ad r28Y4QVdadBBSD5RVGoYZ13ZFEDERoDtoJyZpZfd3IYyqMy8lOwzToqb2la/SDfx 3fvZo3l3hsKpmbbLk0+LhBOO/lr2AEG5yrTLaPM5qOmrKpwQGbkiwyFQsbCy0EXl +fjuncUUzp318ZSwX1n0gML9TXAzYvF/P4IahnPdtPg5fD+w/vF1MUPmolNuh0xQ GPYsmMoGG0yvy6JQLvvDEw/KxMJYlyme/dCEPWxRXcE36hZhx1Pv4VPDc3vCBT0d 31MDYZbgkCky8BRxwIdhg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1700677271; x= 1700684471; bh=MkiWZ7hndeUKcl/hIWbjV8IQ3kJNfZ+yq9JosgeOxnU=; b=O m7uyCE+97C8ZSq/6OKBwWyKEv9gWkvbTgMlQEwaFo6d0wXG7ky4shzpSKmmYkVmr ZVnEDlNVXE6M/quKpBnxMl4F7OgTrq84wLH6JP7DfhbYnn12BSnbZkTaRu1SivfF VUJao4vmqHLyHgPZQiTtNaovT+QAWLLTxzJ31oAAF/u/+9DBat2JMnB6bDFMvpkT MPK1pI2Fi8Dr5qikEv/dNTvVDQjeoBfVZdCNUXjGEVyrEHAvUFAMoxT+ff6ixRRR 5WqRAnardiLg5vDzdeDb8gBw+MdvC0JiuPkuy5MOJDxgAV2K3GaLJDVAyVecYIWO dxfMLb4pdJRs7Zq4VlN9g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehuddguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdefhedmnecujfgurhephf fvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepffgrnhhivghlucgiuhcu oegugihusegugihuuhhurdighiiiqeenucggtffrrghtthgvrhhnpefgfefggeejhfduie ekvdeuteffleeifeeuvdfhheejleejjeekgfffgefhtddtteenucevlhhushhtvghrufhi iigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpegugihusegugihuuhhurdighiii X-ME-Proxy: Feedback-ID: i6a694271:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Nov 2023 13:21:09 -0500 (EST) From: Daniel Xu To: john.fastabend@gmail.com, davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, kuba@kernel.org, andrii@kernel.org, shuah@kernel.org, steffen.klassert@secunet.com, antony.antony@secunet.com, alexei.starovoitov@gmail.com Cc: martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, mykolal@fb.com, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, devel@linux-ipsec.org Subject: [PATCH ipsec-next v1 7/7] bpf: xfrm: Add selftest for bpf_xdp_get_xfrm_state() Date: Wed, 22 Nov 2023 11:20:28 -0700 Message-ID: <84111ba0ea652a7013df520c151d40d400401e9c.1700676682.git.dxu@dxuuu.xyz> X-Mailer: git-send-email 2.42.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 22 Nov 2023 10:22:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783289530232102196 X-GMAIL-MSGID: 1783289530232102196 This commit extends test_tunnel selftest to test the new XDP xfrm state lookup kfunc. Co-developed-by: Antony Antony Signed-off-by: Antony Antony Signed-off-by: Daniel Xu --- .../selftests/bpf/progs/test_tunnel_kern.c | 49 +++++++++++++++++++ tools/testing/selftests/bpf/test_tunnel.sh | 12 +++-- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c index ec7e04e012ae..17bf9ce28460 100644 --- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c +++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c @@ -35,6 +35,10 @@ int bpf_skb_set_fou_encap(struct __sk_buff *skb_ctx, struct bpf_fou_encap *encap, int type) __ksym; int bpf_skb_get_fou_encap(struct __sk_buff *skb_ctx, struct bpf_fou_encap *encap) __ksym; +struct xfrm_state * +bpf_xdp_get_xfrm_state(struct xdp_md *ctx, struct bpf_xfrm_state_opts *opts, + u32 opts__sz) __ksym; +void bpf_xdp_xfrm_state_release(struct xfrm_state *x) __ksym; struct { __uint(type, BPF_MAP_TYPE_ARRAY); @@ -948,4 +952,49 @@ int xfrm_get_state(struct __sk_buff *skb) return TC_ACT_OK; } +SEC("xdp") +int xfrm_get_state_xdp(struct xdp_md *xdp) +{ + struct bpf_xfrm_state_opts opts = {}; + struct xfrm_state *x = NULL; + struct ip_esp_hdr *esph; + struct bpf_dynptr ptr; + u8 esph_buf[8] = {}; + u8 iph_buf[20] = {}; + struct iphdr *iph; + u32 off; + + if (bpf_dynptr_from_xdp(xdp, 0, &ptr)) + goto out; + + off = sizeof(struct ethhdr); + iph = bpf_dynptr_slice(&ptr, off, iph_buf, sizeof(iph_buf)); + if (!iph || iph->protocol != IPPROTO_ESP) + goto out; + + off += sizeof(struct iphdr); + esph = bpf_dynptr_slice(&ptr, off, esph_buf, sizeof(esph_buf)); + if (!esph) + goto out; + + opts.netns_id = BPF_F_CURRENT_NETNS, + opts.daddr.a4 = iph->daddr; + opts.spi = esph->spi; + opts.proto = IPPROTO_ESP; + opts.family = AF_INET; + + x = bpf_xdp_get_xfrm_state(xdp, &opts, sizeof(opts)); + if (!x || opts.error) + goto out; + + if (!x->replay_esn) + goto out; + + bpf_printk("replay-window %d\n", x->replay_esn->replay_window); +out: + if (x) + bpf_xdp_xfrm_state_release(x); + return XDP_PASS; +} + char _license[] SEC("license") = "GPL"; diff --git a/tools/testing/selftests/bpf/test_tunnel.sh b/tools/testing/selftests/bpf/test_tunnel.sh index dd3c79129e87..17d263681c71 100755 --- a/tools/testing/selftests/bpf/test_tunnel.sh +++ b/tools/testing/selftests/bpf/test_tunnel.sh @@ -528,7 +528,7 @@ setup_xfrm_tunnel() # at_ns0 -> root ip netns exec at_ns0 \ ip xfrm state add src 172.16.1.100 dst 172.16.1.200 proto esp \ - spi $spi_in_to_out reqid 1 mode tunnel \ + spi $spi_in_to_out reqid 1 mode tunnel replay-window 42 \ auth-trunc 'hmac(sha1)' $auth 96 enc 'cbc(aes)' $enc ip netns exec at_ns0 \ ip xfrm policy add src 10.1.1.100/32 dst 10.1.1.200/32 dir out \ @@ -537,7 +537,7 @@ setup_xfrm_tunnel() # root -> at_ns0 ip netns exec at_ns0 \ ip xfrm state add src 172.16.1.200 dst 172.16.1.100 proto esp \ - spi $spi_out_to_in reqid 2 mode tunnel \ + spi $spi_out_to_in reqid 2 mode tunnel replay-window 42 \ auth-trunc 'hmac(sha1)' $auth 96 enc 'cbc(aes)' $enc ip netns exec at_ns0 \ ip xfrm policy add src 10.1.1.200/32 dst 10.1.1.100/32 dir in \ @@ -553,14 +553,14 @@ setup_xfrm_tunnel() # root namespace # at_ns0 -> root ip xfrm state add src 172.16.1.100 dst 172.16.1.200 proto esp \ - spi $spi_in_to_out reqid 1 mode tunnel \ + spi $spi_in_to_out reqid 1 mode tunnel replay-window 42 \ auth-trunc 'hmac(sha1)' $auth 96 enc 'cbc(aes)' $enc ip xfrm policy add src 10.1.1.100/32 dst 10.1.1.200/32 dir in \ tmpl src 172.16.1.100 dst 172.16.1.200 proto esp reqid 1 \ mode tunnel # root -> at_ns0 ip xfrm state add src 172.16.1.200 dst 172.16.1.100 proto esp \ - spi $spi_out_to_in reqid 2 mode tunnel \ + spi $spi_out_to_in reqid 2 mode tunnel replay-window 42 \ auth-trunc 'hmac(sha1)' $auth 96 enc 'cbc(aes)' $enc ip xfrm policy add src 10.1.1.200/32 dst 10.1.1.100/32 dir out \ tmpl src 172.16.1.200 dst 172.16.1.100 proto esp reqid 2 \ @@ -585,6 +585,8 @@ test_xfrm_tunnel() tc qdisc add dev veth1 clsact tc filter add dev veth1 proto ip ingress bpf da object-pinned \ ${BPF_PIN_TUNNEL_DIR}/xfrm_get_state + ip link set dev veth1 xdpdrv pinned \ + ${BPF_PIN_TUNNEL_DIR}/xfrm_get_state_xdp ip netns exec at_ns0 ping $PING_ARG 10.1.1.200 sleep 1 grep "reqid 1" ${TRACE} @@ -593,6 +595,8 @@ test_xfrm_tunnel() check_err $? grep "remote ip 0xac100164" ${TRACE} check_err $? + grep "replay-window 42" ${TRACE} + check_err $? cleanup if [ $ret -ne 0 ]; then