From patchwork Sat Oct 29 07:53:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rong Tao X-Patchwork-Id: 13024531 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CBC6C38A02 for ; Sat, 29 Oct 2022 07:53:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229917AbiJ2HxY (ORCPT ); Sat, 29 Oct 2022 03:53:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbiJ2HxX (ORCPT ); Sat, 29 Oct 2022 03:53:23 -0400 X-Greylist: delayed 17127 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 29 Oct 2022 00:53:20 PDT Received: from out203-205-251-73.mail.qq.com (out203-205-251-73.mail.qq.com [203.205.251.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7030072872; Sat, 29 Oct 2022 00:53:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1667029998; bh=+DzGGmzgC+pXMjNXZtuoYW7aaeiptNxaQfitvxP5P1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FYYuTW8Rx4q7D+sLngTrGEU0lDL/uPlA1pWUdhwPnHWsW8f0TL9rOLEbJ9LmZgPvy IvO8nmWDHK8XpkmvNpJIN4e73kPygjt7eaUPk3cVFbnUtFR3Y3beyW4Bw3FUAD6IFU vB6hhLYC5aydu2mCZlwOf98q8eM3Lf8noUrkRjCU= Received: from localhost.localdomain ([111.199.189.86]) by newxmesmtplogicsvrsza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qbfSOgHKUyy02gSB 3c0X7gUx/NxZXnGXhPk9y+lw1gjcA/frEoASpuA/zeO6Q7wpC5mvG29f4Z6kkwQsk5oIPK2zE= From: Rong Tao 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 X-OQ-MSGID: <20221029075312.45206-1-rtoax@foxmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: Rong Tao 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 --- 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");