Skip to content

Commit

Permalink
ovs-tcpdump: Set mirror port mtu
Browse files Browse the repository at this point in the history
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: 314ce64 ("ovs-tcpdump: Add a tcpdump wrapper utility")
Reported-by: Dan Williams <[email protected]>
Signed-off-by: Aaron Conole <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
apconole authored and blp committed Mar 9, 2017
1 parent 6b95d23 commit 26cea6a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions utilities/ovs-tcpdump.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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`" %
Expand Down

0 comments on commit 26cea6a

Please sign in to comment.