From patchwork Sun Sep 25 23:34:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 116832 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 00C43A00C3; Mon, 26 Sep 2022 01:34:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9F236400D5; Mon, 26 Sep 2022 01:34:15 +0200 (CEST) Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by mails.dpdk.org (Postfix) with ESMTP id E322F400D4 for ; Mon, 26 Sep 2022 01:34:13 +0200 (CEST) Received: by mail-pj1-f43.google.com with SMTP id rt12so4771442pjb.1 for ; Sun, 25 Sep 2022 16:34:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=EjGn1mxlYmALNp5KEL6hNCCeEcdCsa4JnCFg9i+YDKU=; b=YCwjPwgTcrdhZq7yFh2WoFnPROw3xJmh109/ULrm9TIv01wMBLV1pT66Abg3Nr2r8q xlXjaegfY0dW5gj4kCHaGHC4brkXqN78tays0KLowrUde5Wc3HQFUEOVTVTKu9JJyFjN lWsh4XWIf1nEfQoML8Ilvbq7Y1iFcwqU46f/NbrCi2lut37Cat6n0WCAnNxvZl6s3CKC IV1JWrnMKuDk1YbJR1HTp3LwL4VCyqPij3OECTZ6j1tr37wCP6r7JcyBwH2ZUS/afstX UF9ntALDYiPjuwcZWJpW64Ut35z1PLNA7ORSo79+683F1TfP6zC/J703sQ+1XdeJ+U3L 0l/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=EjGn1mxlYmALNp5KEL6hNCCeEcdCsa4JnCFg9i+YDKU=; b=4SkEeyqg1QAL7hlAAy7/Ui2rcywem8B5Tid1GCvpEIlGffRFAPDqTu3PQ/DPtxvRwX euovh3j9GEwYMnY4AN7Tlx7gvaEwTjXTdHKCXsih6qIjVDd90eJVyxQHZ8Ihx6KytFAP QKdw5SWcG2DpALbs5WztPOmuq97PI70oZ8FUSmvEyHBVZd8JyULooNhNa/slSOenCTz9 CJ98YKdcDQaFuatCRxC0gBmXoE21KB+9LfoES6W8b3oTSghdQlf6frPHthR5LRHoCjU3 bxGW7ntXoIIX019jXiQ4N6+6f0D4WzSPIj/xM7bwcYCay3ihvcZml9ATbJAdVUrdqwEL 1mlw== X-Gm-Message-State: ACrzQf0bEvWNFW4ifRBE5bno54kIICBTLHUG7Bp8mv8Q7udw/1jjjQ3L VZWG/JJxO5J6wj6ALSMGzt5TgstsOzClGQ== X-Google-Smtp-Source: AMsMyM5HPhAgkBXerYt3gfWgwORWBdc6rBnA1InpkCiqIPIqg+O/ImKOjCXBpmQov/+x1cKwFbzNNA== X-Received: by 2002:a17:90b:4d82:b0:202:9030:e482 with SMTP id oj2-20020a17090b4d8200b002029030e482mr34295345pjb.110.1664148852707; Sun, 25 Sep 2022 16:34:12 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id t31-20020a63445f000000b00412a708f38asm9434437pgk.35.2022.09.25.16.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 16:34:12 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , koncept1@gmail.com, Reshma Pattan Subject: [PATCH] dumpcap: fix list interfaces Date: Sun, 25 Sep 2022 16:34:10 -0700 Message-Id: <20220925233410.98051-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The change to do argument process before EAL init broke the support of list-interfaces option. Fix by setting flag and doing list-interfaces later. Fixes: a8dde09f97df ("app/dumpcap: allow help/version without primary process") Cc: koncept1@gmail.com Signed-off-by: Stephen Hemminger Acked-by: Reshma Pattan --- app/dumpcap/main.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c index a6041d4ff495..490a0f050bc8 100644 --- a/app/dumpcap/main.c +++ b/app/dumpcap/main.c @@ -63,6 +63,8 @@ static unsigned int ring_size = 2048; static const char *capture_comment; static uint32_t snaplen = RTE_MBUF_DEFAULT_BUF_SIZE; static bool dump_bpf; +static bool show_interfaces; + static struct { uint64_t duration; /* nanoseconds */ unsigned long packets; /* number of packets in file */ @@ -256,7 +258,7 @@ static void select_interface(const char *arg) } /* Display list of possible interfaces that can be used. */ -static void show_interfaces(void) +static void dump_interfaces(void) { char name[RTE_ETH_NAME_MAX_LEN]; uint16_t p; @@ -266,6 +268,8 @@ static void show_interfaces(void) continue; printf("%u. %s\n", p, name); } + + exit(0); } static void compile_filter(void) @@ -353,8 +357,8 @@ static void parse_opts(int argc, char **argv) dump_bpf = true; break; case 'D': - show_interfaces(); - exit(0); + show_interfaces = true; + break; case 'f': filter_str = optarg; break; @@ -529,9 +533,6 @@ static void dpdk_init(void) if (rte_eal_init(eal_argc, eal_argv) < 0) rte_exit(EXIT_FAILURE, "EAL init failed: is primary process running?\n"); - - if (rte_eth_dev_count_avail() == 0) - rte_exit(EXIT_FAILURE, "No Ethernet ports found\n"); } /* Create packet ring shared between callbacks and process */ @@ -789,6 +790,12 @@ int main(int argc, char **argv) parse_opts(argc, argv); dpdk_init(); + if (show_interfaces) + dump_interfaces(); + + if (rte_eth_dev_count_avail() == 0) + rte_exit(EXIT_FAILURE, "No Ethernet ports found\n"); + if (filter_str) compile_filter();