Skip to contentSkip to conversation

dumpcap: fix select interface

PATCH Superseded Arshdeep Kaur 3 participants 7 messages Oct 14, 2022 – Oct 21, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dumpcap: fix select interface

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 cbb44143be74 ("app/dumpcap: add new packet capture application")
---
 app/dumpcap/main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
app/dumpcap/main.c +7 -1
index e0a3477d91..11a44ecce4 100644
@@ -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_interface)
+		select_interface(interface_arg);
+
 	if (filter_str)
 		compile_filter();
 
Signature · 1 line
2.37.1
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · On Fri, 14 Oct 2022 13:33:25 -0700 Arshdeep Kaur <[email protected]>…

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 cbb44143be74 ("app/dumpcap: add new packet capture application")

The right fixes line would be when the order of init changed:

Fixes a8dde09f97df ("app/dumpcap: allow help/version without primary process")
#2 lore raw

PATCH v2 1/1 dumpcap: fix select interface

In reply to Arshdeep Kaur

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")
---
 app/dumpcap/main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
app/dumpcap/main.c +7 -1
index e0a3477d91..11a44ecce4 100644
@@ -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_interface)
+		select_interface(interface_arg);
+
 	if (filter_str)
 		compile_filter();
 
Signature · 1 line
2.37.1
#3 lore raw

PATCH v3 1/1 dumpcap: fix select interface

Fixed compilation error.

Fixes a8dde09f97df ("app/dumpcap: allow help/version without primary process")
---
 app/dumpcap/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/dumpcap/main.c +1 -1
index 11a44ecce4..143c93940d 100644
@@ -799,7 +799,7 @@ int main(int argc, char **argv)
 	if (rte_eth_dev_count_avail() == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports found\n");
 
-	if (select_interface)
+	if (select_interfaces)
 		select_interface(interface_arg);
 
 	if (filter_str)
Signature · 1 line
2.37.1
#4 lore raw

PATCH v4 1/1 dumpcap: fix select interface

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")
---
 app/dumpcap/main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
app/dumpcap/main.c +7 -1
index e0a3477d91..143c93940d 100644
@@ -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();
 
Signature · 1 line
2.37.1
#6 lore raw
Quoted 8 lines · Stephen Hemminger
Quoted 5 lines · On Mon, 17 Oct 2022 05:07:52 -0700 Arshdeep Kaur <[email protected]>…

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")
Quoted 3 lines
Quoted 2 lines

Applied, thanks.

Signature · 1 line
David Marchand