From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A6A4C433FE for ; Thu, 16 Jul 2020 16:39:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 188D02065E for ; Thu, 16 Jul 2020 16:39:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=isovalent-com.20150623.gappssmtp.com header.i=@isovalent-com.20150623.gappssmtp.com header.b="JIrzFmjx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729432AbgGPQjv (ORCPT ); Thu, 16 Jul 2020 12:39:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729428AbgGPQju (ORCPT ); Thu, 16 Jul 2020 12:39:50 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6540C08C5C0 for ; Thu, 16 Jul 2020 09:39:49 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id w3so12217525wmi.4 for ; Thu, 16 Jul 2020 09:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=20fCXzpt5xrhYy1Y13gD3+QE2NdQzEx5fXxgZJMqHMA=; b=JIrzFmjxrGCpRUvAIGa3w6dCDS62bwx4fatzmPS/Pt7KZFaI0QOOJDzfWVVK08ekI2 +ojXZwqD0TRI4ODoR/ccLXEfhhmB8xT5HtiO1jQlMNwtHlZKQEDOIRTn1ycZClLTS7i9 uDeY55drkgGr1wmDQx/hp2VI+UYjAm1rPaGMvnm5VaLcXFePDbEQsTg0z2zgYtFC1Ezu RAXvdmdUb45S9fBi6M7PWUAkw3GbB3E4eU+38/4SlCJqdPXJywxOBdCukz09j/oqXmL7 vx6WCS/Kgmq7SCga6sV2c4Wu6sCUCCJHlrAIW6Vg/XscxG0Mf0qGE3jr/1EkEmh1bKBc 9Njw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=20fCXzpt5xrhYy1Y13gD3+QE2NdQzEx5fXxgZJMqHMA=; b=L+ZaGOjVPyN+XMET97dAOYWNlVs2xI6F/CLvVTOxFoYkznQKeatdc+BdgiKXSsWp+u JXpaFkrn0uZnAhISCAIiG90Z4gn6Y+hPM6c7jSsb9s5IOv4y6S/YDnAMwvzhEvELfjVm qWVCM8CqwVBwblA29vZmGaGnztpYAbkT3VysfNhu9nb8QNjlt1nZslEPwBHzztxCDfGg wqrqzshbJCholqRx/qD/cmByduMgRRN8Gp9r48reG5SlrkBsFED+2uy+DcYF1F88a1b5 5M00FmKBEPfBs3abro2/nw8Ehssqk2k9gZoPP7GNL3eIoJBC2Xk4fgn7py/d2xhrR/8y cfVg== X-Gm-Message-State: AOAM533XMdbt4Zjbi5KvfW/3ULcGvDCNrQVHBYaf96dnB1KMXvKK7gYd gtBip8o5f7oXFCVJqwwuwcXyD6Rxukua5eGq X-Google-Smtp-Source: ABdhPJz4xSCI0ZITQq2yaFpHxbVW+beJsF/461Fz0KP7tEPiYoIYNhwY+BBGt/691TccxBy8mQDP+Q== X-Received: by 2002:a1c:a7c4:: with SMTP id q187mr5025307wme.0.1594917588433; Thu, 16 Jul 2020 09:39:48 -0700 (PDT) Received: from [192.168.1.12] ([194.35.117.51]) by smtp.gmail.com with ESMTPSA id y20sm9228648wmi.8.2020.07.16.09.39.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Jul 2020 09:39:47 -0700 (PDT) Subject: Re: [PATCH bpf-next 09/13] tools/bpftool: add bpftool support for bpf map element iterator To: Yonghong Song , bpf@vger.kernel.org, netdev@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , kernel-team@fb.com, Martin KaFai Lau References: <20200713161739.3076283-1-yhs@fb.com> <20200713161749.3077526-1-yhs@fb.com> From: Quentin Monnet Message-ID: <9f865c02-291c-8622-b601-f4613356a469@isovalent.com> Date: Thu, 16 Jul 2020 17:39:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200713161749.3077526-1-yhs@fb.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org 2020-07-13 09:17 UTC-0700 ~ Yonghong Song > The optional parameter "map MAP" can be added to "bpftool iter" > command to create a bpf iterator for map elements. For example, > bpftool iter pin ./prog.o /sys/fs/bpf/p1 map id 333 > > For map element bpf iterator "map MAP" parameter is required. > Otherwise, bpf link creation will return an error. > > Signed-off-by: Yonghong Song > --- > .../bpftool/Documentation/bpftool-iter.rst | 16 ++++++++-- > tools/bpf/bpftool/iter.c | 32 ++++++++++++++++--- > 2 files changed, 42 insertions(+), 6 deletions(-) > > diff --git a/tools/bpf/bpftool/Documentation/bpftool-iter.rst b/tools/bpf/bpftool/Documentation/bpftool-iter.rst > index 8dce698eab79..53ee4fb188b4 100644 > --- a/tools/bpf/bpftool/Documentation/bpftool-iter.rst > +++ b/tools/bpf/bpftool/Documentation/bpftool-iter.rst > @@ -17,14 +17,15 @@ SYNOPSIS > ITER COMMANDS > =================== > > -| **bpftool** **iter pin** *OBJ* *PATH* > +| **bpftool** **iter pin** *OBJ* *PATH* [**map** *MAP*] > | **bpftool** **iter help** > | > | *OBJ* := /a/file/of/bpf_iter_target.o > +| *MAP* := { **id** *MAP_ID* | **pinned** *FILE* } Please don't change the indentation style (other lines have a tab). > > DESCRIPTION > =========== > - **bpftool iter pin** *OBJ* *PATH* > + **bpftool iter pin** *OBJ* *PATH* [**map** *MAP*] > A bpf iterator combines a kernel iterating of > particular kernel data (e.g., tasks, bpf_maps, etc.) > and a bpf program called for each kernel data object > @@ -37,6 +38,10 @@ DESCRIPTION > character ('.'), which is reserved for future extensions > of *bpffs*. > > + Map element bpf iterator requires an additional parameter > + *MAP* so bpf program can iterate over map elements for > + that map. > + Same note on indentation. Could you please also explain in a few words what the "Map element bpf iterator" is? Reusing part of your cover letter (see below) could do, it's just so that users not familiar with the concept can get an idea of what it does. --- User can have a bpf program in kernel to run with each map element, do checking, filtering, aggregation, etc. without copying data to user space. --- > User can then *cat PATH* to see the bpf iterator output. > > **bpftool iter help** [...] > @@ -62,13 +83,16 @@ static int do_pin(int argc, char **argv) > bpf_link__destroy(link); > close_obj: > bpf_object__close(obj); > +close_map_fd: > + if (map_fd >= 0) > + close(map_fd); > return err; > } > > static int do_help(int argc, char **argv) > { > fprintf(stderr, > - "Usage: %1$s %2$s pin OBJ PATH\n" > + "Usage: %1$s %2$s pin OBJ PATH [map MAP]\n" You probably want to add HELP_SPEC_MAP (as in map.c) to tell the user what MAP should be. Could you please also update the bash completion? Thanks, Quentin