network: dhcp6: make UplinkInterface=:self imply WithoutRA=solicit
This commit is contained in:
@@ -58,6 +58,25 @@ static int dhcp6_pd_resolve_uplink(Link *link, Link **ret) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static DHCP6ClientStartMode link_get_dhcp6_client_start_mode(Link *link) {
|
||||
Link *uplink;
|
||||
|
||||
assert(link);
|
||||
|
||||
if (!link->network)
|
||||
return DHCP6_CLIENT_START_MODE_NO;
|
||||
|
||||
/* When WithoutRA= is explicitly specified, then honor it. */
|
||||
if (link->network->dhcp6_client_start_mode >= 0)
|
||||
return link->network->dhcp6_client_start_mode;
|
||||
|
||||
if (dhcp6_pd_resolve_uplink(link, &uplink) < 0)
|
||||
return DHCP6_CLIENT_START_MODE_NO;
|
||||
|
||||
/* When this interface itself is an uplink interface, then start dhcp6 client in managed mode */
|
||||
return uplink == link ? DHCP6_CLIENT_START_MODE_SOLICIT : DHCP6_CLIENT_START_MODE_NO;
|
||||
}
|
||||
|
||||
static bool dhcp6_lease_has_pd_prefix(sd_dhcp6_lease *lease) {
|
||||
uint32_t lifetime_preferred_sec, lifetime_valid_sec;
|
||||
struct in6_addr pd_prefix;
|
||||
@@ -1319,7 +1338,7 @@ int dhcp6_start_on_ra(Link *link, bool information_request) {
|
||||
assert(link->network);
|
||||
assert(in6_addr_is_link_local(&link->ipv6ll_address));
|
||||
|
||||
if (link->network->dhcp6_without_ra != DHCP6_CLIENT_START_MODE_NO)
|
||||
if (link_get_dhcp6_client_start_mode(link) != DHCP6_CLIENT_START_MODE_NO)
|
||||
/* When WithoutRA= is specified, then the DHCPv6 client should be already runnging in
|
||||
* the requested mode. Hence, ignore the requests by RA. */
|
||||
return 0;
|
||||
@@ -1359,6 +1378,7 @@ int dhcp6_start_on_ra(Link *link, bool information_request) {
|
||||
}
|
||||
|
||||
int dhcp6_start(Link *link) {
|
||||
DHCP6ClientStartMode start_mode;
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
@@ -1373,9 +1393,6 @@ int dhcp6_start(Link *link) {
|
||||
if (!link_has_carrier(link))
|
||||
return 0;
|
||||
|
||||
if (link->network->dhcp6_without_ra == DHCP6_CLIENT_START_MODE_NO)
|
||||
return 0;
|
||||
|
||||
if (sd_dhcp6_client_is_running(link->dhcp6_client) > 0)
|
||||
return 0;
|
||||
|
||||
@@ -1388,8 +1405,12 @@ int dhcp6_start(Link *link) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
start_mode = link_get_dhcp6_client_start_mode(link);
|
||||
if (start_mode == DHCP6_CLIENT_START_MODE_NO)
|
||||
return 0;
|
||||
|
||||
r = sd_dhcp6_client_set_information_request(link->dhcp6_client,
|
||||
link->network->dhcp6_without_ra == DHCP6_CLIENT_START_MODE_INFORMATION_REQUEST);
|
||||
start_mode == DHCP6_CLIENT_START_MODE_INFORMATION_REQUEST);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ DHCPv6.UserClass, config_parse_dhcp_user_or_vendor_cl
|
||||
DHCPv6.VendorClass, config_parse_dhcp_user_or_vendor_class, AF_INET6, offsetof(Network, dhcp6_vendor_class)
|
||||
DHCPv6.SendVendorOption, config_parse_dhcp_send_option, AF_INET6, offsetof(Network, dhcp6_client_send_vendor_options)
|
||||
DHCPv6.PrefixDelegationHint, config_parse_dhcp6_pd_prefix_hint, 0, 0
|
||||
DHCPv6.WithoutRA, config_parse_dhcp6_client_start_mode, 0, offsetof(Network, dhcp6_without_ra)
|
||||
DHCPv6.WithoutRA, config_parse_dhcp6_client_start_mode, 0, offsetof(Network, dhcp6_client_start_mode)
|
||||
DHCPv6.SendOption, config_parse_dhcp_send_option, AF_INET6, offsetof(Network, dhcp6_client_send_options)
|
||||
DHCPv6.IAID, config_parse_iaid, AF_INET6, 0
|
||||
DHCPv6.DUIDType, config_parse_duid_type, 0, offsetof(Network, dhcp6_duid)
|
||||
|
||||
@@ -405,6 +405,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
|
||||
.dhcp6_use_hostname = true,
|
||||
.dhcp6_use_ntp = true,
|
||||
.dhcp6_duid.type = _DUID_TYPE_INVALID,
|
||||
.dhcp6_client_start_mode = _DHCP6_CLIENT_START_MODE_INVALID,
|
||||
|
||||
.dhcp6_pd = -1,
|
||||
.dhcp6_pd_announce = true,
|
||||
|
||||
@@ -185,7 +185,7 @@ struct Network {
|
||||
char *dhcp6_mudurl;
|
||||
char **dhcp6_user_class;
|
||||
char **dhcp6_vendor_class;
|
||||
DHCP6ClientStartMode dhcp6_without_ra;
|
||||
DHCP6ClientStartMode dhcp6_client_start_mode;
|
||||
OrderedHashmap *dhcp6_client_send_options;
|
||||
OrderedHashmap *dhcp6_client_send_vendor_options;
|
||||
Set *dhcp6_request_options;
|
||||
|
||||
Reference in New Issue
Block a user