dhcp/nettools: accept missing "subnet mask" (option 1) in DHCP lease
Do the same as dhclient plugin in nm_dhcp_utils_ip4_config_from_options(). https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1037
This commit is contained in:
@@ -237,20 +237,26 @@ lease_parse_address(NDhcp4ClientLease *lease,
|
|||||||
}
|
}
|
||||||
|
|
||||||
r = _client_lease_query(lease, NM_DHCP_OPTION_DHCP4_SUBNET_MASK, &l_data, &l_data_len);
|
r = _client_lease_query(lease, NM_DHCP_OPTION_DHCP4_SUBNET_MASK, &l_data, &l_data_len);
|
||||||
if (r != 0
|
if (r == N_DHCP4_E_UNSET) {
|
||||||
|| !nm_dhcp_lease_data_parse_in_addr(l_data,
|
/* Some DHCP servers may not set the subnet-mask (issue#1037).
|
||||||
l_data_len,
|
* Do the same as the dhclient plugin and use a default. */
|
||||||
&a_netmask,
|
a_plen = _nm_utils_ip4_get_default_prefix(a_address.s_addr);
|
||||||
iface,
|
a_netmask = _nm_utils_ip4_prefix_to_netmask(a_plen);
|
||||||
NM_DHCP_OPTION_DHCP4_SUBNET_MASK)) {
|
} else {
|
||||||
nm_utils_error_set_literal(error,
|
if (r != 0
|
||||||
NM_UTILS_ERROR_UNKNOWN,
|
|| !nm_dhcp_lease_data_parse_in_addr(l_data,
|
||||||
"could not get netmask from lease");
|
l_data_len,
|
||||||
return FALSE;
|
&a_netmask,
|
||||||
|
iface,
|
||||||
|
NM_DHCP_OPTION_DHCP4_SUBNET_MASK)) {
|
||||||
|
nm_utils_error_set_literal(error,
|
||||||
|
NM_UTILS_ERROR_UNKNOWN,
|
||||||
|
"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);
|
|
||||||
|
|
||||||
nm_dhcp_option_add_option_in_addr(options,
|
nm_dhcp_option_add_option_in_addr(options,
|
||||||
AF_INET,
|
AF_INET,
|
||||||
NM_DHCP_OPTION_DHCP4_NM_IP_ADDRESS,
|
NM_DHCP_OPTION_DHCP4_NM_IP_ADDRESS,
|
||||||
|
Reference in New Issue
Block a user