From 9b590e2282714e3b5aae26c3ac2d8c857b1ddb82 Mon Sep 17 00:00:00 2001 From: Martin Klozik Date: Fri, 2 Oct 2015 02:18:09 +0100 Subject: Enable PVP and PVVP deployments for Vanilla OVS Support for PVP and PVVP scenerios using Vanilla OVS was added. VMs are configured to forward traffic between virtual interfaces by standard linux capabilities. Traffic generator script was updated to accept MAC and IP address configuration to allow VM forwarding configuration. VSPERF-66, VSPERF-70 Change-Id: Ia70ab6be547b39928a1eae319faba779d4e29284 Signed-off-by: Martin Klozik Signed-off-by: Dino Simeon Madarang Reviewed-by: Maryam Tahhan Reviewed-by: Brian Castelli Reviewed-by: Gene Snider Reviewed-by: Al Morton Reviewed-by: Tv Rao --- vswitches/ovs_dpdk_vhost.py | 6 +++++ vswitches/ovs_vanilla.py | 53 +++++++++++++++++++++++++++++++++++++++++++-- vswitches/vswitch.py | 7 ++++++ 3 files changed, 64 insertions(+), 2 deletions(-) (limited to 'vswitches') diff --git a/vswitches/ovs_dpdk_vhost.py b/vswitches/ovs_dpdk_vhost.py index 1a53bd6d..874cc97b 100644 --- a/vswitches/ovs_dpdk_vhost.py +++ b/vswitches/ovs_dpdk_vhost.py @@ -158,6 +158,12 @@ class OvsDpdkVhost(IVSwitch): bridge = self._bridges[switch_name] bridge.del_flow(flow) + def dump_flows(self, switch_name): + """See IVswitch for general description + """ + bridge = self._bridges[switch_name] + bridge.dump_flows() + @staticmethod def _get_port_count(bridge, param): """Returns the number of ports having a certain parameter diff --git a/vswitches/ovs_vanilla.py b/vswitches/ovs_vanilla.py index a7d4d206..6716401d 100644 --- a/vswitches/ovs_vanilla.py +++ b/vswitches/ovs_vanilla.py @@ -20,7 +20,9 @@ from conf import settings from vswitches.vswitch import IVSwitch from src.ovs import VSwitchd, OFBridge from tools.module_manager import ModuleManager, KernelModuleInsertMode +from tools import tasks +_LOGGER = logging.getLogger(__name__) VSWITCHD_CONST_ARGS = ['--', '--log-file'] class OvsVanilla(IVSwitch): @@ -36,6 +38,7 @@ class OvsVanilla(IVSwitch): _logger = logging.getLogger() _ports = settings.getValue('VSWITCH_VANILLA_PHY_PORT_NAMES') _current_id = 0 + _vport_id = 0 def __init__(self): #vswitchd_args = VSWITCHD_CONST_ARGS @@ -62,9 +65,18 @@ class OvsVanilla(IVSwitch): Kills ovsdb and vswitchd and removes kernel modules. """ + # remove all tap interfaces + for i in range(self._vport_id): + tapx = 'tap' + str(i) + tasks.run_task(['sudo', 'ip', 'tuntap', 'del', + tapx, 'mode', 'tap'], + _LOGGER, 'Deleting ' + tapx, False) + self._vport_id = 0 + self._vswitchd.kill() self._module_manager.remove_modules() + def add_switch(self, switch_name): """See IVswitch for general description """ @@ -94,16 +106,47 @@ class OvsVanilla(IVSwitch): "defined in config!") raise + if not self._ports[self._current_id]: + self._logger.error("VSWITCH_VANILLA_PHY_PORT_NAMES not set") + raise ValueError("Invalid VSWITCH_VANILLA_PHY_PORT_NAMES") + bridge = self._bridges[switch_name] port_name = self._ports[self._current_id] params = [] + + # For PVP only + tasks.run_task(['sudo', 'ifconfig', port_name, '0'], + _LOGGER, 'Remove IP', False) + of_port = bridge.add_port(port_name, params) self._current_id += 1 return (port_name, of_port) def add_vport(self, switch_name): - """See IVswitch for general description""" - raise NotImplementedError("Not implemented for Vanilla OVS.") + """ + Method adds virtual port into OVS vanilla + + See IVswitch for general description + """ + # Create tap devices for the VM + tap_name = 'tap' + str(self._vport_id) + self._vport_id += 1 + + tasks.run_task(['sudo', 'ip', 'tuntap', 'del', + tap_name, 'mode', 'tap'], + _LOGGER, 'Creating tap device...', False) + + tasks.run_task(['sudo', 'ip', 'tuntap', 'add', + tap_name, 'mode', 'tap'], + _LOGGER, 'Creating tap device...', False) + + tasks.run_task(['sudo', 'ifconfig', tap_name, '0'], + _LOGGER, 'Bring up ' + tap_name, False) + + bridge = self._bridges[switch_name] + of_port = bridge.add_port(tap_name, []) + return (tap_name, of_port) + def get_ports(self, switch_name): """See IVswitch for general description @@ -130,3 +173,9 @@ class OvsVanilla(IVSwitch): flow = flow or {} bridge = self._bridges[switch_name] bridge.del_flow(flow) + + def dump_flows(self, switch_name): + """See IVswitch for general description + """ + bridge = self._bridges[switch_name] + bridge.dump_flows() diff --git a/vswitches/vswitch.py b/vswitches/vswitch.py index 713974ae..dbf3e7d5 100644 --- a/vswitches/vswitch.py +++ b/vswitches/vswitch.py @@ -112,3 +112,10 @@ class IVSwitch(object): For flow==None, all flows are deleted """ raise NotImplementedError() + + def dump_flows(self, switch_name): + """Dump flows from the logical switch + + :param switch_name: The switch on which to operate + """ + raise NotImplementedError() -- cgit 1.2.3-korg