[ovs-dev] [PATCH] ovs-tcpdump: add dump_cmd checker before _doexec()

txfh2007 txfh2007 at aliyun.com
Fri Mar 1 08:48:45 UTC 2019


Hi :
    The ovs-tcpdump script uses python subprocess module to generate dump_cmd thread and capture pkts. Sometimes users would met this error during execution. 
Traceback (most recent call last):
  File "./ovs-tcpdump", line 486, in <module>
    main()
  File "./ovs-tcpdump", line 461, in main
    pipes = _doexec(*([dump_cmd, '-i', mirror_interface] + tcpdargs))
  File "./ovs-tcpdump", line 52, in _doexec
    bufsize=0)
  File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

    The root cause is the dump tool(normally 'tcpdump') is not installed in user's OS. But from the printed error we will mistakenly think that some files are missing. 
    
    This patch adds a checker before insert tcpdump args and _doexec, if someone(especially new users) would uses a wrong dump_cmd, or tcpdump package just not installed on his env. The checker would emit  Error and exit. 

diff --git a/utilities/ovs-tcpdump.in b/utilities/ovs-tcpdump.in
index 269c252f8..f28ecf5b2 100755
--- a/utilities/ovs-tcpdump.in
+++ b/utilities/ovs-tcpdump.in
@@ -416,6 +416,10 @@ def main():
         print("Error: must at least specify an interface with '-i' option")
         sys.exit(1)

+    if os.system("command -v %s" % (dump_cmd)):
+        print("Error: %s is not installed !!"%dump_cmd)
+        sys.exit(1)
+
     if '-l' not in tcpdargs:
         tcpdargs.insert(0, '-l')
 
 





More information about the dev mailing list