Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp827450iob; Wed, 18 May 2022 14:01:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4AOy+0F48w9cczdi5ieAJPsa3U3Ll2zOOXoateXm9eSVZuGFQ/i9TrJF+1A+0reUJ7Rjr X-Received: by 2002:a17:902:b692:b0:14c:935b:2b03 with SMTP id c18-20020a170902b69200b0014c935b2b03mr1413726pls.81.1652907694222; Wed, 18 May 2022 14:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652907694; cv=none; d=google.com; s=arc-20160816; b=XtICqE2AmAQzp32H1Oaf8kEvTK2MaQtfeWe/JQ79xKz/EDgpoAJBe0OMB/IunVc19w gujaM4J09HJKKBrlaFBQsjKU3ImZ0WTvOEJ8YFi4SMkuY+ZJwLRkf5PunsX9JrDdQ7TG EdzJ7Dhxvg6Ps+Tfhmzpq8p6viQER1QwaHV4kkVb6WlunYd5q3c1T48LNIf50EFYCUZG orB201tZKYo0RhiEW/Nl5VuRJmYNzqdUHha3iWjF7reQVX2HqOK+6c8W4wg7wfOgYQX6 XQgmTAaoI0BxecZWvtOocodVtUih7nGi3str8Utd1c4x+99JUXn2EPENrNIu8JuZ+/eE GfaA== 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=U+niHEoMuTDRFqut4OdKlEaLEgHKW232XIT+7USRZJg=; b=zuvv0cYHHtgfqB8jbiZcWxYYdnAup3Kc1NP9N0iiQ9KlkyGo4cWqWpLU4BBxW/omBy FlwZ7bzBE7MHsJWHrAn7UAEaQkYIjMuECk8tySBc9zbtfjCyudAPNIwUCdcsW+6l8LZL ZXRVvUXFX3oXlWv/gDvAnWeJTlLjU6pdf4WkbvaXzFouIFnQTodMzcVo2A02B19X6Bfr /xhCKszsfcZ3DwEzjY3jHg96UHW/tV2ZFqXu7MNOaoMv2W6FgGHnkbHrsvs3rvBWu3ji OR3tpNYx3xV6gF6oH9nPiebI2QEEWrgiiTod/doWoJAFolQUQWteX1T/lRBxlXbh5/QZ /O0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hPMao2+g; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 24-20020a631958000000b003db141baf83si3271678pgz.480.2022.05.18.14.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 14:01:34 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hPMao2+g; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D303C2555B9; Wed, 18 May 2022 14:00:15 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242923AbiERVAG (ORCPT + 99 others); Wed, 18 May 2022 17:00:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242873AbiERU7y (ORCPT ); Wed, 18 May 2022 16:59:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 34E53253AB8 for ; Wed, 18 May 2022 13:59:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652907592; 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=U+niHEoMuTDRFqut4OdKlEaLEgHKW232XIT+7USRZJg=; b=hPMao2+gimeGuVhVy6iALMGI+PGbjtx514MUb2z4QmQJFcb7WdetC+XOwtQhnVZ0b/ZLVY cr9EBgqUZFFKi7LH8dZqJraAR6OUM97tUUUY/xtEqO9LBrroK4P+IQAza/rZC8diDIdB93 P5rR2rbnNUKW4mofBpA2VacvrRQ7wqM= 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-32-cMpIVQCjNICd9pEeRpcK1g-1; Wed, 18 May 2022 16:59:49 -0400 X-MC-Unique: cMpIVQCjNICd9pEeRpcK1g-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 3F7AE811E83; Wed, 18 May 2022 20:59:48 +0000 (UTC) Received: from plouf.redhat.com (unknown [10.39.192.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9A402166B25; Wed, 18 May 2022 20:59:43 +0000 (UTC) From: Benjamin Tissoires To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , 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 v5 04/17] libbpf: add map_get_fd_by_id and map_delete_elem in light skeleton Date: Wed, 18 May 2022 22:59:11 +0200 Message-Id: <20220518205924.399291-5-benjamin.tissoires@redhat.com> In-Reply-To: <20220518205924.399291-1-benjamin.tissoires@redhat.com> References: <20220518205924.399291-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=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 This allows to have a better control over maps from the kernel when preloading eBPF programs. Signed-off-by: Benjamin Tissoires --- 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