[lnst] InterfaceManager: Fix stack deconfiguration for vlans
by Jiří Pírko
commit 126d0df70fa0fdbd3a1ce8f980d954adcade94da
Author: Jan Tluka <jtluka(a)redhat.com>
Date: Mon Apr 28 14:32:29 2014 +0200
InterfaceManager: Fix stack deconfiguration for vlans
There is a bug in deconfiguration of certain vlan setups (eth-team-vlan).
Since IFLA_MASTER is not used in case of VLANs for parent-slave association
IFLA_LINK has to be used instead to correctly deconfigure the network stack.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Slave/InterfaceManager.py | 31 +++++++++++++++++++++++--------
1 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/lnst/Slave/InterfaceManager.py b/lnst/Slave/InterfaceManager.py
index c21dc16..547662d 100644
--- a/lnst/Slave/InterfaceManager.py
+++ b/lnst/Slave/InterfaceManager.py
@@ -186,6 +186,7 @@ class Device(object):
self._ip = None
self._state = None
self._master = None
+ self._parent = None
self._if_manager = if_manager
@@ -203,6 +204,15 @@ class Device(object):
self._name = nl_msg.get_attr("IFLA_IFNAME")
self._ip = None #TODO
self._master = nl_msg.get_attr("IFLA_MASTER")
+ link = nl_msg.get_attr("IFLA_LINK")
+ if link != None:
+ # IFLA_LINK is an index of device that's closer to physical
+ # interface in the stack, e.g. index of eth0 for eth0.100
+ # so to properly deconfigure the stack we have to save
+ # parent index in the child device; this is the opposite
+ # to IFLA_MASTER
+ link_dev = self._if_manager.get_device(link)
+ link_dev.set_parent(self._if_index)
if self._conf_dict:
self._conf_dict["name"] = self._name
@@ -242,10 +252,11 @@ class Device(object):
return self._conf
def clear_configuration(self):
- if self._master != None:
- master_dev = self._if_manager.get_device(self._master)
- if master_dev != None:
- master_dev.clear_configuration()
+ if self._master or self._parent:
+ super_id = self._master if self._master else self._parent
+ super_dev = self._if_manager.get_device(super_id)
+ if super_dev:
+ super_dev.clear_configuration()
if self._conf != None:
self.down()
@@ -253,16 +264,20 @@ class Device(object):
self._conf = None
self._conf_dict = None
+ def set_parent(self, if_index):
+ self._parent = if_index
+
def configure(self):
if self._conf != None and not self._configured:
self._conf.configure()
self._configured = True
def deconfigure(self):
- if self._master != None:
- master_dev = self._if_manager.get_device(self._master)
- if master_dev != None:
- master_dev.deconfigure()
+ if self._master or self._parent:
+ super_id = self._master if self._master else self._parent
+ super_dev = self._if_manager.get_device(super_id)
+ if super_dev:
+ super_dev.deconfigure()
if self._conf != None and self._configured:
self._conf.deconfigure()
9 years, 5 months
[lnst] NetTestController: Fixed silent ignoring of detaching virtual interfaces
by Jiří Pírko
commit eb30299038eb590b7eb5a69b6216b9924875529e
Author: Jan Tluka <jtluka(a)redhat.com>
Date: Fri Apr 25 18:46:35 2014 +0200
NetTestController: Fixed silent ignoring of detaching virtual interfaces
There was a typo, additional quotes, and the condition check was always
false therefore the virtual devices were not detached after config_only
run.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/NetTestController.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 2453042..7324a7c 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -519,7 +519,7 @@ class NetTestController:
break
rpc_con.close()
- if "libvirt_dom" in "machine":
+ if "libvirt_dom" in machine:
libvirt_dom = machine["libvirt_dom"]
domain_ctl = VirtDomainCtl(libvirt_dom)
logging.info("Detaching dynamically created interfaces.")
9 years, 5 months
[PATCH] InterfaceManager: Fix stack deconfiguration for vlans
by Jan Tluka
There is a bug in deconfiguration of certain vlan setups (eth-team-vlan).
Since IFLA_MASTER is not used in case of VLANs for parent-slave association
IFLA_LINK has to be used instead to correctly deconfigure the network stack.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Slave/InterfaceManager.py | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/lnst/Slave/InterfaceManager.py b/lnst/Slave/InterfaceManager.py
index c21dc16..547662d 100644
--- a/lnst/Slave/InterfaceManager.py
+++ b/lnst/Slave/InterfaceManager.py
@@ -186,6 +186,7 @@ class Device(object):
self._ip = None
self._state = None
self._master = None
+ self._parent = None
self._if_manager = if_manager
@@ -203,6 +204,15 @@ class Device(object):
self._name = nl_msg.get_attr("IFLA_IFNAME")
self._ip = None #TODO
self._master = nl_msg.get_attr("IFLA_MASTER")
+ link = nl_msg.get_attr("IFLA_LINK")
+ if link != None:
+ # IFLA_LINK is an index of device that's closer to physical
+ # interface in the stack, e.g. index of eth0 for eth0.100
+ # so to properly deconfigure the stack we have to save
+ # parent index in the child device; this is the opposite
+ # to IFLA_MASTER
+ link_dev = self._if_manager.get_device(link)
+ link_dev.set_parent(self._if_index)
if self._conf_dict:
self._conf_dict["name"] = self._name
@@ -242,10 +252,11 @@ class Device(object):
return self._conf
def clear_configuration(self):
- if self._master != None:
- master_dev = self._if_manager.get_device(self._master)
- if master_dev != None:
- master_dev.clear_configuration()
+ if self._master or self._parent:
+ super_id = self._master if self._master else self._parent
+ super_dev = self._if_manager.get_device(super_id)
+ if super_dev:
+ super_dev.clear_configuration()
if self._conf != None:
self.down()
@@ -253,16 +264,20 @@ class Device(object):
self._conf = None
self._conf_dict = None
+ def set_parent(self, if_index):
+ self._parent = if_index
+
def configure(self):
if self._conf != None and not self._configured:
self._conf.configure()
self._configured = True
def deconfigure(self):
- if self._master != None:
- master_dev = self._if_manager.get_device(self._master)
- if master_dev != None:
- master_dev.deconfigure()
+ if self._master or self._parent:
+ super_id = self._master if self._master else self._parent
+ super_dev = self._if_manager.get_device(super_id)
+ if super_dev:
+ super_dev.deconfigure()
if self._conf != None and self._configured:
self._conf.deconfigure()
--
1.8.1.4
9 years, 5 months
[PATCH] NetTestController: Fixed silent ignoring of detaching virtual interfaces
by Jan Tluka
There was a typo, additional quotes, and the condition check was always
false therefore the virtual devices were not detached after config_only
run.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Controller/NetTestController.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 2453042..7324a7c 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -519,7 +519,7 @@ class NetTestController:
break
rpc_con.close()
- if "libvirt_dom" in "machine":
+ if "libvirt_dom" in machine:
libvirt_dom = machine["libvirt_dom"]
domain_ctl = VirtDomainCtl(libvirt_dom)
logging.info("Detaching dynamically created interfaces.")
--
1.8.1.4
9 years, 5 months
[lnst] set SO_REUSEADDR for lnst-slave's listening socket
by Jiří Pírko
commit c6deb49d74a27e9235deb7a751e3e5342250b725
Author: Jan Tluka <jtluka(a)redhat.com>
Date: Fri Apr 18 14:23:00 2014 +0200
set SO_REUSEADDR for lnst-slave's listening socket
If LNST crashes for some reason user cannot restart it due to "Address
already in use" error. Setting socket option SO_REUSEADDR resolves this.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Slave/NetTestSlave.py | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 99da97b..13b07a2 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -347,6 +347,7 @@ class ServerHandler(object):
self._connection_handler = ConnectionHandler()
try:
self._s_socket = socket.socket()
+ self._s_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self._s_socket.bind(addr)
self._s_socket.listen(1)
except socket.error as e:
9 years, 5 months
[PATCH] set SO_REUSEADDR for lnst-slave's listening socket
by Jan Tluka
If LNST crashes for some reason user cannot restart it due to "Address
already in use" error. Setting socket option SO_REUSEADDR resolves this.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Slave/NetTestSlave.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 99da97b..13b07a2 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -347,6 +347,7 @@ class ServerHandler(object):
self._connection_handler = ConnectionHandler()
try:
self._s_socket = socket.socket()
+ self._s_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self._s_socket.bind(addr)
self._s_socket.listen(1)
except socket.error as e:
--
1.8.1.4
9 years, 5 months
[lnst] NetConfigDevice: ignore address deletion fail
by Jiří Pírko
commit a4bbf01f4584b7fb3856967a6eae1edf46b10b82
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Apr 14 15:26:33 2014 +0200
NetConfigDevice: ignore address deletion fail
The slave would crash on trying to remove an ip address that doesn't
exist on the device. This can happen for a variety of reasons, for
example the user removes the address in one of the tasks. This patch
fixes the crash.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Slave/NetConfigDevice.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Slave/NetConfigDevice.py b/lnst/Slave/NetConfigDevice.py
index 39267a6..4fa1b50 100644
--- a/lnst/Slave/NetConfigDevice.py
+++ b/lnst/Slave/NetConfigDevice.py
@@ -61,7 +61,8 @@ class NetConfigDeviceGeneric(object):
config = self._dev_config
if "addresses" in config:
for address in config["addresses"]:
- exec_cmd("ip addr del %s dev %s" % (address, config["name"]))
+ exec_cmd("ip addr del %s dev %s" % (address, config["name"]),
+ die_on_err=False)
exec_cmd("ip link set %s down" % config["name"])
@classmethod
9 years, 5 months
[lnst] InterfaceManager: update dev name in configuration dict
by Jiří Pírko
commit 091ab4d2d6b0823566b018a0165f1de3257f60e2
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Wed Apr 9 11:09:57 2014 +0200
InterfaceManager: update dev name in configuration dict
This commit solves the problem of updated device names not being visible
in the {Net, Nm}ConfigDevice objects. This caused crashes on slave
deconfiguration if the device changed it's name during test execution.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Slave/InterfaceManager.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Slave/InterfaceManager.py b/lnst/Slave/InterfaceManager.py
index 107601c..c21dc16 100644
--- a/lnst/Slave/InterfaceManager.py
+++ b/lnst/Slave/InterfaceManager.py
@@ -204,6 +204,9 @@ class Device(object):
self._ip = None #TODO
self._master = nl_msg.get_attr("IFLA_MASTER")
+ if self._conf_dict:
+ self._conf_dict["name"] = self._name
+
#return an update message that will be sent to the controller
return {"type": "if_update",
"devname": self._name,
9 years, 5 months
[lnst] add ovs_vlan.xml recipe
by Jiří Pírko
commit fe6c32a0abf2c49560e6a7da01e7796a2343fd0a
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Tue Apr 1 13:43:06 2014 +0200
add ovs_vlan.xml recipe
This commit adds a new example recipe for Open vSwitch. The test follows
the example from the official Open vSwitch Configuration Cookbook on
VLANs
http://openvswitch.org/support/config-cookbooks/vlan-configuration-cookbook/
The only difference is that the recipe uses 6 machines (in my case all
virtual) instead of 2 physical hosts with 2 virtual machines each, but
the end result should be the same.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
recipes/examples/ovs/ovs_vlan.xml | 145 +++++++++++++++++++++++++++++++++++++
1 files changed, 145 insertions(+), 0 deletions(-)
---
diff --git a/recipes/examples/ovs/ovs_vlan.xml b/recipes/examples/ovs/ovs_vlan.xml
new file mode 100644
index 0000000..4ba5496
--- /dev/null
+++ b/recipes/examples/ovs/ovs_vlan.xml
@@ -0,0 +1,145 @@
+<lnstrecipe>
+ <network>
+ <host id="vm1">
+ <interfaces>
+ <eth id="if1" label="n1">
+ <addresses>
+ <address value="192.168.200.1/24"/>
+ </addresses>
+ </eth>
+ </interfaces>
+ </host>
+ <host id="vm2">
+ <interfaces>
+ <eth id="if2" label="n2">
+ <addresses>
+ <address value="192.168.200.2/24"/>
+ </addresses>
+ </eth>
+ </interfaces>
+ </host>
+ <host id="vm3">
+ <interfaces>
+ <eth id="if3" label="n3">
+ <addresses>
+ <address value="192.168.200.3/24"/>
+ </addresses>
+ </eth>
+ </interfaces>
+ </host>
+ <host id="vm4">
+ <interfaces>
+ <eth id="if4" label="n4">
+ <addresses>
+ <address value="192.168.200.4/24"/>
+ </addresses>
+ </eth>
+ </interfaces>
+ </host>
+ <host id="h1">
+ <params>
+ <param name="ovs_support" value="true"/>
+ </params>
+ <interfaces>
+ <eth id="if1" label="n1"/>
+ <eth id="if2" label="n2"/>
+ <eth id="if3" label="data_net"/>
+ <ovs_bridge id="ovs1">
+ <slaves>
+ <slave id="if1"/>
+ <slave id="if2"/>
+ <slave id="if3"/>
+ </slaves>
+ <vlan tag="1">
+ <slaves>
+ <slave id="if1"/>
+ </slaves>
+ </vlan>
+ <vlan tag="2">
+ <slaves>
+ <slave id="if2"/>
+ </slaves>
+ </vlan>
+ </ovs_bridge>
+ </interfaces>
+ </host>
+ <host id="h2">
+ <params>
+ <param name="ovs_support" value="true"/>
+ </params>
+ <interfaces>
+ <eth id="if1" label="n3"/>
+ <eth id="if2" label="n4"/>
+ <eth id="if3" label="data_net"/>
+ <ovs_bridge id="ovs2">
+ <slaves>
+ <slave id="if1"/>
+ <slave id="if2"/>
+ <slave id="if3"/>
+ </slaves>
+ <vlan tag="1">
+ <slaves>
+ <slave id="if1"/>
+ </slaves>
+ </vlan>
+ <vlan tag="2">
+ <slaves>
+ <slave id="if2"/>
+ </slaves>
+ </vlan>
+ </ovs_bridge>
+ </interfaces>
+ </host>
+ </network>
+
+ <task>
+ <run host="vm1" module="IcmpPing" timeout="30" expect="fail">
+ <options>
+ <option name="addr" value="{ip(vm2,if2)}"/>
+ <option name="count" value="40"/>
+ <option name="interval" value="0"/>
+ <option name="limit_rate" value="95"/>
+ </options>
+ </run>
+ <run host="vm1" module="IcmpPing" timeout="30" expect="pass">
+ <options>
+ <option name="addr" value="{ip(vm3,if3)}"/>
+ <option name="count" value="40"/>
+ <option name="interval" value="0"/>
+ <option name="limit_rate" value="95"/>
+ </options>
+ </run>
+ <run host="vm1" module="IcmpPing" timeout="30" expect="fail">
+ <options>
+ <option name="addr" value="{ip(vm4,if4)}"/>
+ <option name="count" value="40"/>
+ <option name="interval" value="0"/>
+ <option name="limit_rate" value="95"/>
+ </options>
+ </run>
+ <run host="vm2" module="IcmpPing" timeout="30" expect="fail">
+ <options>
+ <option name="addr" value="{ip(vm1,if1)}"/>
+ <option name="count" value="40"/>
+ <option name="interval" value="0"/>
+ <option name="limit_rate" value="95"/>
+ </options>
+ </run>
+ <run host="vm2" module="IcmpPing" timeout="30" expect="fail">
+ <options>
+ <option name="addr" value="{ip(vm3,if3)}"/>
+ <option name="count" value="40"/>
+ <option name="interval" value="0"/>
+ <option name="limit_rate" value="95"/>
+ </options>
+ </run>
+ <run host="vm2" module="IcmpPing" timeout="30" expect="pass">
+ <options>
+ <option name="addr" value="{ip(vm4,if4)}"/>
+ <option name="count" value="40"/>
+ <option name="interval" value="0"/>
+ <option name="limit_rate" value="95"/>
+ </options>
+ </run>
+ </task>
+</lnstrecipe>
9 years, 5 months
[lnst] RecipeParser: always initialize ovs_conf
by Jiří Pírko
commit b1442e682b0a655b0c005ca7c7bc12d2db0e6712
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Tue Apr 1 13:42:56 2014 +0200
RecipeParser: always initialize ovs_conf
When the recipe doesn't contain any vlans or bonds, the corresponding
ovs_conf fields wouldn't be created. That causes the slave to crash.
This commit fixes that.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/RecipeParser.py | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
---
diff --git a/lnst/Controller/RecipeParser.py b/lnst/Controller/RecipeParser.py
index c4fe61f..2b554d7 100644
--- a/lnst/Controller/RecipeParser.py
+++ b/lnst/Controller/RecipeParser.py
@@ -141,8 +141,7 @@ class RecipeParser(XmlParser):
iface["slaves"].append(slave)
vlan_elems = iface_tag.findall("vlan")
- if len(vlan_elems) > 0:
- vlans = iface["ovs_conf"]["vlans"] = XmlData(slaves_tag)
+ vlans = iface["ovs_conf"]["vlans"] = XmlData(slaves_tag)
for vlan in vlan_elems:
vlan_tag = str(self._get_attribute(vlan, "tag"))
if vlan_tag in vlans:
@@ -171,8 +170,7 @@ class RecipeParser(XmlParser):
bonded_slaves = {}
bond_elems = iface_tag.findall("bond")
- if len(bond_elems) > 0:
- bonds = iface["ovs_conf"]["bonds"] = XmlData(slaves_tag)
+ bonds = iface["ovs_conf"]["bonds"] = XmlData(slaves_tag)
for bond_tag in bond_elems:
bond_id = str(self._get_attribute(bond_tag, "id"))
if bond_id in bonds:
9 years, 5 months