[ovs-dev] ovs-tcpdump: add dump_cmd checker before _doexec()
diff mbox series

Message ID 6943f17e-05bc-4370-a7ad-029268c6dbf3.txfh2007@aliyun.com
State Superseded
Headers show
Series
  • [ovs-dev] ovs-tcpdump: add dump_cmd checker before _doexec()
Related show

Commit Message

Surya Rudra via dev March 1, 2019, 8:48 a.m. UTC
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.

Comments

0-day Robot March 1, 2019, 9:59 a.m. UTC | #1
Bleep bloop.  Greetings txfh2007 via dev, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
ERROR: Author should not be mailing list.
Lines checked: 47, Warnings: 0, Errors: 1


Please check this out.  If you feel there has been an error, please email aconole@bytheb.org

Thanks,
0-day Robot

Patch
diff mbox series

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')