Edward Haas has uploaded a new change for review.
Change subject: net: support nameserver address with %iface tail ......................................................................
net: support nameserver address with %iface tail
The nameserver address may include an %<iface> tail, to specify on which iface the address is to be reached.
The patch fixes the validation of the nameserver address when this tail exists. In addition, unit tests have been placed to cover the ip validation scenarios.
Change-Id: Iea4d2eea2af8004435dae54ad56588739e028ba2 Signed-off-by: Edward Haas edwardh@redhat.com --- M lib/vdsm/network/ip/validator.py M tests/network/ip_test.py 2 files changed, 51 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/65693/1
diff --git a/lib/vdsm/network/ip/validator.py b/lib/vdsm/network/ip/validator.py index 9e84bd1..113f2c0 100644 --- a/lib/vdsm/network/ip/validator.py +++ b/lib/vdsm/network/ip/validator.py @@ -48,7 +48,17 @@
def _validate_nameservers_address(nameservers_addr): for addr in nameservers_addr: + addr = _normalize_address(addr) if ':' in addr: IPv6.validateAddress(addr) else: IPv4.validateAddress(addr) + + +def _normalize_address(addr): + """ + The nameserver address may be tailed with the interface from which it + should be reached: '2001::1%eth0' + For the purpose of address validation, such tail is ignored. + """ + return addr.split('%', 1)[0] diff --git a/tests/network/ip_test.py b/tests/network/ip_test.py index 8dc328e..e4c7a7e 100644 --- a/tests/network/ip_test.py +++ b/tests/network/ip_test.py @@ -22,7 +22,9 @@
from testlib import VdsmTestCase
+from vdsm.network import errors as ne from vdsm.network.ip import address +from vdsm.network.ip import validator
@attr(type='unit') @@ -44,3 +46,42 @@ self.assertEqual(None, ip.address) self.assertEqual(None, ip.gateway) self.assertEqual(None, ip.defaultRoute) + + +@attr(type='unit') +class TestIPValidator(VdsmTestCase): + + def test_ignore_remove_networks(self): + validator.validate({'NET0': {'remove': True, + 'defaultRoute': False, + 'nameservers': ['8.8.8.8']}}) + + def test_nameserver_defined_on_a_non_primary_network_fails(self): + with self.assertRaises(ne.ConfigNetworkError) as cne: + validator.validate({'NET0': {'defaultRoute': False, + 'nameservers': ['8.8.8.8']}}) + self.assertEqual(cne.exception.errCode, ne.ERR_BAD_PARAMS) + + def test_nameserver_faulty_ipv4_address(self): + with self.assertRaises(ne.ConfigNetworkError) as cne: + validator.validate({'NET0': {'defaultRoute': True, + 'nameservers': ['a.8.8.8']}}) + self.assertEqual(cne.exception.errCode, ne.ERR_BAD_ADDR) + + def test_nameserver_faulty_ipv6_address(self): + with self.assertRaises(ne.ConfigNetworkError) as cne: + validator.validate({'NET0': {'defaultRoute': True, + 'nameservers': ['2001:bla::1']}}) + self.assertEqual(cne.exception.errCode, ne.ERR_BAD_ADDR) + + def test_nameserver_valid_ipv4_address(self): + validator.validate({'NET0': {'defaultRoute': True, + 'nameservers': ['8.8.8.8']}}) + + def test_nameserver_valid_ipv6_address(self): + validator.validate({'NET0': {'defaultRoute': True, + 'nameservers': ['2001::1']}}) + + def test_nameserver_address_with_interface_tail(self): + validator.validate({'NET0': {'defaultRoute': True, + 'nameservers': ['2001::1%eth1']}})
gerrit-hooks has posted comments on this change.
Change subject: net: support nameserver address with %iface tail ......................................................................
Patch Set 1:
* Update Tracker::IGNORE, no bug url/s found * Check Bug-Url::IGNORE, not relevant for branch: master * Check Public Bug::WARN, no public bug url found * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
Dominik Holler has posted comments on this change.
Change subject: net: support nameserver address with %iface tail ......................................................................
Patch Set 1: Code-Review+1
(2 comments)
Currently I only know that the zone id is used for local link addresses, for this reason I suggest to use a local link address as the sample address.
https://gerrit.ovirt.org/#/c/65693/1/lib/vdsm/network/ip/validator.py File lib/vdsm/network/ip/validator.py:
PS1, Line 61: 2001::1%eth0 The zone id is usually used for local link addresses. For this reason would be a local link address here more clean.
https://gerrit.ovirt.org/#/c/65693/1/tests/network/ip_test.py File tests/network/ip_test.py:
PS1, Line 87: 2001::1%eth1 The zone id is usually used for local link addresses. For this reason would be a local link address here more clean.
Edward Haas has posted comments on this change.
Change subject: net: support nameserver address with %iface tail ......................................................................
Patch Set 1:
(1 comment)
https://gerrit.ovirt.org/#/c/65693/1/tests/network/ip_test.py File tests/network/ip_test.py:
PS1, Line 87: 2001::1%eth1
The zone id is usually used for local link addresses. For this reason would
Do you have a reference to the usage of this %tail? I could not seen any specification that limits it to the local scope, on the other hand,I could not find any official text about that '%' in general.
Dominik Holler has posted comments on this change.
Change subject: net: support nameserver address with %iface tail ......................................................................
Patch Set 1:
(1 comment)
https://gerrit.ovirt.org/#/c/65693/1/tests/network/ip_test.py File tests/network/ip_test.py:
PS1, Line 87: 2001::1%eth1
Do you have a reference to the usage of this %tail? I could not seen any sp
rfc6874 does not limit to local link, but seems to be the most relevant usage.
gerrit-hooks has posted comments on this change.
Change subject: net: support nameserver address with %iface tail ......................................................................
Patch Set 2:
* Update Tracker::IGNORE, no bug url/s found * Check Bug-Url::IGNORE, not relevant for branch: master * Check Public Bug::WARN, no public bug url found * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
Edward Haas has posted comments on this change.
Change subject: net: support nameserver address with %iface tail ......................................................................
Patch Set 2:
(1 comment)
https://gerrit.ovirt.org/#/c/65693/1/tests/network/ip_test.py File tests/network/ip_test.py:
PS1, Line 87: fe80::1%eth1
rfc6874 does not limit to local link, but seems to be the most relevant usa
Done
gerrit-hooks has posted comments on this change.
Change subject: net: support nameserver address with %iface tail ......................................................................
Patch Set 3:
* Update Tracker::IGNORE, no bug url/s found * Check Bug-Url::IGNORE, not relevant for branch: master * Check Public Bug::WARN, no public bug url found * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
Edward Haas has posted comments on this change.
Change subject: net: support nameserver address with %iface tail ......................................................................
Patch Set 3: Verified+1
Petr Horáček has posted comments on this change.
Change subject: net: support nameserver address with %iface tail ......................................................................
Patch Set 3: Code-Review-1
We should add a test to func_dns_test.py, to check if both ifcfg and our caps reporting are OK with this usage.
Edward Haas has posted comments on this change.
Change subject: net: support nameserver address with %iface tail ......................................................................
Patch Set 3:
Nothing changed in the reporting or setup itself, only in the validation. It is not practical to test all possible scenarios in functional tests, that's why we have unit tests.
Petr Horáček has posted comments on this change.
Change subject: net: support nameserver address with %iface tail ......................................................................
Patch Set 3: Code-Review+1
Dan Kenigsberg has posted comments on this change.
Change subject: net: support nameserver address with %iface tail ......................................................................
Patch Set 3: Code-Review+2
Dan Kenigsberg has submitted this change and it was merged.
Change subject: net: support nameserver address with %iface tail ......................................................................
net: support nameserver address with %iface tail
The nameserver address may include an %<iface> tail, to specify on which iface the address is to be reached.
The patch fixes the validation of the nameserver address when this tail exists. In addition, unit tests have been placed to cover the ip validation scenarios.
Change-Id: Iea4d2eea2af8004435dae54ad56588739e028ba2 Signed-off-by: Edward Haas edwardh@redhat.com Reviewed-on: https://gerrit.ovirt.org/65693 Continuous-Integration: Jenkins CI Reviewed-by: Petr Horáček phoracek@redhat.com Reviewed-by: Dan Kenigsberg danken@redhat.com --- M lib/vdsm/network/ip/validator.py M tests/network/ip_test.py 2 files changed, 53 insertions(+), 0 deletions(-)
Approvals: Jenkins CI: Passed CI tests Petr Horáček: Looks good to me, but someone else must approve Dan Kenigsberg: Looks good to me, approved Edward Haas: Verified
gerrit-hooks has posted comments on this change.
Change subject: net: support nameserver address with %iface tail ......................................................................
Patch Set 4:
* update_tracker: OK * Set MODIFIED::IGNORE, no Bug-Url found.
vdsm-patches@lists.fedorahosted.org