From c06e6390a48d45cc13a225a1ea99165f4cb933fd Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 21 Jun 2022 11:26:23 +0200 Subject: [PATCH] dhcp/nettools: normalize subnet netmask in nettools client For an IPv4 subnet mask we expect that all the leading bits are set (no "holes"). But _nm_utils_ip4_netmask_to_prefix() does not enforce that, and tries to make the best of it. In face of a netmask with holes, normalize the mask. --- src/core/dhcp/nm-dhcp-nettools.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/dhcp/nm-dhcp-nettools.c b/src/core/dhcp/nm-dhcp-nettools.c index 0a25f90d27..4fe0a9394d 100644 --- a/src/core/dhcp/nm-dhcp-nettools.c +++ b/src/core/dhcp/nm-dhcp-nettools.c @@ -254,7 +254,8 @@ lease_parse_address(NDhcp4ClientLease *lease, "could not get netmask from lease"); return FALSE; } - a_plen = _nm_utils_ip4_netmask_to_prefix(a_netmask); + a_plen = _nm_utils_ip4_netmask_to_prefix(a_netmask); + a_netmask = _nm_utils_ip4_prefix_to_netmask(a_plen); } nm_dhcp_option_add_option_in_addr(options,