linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rong Tao <rtoax@foxmail.com>
To: andrii.nakryiko@gmail.com
Cc: andrii@kernel.org, ast@kernel.org, bpf@vger.kernel.org,
	daniel@iogearbox.net, haoluo@google.com,
	john.fastabend@gmail.com, jolsa@kernel.org, kpsingh@kernel.org,
	linux-kernel@vger.kernel.org, martin.lau@linux.dev,
	rongtao@cestc.cn, rtoax@foxmail.com, sdf@google.com,
	song@kernel.org, yhs@fb.com
Subject: [PATCH bpf-next] samples/bpf: Fix sockex3: missing BPF prog type
Date: Sat, 29 Oct 2022 15:53:12 +0800	[thread overview]
Message-ID: <tencent_7DD02046A8398BE3324F85E0F56ED41EB105@qq.com> (raw)
In-Reply-To: <CAEf4Bza_6qND8iOuiur+xX0cBVkKJfKoJAOjihnVYRjoB3tWqw@mail.gmail.com>

From: Rong Tao <rongtao@cestc.cn>

since commit 450b167fb9be("libbpf: clean up SEC() handling"),
sec_def_matches() does not recognize "socket/xxx" as "socket", therefore,
the BPF program type is not recognized, set "socket/xxx" to SOCKET_FILTER
solves this error.

 $ cd samples/bpf
 $ sudo ./sockex3
 libbpf: prog 'bpf_func_PARSE_IP': missing BPF prog type, check ELF section name 'socket/3'
 libbpf: prog 'bpf_func_PARSE_IP': failed to load: -22
 libbpf: failed to load object './sockex3_kern.o'
 ERROR: loading BPF object file failed

Signed-off-by: Rong Tao <rongtao@cestc.cn>
---
 samples/bpf/sockex3_user.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/samples/bpf/sockex3_user.c b/samples/bpf/sockex3_user.c
index cd6fa79df900..dc79c17ad195 100644
--- a/samples/bpf/sockex3_user.c
+++ b/samples/bpf/sockex3_user.c
@@ -39,6 +39,9 @@ int main(int argc, char **argv)
 		return 0;
 	}
 
+	bpf_object__for_each_program(prog, obj)
+		bpf_program__set_type(prog, BPF_PROG_TYPE_SOCKET_FILTER);
+
 	/* load BPF program */
 	if (bpf_object__load(obj)) {
 		fprintf(stderr, "ERROR: loading BPF object file failed\n");
-- 
2.31.1


  reply	other threads:[~2022-10-29  7:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27 13:33 [PATCH] samples/bpf: Fix sockex3: missing BPF prog type Rong Tao
2022-10-27 13:38 ` [PATCH bpf-next] " Rong Tao
2022-10-27 20:15   ` Andrii Nakryiko
2022-10-28  1:01     ` [PATCH] " Rong Tao
2022-10-28 17:09       ` Andrii Nakryiko
2022-10-29  7:53         ` Rong Tao [this message]
2022-11-03 18:38           ` [PATCH bpf-next] " Andrii Nakryiko
2022-11-04  3:17             ` Rong Tao
2022-11-04 22:53               ` Andrii Nakryiko
2022-11-05  6:48                 ` [PATCH bpf-next] samples/bpf: Fix sockex3 error: " Rong Tao
2022-11-08  1:14                   ` Andrii Nakryiko
2022-11-08  1:20                   ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_7DD02046A8398BE3324F85E0F56ED41EB105@qq.com \
    --to=rtoax@foxmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=rongtao@cestc.cn \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).