If ovs-tcpdump received HUP or TERM signal, mirror and mirror interface should be destroyed. This often happens, when controlling terminal is closed, like ssh session closed, and other users use kill to terminate it.
Signed-off-by: Daniel Ding <zhihui.d...@easystack.cn> --- utilities/ovs-tcpdump.in | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/utilities/ovs-tcpdump.in b/utilities/ovs-tcpdump.in index 7fd26e405..211d50fc5 100755 --- a/utilities/ovs-tcpdump.in +++ b/utilities/ovs-tcpdump.in @@ -17,6 +17,7 @@ import os import pwd from random import randint +import signal import subprocess import sys import time @@ -489,6 +490,17 @@ def main(): print("ERROR: Mirror port (%s) exists for port %s." % (mirror_interface, interface)) sys.exit(1) + + def signal_handler(_signo, _stack_frame): + ovsdb.destroy_mirror(interface, ovsdb.port_bridge(interface)) + ovsdb.destroy_port(mirror_interface, ovsdb.port_bridge(interface)) + + sys.exit(0) + + if sys.platform in ['linux', 'linux2']: + signal.signal(signal.SIGHUP, signal_handler) + signal.signal(signal.SIGTERM, signal_handler) + try: ovsdb.make_port(mirror_interface, ovsdb.port_bridge(interface)) ovsdb.bridge_mirror(interface, mirror_interface, --- Best regards, Daniel Ding _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev