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 A2AD5A04C0; Sun, 17 Nov 2019 18:10:34 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 080B42B86; Sun, 17 Nov 2019 18:10:33 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 55719F04 for ; Sun, 17 Nov 2019 18:10:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574010630; 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; bh=SUT8MCMyT4mHXp22mRyC7yHatYtWPnqkfP5jVGDDD8Y=; b=EvOmrzCURIhblX9XvgaUJ/wk//LOArlIoEQAzpStaEz4hmqDeq6UOrhWRDGCiaM1NJrczk mZD1oAHFdm/UYCratBc4HZ0rWQ1yiwkRpqGK7UwqqsF8PgJGw0z+kysc3i2lLs3dk6Bx5D A5Fpvb8mNr+326cg8QPX1UuiojqxO0w= 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-438-3WQfZAnePv2llWII0zZbOw-1; Sun, 17 Nov 2019 12:10:27 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 860FD477; Sun, 17 Nov 2019 17:10:25 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.205.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1141C61072; Sun, 17 Nov 2019 17:10:22 +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: Sun, 17 Nov 2019 18:10:13 +0100 Message-Id: <20191117171013.17373-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: 3WQfZAnePv2llWII0zZbOw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Subject: [dpdk-dev] [PATCH] app/testpmd: report invalid command line parameter X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- This seems a bit dangerous to take this kind of change. 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. --- 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