[Bug,1305] testpmd: early exit with tap driver in non interactive mode
Commit Message
https://bugs.dpdk.org/show_bug.cgi?id=1305
Bug ID: 1305
Summary: testpmd: early exit with tap driver in non interactive
mode
Product: DPDK
Version: unspecified
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: Normal
Component: testpmd
Assignee: dev@dpdk.org
Reporter: david.marchand@redhat.com
Target Milestone: ---
Reported by Frode, while running OVS-DPDK unit tests.
testpmd behavior changed with commit 0fd1386c30c3 ("app/testpmd: cleanup
cleanly from signal"). Any signal makes testpmd quit.
This can be problematic with the tap driver which uses internal signalling.
Reproducer with strace to illustrate the issue:
$ sudo strace -f -e trace=file build-clang/app/dpdk-testpmd -c 3 --no-huge -m
40 -a 0:0.0 --vdev net_tap0 -- --no-mlockall --total-num-mbufs=2048 -a
...
No commandline core given, start packet forwarding
io packet forwarding - ports=1 - cores=1 - streams=1 - NUMA support enabled, MP
allocation mode: native
Logical Core 1 (socket 0) forwards packets on 1 streams:
RX P=0/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00
[pid 3780703] --- SIGRT_3 {si_signo=SIGRT_3, si_code=0x1, si_pid=65, si_uid=0,
si_int=22, si_ptr=0x16} ---
io packet forwarding packets/burst=32
nb forwarding cores=1 - nb forwarding ports=1
port 0: RX queue number: 1 Tx queue number: 1
Rx offloads=0x0 Tx offloads=0x0
RX queue: 0
RX desc=0 - RX free threshold=0
RX threshold registers: pthresh=0 hthresh=0 wthresh=0
RX Offloads=0x0
TX queue: 0
TX desc=0 - TX free threshold=0
TX threshold registers: pthresh=0 hthresh=0 wthresh=0
TX offloads=0x0 - TX RS bit threshold=0
Press enter to exit
[pid 3780703] --- SIGRT_3 {si_signo=SIGRT_3, si_code=0x1, si_pid=65, si_uid=0,
si_int=22, si_ptr=0x16} ---
Telling cores to stop...
Waiting for lcores to finish...
---------------------- Forward statistics for port 0 ----------------------
RX-packets: 1 RX-dropped: 0 RX-total: 1
TX-packets: 1 TX-dropped: 0 TX-total: 1
----------------------------------------------------------------------------
+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
RX-packets: 1 RX-dropped: 0 RX-total: 1
TX-packets: 1 TX-dropped: 0 TX-total: 1
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Done.
Stopping port 0...
Stopping ports...
Done
Shutting down port 0...
Closing ports...
Port 0 is closed
Done
Bye...
[pid 3780705] --- SIGRTMIN {si_signo=SIGRTMIN, si_code=SI_TKILL,
si_pid=3780703, si_uid=0} ---
[pid 3780705] +++ exited with 0 +++
[pid 3780703] unlink("/var/run/dpdk/rte/mp_socket") = 0
[pid 3780703] unlink("/var/run/dpdk/rte/dpdk_telemetry.v2:1") = 0
==3780703==LeakSanitizer has encountered a fatal error.
==3780703==HINT: For debugging, try setting environment variable
LSAN_OPTIONS=verbosity=1:log_threads=1
==3780703==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
[pid 3780710] +++ exited with 1 +++
[pid 3780704] +++ exited with 1 +++
[pid 3780706] +++ exited with 1 +++
+++ exited with 1 +++
A quick fix I tried:
@@ -4743,22 +4743,11 @@ main(int argc, char** argv)
}
} else {
char c;
- fd_set fds;
printf("Press enter to exit\n");
- FD_ZERO(&fds);
- FD_SET(0, &fds);
-
- /* wait for signal or enter */
- ret = select(1, &fds, NULL, NULL, NULL);
- if (ret < 0 && errno != EINTR)
- rte_exit(EXIT_FAILURE,
- "Select failed: %s\n",
- strerror(errno));
-
/* if got enter then consume it */
- if (ret == 1 && read(0, &c, 1) < 0)
+ if (read(0, &c, 1) < 0 && errno != EINTR)
rte_exit(EXIT_FAILURE,
"Read failed: %s\n",
strerror(errno));