From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 12889A0560;
	Mon, 17 Oct 2022 14:09:27 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id ED8E54021D;
	Mon, 17 Oct 2022 14:09:26 +0200 (CEST)
Received: from mga17.intel.com (mga17.intel.com [192.55.52.151])
 by mails.dpdk.org (Postfix) with ESMTP id 02D6940143
 for <dev@dpdk.org>; Mon, 17 Oct 2022 14:09:24 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1666008565; x=1697544565;
 h=from:to:subject:date:message-id:in-reply-to:references:
 mime-version:content-transfer-encoding;
 bh=hD0UK7K55K3XIZkcMlXyIvwtmqnxJLtCjb2HeBFRWjk=;
 b=a7rN7uin2lggDRgbvD20IS++KlnS2AJoS+kiUSuTeTpkXXoo8CmM2q+j
 2DEOIwhGoUkqTL/lSoDAG+M6HGaAswEXKBD+oS4tF86A+/tax6nrW/IJt
 53s2TA/LR+yGat9Ggbu/vLTMv9kiL4ZcAHlEP2h19zH7KMOkE6Qezi099
 /fX3GrxNr8HC7BOupxGV2/Ucu27yXwu56i3kDbIrAqHerQep+O8kVkSXQ
 gFqKDWqrhgbigLAQ90YRxVYeUBHrscd4bxRbnpzZ9R52J4Xv8lx44IY30
 5hvnpMVKbBwSCYdvfproOQsmC2RWyFXt7HrtGxKWAhTkOJPfyjQfxa4AP A==;
X-IronPort-AV: E=McAfee;i="6500,9779,10502"; a="286174748"
X-IronPort-AV: E=Sophos;i="5.95,191,1661842800"; d="scan'208";a="286174748"
Received: from fmsmga002.fm.intel.com ([10.253.24.26])
 by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 17 Oct 2022 05:09:24 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=McAfee;i="6500,9779,10502"; a="733134817"
X-IronPort-AV: E=Sophos;i="5.95,191,1661842800"; d="scan'208";a="733134817"
Received: from unknown (HELO skx-5gnr-sd6.localdomain) ([10.233.180.92])
 by fmsmga002.fm.intel.com with ESMTP; 17 Oct 2022 05:09:23 -0700
From: Arshdeep Kaur <arshdeep.kaur@intel.com>
To: dev@dpdk.org
Subject: [PATCH v4] dumpcap: fix select interface
Date: Mon, 17 Oct 2022 05:07:52 -0700
Message-Id: <20221017120752.154761-1-arshdeep.kaur@intel.com>
X-Mailer: git-send-email 2.37.1
In-Reply-To: <20221017115655.151909-1-arshdeep.kaur@intel.com>
References: <20221017115655.151909-1-arshdeep.kaur@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

The change to do argument process before EAL init broke
the support of select-interface option. Fix by setting flag
and doing select-interface later.

Fixes: a8dde09f97df ("app/dumpcap: allow help/version without primary process")

Signed-off-by: Arshdeep Kaur <arshdeep.kaur@intel.com>
---
 app/dumpcap/main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index e0a3477d91..143c93940d 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -64,6 +64,8 @@ static const char *capture_comment;
 static uint32_t snaplen = RTE_MBUF_DEFAULT_BUF_SIZE;
 static bool dump_bpf;
 static bool show_interfaces;
+static bool select_interfaces;
+const char *interface_arg;
 
 static struct {
 	uint64_t  duration;	/* nanoseconds */
@@ -370,7 +372,8 @@ static void parse_opts(int argc, char **argv)
 			usage();
 			exit(0);
 		case 'i':
-			select_interface(optarg);
+			select_interfaces = true;
+			interface_arg = optarg;
 			break;
 		case 'n':
 			use_pcapng = true;
@@ -796,6 +799,9 @@ int main(int argc, char **argv)
 	if (rte_eth_dev_count_avail() == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports found\n");
 
+	if (select_interfaces)
+		select_interface(interface_arg);
+
 	if (filter_str)
 		compile_filter();
 
-- 
2.37.1