1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

network: Allow DHCPv6 client to start solicit mode

Now DHCPv6 client start only DHCPv6 INFORMATION-REQUEST mode.
Let's enable Solicit mode too.
This commit is contained in:
Susant Sahani 2020-07-01 23:03:17 +00:00 committed by Yu Watanabe
parent 51115fdc42
commit 838d39af93
6 changed files with 34 additions and 6 deletions

View File

@ -1840,8 +1840,8 @@
<varlistentry>
<term><varname>WithoutRA=</varname></term>
<listitem>
<para>When true, DHCPv6 client starts without router advertisements's managed or other address configuration flag.
Defaults to false.</para>
<para>Allows DHCPv6 client to start without router advertisements's managed or other address configuration flag.
Takes one of <literal>solicit</literal> or <literal>information-request</literal>. Defaults to unset.</para>
</listitem>
</varlistentry>

View File

@ -19,6 +19,7 @@
#include "networkd-link.h"
#include "networkd-manager.h"
#include "siphash24.h"
#include "string-table.h"
#include "string-util.h"
#include "radv-internal.h"
#include "web-util.h"
@ -1205,3 +1206,14 @@ int config_parse_dhcp6_delegated_prefix_token(
return 0;
}
DEFINE_CONFIG_PARSE_ENUM(config_parse_dhcp6_client_start_mode, dhcp6_client_start_mode, DHCP6ClientStartMode,
"Failed to parse WithoutRA= setting");
static const char* const dhcp6_client_start_mode_table[_DHCP6_CLIENT_START_MODE_MAX] = {
[DHCP6_CLIENT_START_MODE_NO] = "no",
[DHCP6_CLIENT_START_MODE_INFORMATION_REQUEST] = "information-request",
[DHCP6_CLIENT_START_MODE_SOLICIT] = "solicit",
};
DEFINE_STRING_TABLE_LOOKUP(dhcp6_client_start_mode, DHCP6ClientStartMode);

View File

@ -4,6 +4,15 @@
#include "sd-dhcp6-client.h"
#include "conf-parser.h"
#include "macro.h"
typedef enum DHCP6ClientStartMode {
DHCP6_CLIENT_START_MODE_NO,
DHCP6_CLIENT_START_MODE_INFORMATION_REQUEST,
DHCP6_CLIENT_START_MODE_SOLICIT,
_DHCP6_CLIENT_START_MODE_MAX,
_DHCP6_CLIENT_START_MODE_INVALID = -1,
} DHCP6ClientStartMode;
typedef struct Link Link;
typedef struct Manager Manager;
@ -17,3 +26,7 @@ int dhcp6_prefix_remove(Manager *m, struct in6_addr *addr);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_pd_hint);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_mud_url);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_delegated_prefix_token);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_client_start_mode);
const char* dhcp6_client_start_mode_to_string(DHCP6ClientStartMode i) _const_;
DHCP6ClientStartMode dhcp6_client_start_mode_from_string(const char *s) _pure_;

View File

@ -1559,11 +1559,13 @@ static int link_acquire_ipv6_conf(Link *link) {
return log_link_warning_errno(link, r, "Could not start IPv6 Router Advertisement: %m");
}
if (link_dhcp6_enabled(link) && link->network->dhcp6_without_ra) {
if (link_dhcp6_enabled(link) && IN_SET(link->network->dhcp6_without_ra,
DHCP6_CLIENT_START_MODE_INFORMATION_REQUEST,
DHCP6_CLIENT_START_MODE_SOLICIT)) {
assert(link->dhcp6_client);
assert(in_addr_is_link_local(AF_INET6, (const union in_addr_union*)&link->ipv6ll_address) > 0);
r = dhcp6_request_address(link, true);
r = dhcp6_request_address(link, link->network->dhcp6_without_ra == DHCP6_CLIENT_START_MODE_INFORMATION_REQUEST);
if (r < 0 && r != -EBUSY)
return log_link_warning_errno(link, r, "Could not acquire DHCPv6 lease: %m");
else

View File

@ -206,7 +206,7 @@ DHCPv6.ForceDHCPv6PDOtherInformation, config_parse_bool,
DHCPv6.AssignAcquiredDelegatedPrefixAddress, config_parse_bool, 0, offsetof(Network, dhcp6_pd_assign_prefix)
DHCPv6.AssignAcquiredDelegatedPrefixToken, config_parse_dhcp6_delegated_prefix_token, 0, 0
DHCPv6.PrefixDelegationHint, config_parse_dhcp6_pd_hint, 0, 0
DHCPv6.WithoutRA, config_parse_bool, 0, offsetof(Network, dhcp6_without_ra)
DHCPv6.WithoutRA, config_parse_dhcp6_client_start_mode, 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_dhcp_route_metric, 0, 0
IPv6AcceptRA.UseAutonomousPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_autonomous_prefix)

View File

@ -17,6 +17,7 @@
#include "networkd-brvlan.h"
#include "networkd-dhcp-common.h"
#include "networkd-dhcp4.h"
#include "networkd-dhcp6.h"
#include "networkd-dhcp-server.h"
#include "networkd-fdb.h"
#include "networkd-ipv6-proxy-ndp.h"
@ -150,7 +151,6 @@ struct Network {
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;
@ -158,6 +158,7 @@ struct Network {
char **dhcp6_user_class;
char **dhcp6_vendor_class;
struct in6_addr dhcp6_pd_address;
DHCP6ClientStartMode dhcp6_without_ra;
OrderedHashmap *dhcp6_client_send_options;
OrderedHashmap *dhcp6_client_send_vendor_options;
Set *dhcp6_request_options;