network: honor VRF table or explicitly specified route table
This commit is contained in:
parent
d5fa333960
commit
bdb9f58086
|
@ -6,7 +6,6 @@
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "hostname-util.h"
|
#include "hostname-util.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "netdev/vrf.h"
|
|
||||||
#include "network-internal.h"
|
#include "network-internal.h"
|
||||||
#include "networkd-link.h"
|
#include "networkd-link.h"
|
||||||
#include "networkd-manager.h"
|
#include "networkd-manager.h"
|
||||||
|
@ -67,11 +66,7 @@ static int link_set_dhcp_routes(Link *link) {
|
||||||
if (!link->network->dhcp_use_routes)
|
if (!link->network->dhcp_use_routes)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* When the interface is part of an VRF use the VRFs routing table, unless
|
table = link_get_dhcp_route_table(link);
|
||||||
* 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;
|
|
||||||
|
|
||||||
r = sd_dhcp_lease_get_address(link->dhcp_lease, &address);
|
r = sd_dhcp_lease_get_address(link->dhcp_lease, &address);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
|
|
@ -289,6 +289,7 @@ static int dhcp6_lease_pd_prefix_acquired(sd_dhcp6_client *client, Link *link) {
|
||||||
|
|
||||||
if (pd_prefix_len < 64) {
|
if (pd_prefix_len < 64) {
|
||||||
Route *route = NULL;
|
Route *route = NULL;
|
||||||
|
uint32_t table;
|
||||||
|
|
||||||
(void) in_addr_to_string(AF_INET6, &pd_prefix, &buf);
|
(void) in_addr_to_string(AF_INET6, &pd_prefix, &buf);
|
||||||
|
|
||||||
|
@ -300,8 +301,10 @@ static int dhcp6_lease_pd_prefix_acquired(sd_dhcp6_client *client, Link *link) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table = link_get_dhcp_route_table(link);
|
||||||
|
|
||||||
route_add(link, AF_INET6, &pd_prefix, pd_prefix_len,
|
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,
|
route_update(route, NULL, 0, NULL, NULL, 0, 0,
|
||||||
RTN_UNREACHABLE);
|
RTN_UNREACHABLE);
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,7 @@ static int ipv4ll_address_claimed(sd_ipv4ll *ll, Link *link) {
|
||||||
route->scope = RT_SCOPE_LINK;
|
route->scope = RT_SCOPE_LINK;
|
||||||
route->protocol = RTPROT_STATIC;
|
route->protocol = RTPROT_STATIC;
|
||||||
route->priority = IPV4LL_ROUTE_METRIC;
|
route->priority = IPV4LL_ROUTE_METRIC;
|
||||||
|
route->table = link_get_vrf_table(link);
|
||||||
|
|
||||||
r = route_configure(route, link, ipv4ll_route_handler);
|
r = route_configure(route, link, ipv4ll_route_handler);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
#include "missing_network.h"
|
#include "missing_network.h"
|
||||||
|
#include "netdev/vrf.h"
|
||||||
#include "netlink-util.h"
|
#include "netlink-util.h"
|
||||||
#include "network-internal.h"
|
#include "network-internal.h"
|
||||||
#include "networkd-ipv6-proxy-ndp.h"
|
#include "networkd-ipv6-proxy-ndp.h"
|
||||||
|
@ -32,6 +33,24 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "virt.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) {
|
DUID* link_get_duid(Link *link) {
|
||||||
if (link->network->duid.type != _DUID_TYPE_INVALID)
|
if (link->network->duid.type != _DUID_TYPE_INVALID)
|
||||||
return &link->network->duid;
|
return &link->network->duid;
|
||||||
|
|
|
@ -185,6 +185,10 @@ int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***
|
||||||
int link_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
|
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_;
|
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 */
|
/* Macros which append INTERFACE= to the message */
|
||||||
|
|
||||||
#define log_link_full(link, level, error, ...) \
|
#define log_link_full(link, level, error, ...) \
|
||||||
|
|
|
@ -103,7 +103,7 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
|
||||||
return log_link_error_errno(link, r, "Could not allocate route: %m");
|
return log_link_error_errno(link, r, "Could not allocate route: %m");
|
||||||
|
|
||||||
route->family = AF_INET6;
|
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->priority = link->network->dhcp_route_metric;
|
||||||
route->protocol = RTPROT_RA;
|
route->protocol = RTPROT_RA;
|
||||||
route->pref = preference;
|
route->pref = preference;
|
||||||
|
@ -238,7 +238,7 @@ static int ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) {
|
||||||
return log_link_error_errno(link, r, "Could not allocate route: %m");
|
return log_link_error_errno(link, r, "Could not allocate route: %m");
|
||||||
|
|
||||||
route->family = AF_INET6;
|
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->priority = link->network->dhcp_route_metric;
|
||||||
route->protocol = RTPROT_RA;
|
route->protocol = RTPROT_RA;
|
||||||
route->flags = RTM_F_PREFIX;
|
route->flags = RTM_F_PREFIX;
|
||||||
|
@ -299,7 +299,7 @@ static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) {
|
||||||
return log_link_error_errno(link, r, "Could not allocate route: %m");
|
return log_link_error_errno(link, r, "Could not allocate route: %m");
|
||||||
|
|
||||||
route->family = AF_INET6;
|
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->protocol = RTPROT_RA;
|
||||||
route->pref = preference;
|
route->pref = preference;
|
||||||
route->gw.in6 = gateway;
|
route->gw.in6 = gateway;
|
||||||
|
|
Loading…
Reference in a new issue