From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3B88EA0350 for ; Mon, 18 Nov 2019 16:37:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1D2632B87; Mon, 18 Nov 2019 16:37:33 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 3F35C2142 for ; Mon, 18 Nov 2019 16:37:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574091451; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eT73Yk9GQK1HqPcO1uaaYjGXBGlNweCMaAUUIEJKKnk=; b=eb3YLGmAjhQo1HN/Yv/qYJkIUmfRzTcJG2391/A3DOvLDytdhFSF8q4vOTzB0OmqpPkQSe GOttI6paMMixGLWew4d3Kvd7s/TfCF6EkVm3mPl4Uz7dyk+KZeMk4tctO8dMhi7MltdLul lcEz83gZig5Qq9rPw4WT4iyy4JBAuTQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-212-MkheZB3RMma5kd0WXLGBKA-1; Mon, 18 Nov 2019 10:37:28 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 690CA109993E; Mon, 18 Nov 2019 15:37:26 +0000 (UTC) Received: from dmarchan.remote.csb (ovpn-204-42.brq.redhat.com [10.40.204.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21B5E5DDAA; Mon, 18 Nov 2019 15:37:23 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@intel.com, stable@dpdk.org, Wenzhuo Lu , Jingjing Wu , Bernard Iremonger Date: Mon, 18 Nov 2019 16:37:14 +0100 Message-Id: <20191118153714.17610-1-david.marchand@redhat.com> In-Reply-To: <20191117171013.17373-1-david.marchand@redhat.com> References: <20191117171013.17373-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: MkheZB3RMma5kd0WXLGBKA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] [PATCH v2] app/testpmd: report invalid command line parameter X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" We currently do not check that a non option string has been passed to testpmd. Example: $ ./master/app/testpmd --no-huge -m 512 --vdev net_null0 \ =09--vdev net_null1 -- -i nb-cores=3D2 --total-num-mbuf 2048 [...] testpmd> show config fwd io packet forwarding - ports=3D2 - cores=3D1 - streams=3D2 - NUMA support enabled, MP allocation mode: native Logical Core 1 (socket 0) forwards packets on 2 streams: RX P=3D0/Q=3D0 (socket 0) -> TX P=3D1/Q=3D0 (socket 0) peer=3D02:00:00:00= :00:01 RX P=3D1/Q=3D0 (socket 0) -> TX P=3D0/Q=3D0 (socket 0) peer=3D02:00:00:00= :00:00 Here nb-cores=3D2 is just ignored, while the (probably sleepy) user did not notice this. Validate that all strings passed to testpmd are part of a known option. After this patch: $ ./master/app/testpmd --no-huge -m 512 --vdev net_null0 \ =09--vdev net_null1 -- -i nb-cores=3D2 --total-num-mbuf 2048 [...] Invalid parameter: nb-cores=3D2 EAL: Error - exiting with code: 1 Cause: Command line incorrect While at it, when passing an unknown option, print the string that gets refused by getopt_long to help the user. Fixes: af75078fece3 ("first public release") Cc: stable@dpdk.org Signed-off-by: David Marchand Reviewed-by: Ferruh Yigit --- This seems a bit dangerous to take this kind of change this late. Some "working fine" scripts might now report failures from testpmd because of garbage in the command line. Sending the patch anyway to see what others think about it. Changelog since v1: - fixed example in commitlog, --- app/test-pmd/parameters.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index deca7a6828..2e7a504415 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -1363,12 +1363,19 @@ launch_args_parse(int argc, char** argv) =09=09=09break; =09=09default: =09=09=09usage(argv[0]); +=09=09=09printf("Invalid option: %s\n", argv[optind]); =09=09=09rte_exit(EXIT_FAILURE, =09=09=09=09 "Command line is incomplete or incorrect\n"); =09=09=09break; =09=09} =09} =20 +=09if (optind !=3D argc) { +=09=09usage(argv[0]); +=09=09printf("Invalid parameter: %s\n", argv[optind]); +=09=09rte_exit(EXIT_FAILURE, "Command line is incorrect\n"); +=09} + =09/* Set offload configuration from command line parameters. */ =09rx_mode.offloads =3D rx_offloads; =09tx_mode.offloads =3D tx_offloads; --=20 2.23.0