Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1162461pxb; Wed, 6 Apr 2022 10:10:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEl9a4CugGoCGX907R9iKdAoYO0Xzf05miWtFcCinyPTvDElPQOQWgZasX8NGn/4jfvMem X-Received: by 2002:a63:dc42:0:b0:382:6aff:3f17 with SMTP id f2-20020a63dc42000000b003826aff3f17mr7880010pgj.5.1649265057276; Wed, 06 Apr 2022 10:10:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649265057; cv=none; d=google.com; s=arc-20160816; b=kkCc6+pdakj/Dxmn5Hr8Uvr9wHnBh22ym9GAWAYOWc8hmVOay4jJ+c6Epwwz8j0Qm0 KlAuAf/vgrhWsGgBPpoo9O7o1W05/lrURgcSbVh09H4Bl1hwWPnbPWPxtkIuRLyrFaoJ oTSNcqgmkN0iQDZ0DXXRdLIHRiJHdAWV8GM1eUDJ/qNFAssW8+S+lYdiFcqH1eU5ocQn 02g+lTAqvKh4odnpr+5gnXVY0s4cb0Lq5MwlcshyN/bSsHXfNjMudhg9D6symPp3TJt0 tLbUjy+g5knLxEbgJ0pFebA2DvtDNhc5u7c0bMQo5N4HFV+DyHylKR2ygvA4PXQNY8cY BMsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:mime-version :content-transfer-encoding:subject:to:from:date:dkim-signature; bh=g5GjYLHdeKIBvnZMkoAoa1N6JR0rc0veA8jEts7dzUM=; b=kUj8TGCSZmLUASmq02xBxR1lQ0IJaUWayuUecyEHaNfg/myihn9I6n7+Vcs6rQQQQW vy0O1W7XgC+Gke8yVOD2bY/D2pZeNlxL82u59ycpI7QGRkuzG0h9mEiDTeNxKJSYinQR l/tVe51fbJR9zlllQK8QtAWHHMhfSiGqjiZBr6Ak54YB44pJ2nMmjCR16b5huxyoNjQ3 mddcI98gg0yjai4Z4KvEkut//DY3pGbsVXKr6OyELpV8rHj/yKAPHsSh3K+ZvsMi2WIE 3ajiZsum19aKHt4CT5/87buOctNr/MNouniE89nnwibx4LW8dyfF4q2/GmEyd1YKLrnv sqCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mail.ustc.edu.cn header.s=dkim header.b=b9h3PyVi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t6-20020a170902e84600b00153b2d16455si18208060plg.93.2022.04.06.10.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 10:10:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@mail.ustc.edu.cn header.s=dkim header.b=b9h3PyVi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DF87D1BA464; Wed, 6 Apr 2022 10:02:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237372AbiDFREi (ORCPT + 99 others); Wed, 6 Apr 2022 13:04:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238469AbiDFREM (ORCPT ); Wed, 6 Apr 2022 13:04:12 -0400 X-Greylist: delayed 340 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 06 Apr 2022 07:49:01 PDT Received: from ustc.edu.cn (email6.ustc.edu.cn [IPv6:2001:da8:d800::8]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BFC0447584B; Wed, 6 Apr 2022 07:49:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ustc.edu.cn; s=dkim; h=Received:Date:From:To:Subject: Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID; bh=0sTHv7VvDW8oTRBOt7TYuMhuoXUUhBY50zm+RywcRJE=; b=b9h3PyVixUBqF KdSzg25xtAg1bM9do59cLls0FxVNtMiuN5dE00nOczYsctJePDcLnlWePt3TUml0 lkXHk9TmEdJ0gEVhv89R6YHC9B9MVjpEO3gXiby3n8aOBkusTPiiYIm9GlxOmTTK t8KSj+6s834UqP1X8xhiBkRla6El1U= Received: by ajax-webmail-newmailweb.ustc.edu.cn (Coremail) ; Wed, 6 Apr 2022 22:43:20 +0800 (GMT+08:00) X-Originating-IP: [222.64.172.188] Date: Wed, 6 Apr 2022 22:43:20 +0800 (GMT+08:00) X-CM-HeaderCharset: UTF-8 From: wuzongyo@mail.ustc.edu.cn To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Question] Failed to load ebpf program with BTF-defined map X-Priority: 3 X-Mailer: Coremail Webmail Server Version XT3.0.8 dev build 20210401(c5ff3689) Copyright (c) 2002-2022 www.mailtech.cn ustccn X-SendMailWithSms: false Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=UTF-8 MIME-Version: 1.0 Message-ID: <12b95db5.295d.17fff547855.Coremail.wuzongyo@mail.ustc.edu.cn> X-Coremail-Locale: zh_CN X-CM-TRANSID: LkAmygAXHtYIp01iy+ADAA--.0W X-CM-SenderInfo: pzx200xj1rqzxdloh3xvwfhvlgxou0/1tbiAQwICVQhoFZrBAABsh X-Coremail-Antispam: 1Ur529EdanIXcx71UUUUU7IcSsGvfJ3iIAIbVAYjsxI4VWxJw CS07vEb4IE77IF4wCS07vE1I0E4x80FVAKz4kxMIAIbVAFxVCaYxvI4VCIwcAKzIAtYxBI daVFxhVjvjDU= X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi, I wrote a simple tc-bpf program like that: #include #include #include #include struct { __uint(type, BPF_MAP_TYPE_HASH); __uint(max_entries, 1); __type(key, int); __type(value, int); } hmap SEC(".maps"); SEC("classifier") int _classifier(struct __sk_buff *skb) { int key = 0; int *val; val = bpf_map_lookup_elem(&hmap, &key); if (!val) return TC_ACT_OK; return TC_ACT_OK; } char __license[] SEC("license") = "GPL"; Then I tried to use tc to load the program: tc qdisc add dev eth0 clsact tc filter add dev eth0 egress bpf da obj test_bpf.o But the program loading failed with error messages: Prog section 'classifier' rejected: Permission denied (13)! - Type: 3 - Instructions: 9 (0 over limit - License: GPL Verifier analysis: Error fetching program/map! Unable to load program I tried to replace the map definition with the following code and the program is loaded successfully! struct bpf_map_def SEC("maps") hmap = { .type = BPF_MAP_TYPE_HASH, .key_size = sizeof(int), .value_size = sizeof(int), .max_entries = 1, }; With bpftrace, I can find that the errno -EACCES is returned by function do_check(). But I am still confused what's wrong with it. Linux Version: 5.17.0-rc3+ with CONFIG_DEBUG_INFO_BTF=y TC Version: 5.14.0 Any suggestion will be appreciated! Thanks