[ovs-dev] [PATCH] ovs-tcpdump: Set mirror port mtu

Aaron Conole aconole at redhat.com
Wed Feb 22 19:59:41 UTC 2017


When using ovs-tcpdump to mirror interfaces with MTU larger than the default,
Open vSwitch will lower the interfaces we are interested in monitoring.
Instead, probe the MTU and set the mirrored port's MTU value correctly.

Fixes: 314ce6479a83 ("ovs-tcpdump: Add a tcpdump wrapper utility")
Reported-by: Dan Williams <dcbw at redhat.com>
Signed-off-by: Aaron Conole <aconole at redhat.com>
---
 utilities/ovs-tcpdump.in | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/utilities/ovs-tcpdump.in b/utilities/ovs-tcpdump.in
index a6e4ada..f0c0774 100755
--- a/utilities/ovs-tcpdump.in
+++ b/utilities/ovs-tcpdump.in
@@ -48,7 +48,7 @@ def _doexec(*args, **kwargs):
     return proc
 
 
-def _install_tap_linux(tap_name):
+def _install_tap_linux(tap_name, mtu_value=None):
     """Uses /dev/net/tun to create a tap device"""
     global tapdev_fd
 
@@ -63,6 +63,12 @@ def _install_tap_linux(tap_name):
     fcntl.ioctl(tapdev_fd, TUNSETOWNER, os.getegid())
 
     time.sleep(1)  # required to give the new device settling time
+    if mtu_value is not None:
+        pipe = _doexec(
+            *(['ip', 'link', 'set', 'dev', str(tap_name), 'mtu',
+               str(mtu_value)]))
+        pipe.wait()
+
     pipe = _doexec(
         *(['ip', 'link', 'set', 'dev', str(tap_name), 'up']))
     pipe.wait()
@@ -174,6 +180,13 @@ class OVSDB(object):
         except Exception:
             raise OVSDBException('Unable to find port %s bridge' % port_name)
 
+    def interface_mtu(self, intf_name):
+        try:
+            intf = self._find_row_by_name('Interface', intf_name)
+            return intf.mtu[0]
+        except Exception:
+            return None
+
     def interface_exists(self, intf_name):
         return bool(self._find_row_by_name('Interface', intf_name))
 
@@ -395,7 +408,8 @@ def main():
 
     if sys.platform in _make_taps and \
        mirror_interface not in netifaces.interfaces():
-        _make_taps[sys.platform](mirror_interface)
+        _make_taps[sys.platform](mirror_interface,
+                                 ovsdb.interface_mtu(interface))
 
     if mirror_interface not in netifaces.interfaces():
         print("ERROR: Please create an interface called `%s`" %
-- 
2.9.3



More information about the dev mailing list