mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-08 20:58:20 +03:00
networkd: Allow specifying RouteTable for DHCP
This commit is contained in:
parent
dd8352659c
commit
f594276b86
@ -917,6 +917,15 @@
|
||||
DHCP server.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>RouteTable=<replaceable>num</replaceable></varname></term>
|
||||
<listitem>
|
||||
<para>The table identifier for dhcp routes (a number between 1 and 4294967295, or 0 to unset).
|
||||
The table can be retrieved using <command>ip route show table <replaceable>num</replaceable></command>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
@ -95,6 +95,7 @@ static int link_set_dhcp_routes(Link *link) {
|
||||
route_gw->scope = RT_SCOPE_LINK;
|
||||
route_gw->protocol = RTPROT_DHCP;
|
||||
route_gw->priority = link->network->dhcp_route_metric;
|
||||
route_gw->table = link->network->dhcp_route_table;
|
||||
|
||||
r = route_configure(route_gw, link, dhcp4_route_handler);
|
||||
if (r < 0)
|
||||
@ -106,6 +107,7 @@ static int link_set_dhcp_routes(Link *link) {
|
||||
route->gw.in = gateway;
|
||||
route->prefsrc.in = address;
|
||||
route->priority = link->network->dhcp_route_metric;
|
||||
route->table = link->network->dhcp_route_table;
|
||||
|
||||
r = route_configure(route, link, dhcp4_route_handler);
|
||||
if (r < 0) {
|
||||
@ -136,6 +138,7 @@ static int link_set_dhcp_routes(Link *link) {
|
||||
assert_se(sd_dhcp_route_get_destination(static_routes[i], &route->dst.in) >= 0);
|
||||
assert_se(sd_dhcp_route_get_destination_prefix_length(static_routes[i], &route->dst_prefixlen) >= 0);
|
||||
route->priority = link->network->dhcp_route_metric;
|
||||
route->table = link->network->dhcp_route_table;
|
||||
|
||||
r = route_configure(route, link, dhcp4_route_handler);
|
||||
if (r < 0)
|
||||
|
@ -92,6 +92,7 @@ DHCP.VendorClassIdentifier, config_parse_string,
|
||||
DHCP.DUIDType, config_parse_duid_type, 0, offsetof(Network, duid.type)
|
||||
DHCP.DUIDRawData, config_parse_duid_rawdata, 0, offsetof(Network, duid)
|
||||
DHCP.RouteMetric, config_parse_unsigned, 0, offsetof(Network, dhcp_route_metric)
|
||||
DHCP.RouteTable, config_parse_dhcp_route_table, 0, offsetof(Network, dhcp_route_table)
|
||||
DHCP.UseTimezone, config_parse_bool, 0, offsetof(Network, dhcp_use_timezone)
|
||||
DHCP.IAID, config_parse_iaid, 0, offsetof(Network, iaid)
|
||||
IPv6AcceptRA.UseDNS, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_dns)
|
||||
|
@ -111,6 +111,7 @@ static int network_load_one(Manager *manager, const char *filename) {
|
||||
network->dhcp_send_hostname = true;
|
||||
network->dhcp_route_metric = DHCP_ROUTE_METRIC;
|
||||
network->dhcp_client_identifier = DHCP_CLIENT_ID_DUID;
|
||||
network->dhcp_route_table = RT_TABLE_MAIN;
|
||||
|
||||
network->dhcp_server_emit_dns = true;
|
||||
network->dhcp_server_emit_ntp = true;
|
||||
@ -1033,6 +1034,36 @@ int config_parse_dnssec_negative_trust_anchors(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_dhcp_route_table(const char *unit,
|
||||
const char *filename,
|
||||
unsigned line,
|
||||
const char *section,
|
||||
unsigned section_line,
|
||||
const char *lvalue,
|
||||
int ltype,
|
||||
const char *rvalue,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
uint32_t rt;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
r = safe_atou32(rvalue, &rt);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Unable to read RouteTable, ignoring assignment: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*((uint32_t *)data) = rt;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_dhcp_use_domains, dhcp_use_domains, DHCPUseDomains, "Failed to parse DHCP use domains setting");
|
||||
|
||||
static const char* const dhcp_use_domains_table[_DHCP_USE_DOMAINS_MAX] = {
|
||||
|
@ -123,6 +123,7 @@ struct Network {
|
||||
bool dhcp_use_routes;
|
||||
bool dhcp_use_timezone;
|
||||
unsigned dhcp_route_metric;
|
||||
uint32_t dhcp_route_table;
|
||||
|
||||
/* DHCP Server Support */
|
||||
bool dhcp_server;
|
||||
@ -228,6 +229,7 @@ int config_parse_dhcp_server_ntp(const char *unit, const char *filename, unsigne
|
||||
int config_parse_dnssec_negative_trust_anchors(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
int config_parse_dhcp_use_domains(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
int config_parse_lldp_mode(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
int config_parse_dhcp_route_table(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
|
||||
/* Legacy IPv4LL support */
|
||||
int config_parse_ipv4ll(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
|
Loading…
x
Reference in New Issue
Block a user