]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: Introduce UseCaptivePortal DHCPv6 option
authorRonan Pigott <ronan@rjp.ie>
Thu, 29 Jun 2023 23:33:57 +0000 (16:33 -0700)
committerRonan Pigott <ronan@rjp.ie>
Sun, 2 Jul 2023 08:13:43 +0000 (01:13 -0700)
Acepts a boolean. When enabled requests and retains captive portal
configuration from the DHCPv6 server.

man/systemd.network.xml
src/network/networkd-dhcp6.c
src/network/networkd-network-gperf.gperf
src/network/networkd-network.c
src/network/networkd-network.h
src/network/networkd-state-file.c

index 452d2835b00f3de69ec6f496b71e36052d8c40cf..b623a4aa75b7f7408867ae7452b2381e4c0703cc 100644 (file)
@@ -2290,6 +2290,14 @@ allow my_server_t localnet_peer_t:peer recv;</programlisting>
         </listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><varname>UseCaptivePortal=</varname></term>
+        <listitem>
+          <para>When true (the default), the captive portal advertised by the DHCPv6 server will be recorded
+          and made available to client programs and displayed in the networkctl status output per-link.</para>
+        </listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><varname>UseDelegatedPrefix=</varname></term>
         <listitem>
index 43be98837768393c836795fdb7f66ab694fc0431..57272e7bf609dfe8de6d20b313793c3e42454246 100644 (file)
@@ -635,6 +635,12 @@ static int dhcp6_configure(Link *link) {
                         return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to request domains: %m");
         }
 
+        if (link->network->dhcp6_use_captive_portal > 0) {
+                r = sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_CAPTIVE_PORTAL);
+                if (r < 0)
+                        return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to request captive portal: %m");
+        }
+
         if (link->network->dhcp6_use_ntp) {
                 r = sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_NTP_SERVER);
                 if (r < 0)
index 92ea9eaeefc6961656a269571435aba548efb712..ab0d252b940632ae4f418a869135ea8f5d6d6dbf 100644 (file)
@@ -258,6 +258,7 @@ DHCPv6.UseDNS,                               config_parse_dhcp_use_dns,
 DHCPv6.UseHostname,                          config_parse_bool,                                        0,                             offsetof(Network, dhcp6_use_hostname)
 DHCPv6.UseDomains,                           config_parse_dhcp_use_domains,                            AF_INET6,                      0
 DHCPv6.UseNTP,                               config_parse_dhcp_use_ntp,                                AF_INET6,                      0
+DHCPv6.UseCaptivePortal,                     config_parse_bool,                                        0,                             offsetof(Network, dhcp6_use_captive_portal)
 DHCPv6.MUDURL,                               config_parse_mud_url,                                     0,                             offsetof(Network, dhcp6_mudurl)
 DHCPv6.RequestOptions,                       config_parse_dhcp_request_options,                        AF_INET6,                      0
 DHCPv6.UserClass,                            config_parse_dhcp_user_or_vendor_class,                   AF_INET6,                      offsetof(Network, dhcp6_user_class)
index b2a2d8052c3812ecaec42ad94e9333ac34cb77b4..a92c229d4f2abe56cf6cdf02163f2cc7aba56042 100644 (file)
@@ -414,6 +414,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
                 .dhcp6_use_dns = true,
                 .dhcp6_use_hostname = true,
                 .dhcp6_use_ntp = true,
+                .dhcp6_use_captive_portal = true,
                 .dhcp6_use_rapid_commit = true,
                 .dhcp6_duid.type = _DUID_TYPE_INVALID,
                 .dhcp6_client_start_mode = _DHCP6_CLIENT_START_MODE_INVALID,
index b4666f1d63c8b6f108a5bc74551205ee8f3ff25b..e473a725005137c23e0b968e71015c9d96d7b06e 100644 (file)
@@ -170,6 +170,7 @@ struct Network {
         bool dhcp6_use_hostname;
         bool dhcp6_use_ntp;
         bool dhcp6_use_ntp_set;
+        bool dhcp6_use_captive_portal;
         bool dhcp6_use_rapid_commit;
         DHCPUseDomains dhcp6_use_domains;
         bool dhcp6_use_domains_set;
index e313d9e9182d56c00a47c3ff4c63feffd978606b..5f5cb3239d03216bffc5a7ecbffb7ae6056ec738 100644 (file)
@@ -465,7 +465,7 @@ static void link_save_domains(Link *link, FILE *f, OrderedSet *static_domains, D
 
 int link_save(Link *link) {
         const char *admin_state, *oper_state, *carrier_state, *address_state, *ipv4_address_state, *ipv6_address_state,
-              *dhcp_captive_portal = NULL;
+              *dhcp_captive_portal = NULL, *dhcp6_captive_portal = NULL;
         _cleanup_(unlink_and_freep) char *temp_path = NULL;
         _cleanup_fclose_ FILE *f = NULL;
         int r;
@@ -613,8 +613,21 @@ int link_save(Link *link) {
                                 return r;
                 }
 
+                if (link->dhcp6_lease && link->network->dhcp6_use_captive_portal) {
+                        r = sd_dhcp6_lease_get_captive_portal(link->dhcp6_lease, &dhcp6_captive_portal);
+                        if (r < 0 && r != -ENODATA)
+                                return r;
+                }
+
+                if (dhcp6_captive_portal && dhcp_captive_portal && !streq(dhcp_captive_portal, dhcp6_captive_portal))
+                        log_link_warning(link, "DHCPv6 Captive Portal (%s) does not match DHCPv4 (%s). Ignoring DHCPv6 portal.",
+                                dhcp6_captive_portal, dhcp_captive_portal);
+
+
                 if (dhcp_captive_portal)
                         fprintf(f, "CAPTIVE_PORTAL=%s\n", dhcp_captive_portal);
+                else if (dhcp6_captive_portal)
+                        fprintf(f, "CAPTIVE_PORTAL=%s\n", dhcp6_captive_portal);
 
                 /************************************************************/