network: set both dhcp_route_metric and dhcp6_route_metric by DHCP.RouteMetric= for backward compatibility
But [DHCPv4] or [DHCPv6] section take precedence. This also update so for UseDNS= and UseNTP=.
This commit is contained in:
parent
1bf1bfd958
commit
bdad94d0d6
|
@ -63,6 +63,50 @@ int config_parse_dhcp(
|
|||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_dhcp_route_metric(
|
||||
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) {
|
||||
|
||||
Network *network = data;
|
||||
uint32_t metric;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
r = safe_atou32(rvalue, &metric);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Failed to parse RouteMetric=%s, ignoring assignment: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (streq_ptr(section, "DHCPv4")) {
|
||||
network->dhcp_route_metric = metric;
|
||||
network->dhcp_route_metric_set = true;
|
||||
} else if (streq_ptr(section, "DHCPv6")) {
|
||||
network->dhcp6_route_metric = metric;
|
||||
network->dhcp6_route_metric_set = true;
|
||||
} else { /* [DHCP] section */
|
||||
if (!network->dhcp_route_metric_set)
|
||||
network->dhcp_route_metric = metric;
|
||||
if (!network->dhcp6_route_metric_set)
|
||||
network->dhcp6_route_metric = metric;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_dhcp_use_dns(
|
||||
const char* unit,
|
||||
const char *filename,
|
||||
|
@ -90,8 +134,18 @@ int config_parse_dhcp_use_dns(
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (streq_ptr(section, "DHCPv4")) {
|
||||
network->dhcp_use_dns = r;
|
||||
network->dhcp_use_dns_set = true;
|
||||
} else if (streq_ptr(section, "DHCPv6")) {
|
||||
network->dhcp6_use_dns = r;
|
||||
network->dhcp6_use_dns_set = true;
|
||||
} else { /* [DHCP] section */
|
||||
if (!network->dhcp_use_dns_set)
|
||||
network->dhcp_use_dns = r;
|
||||
if (!network->dhcp6_use_dns_set)
|
||||
network->dhcp6_use_dns = r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -155,8 +209,18 @@ int config_parse_dhcp_use_ntp(
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (streq_ptr(section, "DHCPv4")) {
|
||||
network->dhcp_use_ntp = r;
|
||||
network->dhcp_use_ntp_set = true;
|
||||
} else if (streq_ptr(section, "DHCPv6")) {
|
||||
network->dhcp6_use_ntp = r;
|
||||
network->dhcp6_use_ntp_set = true;
|
||||
} else { /* [DHCP] section */
|
||||
if (!network->dhcp_use_ntp_set)
|
||||
network->dhcp_use_ntp = r;
|
||||
if (!network->dhcp6_use_ntp_set)
|
||||
network->dhcp6_use_ntp = r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ const char *dhcp_option_data_type_to_string(DHCPOptionDataType d) _const_;
|
|||
DHCPOptionDataType dhcp_option_data_type_from_string(const char *d) _pure_;
|
||||
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_route_metric);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_dns);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_domains);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_ntp);
|
||||
|
|
|
@ -158,9 +158,9 @@ Route.MultiPathRoute, config_parse_multipath_route,
|
|||
NextHop.Id, config_parse_nexthop_id, 0, 0
|
||||
NextHop.Gateway, config_parse_nexthop_gateway, 0, 0
|
||||
DHCPv4.ClientIdentifier, config_parse_dhcp_client_identifier, 0, offsetof(Network, dhcp_client_identifier)
|
||||
DHCPv4.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_use_dns)
|
||||
DHCPv4.UseDNS, config_parse_dhcp_use_dns, 0, 0
|
||||
DHCPv4.RoutesToDNS, config_parse_bool, 0, offsetof(Network, dhcp_routes_to_dns)
|
||||
DHCPv4.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp_use_ntp)
|
||||
DHCPv4.UseNTP, config_parse_dhcp_use_ntp, 0, 0
|
||||
DHCPv4.UseSIP, config_parse_bool, 0, offsetof(Network, dhcp_use_sip)
|
||||
DHCPv4.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_use_mtu)
|
||||
DHCPv4.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_use_hostname)
|
||||
|
@ -178,7 +178,7 @@ DHCPv4.MaxAttempts, config_parse_dhcp_max_attempts,
|
|||
DHCPv4.UserClass, config_parse_dhcp_user_class, AF_INET, offsetof(Network, dhcp_user_class)
|
||||
DHCPv4.DUIDType, config_parse_duid_type, 0, offsetof(Network, duid)
|
||||
DHCPv4.DUIDRawData, config_parse_duid_rawdata, 0, offsetof(Network, duid)
|
||||
DHCPv4.RouteMetric, config_parse_uint32, 0, offsetof(Network, dhcp_route_metric)
|
||||
DHCPv4.RouteMetric, config_parse_dhcp_route_metric, 0, 0
|
||||
DHCPv4.RouteTable, config_parse_section_route_table, 0, 0
|
||||
DHCPv4.UseTimezone, config_parse_bool, 0, offsetof(Network, dhcp_use_timezone)
|
||||
DHCPv4.IAID, config_parse_iaid, 0, 0
|
||||
|
@ -191,8 +191,8 @@ DHCPv4.SendOption, config_parse_dhcp_send_option,
|
|||
DHCPv4.SendVendorOption, config_parse_dhcp_send_option, 0, offsetof(Network, dhcp_client_send_vendor_options)
|
||||
DHCPv4.RouteMTUBytes, config_parse_mtu, AF_INET, offsetof(Network, dhcp_route_mtu)
|
||||
DHCPv4.FallbackLeaseLifetimeSec, config_parse_dhcp_fallback_lease_lifetime, 0, 0
|
||||
DHCPv6.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp6_use_dns)
|
||||
DHCPv6.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp6_use_ntp)
|
||||
DHCPv6.UseDNS, config_parse_dhcp_use_dns, 0, 0
|
||||
DHCPv6.UseNTP, config_parse_dhcp_use_ntp, 0, 0
|
||||
DHCPv6.RapidCommit, config_parse_bool, 0, offsetof(Network, rapid_commit)
|
||||
DHCPv6.MUDURL, config_parse_dhcp6_mud_url, 0, 0
|
||||
DHCPv6.RequestOptions, config_parse_dhcp_request_options, AF_INET6, 0
|
||||
|
@ -204,7 +204,7 @@ DHCPv6.AssignAcquiredDelegatedPrefixAddress, config_parse_bool,
|
|||
DHCPv6.PrefixDelegationHint, config_parse_dhcp6_pd_hint, 0, 0
|
||||
DHCPv6.WithoutRA, config_parse_bool, 0, offsetof(Network, dhcp6_without_ra)
|
||||
DHCPv6.SendOption, config_parse_dhcp_send_option, AF_INET6, offsetof(Network, dhcp6_client_send_options)
|
||||
DHCPv6.RouteMetric, config_parse_uint32, 0, offsetof(Network, dhcp6_route_metric)
|
||||
DHCPv6.RouteMetric, config_parse_dhcp_route_metric, 0, 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)
|
||||
|
@ -395,7 +395,7 @@ DHCP.VendorClassIdentifier, config_parse_string,
|
|||
DHCP.UserClass, config_parse_dhcp_user_class, AF_INET, offsetof(Network, dhcp_user_class)
|
||||
DHCP.DUIDType, config_parse_duid_type, 0, offsetof(Network, duid)
|
||||
DHCP.DUIDRawData, config_parse_duid_rawdata, 0, offsetof(Network, duid)
|
||||
DHCP.RouteMetric, config_parse_uint32, 0, offsetof(Network, dhcp_route_metric)
|
||||
DHCP.RouteMetric, config_parse_dhcp_route_metric, 0, 0
|
||||
DHCP.RouteTable, config_parse_section_route_table, 0, 0
|
||||
DHCP.UseTimezone, config_parse_bool, 0, offsetof(Network, dhcp_use_timezone)
|
||||
DHCP.IAID, config_parse_iaid, 0, 0
|
||||
|
|
|
@ -96,6 +96,7 @@ struct Network {
|
|||
char *dhcp_hostname;
|
||||
uint64_t dhcp_max_attempts;
|
||||
uint32_t dhcp_route_metric;
|
||||
bool dhcp_route_metric_set;
|
||||
uint32_t dhcp_route_table;
|
||||
uint32_t dhcp_fallback_lease_lifetime;
|
||||
uint32_t dhcp_route_mtu;
|
||||
|
@ -106,8 +107,10 @@ struct Network {
|
|||
bool dhcp_send_hostname;
|
||||
bool dhcp_broadcast;
|
||||
bool dhcp_use_dns;
|
||||
bool dhcp_use_dns_set;
|
||||
bool dhcp_routes_to_dns;
|
||||
bool dhcp_use_ntp;
|
||||
bool dhcp_use_ntp_set;
|
||||
bool dhcp_use_sip;
|
||||
bool dhcp_use_mtu;
|
||||
bool dhcp_use_routes;
|
||||
|
@ -129,10 +132,13 @@ struct Network {
|
|||
|
||||
/* DHCPv6 Client support*/
|
||||
bool dhcp6_use_dns;
|
||||
bool dhcp6_use_dns_set;
|
||||
bool dhcp6_use_ntp;
|
||||
bool dhcp6_use_ntp_set;
|
||||
bool dhcp6_without_ra;
|
||||
uint8_t dhcp6_pd_length;
|
||||
uint32_t dhcp6_route_metric;
|
||||
bool dhcp6_route_metric_set;
|
||||
char *dhcp6_mudurl;
|
||||
char **dhcp6_user_class;
|
||||
char **dhcp6_vendor_class;
|
||||
|
|
Loading…
Reference in a new issue