[ovs-dev] [PATCH 3/4] ovs-tcpdump: Fix error handling when parsing parameter.
nickcooper-zhangtonghao
nic at opencloud.tech
Wed Nov 9 02:01:25 UTC 2016
> On Nov 9, 2016, at 1:47 AM, Aaron Conole <aconole at redhat.com> wrote:
>
> nickcooper-zhangtonghao <nic at opencloud.tech <mailto:nic at opencloud.tech>> writes:
>
>> Signed-off-by: nickcooper-zhangtonghao <nic at opencloud.tech <mailto:nic at opencloud.tech>>
>> ---
>> utilities/ovs-tcpdump.in | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/utilities/ovs-tcpdump.in b/utilities/ovs-tcpdump.in
>> index c189bc8..d03568d 100755
>> --- a/utilities/ovs-tcpdump.in
>> +++ b/utilities/ovs-tcpdump.in
>> @@ -432,9 +432,12 @@ def main():
>> print(data)
>> raise KeyboardInterrupt
>> except KeyboardInterrupt:
>> - pipes.terminate()
>> + if pipes.poll() is None:
>> + pipes.terminate()
>> +
>> ovsdb.destroy_mirror('m%s' % interface, ovsdb.port_bridge(interface))
>> ovsdb.destroy_port(mirror_interface, ovsdb.port_bridge(interface))
>
>> + sys.exit(1)
>
> NAK to this - this will make the normal termination path read like an error
> on the terminal.
>
> Try it out:
>
> ovs-tcpdump -i port0 -c 1
> echo $?
Hi Aaron
Thanks for your reply. If you run the ovs-tcpdump with invalid option or
option without an argument, sometimes ovs-tcpdump will crash.
When run the “pipes.terminate()”, parent process does’t known whether
the subprocess has exited. We should check it before running the “pipes.terminate()”.
For example:
# ovs-tcpdump -i eth1 -nnn -w
tcpdump: option requires an argument -- 'w'
tcpdump version 4.5.1
libpcap version 1.5.3
Usage: tcpdump [-aAbdDefhHIJKlLnNOpqRStuUvxX] [ -B size ] [ -c count ]
[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
[ -i interface ] [ -j tstamptype ] [ -M secret ]
[ -P in|out|inout ]
[ -r file ] [ -s snaplen ] [ -T type ] [ -V file ] [ -w file ]
[ -W filecount ] [ -y datalinktype ] [ -z command ]
[ -Z user ] [ expression ]
Traceback (most recent call last):
File "/root/ovs_master_dev_new/utilities/ovs-tcpdump.py", line 453, in <module>
main()
File "/root/ovs_master_dev_new/utilities/ovs-tcpdump.py", line 439, in main
pipes.terminate()
File "/usr/lib64/python2.7/subprocess.py", line 1551, in terminate
self.send_signal(signal.SIGTERM)
File "/usr/lib64/python2.7/subprocess.py", line 1546, in send_signal
os.kill(self.pid, sig)
OSError: [Errno 3] No such process
and
# ovs-tcpdump -i eth1 -nnn -1
tcpdump: invalid option -- '1'
tcpdump version 4.5.1
libpcap version 1.5.3
Usage: tcpdump [-aAbdDefhHIJKlLnNOpqRStuUvxX] [ -B size ] [ -c count ]
[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
[ -i interface ] [ -j tstamptype ] [ -M secret ]
[ -P in|out|inout ]
[ -r file ] [ -s snaplen ] [ -T type ] [ -V file ] [ -w file ]
[ -W filecount ] [ -y datalinktype ] [ -z command ]
[ -Z user ] [ expression ]
Traceback (most recent call last):
File "/root/ovs_master_dev_new/utilities/ovs-tcpdump.py", line 453, in <module>
main()
File "/root/ovs_master_dev_new/utilities/ovs-tcpdump.py", line 439, in main
pipes.terminate()
File "/usr/lib64/python2.7/subprocess.py", line 1551, in terminate
self.send_signal(signal.SIGTERM)
File "/usr/lib64/python2.7/subprocess.py", line 1546, in send_signal
os.kill(self.pid, sig)
OSError: [Errno 3] No such process
Thanks.
Nick
More information about the dev
mailing list