Message ID | 1668517207-11822-1-git-send-email-yangtiezhu@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2716094wru; Tue, 15 Nov 2022 05:11:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf76ibgq81Ki1kWeUqPmWmUz48kX9bFv5gsiiLvV1IqSnIGAEf9zphs+xbiX1PwppphDlkOg X-Received: by 2002:a63:f504:0:b0:470:60a5:146d with SMTP id w4-20020a63f504000000b0047060a5146dmr16402516pgh.156.1668517889550; Tue, 15 Nov 2022 05:11:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668517889; cv=none; d=google.com; s=arc-20160816; b=Sf0ed1HOR6SnHA3C3HFy3budmBHzPKIA1ZYfNBdp8bWGb09KHg59YOEKiHXjMVzVWo QnZjafxm3vt6LFBF2lgeXUVhWYdJK2LJOjmhtKitIeQkPP3kWhP4hGifQ4QD76RdWLA5 kuE8/cHeFgEJsxINgdEJRF8HurIUAszFbq72EXDcr1vT/stQprtNFo3DDxQgnz8CGY3d QqrYn5ULTcj9mttbn55EIX0/jsRFY+La/DpCvR+vfJGgWO607sS5awFOBBZ+ayl3gdEd kNb3Csfbu7t1jwEWdNZnSSI9RXjOv262LcWtJ92qmyVupYWOncUaDN527hoq4MyCiuGN oJqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=IrI66gzIUkd4c6KrDWqf7dXXIr+fHA/D2YeP8XUJxnA=; b=NTsClwnVkClwByd67MQt5CV2/I6U0PKqt8+ikevxkg4W1NVr3fBuRzrPYp+RykBnYM FnEeXNW4ZpkclHVx2Yry2W2D7O6CP/rb640OFogmbKzC9C30ERUhj3AbOiKj+1jTajR0 zdUmjZHfhyBmMGHXUXhTn+UxUD4FdGq5fOLSQyqO0UaWy+57+UPHqsdb/cNz2TusdQCO bMv6/CQqu+l3mA+tMBspEQNpMXPJYShSZuCOtwvxOzuTJUVIXtgpWZAUq3hdMwit7ZQB aW4v7emfcxua36GNG/IaN79uOjTKe93Zwt7BJp7tkTrZPWzzN1qjpqYACQSrH/P4FQC6 Iuag== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v25-20020a637a19000000b0044ed36e4c57si12743648pgc.217.2022.11.15.05.10.56; Tue, 15 Nov 2022 05:11:29 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230468AbiKONAN (ORCPT <rfc822;lkml4gm@gmail.com> + 99 others); Tue, 15 Nov 2022 08:00:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbiKONAL (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 15 Nov 2022 08:00:11 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 93BFD63C9; Tue, 15 Nov 2022 05:00:09 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8AxDdlYjXNjuEQHAA--.21336S3; Tue, 15 Nov 2022 21:00:08 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxHuJXjXNjIaQTAA--.52645S2; Tue, 15 Nov 2022 21:00:07 +0800 (CST) From: Tiezhu Yang <yangtiezhu@loongson.cn> To: Quentin Monnet <quentin@isovalent.com>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Andrii Nakryiko <andrii@kernel.org> Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v2] bpftool: Check argc first before "file" in do_batch() Date: Tue, 15 Nov 2022 21:00:07 +0800 Message-Id: <1668517207-11822-1-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf8BxHuJXjXNjIaQTAA--.52645S2 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvdXoW7JF4fWF43WFy5Aw4DKF47XFb_yoWDXrX_ua 9xXF1avFn5Jryakr47W3yq9ryxKa1rArsYqrZI9r18Jr48J3y7ZF18C395Xw45uFyjk3W2 yFZ3u34fGF129jkaLaAFLSUrUUUUbb8apTn2vfkv8UJUUUU8wcxFpf9Il3svdxBIdaVrn0 xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3UjIYCTnIWjp_UUUY 87kC6x804xWl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3w AFIxvE14AKwVWUXVWUAwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK 6xIIjxv20xvE14v26r1I6r4UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r1j6r4UM28EF7 xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Cr1j6rxdM2AI xVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64 kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVWxJVW8Jr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s 026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_ JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14 v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xva j40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JV W8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU1A9N7UUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749567815050424370?= X-GMAIL-MSGID: =?utf-8?q?1749567815050424370?= |
Series |
[bpf-next,v2] bpftool: Check argc first before "file" in do_batch()
|
|
Commit Message
Tiezhu Yang
Nov. 15, 2022, 1 p.m. UTC
If the parameters for batch are more than 2, check argc first can
return immediately, no need to use is_prefix() to check "file" with
a little overhead and then check argc, it is better to check "file"
only when the parameters for batch are 2.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
tools/bpf/bpftool/main.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On 11/15, Tiezhu Yang wrote: > If the parameters for batch are more than 2, check argc first can > return immediately, no need to use is_prefix() to check "file" with > a little overhead and then check argc, it is better to check "file" > only when the parameters for batch are 2. > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Acked-by: Stanislav Fomichev <sdf@google.com> > --- > tools/bpf/bpftool/main.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c > index 741e50e..337ab79 100644 > --- a/tools/bpf/bpftool/main.c > +++ b/tools/bpf/bpftool/main.c > @@ -337,12 +337,12 @@ static int do_batch(int argc, char **argv) > if (argc < 2) { > p_err("too few parameters for batch"); > return -1; > - } else if (!is_prefix(*argv, "file")) { > - p_err("expected 'file', got: %s", *argv); > - return -1; > } else if (argc > 2) { > p_err("too many parameters for batch"); > return -1; > + } else if (!is_prefix(*argv, "file")) { > + p_err("expected 'file', got: %s", *argv); > + return -1; > } > NEXT_ARG(); > -- > 2.1.0
On Tue, 15 Nov 2022 at 18:42, <sdf@google.com> wrote: > > On 11/15, Tiezhu Yang wrote: > > If the parameters for batch are more than 2, check argc first can > > return immediately, no need to use is_prefix() to check "file" with > > a little overhead and then check argc, it is better to check "file" > > only when the parameters for batch are 2. > > > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> > > Acked-by: Stanislav Fomichev <sdf@google.com> Reviewed-by: Quentin Monnet <quentin@isovalent.com> Thanks
Hello: This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <ast@kernel.org>: On Tue, 15 Nov 2022 21:00:07 +0800 you wrote: > If the parameters for batch are more than 2, check argc first can > return immediately, no need to use is_prefix() to check "file" with > a little overhead and then check argc, it is better to check "file" > only when the parameters for batch are 2. > > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> > > [...] Here is the summary with links: - [bpf-next,v2] bpftool: Check argc first before "file" in do_batch() https://git.kernel.org/bpf/bpf-next/c/df9c41e9db2d You are awesome, thank you!
diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c index 741e50e..337ab79 100644 --- a/tools/bpf/bpftool/main.c +++ b/tools/bpf/bpftool/main.c @@ -337,12 +337,12 @@ static int do_batch(int argc, char **argv) if (argc < 2) { p_err("too few parameters for batch"); return -1; - } else if (!is_prefix(*argv, "file")) { - p_err("expected 'file', got: %s", *argv); - return -1; } else if (argc > 2) { p_err("too many parameters for batch"); return -1; + } else if (!is_prefix(*argv, "file")) { + p_err("expected 'file', got: %s", *argv); + return -1; } NEXT_ARG();