This patch adds two new methods to our API - set_mtu and get_mtu. Names are self-explanatory, the only drawback these methods have, is that setting MTU to a certain value is persistent on non-virtual devices. Workaround for this is to store mtu values before the test run and set them back after the test finished. I will try to implement persistency toggling in the future.
Signed-off-by: Jiri Prochazka jprochaz@redhat.com --- lnst/Controller/Machine.py | 6 ++++++ lnst/Controller/Task.py | 6 ++++++ lnst/Slave/NetTestSlave.py | 12 ++++++++++++ 3 files changed, 24 insertions(+)
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py index e303c1a..fd4f004 100644 --- a/lnst/Controller/Machine.py +++ b/lnst/Controller/Machine.py @@ -696,6 +696,12 @@ class Interface(object): self._machine._rpc_call("deconfigure_interface", self.get_id()) self._configured = False
+ def set_mtu(self, mtu): + self._machine._rpc_call("set_mtu", self.get_id(), mtu) + + def get_mtu(self): + return self._machine._rpc_call("get_mtu", self.get_id()) + class StaticInterface(Interface): """ Static interface
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py index be6b5cc..ee0d468 100644 --- a/lnst/Controller/Task.py +++ b/lnst/Controller/Task.py @@ -346,6 +346,12 @@ class InterfaceAPI(object): def get_ip_prefix(self, ip_index): return VolatileValue(self._if.get_prefix, ip_index)
+ def set_mtu(self, mtu): + self._if.set_mtu(mtu) + + def get_mtu(self): + return VolatileValue(self._if.get_mtu) + class ModuleAPI(object): """ An API class representing a module. """
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py index 8eb1f99..65601a8 100644 --- a/lnst/Slave/NetTestSlave.py +++ b/lnst/Slave/NetTestSlave.py @@ -609,6 +609,18 @@ class SlaveMethods: device.set_netns(None) return True
+ def set_mtu(self, if_id, mtu): + device = self._if_manager.get_mapped_device(if_id) + dev_name = device.get_name() + exec_cmd("ip link set dev %s mtu %s" % (dev_name, mtu)) + return True + + def get_mtu(self, if_id): + device = self._if_manager.get_mapped_device(if_id) + dev_name = device.get_name() + mtu, _ = exec_cmd("cat /sys/class/net/%s/mtu" % dev_name, log_outputs=False) + return mtu + class ServerHandler(ConnectionHandler): def __init__(self, addr): super(ServerHandler, self).__init__()
Thu, Apr 30, 2015 at 04:39:51PM CEST, jprochaz@redhat.com wrote:
...
- def set_mtu(self, if_id, mtu):
device = self._if_manager.get_mapped_device(if_id)
dev_name = device.get_name()
exec_cmd("ip link set dev %s mtu %s" % (dev_name, mtu))
return True
- def get_mtu(self, if_id):
device = self._if_manager.get_mapped_device(if_id)
dev_name = device.get_name()
mtu, _ = exec_cmd("cat /sys/class/net/%s/mtu" % dev_name, log_outputs=False)
you use netlink for set and sysfs for get? That's weird. Also, why not to use pyroute2 for this?
On Fri, May 01, 2015 at 09:30:22AM +0200, Jiri Pirko wrote:
Thu, Apr 30, 2015 at 04:39:51PM CEST, jprochaz@redhat.com wrote:
...
- def set_mtu(self, if_id, mtu):
device = self._if_manager.get_mapped_device(if_id)
dev_name = device.get_name()
exec_cmd("ip link set dev %s mtu %s" % (dev_name, mtu))
return True
- def get_mtu(self, if_id):
device = self._if_manager.get_mapped_device(if_id)
dev_name = device.get_name()
mtu, _ = exec_cmd("cat /sys/class/net/%s/mtu" % dev_name, log_outputs=False)
you use netlink for set and sysfs for get? That's weird. Also, why not to use pyroute2 for this?
There's also the 'config' type command that can be used for the 'set' operation and will also ensure that when the Task finishes, mtu will be reset to the original value.
LNST-developers mailing list LNST-developers@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/lnst-developers
I've sent a new implementation for set_mtu. It uses implementation of config method to set up MTU.
The first idea for set_mtu method was it to be InterfaceAPI method, but because config is HostAPI method and uses running custom command via rpc calls, the implementation couldn't be done in a nice way, so I made it HostAPI method as well.
The new implementation should be better, both methods use sysfs. The reason for not using pyroute, is that config method uses sysfs and it's pointless to make a new implementation for the pretty much same thing.
Next thing I want to discuss, if this patch set will be accepted, is integration into ENRT/NS-Sanity tests via aliases.
-- Jiri Prochazka LNST developer (www.lnst-project.org) Red Hat Czech s.r.o.
----- Original Message ----- From: "Ondrej Lichtner" olichtne@redhat.com To: "Jiri Pirko" jiri@resnulli.us Cc: "Jiri Prochazka" jprochaz@redhat.com, lnst-developers@lists.fedorahosted.org Sent: Friday, May 1, 2015 8:39:55 PM Subject: Re: [PATCH] Add set_mtu and get_mtu API methods
On Fri, May 01, 2015 at 09:30:22AM +0200, Jiri Pirko wrote:
Thu, Apr 30, 2015 at 04:39:51PM CEST, jprochaz@redhat.com wrote:
...
- def set_mtu(self, if_id, mtu):
device = self._if_manager.get_mapped_device(if_id)
dev_name = device.get_name()
exec_cmd("ip link set dev %s mtu %s" % (dev_name, mtu))
return True
- def get_mtu(self, if_id):
device = self._if_manager.get_mapped_device(if_id)
dev_name = device.get_name()
mtu, _ = exec_cmd("cat /sys/class/net/%s/mtu" % dev_name, log_outputs=False)
you use netlink for set and sysfs for get? That's weird. Also, why not to use pyroute2 for this?
There's also the 'config' type command that can be used for the 'set' operation and will also ensure that when the Task finishes, mtu will be reset to the original value.
LNST-developers mailing list LNST-developers@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/lnst-developers
I meant the RPC method config, not the HostAPI method... The way I imagine it it should be a 'lnst/Controller/Machine:class Interface' method, that constructs the 'config' rpc command and sends it through a 'lnst/Controller/Machine:class Machine' object to the slave. The InterfaceAPI class should just be an interface (as in design patterns) to the Interface class methods.
I don't really see the use in HostAPI methods for {set, get}_mtu() but you can keep them if you think they're useful. But they definitely should be available from InterfaceAPI.
-Ondrej
On Sat, May 02, 2015 at 05:51:00AM -0400, Jiri Prochazka wrote:
I've sent a new implementation for set_mtu. It uses implementation of config method to set up MTU.
The first idea for set_mtu method was it to be InterfaceAPI method, but because config is HostAPI method and uses running custom command via rpc calls, the implementation couldn't be done in a nice way, so I made it HostAPI method as well.
The new implementation should be better, both methods use sysfs. The reason for not using pyroute, is that config method uses sysfs and it's pointless to make a new implementation for the pretty much same thing.
Next thing I want to discuss, if this patch set will be accepted, is integration into ENRT/NS-Sanity tests via aliases.
-- Jiri Prochazka LNST developer (www.lnst-project.org) Red Hat Czech s.r.o.
----- Original Message ----- From: "Ondrej Lichtner" olichtne@redhat.com To: "Jiri Pirko" jiri@resnulli.us Cc: "Jiri Prochazka" jprochaz@redhat.com, lnst-developers@lists.fedorahosted.org Sent: Friday, May 1, 2015 8:39:55 PM Subject: Re: [PATCH] Add set_mtu and get_mtu API methods
On Fri, May 01, 2015 at 09:30:22AM +0200, Jiri Pirko wrote:
Thu, Apr 30, 2015 at 04:39:51PM CEST, jprochaz@redhat.com wrote:
...
- def set_mtu(self, if_id, mtu):
device = self._if_manager.get_mapped_device(if_id)
dev_name = device.get_name()
exec_cmd("ip link set dev %s mtu %s" % (dev_name, mtu))
return True
- def get_mtu(self, if_id):
device = self._if_manager.get_mapped_device(if_id)
dev_name = device.get_name()
mtu, _ = exec_cmd("cat /sys/class/net/%s/mtu" % dev_name, log_outputs=False)
you use netlink for set and sysfs for get? That's weird. Also, why not to use pyroute2 for this?
There's also the 'config' type command that can be used for the 'set' operation and will also ensure that when the Task finishes, mtu will be reset to the original value.
LNST-developers mailing list LNST-developers@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/lnst-developers
lnst-developers@lists.fedorahosted.org