summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-09-25 20:32:28 +0200
committerChristian Poessinger <christian@poessinger.com>2020-09-25 20:34:46 +0200
commit49a79954373eb3f70eddb444e855ed744a322e58 (patch)
tree212834ff8ac74144e7449a7f0056f97708cdf99a /python
parente76d9a009632629e6a22b0d77eebc913c9268a6d (diff)
downloadvyos-1x-49a79954373eb3f70eddb444e855ed744a322e58.tar.gz
vyos-1x-49a79954373eb3f70eddb444e855ed744a322e58.zip
ifconfig: T2912: add helper to retrieve interface min/max supported MTU
>>> from vyos.ifconfig import Interface >>> tmp=Interface('eth0') >>> tmp.get_min_mtu() 60 >>> tmp.get_max_mtu() 9000
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig/interface.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index 807191b3d..c8ba05edd 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -78,6 +78,14 @@ class Interface(Control):
'shellcmd': 'ip -json link show dev {ifname}',
'format': lambda j: 'up' if 'UP' in jmespath.search('[*].flags | [0]', json.loads(j)) else 'down',
},
+ 'min_mtu': {
+ 'shellcmd': 'ip -json -detail link list dev {ifname}',
+ 'format': lambda j: jmespath.search('[*].min_mtu | [0]', json.loads(j)),
+ },
+ 'max_mtu': {
+ 'shellcmd': 'ip -json -detail link list dev {ifname}',
+ 'format': lambda j: jmespath.search('[*].max_mtu | [0]', json.loads(j)),
+ },
}
_command_set = {
@@ -282,6 +290,28 @@ class Interface(Control):
cmd = 'ip link del dev {ifname}'.format(**self.config)
return self._cmd(cmd)
+ def get_min_mtu(self):
+ """
+ Get hardware minimum supported MTU
+
+ Example:
+ >>> from vyos.ifconfig import Interface
+ >>> Interface('eth0').get_min_mtu()
+ '60'
+ """
+ return self.get_interface('min_mtu')
+
+ def get_max_mtu(self):
+ """
+ Get hardware maximum supported MTU
+
+ Example:
+ >>> from vyos.ifconfig import Interface
+ >>> Interface('eth0').get_max_mtu()
+ '9000'
+ """
+ return self.get_interface('max_mtu')
+
def get_mtu(self):
"""
Get/set interface mtu in bytes.