From nobody Mon Sep 16 19:43:21 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F13D14B07C for ; Tue, 23 Jul 2024 07:10:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721718647; cv=none; b=n70T8XTAK1SIoq/z9EA4wHZ8S/dCmh4LECxvkoA1EaHXiteo34dbR/DKN40SMLvXLTM1L4yneliVTkEuSZu996UVgjw7VDU86BFvw78X+VnUL1SSTQ42SW62EQUXr5QONgQPBU5CkB+YafOuLePnyaoujDK1TVLr3mPoBD4qsfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721718647; c=relaxed/simple; bh=u/QsKyttUCU09OB5lypgCukROiu0KDjYn/kne8MGZsg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tUXaMcvCefPHxnLY61X5lDvUkCamemwxbgULlV3f03pcSYe8FDgIBLfdD6i90MFJyqEc4Yq7XYDIiEUMG5Kdw4/6jI5OEM9J5rHOXeKyEJDHz3yvpkaRYtZ9rwkxKGn/g7XCM9iAFIEvYUHE7bWweIr/K1V/nX/oNwP8wu/4m7c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=JyOQpiaJ; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JyOQpiaJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721718645; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YdPO/Vt26loGhN/7TbhKVqyyms9ZE6JlxaJFW/Mi4bc=; b=JyOQpiaJNqmRnGut4aQpiTY5mTwGdh39SDA/vP0g5N3Q9S1/cEdC3jX7rA9/BhTdkgksN8 cmTeGlpQZAB2R31z8yNAboerqXkBacAYpIx+Vp2lkSS8JYQASAwSYkK6Ck2F9IXKMYNgGF 9FRX5j7FTgNPdPUO8c2KuHwsJ/Pb4hE= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-422-NxUWQI8GPx6Udv3-oRtnSA-1; Tue, 23 Jul 2024 03:10:39 -0400 X-MC-Unique: NxUWQI8GPx6Udv3-oRtnSA-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E09B81955F43; Tue, 23 Jul 2024 07:10:37 +0000 (UTC) Received: from alecto.usersys.redhat.com (unknown [10.45.224.129]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B85293000194; Tue, 23 Jul 2024 07:10:34 +0000 (UTC) From: Artem Savkov To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , bpf@vger.kernel.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Artem Savkov Subject: [PATCH bpf-next v3] selftests/bpf: fix compilation failure when CONFIG_NET_FOU!=y Date: Tue, 23 Jul 2024 09:10:31 +0200 Message-ID: <20240723071031.3389423-1-asavkov@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Without CONFIG_NET_FOU bpf selftests are unable to build because of missing definitions. Add ___local versions of struct bpf_fou_encap and enum bpf_fou_encap_type to fix the issue. Signed-off-by: Artem Savkov --- v3: swith from using BPF_NO_KFUNC_PROTOTYPES to casting to keep kfunc prototype intact. v2: added BPF_NO_KFUNC_PROTOTYPES define to avoid issues when CONFIG_NET_FOU is set. --- .../selftests/bpf/progs/test_tunnel_kern.c | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/t= esting/selftests/bpf/progs/test_tunnel_kern.c index 3f5abcf3ff136..fcff3010d8a60 100644 --- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c +++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c @@ -26,6 +26,18 @@ */ #define ASSIGNED_ADDR_VETH1 0xac1001c8 =20 +struct bpf_fou_encap___local { + __be16 sport; + __be16 dport; +}; + +enum bpf_fou_encap_type___local { + FOU_BPF_ENCAP_FOU___local, + FOU_BPF_ENCAP_GUE___local, +}; + +struct bpf_fou_encap; + 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, @@ -745,7 +757,7 @@ SEC("tc") int ipip_gue_set_tunnel(struct __sk_buff *skb) { struct bpf_tunnel_key key =3D {}; - struct bpf_fou_encap encap =3D {}; + struct bpf_fou_encap___local encap =3D {}; void *data =3D (void *)(long)skb->data; struct iphdr *iph =3D data; void *data_end =3D (void *)(long)skb->data_end; @@ -769,7 +781,8 @@ int ipip_gue_set_tunnel(struct __sk_buff *skb) encap.sport =3D 0; encap.dport =3D bpf_htons(5555); =20 - ret =3D bpf_skb_set_fou_encap(skb, &encap, FOU_BPF_ENCAP_GUE); + ret =3D bpf_skb_set_fou_encap(skb, (struct bpf_fou_encap *)&encap, + FOU_BPF_ENCAP_GUE___local); if (ret < 0) { log_err(ret); return TC_ACT_SHOT; @@ -782,7 +795,7 @@ SEC("tc") int ipip_fou_set_tunnel(struct __sk_buff *skb) { struct bpf_tunnel_key key =3D {}; - struct bpf_fou_encap encap =3D {}; + struct bpf_fou_encap___local encap =3D {}; void *data =3D (void *)(long)skb->data; struct iphdr *iph =3D data; void *data_end =3D (void *)(long)skb->data_end; @@ -806,7 +819,8 @@ int ipip_fou_set_tunnel(struct __sk_buff *skb) encap.sport =3D 0; encap.dport =3D bpf_htons(5555); =20 - ret =3D bpf_skb_set_fou_encap(skb, &encap, FOU_BPF_ENCAP_FOU); + ret =3D bpf_skb_set_fou_encap(skb, (struct bpf_fou_encap *)&encap, + FOU_BPF_ENCAP_FOU___local); if (ret < 0) { log_err(ret); return TC_ACT_SHOT; @@ -820,7 +834,7 @@ int ipip_encap_get_tunnel(struct __sk_buff *skb) { int ret; struct bpf_tunnel_key key =3D {}; - struct bpf_fou_encap encap =3D {}; + struct bpf_fou_encap___local encap =3D {}; =20 ret =3D bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 0); if (ret < 0) { @@ -828,7 +842,7 @@ int ipip_encap_get_tunnel(struct __sk_buff *skb) return TC_ACT_SHOT; } =20 - ret =3D bpf_skb_get_fou_encap(skb, &encap); + ret =3D bpf_skb_get_fou_encap(skb, (struct bpf_fou_encap *)&encap); if (ret < 0) { log_err(ret); return TC_ACT_SHOT; --=20 2.45.2