/* When the interface is part of an VRF use the VRFs routing table, unless
* there is a another table specified. */
table = link->network->dhcp_route_table;
- if (!link->network->dhcp_route_table_set && link->network->vrf != NULL)
+ if (!link->network->dhcp_route_table_set && link->network->vrf)
table = VRF(link->network->vrf)->table;
r = sd_dhcp_lease_get_address(link->dhcp_lease, &address);
log_link_warning(link, "Classless static routes received from DHCP server: ignoring static-route option and router option");
if (r >= 0 && !classless_route) {
- _cleanup_(route_freep) Route *route = NULL;
- _cleanup_(route_freep) Route *route_gw = NULL;
-
- r = route_new(&route);
- if (r < 0)
- return log_link_error_errno(link, r, "Could not allocate route: %m");
-
- route->protocol = RTPROT_DHCP;
+ _cleanup_(route_freep) Route *route = NULL, *route_gw = NULL;
r = route_new(&route_gw);
if (r < 0)
link->dhcp4_messages++;
+ r = route_new(&route);
+ if (r < 0)
+ return log_link_error_errno(link, r, "Could not allocate route: %m");
+
route->family = AF_INET;
route->gw.in = gateway;
route->prefsrc.in = address;
+ route->protocol = RTPROT_DHCP;
route->priority = link->network->dhcp_route_metric;
route->table = table;