[ovs-dev] ovs-tcpdump error

Bodireddy, Bhanuprakash bhanuprakash.bodireddy at intel.com
Fri Nov 10 10:12:50 UTC 2017


>Aaron Conole <aconole at redhat.com> writes:
>
>> Hi Bhanu,
>>
>> "Bodireddy, Bhanuprakash" <bhanuprakash.bodireddy at intel.com> writes:
>>
>>> Hi,
>>>
>>>
>>>
>>> ovs-tcpdump throws the below error when trying to capture packets on
>>> one of the vhostuserports.
>>>
>>>
>>>
>>> $ ovs-tcpdump -i dpdkvhostuser0
>>>
>>>    ERROR: Please create an interface called `midpdkvhostuser0`
>>>
>>>     See your OS guide for how to do this.
>>>
>>>     Ex: ip link add midpdkvhostuser0 type veth peer name
>>> midpdkvhostuser02
>>>
>>>
>>>
>>> $ ip link add midpdkvhostuser0 type veth peer name midpdkvhostuser02
>>>
>>>      Error: argument "midpdkvhostuser0" is wrong: "name" too long
>>>
>>>
>>>
>>> To get around this issue, I have to pass  ‘—mirror-to’ option as below.
>>>
>>>
>>>
>>> $ ovs-tcpdump -i dpdkvhostuser0 -XX --mirror-to vh0
>>>
>>>
>>>
>>> Is this due to the length of the port name?  Would be nice to fix this issue.
>>
>> Thanks for the detailed write up.
>>
>> It is related to the mirror port name length.  The mirror port is
>> bound by IFNAMSIZ restriction, so it must be 15 characters + nul, and
>> midpdkvhostuser0 would be 16 + nul.  This is a linux specific
>> restriction, and it won't be changed because it is very much a well
>> established UAPI (and changing it will have implications on code not
>> able to deal with larger sized name buffers).
>>
>> I'm not sure how best to fix it.  My concession was the mirror-to
>> option.  Perhaps there's a better way?
>
>Hi Bhanu, I've been thinking about this a bit more.  How about something like
>the following patch?
>
>If you think it's acceptable, I'll submit it formally.

Hi Aaron,

I am on fedora and applied the patch but couldn't verify the fix as I get the below error.

Traceback (most recent call last):
  File "./utilities/ovs-tcpdump", line 21, in <module>
    import random.randint
ImportError: No module named randint

When I slightly change the code to

-import random.randint
+ from random import randint
...
-return "ovsmi%06d" % random.randint(1, 999999)
+return "ovsmi%06d" % randint(1, 999999)

I get below error
Traceback (most recent call last):
  File "./utilities/ovs-tcpdump", line 478, in <module>
    main()
  File "./utilities/ovs-tcpdump", line 419, in main
    mirror_interface = mirror_interface or _make_mirror_name(interface)
TypeError: 'dict' object is not callable

Why is this so?

- Bhanuprakash.

>
>---
>
>diff --git a/utilities/ovs-tcpdump.in b/utilities/ovs-tcpdump.in index
>6718c77..76e8a7b 100755
>--- a/utilities/ovs-tcpdump.in
>+++ b/utilities/ovs-tcpdump.in
>@@ -18,6 +18,7 @@ import fcntl
>
> import os
> import pwd
>+import random.randint
> import struct
> import subprocess
> import sys
>@@ -39,6 +40,7 @@ except Exception:
>
> tapdev_fd = None
> _make_taps = {}
>+_make_mirror_name = {}
>
>
> def _doexec(*args, **kwargs):
>@@ -76,8 +78,16 @@ def _install_tap_linux(tap_name, mtu_value=None):
>     pipe.wait()
>
>
>+def _make_linux_mirror_name(interface_name):
>+    if interface_name.length() > 13:
>+        return "ovsmi%06d" % random.randint(1, 999999)
>+    return "mi%s" % interface_name
>+
>+
> _make_taps['linux'] = _install_tap_linux  _make_taps['linux2'] =
>_install_tap_linux
>+_make_mirror_name['linux'] = _make_linux_mirror_name
>+_make_mirror_name['linux2'] = _make_linux_mirror_name
>
>
> def username():
>@@ -406,7 +416,7 @@ def main():
>         print("TCPDUMP Args: %s" % ' '.join(tcpdargs))
>
>     ovsdb = OVSDB(db_sock)
>-    mirror_interface = mirror_interface or "mi%s" % interface
>+    mirror_interface = mirror_interface or _make_mirror_name(interface)
>
>     if sys.platform in _make_taps and \
>        mirror_interface not in netifaces.interfaces():
>---


More information about the dev mailing list