]> git.proxmox.com Git - ovs.git/commitdiff
ovs-tcpdump: Set mirror port mtu
authorAaron Conole <aconole@redhat.com>
Wed, 22 Feb 2017 19:59:41 +0000 (14:59 -0500)
committerBen Pfaff <blp@ovn.org>
Thu, 9 Mar 2017 00:16:56 +0000 (16:16 -0800)
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@redhat.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
utilities/ovs-tcpdump.in

index a6e4adadb428bf6a2479f8c2f77f4fa2416ea91d..f0c0774a9613a672c75d9cd4cc5d8eef445b3197 100755 (executable)
@@ -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`" %