summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2022-11-05 18:19:36 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2023-04-03 16:04:55 +0200
commitfa997be216bfd3158e2ebdd751ba27119494e8c7 (patch)
tree2ac7fb304cdcf130e89bba229c1f211679fde77b
parente2b9019ac0c26e2f51c15f24e6abcdcd05dcdc9b (diff)
downloadNetworkManager-fa997be216bfd3158e2ebdd751ba27119494e8c7.tar.gz
dhcp: export the prefix delegation
Export the IA_PD option so that it is available via D-Bus and in the lease file in /run.
-rw-r--r--src/core/dhcp/nm-dhcp-options.c2
-rw-r--r--src/core/dhcp/nm-dhcp-options.h3
-rw-r--r--src/core/dhcp/nm-dhcp-systemd.c20
3 files changed, 24 insertions, 1 deletions
diff --git a/src/core/dhcp/nm-dhcp-options.c b/src/core/dhcp/nm-dhcp-options.c
index 33a9f4ed1d..7c47c82e05 100644
--- a/src/core/dhcp/nm-dhcp-options.c
+++ b/src/core/dhcp/nm-dhcp-options.c
@@ -199,6 +199,7 @@ const NMDhcpOption _nm_dhcp_option_dhcp6_options[] = {
REQ(NM_DHCP_OPTION_DHCP6_DNS_SERVERS, "dhcp6_name_servers", TRUE),
REQ(NM_DHCP_OPTION_DHCP6_DOMAIN_LIST, "dhcp6_domain_search", TRUE),
+ REQ(NM_DHCP_OPTION_DHCP6_IA_PD, "ip6_prefix", FALSE),
REQ(NM_DHCP_OPTION_DHCP6_SNTP_SERVERS, "dhcp6_sntp_servers", TRUE),
REQ(NM_DHCP_OPTION_DHCP6_FQDN, "fqdn_fqdn", FALSE),
REQ(NM_DHCP_OPTION_DHCP6_NTP_SERVER, "dhcp6_ntp_servers", TRUE),
@@ -237,6 +238,7 @@ static const NMDhcpOption *const _sorted_options_6[G_N_ELEMENTS(_nm_dhcp_option_
A(14),
A(15),
A(16),
+ A(17),
#undef A
};
diff --git a/src/core/dhcp/nm-dhcp-options.h b/src/core/dhcp/nm-dhcp-options.h
index 050080d975..1c61c74d59 100644
--- a/src/core/dhcp/nm-dhcp-options.h
+++ b/src/core/dhcp/nm-dhcp-options.h
@@ -161,6 +161,7 @@ typedef enum {
NM_DHCP_OPTION_DHCP6_SERVER_ID = 2,
NM_DHCP_OPTION_DHCP6_DNS_SERVERS = 23,
NM_DHCP_OPTION_DHCP6_DOMAIN_LIST = 24,
+ NM_DHCP_OPTION_DHCP6_IA_PD = 25, /* RFC 8415 */
NM_DHCP_OPTION_DHCP6_SNTP_SERVERS = 31,
NM_DHCP_OPTION_DHCP6_FQDN = 39,
NM_DHCP_OPTION_DHCP6_NTP_SERVER = 56, /* RFC 5908 */
@@ -188,7 +189,7 @@ typedef struct {
} NMDhcpOption;
extern const NMDhcpOption _nm_dhcp_option_dhcp4_options[143];
-extern const NMDhcpOption _nm_dhcp_option_dhcp6_options[17];
+extern const NMDhcpOption _nm_dhcp_option_dhcp6_options[18];
static inline const char *
nm_dhcp_option_get_name(const NMDhcpOption *option)
diff --git a/src/core/dhcp/nm-dhcp-systemd.c b/src/core/dhcp/nm-dhcp-systemd.c
index b26a15a45b..0fc5f92866 100644
--- a/src/core/dhcp/nm-dhcp-systemd.c
+++ b/src/core/dhcp/nm-dhcp-systemd.c
@@ -155,6 +155,26 @@ lease_to_ip6_config(NMDhcpSystemd *self, sd_dhcp6_lease *lease, gint32 ts, GErro
str->str);
}
+ {
+ struct in6_addr prefix;
+ uint8_t prefix_len;
+
+ nm_gstring_prepare(&str);
+ sd_dhcp6_lease_reset_pd_prefix_iter(lease);
+ while (!sd_dhcp6_lease_get_pd(lease, &prefix, &prefix_len, NULL, NULL)) {
+ nm_gstring_add_space_delimiter(str);
+ nm_inet6_ntop(&prefix, addr_str);
+ g_string_append_printf(str, "%s/%u", addr_str, prefix_len);
+ }
+ if (str->len > 0) {
+ nm_dhcp_option_add_option(options,
+ TRUE,
+ AF_INET6,
+ NM_DHCP_OPTION_DHCP6_IA_PD,
+ str->str);
+ }
+ }
+
num = sd_dhcp6_lease_get_domains(lease, &domains);
if (num > 0) {
nm_gstring_prepare(&str);