summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-09-24 18:33:30 +0200
committerChristian Poessinger <christian@poessinger.com>2019-09-24 21:53:25 +0200
commit8138766884bb7fe301dc21d2cb0bd3556d169d2e (patch)
treefd75470c7006d261f235a325cdd2e4ec2fdfd4b7
parent78badc8690cb06a0062694c21eb5329b830233d5 (diff)
downloadvyos-1x-8138766884bb7fe301dc21d2cb0bd3556d169d2e.tar.gz
vyos-1x-8138766884bb7fe301dc21d2cb0bd3556d169d2e.zip
Python/ifconfig: T1557: refactor Interface 'link_detect' property to set_link_detect()
-rw-r--r--python/vyos/ifconfig.py22
-rwxr-xr-xsrc/conf_mode/interface-bonding.py4
-rwxr-xr-xsrc/conf_mode/interface-bridge.py2
-rwxr-xr-xsrc/conf_mode/interface-ethernet.py4
4 files changed, 9 insertions, 23 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py
index 1f8612681..749bc6a1a 100644
--- a/python/vyos/ifconfig.py
+++ b/python/vyos/ifconfig.py
@@ -235,23 +235,9 @@ class Interface:
return self._write_sysfs('/proc/sys/net/ipv4/neigh/{0}/base_reachable_time_ms'
.format(self._ifname), (int(tmo) * 1000))
- @property
- def link_detect(self):
- """
- How does the kernel act when receiving packets on 'down' interfaces
-
- Example:
- >>> from vyos.ifconfig import Interface
- >>> Interface('eth0').link_detect
- '0'
- """
- return self._read_sysfs('/proc/sys/net/ipv4/conf/{0}/link_filter'
- .format(self._ifname))
-
- @link_detect.setter
- def link_detect(self, link_filter):
+ def set_link_detect(self, link_filter):
"""
- Konfigure kernel response in packets received on interfaces that are 'down'
+ Configure kernel response in packets received on interfaces that are 'down'
0 - Allow packets to be received for the address on this interface
even if interface is disabled or no carrier.
@@ -267,9 +253,9 @@ class Interface:
Example:
>>> from vyos.ifconfig import Interface
- >>> Interface('eth0').link_detect = '1'
+ >>> Interface('eth0').set_link_detect(1)
"""
- if link_filter >= 0 and link_filter <= 2:
+ if int(link_filter) >= 0 and int(link_filter) <= 2:
return self._write_sysfs('/proc/sys/net/ipv4/conf/{0}/link_filter'
.format(self._ifname), link_filter)
else:
diff --git a/src/conf_mode/interface-bonding.py b/src/conf_mode/interface-bonding.py
index 83cd2facc..dce4a8106 100755
--- a/src/conf_mode/interface-bonding.py
+++ b/src/conf_mode/interface-bonding.py
@@ -86,7 +86,7 @@ def apply_vlan_config(vlan, config):
# update interface description used e.g. within SNMP
vlan.ifalias = config['description']
# ignore link state changes
- vlan.link_detect = config['disable_link_detect']
+ vlan.set_link_detect(config['disable_link_detect'])
# Maximum Transmission Unit (MTU)
vlan.set_mtu(config['mtu'])
# Change VLAN interface MAC address
@@ -376,7 +376,7 @@ def apply(bond):
#
# ignore link state changes
- b.link_detect = bond['disable_link_detect']
+ b.set_link_detect(bond['disable_link_detect'])
# Bonding transmit hash policy
b.xmit_hash_policy = bond['hash_policy']
# configure ARP cache timeout in milliseconds
diff --git a/src/conf_mode/interface-bridge.py b/src/conf_mode/interface-bridge.py
index ef8680c5f..558ec3cc6 100755
--- a/src/conf_mode/interface-bridge.py
+++ b/src/conf_mode/interface-bridge.py
@@ -238,7 +238,7 @@ def apply(bridge):
# configure ARP cache timeout
i.arp_cache_tmo = bridge['arp_cache_tmo']
# ignore link state changes
- i.link_detect = bridge['disable_link_detect']
+ i.set_link_detect(bridge['disable_link_detect'])
return None
diff --git a/src/conf_mode/interface-ethernet.py b/src/conf_mode/interface-ethernet.py
index 7708c0086..f4bc53a32 100755
--- a/src/conf_mode/interface-ethernet.py
+++ b/src/conf_mode/interface-ethernet.py
@@ -69,7 +69,7 @@ def apply_vlan_config(vlan, config):
# update interface description used e.g. within SNMP
vlan.ifalias = config['description']
# ignore link state changes
- vlan.link_detect = config['disable_link_detect']
+ vlan.set_link_detect(config['disable_link_detect'])
# Maximum Transmission Unit (MTU)
vlan.set_mtu(config['mtu'])
# Change VLAN interface MAC address
@@ -278,7 +278,7 @@ def apply(eth):
#
# ignore link state changes
- e.link_detect = eth['disable_link_detect']
+ e.set_link_detect(eth['disable_link_detect'])
# disable ethernet flow control (pause frames)
e.set_flow_control(eth['flow_control'])
# configure ARP cache timeout in milliseconds