dhcp/dhclient: fix setting "src" attribute for certain routes

Fixes: 2dc7a3d9f9 ('dhcp: set "src" for DHCPv4 routes')
This commit is contained in:
Thomas Haller 2022-04-13 10:43:13 +02:00
parent 8e5f60dfd3
commit 197e73ac7c
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -277,7 +277,10 @@ ip4_process_classless_routes(const char *iface,
}
static void
process_classful_routes(const char *iface, GHashTable *options, NML3ConfigData *l3cd)
process_classful_routes(const char *iface,
GHashTable *options,
NML3ConfigData *l3cd,
in_addr_t address)
{
gs_free const char **searches = NULL;
const char **s;
@ -326,6 +329,7 @@ process_classful_routes(const char *iface, GHashTable *options, NML3ConfigData *
route.plen = 32;
}
route.gateway = rt_route;
route.pref_src = address;
route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
route.table_any = TRUE;
route.table_coerced = 0;
@ -428,7 +432,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
* the 'static_routes' option.
*/
if (!ip4_process_classless_routes(iface, options, l3cd, address.address, &gateway))
process_classful_routes(iface, options, l3cd);
process_classful_routes(iface, options, l3cd, address.address);
if (gateway) {
_LOG2I(LOGD_DHCP4, iface, " gateway %s", _nm_utils_inet4_ntop(gateway, sbuf));
@ -458,6 +462,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
const NMPlatformIP4Route r = {
.rt_source = NM_IP_CONFIG_SOURCE_DHCP,
.gateway = gateway,
.pref_src = address.address,
.table_any = TRUE,
.table_coerced = 0,
.metric_any = TRUE,