Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp693593imi; Thu, 21 Jul 2022 09:07:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vHxdso/SF3l4u3Z0fvjPyiFRgLneMw205Oe2vaJgpK6endt2XkbfMWONV9Dkv1NdS7tVUc X-Received: by 2002:a67:f454:0:b0:357:2721:eaff with SMTP id r20-20020a67f454000000b003572721eaffmr16756561vsn.30.1658419658195; Thu, 21 Jul 2022 09:07:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658419658; cv=none; d=google.com; s=arc-20160816; b=yYypgvITriAYSIaaSGZLIgPB2lefykj+9Bp9Xw6PV1eBY/3dWQvFl8Dnz+d7HvvxsI oWHqdL3g6Wwr49IEwRdFhTZWxISQfgJ4aJk6l6ZVgyfBcRIdxzHt2wPmTMOBMUWfRLIk ETZ69GZI9KgpwCMI6mMa6mPrqt+PYb9WlKNMV1eG26cic7XAZDdDmGvPFFNGIgJUTPLw PIDfY2Uz6VKjiO4LzldlEeBOuw9Js3ruYhM3XKVvIU9EZx7lENMKGkAAk62YheNg0rEJ CwiNOgfB8h0g/Tzju0tXcjIWw7CidTF/7s9+86SBjWQjvLBOyqXi009T6mtLoZfaq/VW bMUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=amsqiHjbAkA62MGJKMEme7kdXdh0SccxhuiEsDXQqww=; b=mcownxV1hnLpuLwq42z+fN6iapUu33ZTq/ygrIXx/SbIPNIiEu+cPlbgu+k6kOFV1J RTt40I7h4gLF7lrrVhKltiul6qhdgHYVeBHKyUg/RwKLsWgUS1SMZnvCIm5FMp6WqAYs 6gVN4QoOEbqmFp3MI3A/7iPc251A4JhlYsu8GSpu24JARZKCeVVJCRlyjohtmJ9aSGwC EPxuNxAhQiPuJJK0073bnZtFv/cexPWNWzJS5x4uvS7gGCXVGDgHBEeqKaGXjUiJ5NyT zFqvoyNxYKdG/GnLZNKAqCjDhwvw/C+MY8fz+/E/5sotNG2JVvDrIU2NfTs9JMlQ5XJg nWpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TMCUhKkp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l11-20020a67b74b000000b00357b692a25dsi304138vsh.561.2022.07.21.09.07.21; Thu, 21 Jul 2022 09:07:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TMCUhKkp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232644AbiGUPib (ORCPT + 99 others); Thu, 21 Jul 2022 11:38:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232018AbiGUPhz (ORCPT ); Thu, 21 Jul 2022 11:37:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8EAF088CE8 for ; Thu, 21 Jul 2022 08:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658417829; 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=amsqiHjbAkA62MGJKMEme7kdXdh0SccxhuiEsDXQqww=; b=TMCUhKkpdBHtIvnVboIHxwsxTkR6Lo2yqljwfE3OiM6HIrfTalrGQL4qhYdIe2ZNhwH2vT km1cv81fxPZnbFOII0jEzhs2cc1iS2Af/IajtTow2+/LCQFbAxGL5xxu5uyJntl+1qxKp1 bShOPdGR3ykyHpjdNsi6aySvfveoU24= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-195-aoCAAWRqMCKM7Y8nB13CzA-1; Thu, 21 Jul 2022 11:37:00 -0400 X-MC-Unique: aoCAAWRqMCKM7Y8nB13CzA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D1E5811E80; Thu, 21 Jul 2022 15:36:59 +0000 (UTC) Received: from plouf.redhat.com (unknown [10.39.194.200]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB41D2166B26; Thu, 21 Jul 2022 15:36:55 +0000 (UTC) From: Benjamin Tissoires To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , Kumar Kartikeya Dwivedi , John Fastabend , KP Singh , Shuah Khan , Dave Marchevsky , Joe Stringer , Jonathan Corbet Cc: Tero Kristo , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, Benjamin Tissoires Subject: [PATCH bpf-next v7 08/24] libbpf: add map_get_fd_by_id and map_delete_elem in light skeleton Date: Thu, 21 Jul 2022 17:36:09 +0200 Message-Id: <20220721153625.1282007-9-benjamin.tissoires@redhat.com> In-Reply-To: <20220721153625.1282007-1-benjamin.tissoires@redhat.com> References: <20220721153625.1282007-1-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 This allows to have a better control over maps from the kernel when preloading eBPF programs. Acked-by: Yonghong Song Signed-off-by: Benjamin Tissoires --- no changes in v7 no changes in v6 new in v5 --- tools/lib/bpf/skel_internal.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/lib/bpf/skel_internal.h b/tools/lib/bpf/skel_internal.h index bd6f4505e7b1..bc1db60ad744 100644 --- a/tools/lib/bpf/skel_internal.h +++ b/tools/lib/bpf/skel_internal.h @@ -251,6 +251,29 @@ static inline int skel_map_update_elem(int fd, const void *key, return skel_sys_bpf(BPF_MAP_UPDATE_ELEM, &attr, attr_sz); } +static inline int skel_map_delete_elem(int fd, const void *key) +{ + const size_t attr_sz = offsetofend(union bpf_attr, flags); + union bpf_attr attr; + + memset(&attr, 0, attr_sz); + attr.map_fd = fd; + attr.key = (long)key; + + return skel_sys_bpf(BPF_MAP_DELETE_ELEM, &attr, attr_sz); +} + +static inline int skel_map_get_fd_by_id(__u32 id) +{ + const size_t attr_sz = offsetofend(union bpf_attr, flags); + union bpf_attr attr; + + memset(&attr, 0, attr_sz); + attr.map_id = id; + + return skel_sys_bpf(BPF_MAP_GET_FD_BY_ID, &attr, attr_sz); +} + static inline int skel_raw_tracepoint_open(const char *name, int prog_fd) { const size_t attr_sz = offsetofend(union bpf_attr, raw_tracepoint.prog_fd); -- 2.36.1