patch 'app/pdump: handle SIGTERM and SIGHUP' has been queued to stable release 21.11.8

Kevin Traynor ktraynor at redhat.com
Fri Aug 23 18:19:17 CEST 2024


Hi,

FYI, your patch has been queued to stable release 21.11.8

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 08/28/24. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/717d90c8b8b7d33deb80fea44df756d9fea29c44

Thanks.

Kevin

---
>From 717d90c8b8b7d33deb80fea44df756d9fea29c44 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen at networkplumber.org>
Date: Wed, 3 Jul 2024 08:45:44 -0700
Subject: [PATCH] app/pdump: handle SIGTERM and SIGHUP

[ upstream commit e1253df666fdc672bc378722db0da2ce3091a8dd ]

The pdump application will leak ring and memory pool if killed
by SIGTERM.  Like dumpcap, the pdump process should cleanup
if process terminates due to being killed or hangup.

Fixes: caa7028276b8 ("app/pdump: add tool for packet capturing")

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 app/pdump/main.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/app/pdump/main.c b/app/pdump/main.c
index 71fd83dada..0986034e44 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -574,11 +574,7 @@ disable_primary_monitor(void)
 
 static void
-signal_handler(int sig_num)
+signal_handler(int sig_num __rte_unused)
 {
-	if (sig_num == SIGINT) {
-		printf("\n\nSignal %d received, preparing to exit...\n",
-				sig_num);
-		quit_signal = 1;
-	}
+	quit_signal = 1;
 }
 
@@ -977,4 +973,9 @@ int
 main(int argc, char **argv)
 {
+	struct sigaction action = {
+		.sa_flags = SA_RESTART,
+		.sa_handler = signal_handler,
+	};
+	struct sigaction origaction;
 	int diag;
 	int ret;
@@ -985,6 +986,12 @@ main(int argc, char **argv)
 	char *argp[argc + 2];
 
-	/* catch ctrl-c so we can print on exit */
-	signal(SIGINT, signal_handler);
+	/* catch ctrl-c so we can cleanup on exit */
+	sigemptyset(&action.sa_mask);
+	sigaction(SIGTERM, &action, NULL);
+	sigaction(SIGINT, &action, NULL);
+	sigaction(SIGPIPE, &action, NULL);
+	sigaction(SIGHUP, NULL, &origaction);
+	if (origaction.sa_handler == SIG_DFL)
+		sigaction(SIGHUP, &action, NULL);
 
 	argp[0] = argv[0];
-- 
2.46.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-08-23 17:18:13.568595568 +0100
+++ 0129-app-pdump-handle-SIGTERM-and-SIGHUP.patch	2024-08-23 17:18:09.892430706 +0100
@@ -1 +1 @@
-From e1253df666fdc672bc378722db0da2ce3091a8dd Mon Sep 17 00:00:00 2001
+From 717d90c8b8b7d33deb80fea44df756d9fea29c44 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit e1253df666fdc672bc378722db0da2ce3091a8dd ]
+
@@ -11 +12,0 @@
-Cc: stable at dpdk.org
@@ -15,2 +16,2 @@
- app/pdump/main.c | 21 +++++++++++++++------
- 1 file changed, 15 insertions(+), 6 deletions(-)
+ app/pdump/main.c | 23 +++++++++++++++--------
+ 1 file changed, 15 insertions(+), 8 deletions(-)
@@ -19 +20 @@
-index 3bdbb8dc78..fa85859703 100644
+index 71fd83dada..0986034e44 100644
@@ -22 +23 @@
-@@ -572,9 +572,7 @@ disable_primary_monitor(void)
+@@ -574,11 +574,7 @@ disable_primary_monitor(void)
@@ -28,0 +30,2 @@
+-		printf("\n\nSignal %d received, preparing to exit...\n",
+-				sig_num);
@@ -34 +37 @@
-@@ -976,4 +974,9 @@ int
+@@ -977,4 +973,9 @@ int
@@ -44 +47 @@
-@@ -984,6 +987,12 @@ main(int argc, char **argv)
+@@ -985,6 +986,12 @@ main(int argc, char **argv)



More information about the stable mailing list