summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_ethernet.py12
-rwxr-xr-xsrc/conf_mode/interfaces-ethernet.py11
2 files changed, 16 insertions, 7 deletions
diff --git a/smoketest/scripts/cli/test_interfaces_ethernet.py b/smoketest/scripts/cli/test_interfaces_ethernet.py
index 0f3579c30..6b21853c3 100755
--- a/smoketest/scripts/cli/test_interfaces_ethernet.py
+++ b/smoketest/scripts/cli/test_interfaces_ethernet.py
@@ -136,6 +136,18 @@ class EthernetInterfaceTest(BasicInterfaceTest.BaseTest):
# manually, else tearDown() will have problem in commit()
self.session.delete(unknonw_interface)
+ def test_speed_duplex_verify(self):
+ for interface in self._interfaces:
+ self.session.set(self._base_path + [interface, 'speed', '1000'])
+
+ # check validate() - if either speed or duplex is not auto, the
+ # other one must be manually configured, too
+ with self.assertRaises(ConfigSessionError):
+ self.session.commit()
+ self.session.set(self._base_path + [interface, 'duplex', 'full'])
+
+ self.session.commit()
+
def test_eapol_support(self):
for interface in self._interfaces:
# Enable EAPoL
diff --git a/src/conf_mode/interfaces-ethernet.py b/src/conf_mode/interfaces-ethernet.py
index 0a904c592..e7f0cd6a5 100755
--- a/src/conf_mode/interfaces-ethernet.py
+++ b/src/conf_mode/interfaces-ethernet.py
@@ -62,13 +62,10 @@ def verify(ethernet):
ifname = ethernet['ifname']
verify_interface_exists(ifname)
- if ethernet.get('speed', None) == 'auto':
- if ethernet.get('duplex', None) != 'auto':
- raise ConfigError('If speed is hardcoded, duplex must be hardcoded, too')
-
- if ethernet.get('duplex', None) == 'auto':
- if ethernet.get('speed', None) != 'auto':
- raise ConfigError('If duplex is hardcoded, speed must be hardcoded, too')
+ # No need to check speed and duplex keys as both have default values.
+ if ((ethernet['speed'] == 'auto' and ethernet['duplex'] != 'auto') or
+ (ethernet['speed'] != 'auto' and ethernet['duplex'] == 'auto')):
+ raise ConfigError('Speed/Duplex missmatch. Must be both auto or manually configured')
verify_mtu(ethernet)
verify_mtu_ipv6(ethernet)