diff options
author | Martin Basti <mbasti@redhat.com> | 2016-09-02 17:07:03 +0200 |
---|---|---|
committer | David Kupka <dkupka@redhat.com> | 2016-09-07 16:22:03 +0200 |
commit | 71ad8d4fc982b5349248d50338e1d16ce45c523e (patch) | |
tree | 4e59604db2722432ef625f8da575a029a94a0bf7 /ipapython | |
parent | 81d64d530cca148198312d3d993502575b288f63 (diff) | |
download | freeipa-71ad8d4fc982b5349248d50338e1d16ce45c523e.tar.gz freeipa-71ad8d4fc982b5349248d50338e1d16ce45c523e.tar.xz freeipa-71ad8d4fc982b5349248d50338e1d16ce45c523e.zip |
Allow broadcast ip addresses
Currently environments may use prefix /31 on point-to-point connections what
makes IPA validators to fail. IPA should not care if IP address is broadcast
or not. In some cases (when prefix is not specified) IPA cannot decide
properly if broadcast address is really broadcast.
This commit allows usage of broadcast addresses in:
* host plugin
* dns plugin
* server-installer
* client-installer
https://fedorahosted.org/freeipa/ticket/5814
Reviewed-By: David Kupka <dkupka@redhat.com>
Diffstat (limited to 'ipapython')
-rw-r--r-- | ipapython/ipautil.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 8a9aa0ed2..6ef39ab12 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -132,8 +132,7 @@ class CheckedIPAddress(UnsafeIPAddress): Reserved or link-local addresses are never accepted. """ def __init__(self, addr, match_local=False, parse_netmask=True, - allow_loopback=False, allow_broadcast=False, - allow_multicast=False): + allow_loopback=False, allow_multicast=False): super(CheckedIPAddress, self).__init__(addr) if isinstance(addr, CheckedIPAddress): @@ -199,15 +198,14 @@ class CheckedIPAddress(UnsafeIPAddress): elif self.version == 6: self._net = netaddr.IPNetwork(str(self) + '/64') - if not allow_broadcast and (self.version == 4 and - self == self._net.broadcast): - raise ValueError("cannot use broadcast IP address {}".format(addr)) - self.prefixlen = self._net.prefixlen def is_network_addr(self): return self == self._net.network + def is_broadcast_addr(self): + return self.version == 4 and self == self._net.broadcast + def valid_ip(addr): return netaddr.valid_ipv4(addr) or netaddr.valid_ipv6(addr) |