</varlistentry>
<varlistentry>
+ <term><varname>RouteMetric=</varname></term>
<term><varname>UseDNS=</varname></term>
<term><varname>UseNTP=</varname></term>
<term><varname>UseHostname=</varname></term>
#include "socket-util.h"
#include "string-table.h"
#include "strv.h"
+#include "vrf.h"
+
+static uint32_t link_get_vrf_table(Link *link) {
+ assert(link);
+ assert(link->network);
+
+ return link->network->vrf ? VRF(link->network->vrf)->table : RT_TABLE_MAIN;
+}
+
+uint32_t link_get_dhcp4_route_table(Link *link) {
+ assert(link);
+ assert(link->network);
+
+ /* 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_dhcp6_route_table(Link *link) {
+ assert(link);
+ assert(link->network);
+
+ if (link->network->dhcp6_route_table_set)
+ return link->network->dhcp6_route_table;
+ return link_get_vrf_table(link);
+}
+
+uint32_t link_get_ipv6_accept_ra_route_table(Link *link) {
+ assert(link);
+ assert(link->network);
+
+ if (link->network->ipv6_accept_ra_route_table_set)
+ return link->network->ipv6_accept_ra_route_table;
+ return link_get_vrf_table(link);
+}
bool link_dhcp_enabled(Link *link, int family) {
assert(link);
return 0;
}
-int config_parse_section_route_table(
+int config_parse_dhcp_or_ra_route_table(
const char *unit,
const char *filename,
unsigned line,
assert(filename);
assert(lvalue);
+ assert(IN_SET(ltype,
+ (RTPROT_DHCP<<16) | AF_UNSPEC,
+ (RTPROT_DHCP<<16) | AF_INET,
+ (RTPROT_DHCP<<16) | AF_INET6,
+ (RTPROT_RA<<16) | AF_INET6));
assert(rvalue);
assert(data);
return 0;
}
- if (STRPTR_IN_SET(section, "DHCP", "DHCPv4")) {
+ switch(ltype) {
+ case (RTPROT_DHCP<<16) | AF_INET:
network->dhcp_route_table = rt;
network->dhcp_route_table_set = true;
- } else { /* section is IPv6AcceptRA */
+ network->dhcp_route_table_set_explicitly = true;
+ break;
+ case (RTPROT_DHCP<<16) | AF_INET6:
+ network->dhcp6_route_table = rt;
+ network->dhcp6_route_table_set = true;
+ network->dhcp6_route_table_set_explicitly = true;
+ break;
+ case (RTPROT_DHCP<<16) | AF_UNSPEC:
+ /* For backward compatibility. */
+ if (!network->dhcp_route_table_set_explicitly) {
+ network->dhcp_route_table = rt;
+ network->dhcp_route_table_set = true;
+ }
+ if (!network->dhcp6_route_table_set_explicitly) {
+ network->dhcp6_route_table = rt;
+ network->dhcp6_route_table_set = true;
+ }
+ break;
+ case (RTPROT_RA<<16) | AF_INET6:
network->ipv6_accept_ra_route_table = rt;
network->ipv6_accept_ra_route_table_set = true;
+ break;
+ default:
+ assert_not_reached();
}
return 0;
bool set;
} DUID;
+uint32_t link_get_dhcp4_route_table(Link *link);
+uint32_t link_get_dhcp6_route_table(Link *link);
+uint32_t link_get_ipv6_accept_ra_route_table(Link *link);
+
bool link_dhcp_enabled(Link *link, int family);
static inline bool link_dhcp4_enabled(Link *link) {
return link_dhcp_enabled(link, AF_INET);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_domains);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_ntp);
CONFIG_PARSER_PROTOTYPE(config_parse_iaid);
-CONFIG_PARSER_PROTOTYPE(config_parse_section_route_table);
+CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_or_ra_route_table);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_user_or_vendor_class);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_send_option);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_request_options);
if (!route->priority_set)
route->priority = link->network->dhcp_route_metric;
if (!route->table_set)
- route->table = link_get_dhcp_route_table(link);
+ route->table = link_get_dhcp4_route_table(link);
if (route->mtu == 0)
route->mtu = link->network->dhcp_route_mtu;
route->family = AF_INET6;
route->dst.in6 = *addr;
route->dst_prefixlen = prefixlen;
- route->table = link_get_dhcp_route_table(link);
+ route->table = link_get_dhcp6_route_table(link);
route->type = RTN_UNREACHABLE;
route->protocol = RTPROT_DHCP;
DHCPv4.DUIDType, config_parse_network_duid_type, 0, 0
DHCPv4.DUIDRawData, config_parse_network_duid_rawdata, 0, 0
DHCPv4.RouteMetric, config_parse_dhcp_or_ra_route_metric, AF_INET, 0
-DHCPv4.RouteTable, config_parse_section_route_table, 0, 0
+DHCPv4.RouteTable, config_parse_dhcp_or_ra_route_table, (RTPROT_DHCP<<16) | AF_INET, 0
DHCPv4.UseTimezone, config_parse_bool, 0, offsetof(Network, dhcp_use_timezone)
DHCPv4.ListenPort, config_parse_uint16, 0, offsetof(Network, dhcp_client_port)
DHCPv4.SendRelease, config_parse_bool, 0, offsetof(Network, dhcp_send_release)
DHCPv6.IAID, config_parse_iaid, AF_INET6, 0
DHCPv6.DUIDType, config_parse_duid_type, 0, offsetof(Network, dhcp6_duid)
DHCPv6.DUIDRawData, config_parse_duid_rawdata, 0, offsetof(Network, dhcp6_duid)
+DHCPv6.RouteTable, config_parse_dhcp_or_ra_route_table, (RTPROT_DHCP<<16) | AF_INET6, 0
IPv6AcceptRA.UseAutonomousPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_autonomous_prefix)
IPv6AcceptRA.UseOnLinkPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_onlink_prefix)
IPv6AcceptRA.UseDNS, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_dns)
IPv6AcceptRA.UseDomains, config_parse_ipv6_accept_ra_use_domains, 0, offsetof(Network, ipv6_accept_ra_use_domains)
IPv6AcceptRA.UseMTU, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_mtu)
IPv6AcceptRA.DHCPv6Client, config_parse_ipv6_accept_ra_start_dhcp6_client, 0, offsetof(Network, ipv6_accept_ra_start_dhcp6_client)
-IPv6AcceptRA.RouteTable, config_parse_section_route_table, 0, 0
+IPv6AcceptRA.RouteTable, config_parse_dhcp_or_ra_route_table, (RTPROT_RA<<16) | AF_INET6, 0
IPv6AcceptRA.RouteMetric, config_parse_dhcp_or_ra_route_metric, AF_INET6, 0
IPv6AcceptRA.RouterAllowList, config_parse_address_filter, AF_INET6, offsetof(Network, ndisc_allow_listed_router)
IPv6AcceptRA.RouterDenyList, config_parse_address_filter, AF_INET6, offsetof(Network, ndisc_deny_listed_router)
DHCP.DUIDType, config_parse_network_duid_type, 0, 0
DHCP.DUIDRawData, config_parse_network_duid_rawdata, 0, 0
DHCP.RouteMetric, config_parse_dhcp_or_ra_route_metric, AF_UNSPEC, 0
-DHCP.RouteTable, config_parse_section_route_table, 0, 0
+DHCP.RouteTable, config_parse_dhcp_or_ra_route_table, (RTPROT_DHCP<<16) | AF_UNSPEC, 0
DHCP.UseTimezone, config_parse_bool, 0, offsetof(Network, dhcp_use_timezone)
DHCP.ListenPort, config_parse_uint16, 0, offsetof(Network, dhcp_client_port)
DHCP.RapidCommit, config_parse_bool, 0, offsetof(Network, dhcp6_rapid_commit)
uint32_t dhcp_route_metric;
bool dhcp_route_metric_set;
uint32_t dhcp_route_table;
+ bool dhcp_route_table_set;
+ bool dhcp_route_table_set_explicitly;
uint32_t dhcp_fallback_lease_lifetime;
uint32_t dhcp_route_mtu;
uint16_t dhcp_client_port;
int dhcp_use_gateway;
bool dhcp_use_timezone;
bool dhcp_use_hostname;
- bool dhcp_route_table_set;
bool dhcp_send_release;
bool dhcp_send_decline;
DHCPUseDomains dhcp_use_domains;
bool dhcp6_use_ntp;
bool dhcp6_use_ntp_set;
bool dhcp6_rapid_commit;
+ bool dhcp6_route_table;
+ bool dhcp6_route_table_set;
+ bool dhcp6_route_table_set_explicitly;
DHCPUseDomains dhcp6_use_domains;
bool dhcp6_use_domains_set;
uint32_t dhcp6_iaid;
#define ROUTES_DEFAULT_MAX_PER_FAMILY 4096U
-static uint32_t link_get_vrf_table(const Link *link) {
- return link->network->vrf ? VRF(link->network->vrf)->table : RT_TABLE_MAIN;
-}
-
-uint32_t link_get_dhcp_route_table(const 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(const 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);
-}
-
static const char * const route_type_table[__RTN_MAX] = {
[RTN_UNICAST] = "unicast",
[RTN_LOCAL] = "local",
int link_drop_routes(Link *link);
int link_drop_foreign_routes(Link *link);
-uint32_t link_get_dhcp_route_table(const Link *link);
-uint32_t link_get_ipv6_accept_ra_route_table(const Link *link);
-
int link_request_route(
Link *link,
Route *route,
IAID=
DUIDType=
DUIDRawData=
+RouteTable=
[DHCPv6PrefixDelegation]
SubnetId=
Announce=