#include "alloc-util.h"
#include "hostname-util.h"
#include "parse-util.h"
-#include "netdev/vrf.h"
#include "network-internal.h"
#include "networkd-link.h"
#include "networkd-manager.h"
if (!link->network->dhcp_use_routes)
return 0;
- /* 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)
- table = VRF(link->network->vrf)->table;
+ table = link_get_dhcp_route_table(link);
r = sd_dhcp_lease_get_address(link->dhcp_lease, &address);
if (r < 0)
if (pd_prefix_len < 64) {
Route *route = NULL;
+ uint32_t table;
(void) in_addr_to_string(AF_INET6, &pd_prefix, &buf);
continue;
}
+ table = link_get_dhcp_route_table(link);
+
route_add(link, AF_INET6, &pd_prefix, pd_prefix_len,
- 0, 0, 0, &route);
+ 0, 0, table, &route);
route_update(route, NULL, 0, NULL, NULL, 0, 0,
RTN_UNREACHABLE);
route->scope = RT_SCOPE_LINK;
route->protocol = RTPROT_STATIC;
route->priority = IPV4LL_ROUTE_METRIC;
+ route->table = link_get_vrf_table(link);
r = route_configure(route, link, ipv4ll_route_handler);
if (r < 0)
#include "fd-util.h"
#include "fileio.h"
#include "missing_network.h"
+#include "netdev/vrf.h"
#include "netlink-util.h"
#include "network-internal.h"
#include "networkd-ipv6-proxy-ndp.h"
#include "util.h"
#include "virt.h"
+uint32_t link_get_vrf_table(Link *link) {
+ return link->network->vrf ? VRF(link->network->vrf)->table : RT_TABLE_MAIN;
+}
+
+uint32_t link_get_dhcp_route_table(Link *link) {
+ /* When the interface is part of an VRF use the VRFs routing table, unless
+ * another table is explicitly specified. */
+ if (link->network->dhcp_route_table_set)
+ return link->network->dhcp_route_table;
+ return link_get_vrf_table(link);
+}
+
+uint32_t link_get_ipv6_accept_ra_route_table(Link *link) {
+ if (link->network->ipv6_accept_ra_route_table_set)
+ return link->network->ipv6_accept_ra_route_table;
+ return link_get_vrf_table(link);
+}
+
DUID* link_get_duid(Link *link) {
if (link->network->duid.type != _DUID_TYPE_INVALID)
return &link->network->duid;
int link_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
int link_send_changed(Link *link, const char *property, ...) _sentinel_;
+uint32_t link_get_vrf_table(Link *link);
+uint32_t link_get_dhcp_route_table(Link *link);
+uint32_t link_get_ipv6_accept_ra_route_table(Link *link);
+
/* Macros which append INTERFACE= to the message */
#define log_link_full(link, level, error, ...) \
return log_link_error_errno(link, r, "Could not allocate route: %m");
route->family = AF_INET6;
- route->table = link->network->ipv6_accept_ra_route_table;
+ route->table = link_get_ipv6_accept_ra_route_table(link);
route->priority = link->network->dhcp_route_metric;
route->protocol = RTPROT_RA;
route->pref = preference;
return log_link_error_errno(link, r, "Could not allocate route: %m");
route->family = AF_INET6;
- route->table = link->network->ipv6_accept_ra_route_table;
+ route->table = link_get_ipv6_accept_ra_route_table(link);
route->priority = link->network->dhcp_route_metric;
route->protocol = RTPROT_RA;
route->flags = RTM_F_PREFIX;
return log_link_error_errno(link, r, "Could not allocate route: %m");
route->family = AF_INET6;
- route->table = link->network->ipv6_accept_ra_route_table;
+ route->table = link_get_ipv6_accept_ra_route_table(link);
route->protocol = RTPROT_RA;
route->pref = preference;
route->gw.in6 = gateway;