Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp630612rwe; Wed, 24 Aug 2022 06:46:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR6g7ddT8nG0EWZjZNd9JjuFjp4JCl0afIWzRnxdxnBnosONuRfh3gne1fIzMPr6TdNiNNoU X-Received: by 2002:a17:907:1de8:b0:73d:65a5:e99a with SMTP id og40-20020a1709071de800b0073d65a5e99amr2858009ejc.135.1661348764992; Wed, 24 Aug 2022 06:46:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661348764; cv=none; d=google.com; s=arc-20160816; b=ZSR4pOGmcP5K7gZiYztuVsJJmQIHwiaVs6tqPRHi71b0oOH7+gi0kD7Jug0s1CL1Dq Z+GnvCNFjLoiLVhEfqGxA25ARCnqOO6blhAvWU7M3o61jGiMlzSZEiFFAY5MeR36DGRD cm3VXAs5nTU7DxM5vsaQQhqfdWygBLIBMyXRz1tzWOkeBWFZyCwkcngRY9LZpYME61lO bEds5OL1SElmgwqAvpY0rknV4ow/PP/yclPf4l8aZ0BNescFo2MQ2YXpfxU26ieTQ2BQ 1ne0833nQTOfvgb9bvB+Az3s00M9xzETvBUnuRyCOUu9GQkfknG8q12sF24aGoKSo6pw T/dg== 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=OfbbgckAA8b8IGBbIFhs4TFoQczUT6RAdpeMjlYjV4U=; b=JrXn5ZmZQpli0kz/gYUQd9eFxSdxs0gUP+FTF2E+N1p5ojOAH0K1aAlrljfbL4hbiG CO9mzRmWV5goLnKGmlw24E30c3J3jaLX8+yMxC4Z6ssuZlof8WS16pAGMJen0iiXfaE6 +9ToiKRqwyemU95J+p6J6Z+3FQXnIYXJav73+fjadJwPb8zrLoFb2OFyDTdv3lLkaEul dwsVwTG4oadufv2KHwJQYobfvOHU+JRdDBPNgSPyyC2huZBeInppOtb/tcYV1bzWkkpM aCchyvT7PYtK1ncbRODRnEatd2mKQ5LJgM1wNiO8F276t0RmHsSArp7j+NlQga3M00A1 ztRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="S3v9P/sm"; 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 a65-20020a509ec7000000b0043dd133f9afsi3822015edf.274.2022.08.24.06.45.36; Wed, 24 Aug 2022 06:46:04 -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="S3v9P/sm"; 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 S236726AbiHXNmY (ORCPT + 99 others); Wed, 24 Aug 2022 09:42:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238389AbiHXNmA (ORCPT ); Wed, 24 Aug 2022 09:42:00 -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 ESMTPS id D33F5816BC for ; Wed, 24 Aug 2022 06:41:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661348492; 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=OfbbgckAA8b8IGBbIFhs4TFoQczUT6RAdpeMjlYjV4U=; b=S3v9P/smuCv7vL9nR81sdEuLuxUEO/8L9CWkzBhm8+w/gO0MDoVkcjUi+mnJwwubIhh5nA baa7odOxC5jN2dxzdcPLIEBhB6UEfeuKBVDdxGP0aPa+UqhbUi/QZyc7uQsaUTUJXMpL4d t5cJxpMJOjL+S+QwQWZ4MDy6LLhLBk4= 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-99-1L-DFxkQNKmLF9f2NgWsDQ-1; Wed, 24 Aug 2022 09:41:28 -0400 X-MC-Unique: 1L-DFxkQNKmLF9f2NgWsDQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 72CC785A58A; Wed, 24 Aug 2022 13:41:26 +0000 (UTC) Received: from plouf.redhat.com (unknown [10.39.192.211]) by smtp.corp.redhat.com (Postfix) with ESMTP id 464B518ECC; Wed, 24 Aug 2022 13:41:23 +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 v9 07/23] libbpf: add map_get_fd_by_id and map_delete_elem in light skeleton Date: Wed, 24 Aug 2022 15:40:37 +0200 Message-Id: <20220824134055.1328882-8-benjamin.tissoires@redhat.com> In-Reply-To: <20220824134055.1328882-1-benjamin.tissoires@redhat.com> References: <20220824134055.1328882-1-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Spam-Status: No, score=-2.8 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,T_SCC_BODY_TEXT_LINE 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 v9 no changes in v8 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 00c5f94b43be..1e82ab06c3eb 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