summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-12-14 17:04:21 +0100
committerThomas Haller <thaller@redhat.com>2018-12-19 09:23:08 +0100
commit3102b49f623c499638c8f284c2f651829f904dc2 (patch)
tree95844e19b70d2a0d61688e5735511518068b6831
parent9a6a35401322e2b387fb164f7f2d68963f4a1512 (diff)
downloadNetworkManager-3102b49f623c499638c8f284c2f651829f904dc2.tar.gz
core: allow addresses with zero prefix length
There is really no problem here, allow it. Previously we would assert against a non-zero prefix length. But I am not sure that all callers really ensured that this couldn't happen. Anyway, there is no problem we such addresses, really. Only we need to make sure that nm_ip4_config_add_dependent_routes() and nm_ip6_config_add_dependent_routes() don't add prefix routes for such addresses (which is the case now).
-rw-r--r--src/dhcp/nm-dhcp-systemd.c1
-rw-r--r--src/nm-ip4-config.c2
-rw-r--r--src/nm-ip6-config.c4
3 files changed, 4 insertions, 3 deletions
diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c
index 3f9530b661..614485c4e7 100644
--- a/src/dhcp/nm-dhcp-systemd.c
+++ b/src/dhcp/nm-dhcp-systemd.c
@@ -310,7 +310,6 @@ lease_to_ip4_config (NMDedupMultiIndex *multi_idx,
SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME,
(guint64) (ts_time + a_lifetime));
- // TODO: ensure a_plen of zero is handled correctly.
nm_ip4_config_add_address (ip4_config,
&((const NMPlatformIP4Address) {
.address = a_address.s_addr,
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c
index a6b6f83fec..1179a77ffa 100644
--- a/src/nm-ip4-config.c
+++ b/src/nm-ip4-config.c
@@ -2113,7 +2113,7 @@ nm_ip4_config_add_address (NMIP4Config *self, const NMPlatformIP4Address *new)
{
g_return_if_fail (self);
g_return_if_fail (new);
- g_return_if_fail (new->plen > 0 && new->plen <= 32);
+ g_return_if_fail (new->plen <= 32);
g_return_if_fail (NM_IP4_CONFIG_GET_PRIVATE (self)->ifindex > 0);
_add_address (self, NULL, new);
diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c
index c1864d338a..6d54809edd 100644
--- a/src/nm-ip6-config.c
+++ b/src/nm-ip6-config.c
@@ -485,6 +485,8 @@ nm_ip6_config_add_dependent_routes (NMIP6Config *self,
if (NM_FLAGS_HAS (my_addr->n_ifa_flags, IFA_F_NOPREFIXROUTE))
continue;
+ if (my_addr->plen == 0)
+ continue;
has_peer = !IN6_IS_ADDR_UNSPECIFIED (&my_addr->peer_address);
@@ -1593,7 +1595,7 @@ nm_ip6_config_add_address (NMIP6Config *self, const NMPlatformIP6Address *new)
{
g_return_if_fail (self);
g_return_if_fail (new);
- g_return_if_fail (new->plen > 0 && new->plen <= 128);
+ g_return_if_fail (new->plen <= 128);
g_return_if_fail (NM_IP6_CONFIG_GET_PRIVATE (self)->ifindex > 0);
_add_address (self, NULL, new);