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.
This commit is contained in:
Beniamino Galvani 2022-11-05 18:19:36 +01:00
parent e2b9019ac0
commit fa997be216
3 changed files with 24 additions and 1 deletions

View file

@ -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
};

View file

@ -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)

View file

@ -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);