DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] dumpcap: fix pathname for output file
@ 2022-10-19 18:32 Stephen Hemminger
  2022-10-19 18:52 ` [PATCH v2] " Stephen Hemminger
  2022-10-20 17:28 ` [PATCH v3] " Stephen Hemminger
  0 siblings, 2 replies; 4+ messages in thread
From: Stephen Hemminger @ 2022-10-19 18:32 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

When dumpcap is run with a longer path name such as when
testing, the file prefix would be computed incorrectly.

Also, print out the resulting filename which is what
similar wireshark program does.

Fixes: cbb44143be74 ("app/dumpcap: add new packet capture application")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/dumpcap/main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index e0a3477d912f..9f716b1fbe43 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -637,6 +637,7 @@ static dumpcap_out_t create_output(void)
 	else {
 		mode_t mode = group_read ? 0640 : 0600;
 
+		fprintf(stderr, "File: %s\n", output_name);
 		fd = open(output_name, O_WRONLY | O_CREAT, mode);
 		if (fd < 0)
 			rte_exit(EXIT_FAILURE, "Can not open \"%s\": %s\n",
@@ -784,8 +785,14 @@ int main(int argc, char **argv)
 	struct rte_ring *r;
 	struct rte_mempool *mp;
 	dumpcap_out_t out;
+	char *p;
 
-	progname = argv[0];
+	p = strrchr(argv[0], '/');
+	if (p == NULL)
+		progname = argv[0];
+	else
+		progname = p + 1;
+	printf("progname = '%s'\n", progname);
 
 	parse_opts(argc, argv);
 	dpdk_init();
-- 
2.35.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] dumpcap: fix pathname for output file
  2022-10-19 18:32 [PATCH] dumpcap: fix pathname for output file Stephen Hemminger
@ 2022-10-19 18:52 ` Stephen Hemminger
  2022-10-20 17:28 ` [PATCH v3] " Stephen Hemminger
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2022-10-19 18:52 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

When dumpcap is run with a longer path name such as when
testing, the file prefix would be computed incorrectly.

Also, print out the resulting filename which is what
similar wireshark program does.

Fixes: cbb44143be74 ("app/dumpcap: add new packet capture application")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
v2 - get rid of debug printf

 app/dumpcap/main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index e0a3477d912f..9f716b1fbe43 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -637,6 +637,7 @@ static dumpcap_out_t create_output(void)
 	else {
 		mode_t mode = group_read ? 0640 : 0600;
 
+		fprintf(stderr, "File: %s\n", output_name);
 		fd = open(output_name, O_WRONLY | O_CREAT, mode);
 		if (fd < 0)
 			rte_exit(EXIT_FAILURE, "Can not open \"%s\": %s\n",
@@ -784,8 +785,14 @@ int main(int argc, char **argv)
 	struct rte_ring *r;
 	struct rte_mempool *mp;
 	dumpcap_out_t out;
+	char *p;
 
-	progname = argv[0];
+	p = strrchr(argv[0], '/');
+	if (p == NULL)
+		progname = argv[0];
+	else
+		progname = p + 1;
+	printf("progname = '%s'\n", progname);
 
 	parse_opts(argc, argv);
 	dpdk_init();
-- 
2.35.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3] dumpcap: fix pathname for output file
  2022-10-19 18:32 [PATCH] dumpcap: fix pathname for output file Stephen Hemminger
  2022-10-19 18:52 ` [PATCH v2] " Stephen Hemminger
@ 2022-10-20 17:28 ` Stephen Hemminger
  2022-10-21 13:07   ` David Marchand
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2022-10-20 17:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

When dumpcap is run with a longer path name such as when
testing, the file prefix would be computed incorrectly.

Also, print out the resulting filename which is what
similar wireshark program does.

Fixes: cbb44143be74 ("app/dumpcap: add new packet capture application")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
v3 - get rid of printf

 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 e0a3477d912f..32d97df3aafa 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -637,6 +637,7 @@ static dumpcap_out_t create_output(void)
 	else {
 		mode_t mode = group_read ? 0640 : 0600;
 
+		fprintf(stderr, "File: %s\n", output_name);
 		fd = open(output_name, O_WRONLY | O_CREAT, mode);
 		if (fd < 0)
 			rte_exit(EXIT_FAILURE, "Can not open \"%s\": %s\n",
@@ -784,8 +785,13 @@ int main(int argc, char **argv)
 	struct rte_ring *r;
 	struct rte_mempool *mp;
 	dumpcap_out_t out;
+	char *p;
 
-	progname = argv[0];
+	p = strrchr(argv[0], '/');
+	if (p == NULL)
+		progname = argv[0];
+	else
+		progname = p + 1;
 
 	parse_opts(argc, argv);
 	dpdk_init();
-- 
2.35.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] dumpcap: fix pathname for output file
  2022-10-20 17:28 ` [PATCH v3] " Stephen Hemminger
@ 2022-10-21 13:07   ` David Marchand
  0 siblings, 0 replies; 4+ messages in thread
From: David Marchand @ 2022-10-21 13:07 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

On Thu, Oct 20, 2022 at 7:29 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> When dumpcap is run with a longer path name such as when
> testing, the file prefix would be computed incorrectly.
>
> Also, print out the resulting filename which is what
> similar wireshark program does.
>
> Fixes: cbb44143be74 ("app/dumpcap: add new packet capture application")
Cc: stable@dpdk.org

> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Applied, thanks.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-21 13:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19 18:32 [PATCH] dumpcap: fix pathname for output file Stephen Hemminger
2022-10-19 18:52 ` [PATCH v2] " Stephen Hemminger
2022-10-20 17:28 ` [PATCH v3] " Stephen Hemminger
2022-10-21 13:07   ` David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).