Merge pull request #15136 from yuwata/network-dhcp4-use-gateway
network: add a flag to ignore gateway provided by DHCP server
This commit is contained in:
@@ -323,6 +323,9 @@ static int link_set_dhcp_routes(Link *link) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!link->network->dhcp_use_gateway)
|
||||
return 0;
|
||||
|
||||
r = sd_dhcp_lease_get_router(link->dhcp_lease, &router);
|
||||
if (IN_SET(r, 0, -ENODATA))
|
||||
log_link_info(link, "DHCP: No gateway received from DHCP server.");
|
||||
@@ -451,7 +454,7 @@ static int dhcp_remove_router(Link *link, sd_dhcp_lease *lease, const struct in_
|
||||
assert(link);
|
||||
assert(address);
|
||||
|
||||
if (!link->network->dhcp_use_routes)
|
||||
if (!link->network->dhcp_use_gateway)
|
||||
return 0;
|
||||
|
||||
r = sd_dhcp_lease_get_router(lease, &router);
|
||||
|
||||
@@ -163,6 +163,7 @@ DHCPv4.UseMTU, config_parse_bool,
|
||||
DHCPv4.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_use_hostname)
|
||||
DHCPv4.UseDomains, config_parse_dhcp_use_domains, 0, offsetof(Network, dhcp_use_domains)
|
||||
DHCPv4.UseRoutes, config_parse_bool, 0, offsetof(Network, dhcp_use_routes)
|
||||
DHCPv4.UseGateway, config_parse_bool, 0, offsetof(Network, dhcp_use_gateway)
|
||||
DHCPv4.RequestOptions, config_parse_dhcp_request_options, 0, 0
|
||||
DHCPv4.Anonymize, config_parse_bool, 0, offsetof(Network, dhcp_anonymize)
|
||||
DHCPv4.SendHostname, config_parse_bool, 0, offsetof(Network, dhcp_send_hostname)
|
||||
|
||||
@@ -384,6 +384,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
|
||||
.dhcp_use_dns = true,
|
||||
.dhcp_use_hostname = true,
|
||||
.dhcp_use_routes = true,
|
||||
.dhcp_use_gateway = true,
|
||||
/* NOTE: this var might be overwritten by network_apply_anonymize_if_set */
|
||||
.dhcp_send_hostname = true,
|
||||
.dhcp_send_release = true,
|
||||
|
||||
@@ -109,6 +109,7 @@ struct Network {
|
||||
bool dhcp_use_sip;
|
||||
bool dhcp_use_mtu;
|
||||
bool dhcp_use_routes;
|
||||
bool dhcp_use_gateway;
|
||||
bool dhcp_use_timezone;
|
||||
bool rapid_commit;
|
||||
bool dhcp_use_hostname;
|
||||
|
||||
Reference in New Issue
Block a user