Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2162383rdh; Sat, 25 Nov 2023 16:38:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEss4E2n3u4VsepBtIoLxCY3+HdwHnzul116UQnybKPQ1J/RdQPID1uDiGXS7pw0bDrFlz9 X-Received: by 2002:a05:6808:22a6:b0:3b8:45eb:1e81 with SMTP id bo38-20020a05680822a600b003b845eb1e81mr10182870oib.49.1700959129219; Sat, 25 Nov 2023 16:38:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700959129; cv=none; d=google.com; s=arc-20160816; b=ViMjjEPsw1tju9RxjqSNTUzvlYegMWjJBRCAWx8q2gb3aT99MKDLWYtEH3+f/yvtgv mrDMhE2OgW0TWJlxbpoNBEh9QSIoYmgqSwKJn3OlLqUnnLn1/GU4AEhmJRZ8WVUXjsM+ h1vAZvWKqQ4UWaWu+0XBnVwumHOWUsFv0KHBdOAt7KpMSWJq41Isn8l3xaSagc/VllyB fi7pp6HpRgpTCPmQEOLuSRC87ZhvN1dsmP3LIGob6Q74ZJ5Dak5plTfMD/ytF3uhEJU2 bL3weak4ORaGfjiEe3L8LFxNGBofuBA0k7D56BA6Rq/Sk+vGOY3RIl9FmepXqKoSZIO9 gJsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=s/ZPoKiZbkIfm1dDuAoTcnp78skWk0ipL2jJQiXwSIE=; fh=mCmIINJYqkXu3Q7isQTbyUeIpmtuHZg7u/TZin6464U=; b=wMFXgjSH6RFIvSRpMTULZ5oAaHg2iCRpmJ6SZvsk5V69BUON6+efBG/q+BR549m7db ctyV0bMxfFxAbzcfIsqjlhUtdREkksIxyCI7md+PKag2+iO/V2DhzhZ7rv4qMWmmeUZt vEF2uQ9sgqhfcBmTYHC+NEW1lDMX/eo8hddP7b4pn90WZGCT5JDys2XO8ZYreMxsklpx dcTP4KGNPazflsPmdqdGXxYDszSNeanONm8gpKc9Pcl58o4nLVQlhz94PRYNiSTpjoAj ed7BA7+wvLkquWwWbhnp0Dc3OWm+iaawqivHbO9o9BcPPzB9HUnPJwX9mIM96YdkTyiT te7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=D32KG8WI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id z42-20020a056a001daa00b006cbfbb699bfsi3881024pfw.156.2023.11.25.16.38.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 16:38:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=D32KG8WI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C6E318065000; Sat, 25 Nov 2023 16:38:14 -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 S229784AbjKZAer (ORCPT + 99 others); Sat, 25 Nov 2023 19:34:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjKZAeq (ORCPT ); Sat, 25 Nov 2023 19:34:46 -0500 Received: from out-170.mta0.migadu.com (out-170.mta0.migadu.com [91.218.175.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E80C133 for ; Sat, 25 Nov 2023 16:34:50 -0800 (PST) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1700958888; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s/ZPoKiZbkIfm1dDuAoTcnp78skWk0ipL2jJQiXwSIE=; b=D32KG8WIWSBlHoBw7qhYyejBIRSZr+xdqovTapw2Vt6keOmhtykzSweeRHG0kTVlyIwyNo P2ayW2Bgvur9fHVvNA+qnJGp0E9Rkloz5zbiNgzzKESB1UBtAKg3lZALqHBjehuWlQRlBg HSB3WDuzyt6JS4FtcRXcea9ZIrbWyuI= Date: Sat, 25 Nov 2023 16:34:36 -0800 MIME-Version: 1.0 Subject: Re: [PATCH ipsec-next v1 5/7] bpf: selftests: test_tunnel: Use vmlinux.h declarations Content-Language: en-GB To: Daniel Xu , 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, 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 References: X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT 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_NONE,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]); Sat, 25 Nov 2023 16:38:14 -0800 (PST) On 11/22/23 1:20 PM, Daniel Xu wrote: > 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)); In my particular setup, I have struct vxlanhdr defined in vmlinux.h so I hit a compilation failure. > > -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,