|
|
146a1d |
From 40422ede3f44f4018377a81db1056fb3439107b2 Mon Sep 17 00:00:00 2001
|
|
|
146a1d |
From: Beniamino Galvani <bgalvani@redhat.com>
|
|
|
146a1d |
Date: Wed, 22 Jul 2020 05:03:47 +0200
|
|
|
146a1d |
Subject: [PATCH 1/4] systemd: dhcp6: remove assertions in
|
|
|
146a1d |
dhcp6_option_parse_domainname()
|
|
|
146a1d |
|
|
|
146a1d |
Assertions are for programming errors; here the input comes directly
|
|
|
146a1d |
from the DHCP response packet.
|
|
|
146a1d |
|
|
|
146a1d |
https://github.com/systemd/systemd/commit/af710b535b4ceacd0aecec6748a4f8ee57742e99
|
|
|
146a1d |
(cherry picked from commit e2248143af0d4ec61e571c4f358d5d7f1044289c)
|
|
|
146a1d |
---
|
|
|
146a1d |
src/systemd/src/libsystemd-network/dhcp6-option.c | 6 ++++--
|
|
|
146a1d |
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
|
146a1d |
|
|
|
146a1d |
diff --git a/src/systemd/src/libsystemd-network/dhcp6-option.c b/src/systemd/src/libsystemd-network/dhcp6-option.c
|
|
|
146a1d |
index d596752b3b91..717fcdffb815 100644
|
|
|
146a1d |
--- a/src/systemd/src/libsystemd-network/dhcp6-option.c
|
|
|
146a1d |
+++ b/src/systemd/src/libsystemd-network/dhcp6-option.c
|
|
|
146a1d |
@@ -649,8 +649,10 @@ int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char *
|
|
|
146a1d |
_cleanup_strv_free_ char **names = NULL;
|
|
|
146a1d |
int r;
|
|
|
146a1d |
|
|
|
146a1d |
- assert_return(optlen > 1, -ENODATA);
|
|
|
146a1d |
- assert_return(optval[optlen - 1] == '\0', -EINVAL);
|
|
|
146a1d |
+ if (optlen <= 1)
|
|
|
146a1d |
+ return -ENODATA;
|
|
|
146a1d |
+ if (optval[optlen - 1] != '\0')
|
|
|
146a1d |
+ return -EINVAL;
|
|
|
146a1d |
|
|
|
146a1d |
while (pos < optlen) {
|
|
|
146a1d |
_cleanup_free_ char *ret = NULL;
|
|
|
146a1d |
--
|
|
|
146a1d |
2.26.2
|
|
|
146a1d |
|
|
|
146a1d |
|
|
|
146a1d |
From ab72f05d16d641bccaa1b4870bfb91c03661f1c5 Mon Sep 17 00:00:00 2001
|
|
|
146a1d |
From: Beniamino Galvani <bgalvani@redhat.com>
|
|
|
146a1d |
Date: Thu, 6 Aug 2020 10:49:07 +0200
|
|
|
146a1d |
Subject: [PATCH 2/4] systemd: dhcp6: parse the FQDN option
|
|
|
146a1d |
|
|
|
146a1d |
Parse option 39 (Client Fully Qualified Domain Name, RFC 4704) from the DHCP
|
|
|
146a1d |
reply, which specifies the FQDN assigned by the server to the client.
|
|
|
146a1d |
|
|
|
146a1d |
https://github.com/systemd/systemd/commit/c43eea9f2effbb066901a61eafef473558d37b0f
|
|
|
146a1d |
(cherry picked from commit 813fb7d64ee4cb0f935a3a15b9f5b8f5771655da)
|
|
|
146a1d |
---
|
|
|
146a1d |
.../src/libsystemd-network/dhcp6-internal.h | 5 +-
|
|
|
146a1d |
.../libsystemd-network/dhcp6-lease-internal.h | 2 +
|
|
|
146a1d |
.../src/libsystemd-network/dhcp6-option.c | 118 ++++++++++++------
|
|
|
146a1d |
.../src/libsystemd-network/sd-dhcp6-client.c | 7 ++
|
|
|
146a1d |
.../src/libsystemd-network/sd-dhcp6-lease.c | 39 +++++-
|
|
|
146a1d |
src/systemd/src/systemd/sd-dhcp6-lease.h | 1 +
|
|
|
146a1d |
6 files changed, 129 insertions(+), 43 deletions(-)
|
|
|
146a1d |
|
|
|
146a1d |
diff --git a/src/systemd/src/libsystemd-network/dhcp6-internal.h b/src/systemd/src/libsystemd-network/dhcp6-internal.h
|
|
|
146a1d |
index b0d1216eed84..068dcade0583 100644
|
|
|
146a1d |
--- a/src/systemd/src/libsystemd-network/dhcp6-internal.h
|
|
|
146a1d |
+++ b/src/systemd/src/libsystemd-network/dhcp6-internal.h
|
|
|
146a1d |
@@ -109,8 +109,9 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia, uint16_t *ret_stat
|
|
|
146a1d |
int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,
|
|
|
146a1d |
struct in6_addr **addrs, size_t count,
|
|
|
146a1d |
size_t *allocated);
|
|
|
146a1d |
-int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen,
|
|
|
146a1d |
- char ***str_arr);
|
|
|
146a1d |
+int dhcp6_option_parse_domainname_list(const uint8_t *optval, uint16_t optlen,
|
|
|
146a1d |
+ char ***str_arr);
|
|
|
146a1d |
+int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char **str);
|
|
|
146a1d |
|
|
|
146a1d |
int dhcp6_network_bind_udp_socket(int index, struct in6_addr *address);
|
|
|
146a1d |
int dhcp6_network_send_udp_socket(int s, struct in6_addr *address,
|
|
|
146a1d |
diff --git a/src/systemd/src/libsystemd-network/dhcp6-lease-internal.h b/src/systemd/src/libsystemd-network/dhcp6-lease-internal.h
|
|
|
146a1d |
index e004f48b4e24..df6c95e0b360 100644
|
|
|
146a1d |
--- a/src/systemd/src/libsystemd-network/dhcp6-lease-internal.h
|
|
|
146a1d |
+++ b/src/systemd/src/libsystemd-network/dhcp6-lease-internal.h
|
|
|
146a1d |
@@ -35,6 +35,7 @@ struct sd_dhcp6_lease {
|
|
|
146a1d |
size_t ntp_allocated;
|
|
|
146a1d |
char **ntp_fqdn;
|
|
|
146a1d |
size_t ntp_fqdn_count;
|
|
|
146a1d |
+ char *fqdn;
|
|
|
146a1d |
};
|
|
|
146a1d |
|
|
|
146a1d |
int dhcp6_lease_ia_rebind_expire(const DHCP6IA *ia, uint32_t *expire);
|
|
|
146a1d |
@@ -57,5 +58,6 @@ int dhcp6_lease_set_domains(sd_dhcp6_lease *lease, uint8_t *optval,
|
|
|
146a1d |
int dhcp6_lease_set_ntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen);
|
|
|
146a1d |
int dhcp6_lease_set_sntp(sd_dhcp6_lease *lease, uint8_t *optval,
|
|
|
146a1d |
size_t optlen) ;
|
|
|
146a1d |
+int dhcp6_lease_set_fqdn(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen);
|
|
|
146a1d |
|
|
|
146a1d |
int dhcp6_lease_new(sd_dhcp6_lease **ret);
|
|
|
146a1d |
diff --git a/src/systemd/src/libsystemd-network/dhcp6-option.c b/src/systemd/src/libsystemd-network/dhcp6-option.c
|
|
|
146a1d |
index 717fcdffb815..a6dad9340643 100644
|
|
|
146a1d |
--- a/src/systemd/src/libsystemd-network/dhcp6-option.c
|
|
|
146a1d |
+++ b/src/systemd/src/libsystemd-network/dhcp6-option.c
|
|
|
146a1d |
@@ -644,61 +644,103 @@ int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,
|
|
|
146a1d |
return count;
|
|
|
146a1d |
}
|
|
|
146a1d |
|
|
|
146a1d |
-int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char ***str_arr) {
|
|
|
146a1d |
- size_t pos = 0, idx = 0;
|
|
|
146a1d |
- _cleanup_strv_free_ char **names = NULL;
|
|
|
146a1d |
+static int parse_domain(const uint8_t **data, uint16_t *len, char **out_domain) {
|
|
|
146a1d |
+ _cleanup_free_ char *ret = NULL;
|
|
|
146a1d |
+ size_t n = 0, allocated = 0;
|
|
|
146a1d |
+ const uint8_t *optval = *data;
|
|
|
146a1d |
+ uint16_t optlen = *len;
|
|
|
146a1d |
+ bool first = true;
|
|
|
146a1d |
int r;
|
|
|
146a1d |
|
|
|
146a1d |
if (optlen <= 1)
|
|
|
146a1d |
return -ENODATA;
|
|
|
146a1d |
- if (optval[optlen - 1] != '\0')
|
|
|
146a1d |
- return -EINVAL;
|
|
|
146a1d |
|
|
|
146a1d |
- while (pos < optlen) {
|
|
|
146a1d |
- _cleanup_free_ char *ret = NULL;
|
|
|
146a1d |
- size_t n = 0, allocated = 0;
|
|
|
146a1d |
- bool first = true;
|
|
|
146a1d |
-
|
|
|
146a1d |
- for (;;) {
|
|
|
146a1d |
- const char *label;
|
|
|
146a1d |
- uint8_t c;
|
|
|
146a1d |
+ for (;;) {
|
|
|
146a1d |
+ const char *label;
|
|
|
146a1d |
+ uint8_t c;
|
|
|
146a1d |
|
|
|
146a1d |
- c = optval[pos++];
|
|
|
146a1d |
+ if (optlen == 0)
|
|
|
146a1d |
+ break;
|
|
|
146a1d |
|
|
|
146a1d |
- if (c == 0)
|
|
|
146a1d |
- /* End of name */
|
|
|
146a1d |
- break;
|
|
|
146a1d |
- if (c > 63)
|
|
|
146a1d |
- return -EBADMSG;
|
|
|
146a1d |
+ c = *optval;
|
|
|
146a1d |
+ optval++;
|
|
|
146a1d |
+ optlen--;
|
|
|
146a1d |
|
|
|
146a1d |
- /* Literal label */
|
|
|
146a1d |
- label = (const char *)&optval[pos];
|
|
|
146a1d |
- pos += c;
|
|
|
146a1d |
- if (pos >= optlen)
|
|
|
146a1d |
- return -EMSGSIZE;
|
|
|
146a1d |
+ if (c == 0)
|
|
|
146a1d |
+ /* End label */
|
|
|
146a1d |
+ break;
|
|
|
146a1d |
+ if (c > 63)
|
|
|
146a1d |
+ return -EBADMSG;
|
|
|
146a1d |
+ if (c > optlen)
|
|
|
146a1d |
+ return -EMSGSIZE;
|
|
|
146a1d |
|
|
|
146a1d |
- if (!GREEDY_REALLOC(ret, allocated, n + !first + DNS_LABEL_ESCAPED_MAX))
|
|
|
146a1d |
- return -ENOMEM;
|
|
|
146a1d |
+ /* Literal label */
|
|
|
146a1d |
+ label = (const char *)optval;
|
|
|
146a1d |
+ optval += c;
|
|
|
146a1d |
+ optlen -= c;
|
|
|
146a1d |
|
|
|
146a1d |
- if (first)
|
|
|
146a1d |
- first = false;
|
|
|
146a1d |
- else
|
|
|
146a1d |
- ret[n++] = '.';
|
|
|
146a1d |
+ if (!GREEDY_REALLOC(ret, allocated, n + !first + DNS_LABEL_ESCAPED_MAX))
|
|
|
146a1d |
+ return -ENOMEM;
|
|
|
146a1d |
|
|
|
146a1d |
- r = dns_label_escape(label, c, ret + n, DNS_LABEL_ESCAPED_MAX);
|
|
|
146a1d |
- if (r < 0)
|
|
|
146a1d |
- return r;
|
|
|
146a1d |
+ if (first)
|
|
|
146a1d |
+ first = false;
|
|
|
146a1d |
+ else
|
|
|
146a1d |
+ ret[n++] = '.';
|
|
|
146a1d |
|
|
|
146a1d |
- n += r;
|
|
|
146a1d |
- }
|
|
|
146a1d |
+ r = dns_label_escape(label, c, ret + n, DNS_LABEL_ESCAPED_MAX);
|
|
|
146a1d |
+ if (r < 0)
|
|
|
146a1d |
+ return r;
|
|
|
146a1d |
|
|
|
146a1d |
- if (n == 0)
|
|
|
146a1d |
- continue;
|
|
|
146a1d |
+ n += r;
|
|
|
146a1d |
+ }
|
|
|
146a1d |
|
|
|
146a1d |
+ if (n) {
|
|
|
146a1d |
if (!GREEDY_REALLOC(ret, allocated, n + 1))
|
|
|
146a1d |
return -ENOMEM;
|
|
|
146a1d |
-
|
|
|
146a1d |
ret[n] = 0;
|
|
|
146a1d |
+ }
|
|
|
146a1d |
+
|
|
|
146a1d |
+ *out_domain = TAKE_PTR(ret);
|
|
|
146a1d |
+ *data = optval;
|
|
|
146a1d |
+ *len = optlen;
|
|
|
146a1d |
+
|
|
|
146a1d |
+ return n;
|
|
|
146a1d |
+}
|
|
|
146a1d |
+
|
|
|
146a1d |
+int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char **str) {
|
|
|
146a1d |
+ _cleanup_free_ char *domain = NULL;
|
|
|
146a1d |
+ int r;
|
|
|
146a1d |
+
|
|
|
146a1d |
+ r = parse_domain(&optval, &optlen, &domain);
|
|
|
146a1d |
+ if (r < 0)
|
|
|
146a1d |
+ return r;
|
|
|
146a1d |
+ if (r == 0)
|
|
|
146a1d |
+ return -ENODATA;
|
|
|
146a1d |
+ if (optlen != 0)
|
|
|
146a1d |
+ return -EINVAL;
|
|
|
146a1d |
+
|
|
|
146a1d |
+ *str = TAKE_PTR(domain);
|
|
|
146a1d |
+ return 0;
|
|
|
146a1d |
+}
|
|
|
146a1d |
+
|
|
|
146a1d |
+int dhcp6_option_parse_domainname_list(const uint8_t *optval, uint16_t optlen, char ***str_arr) {
|
|
|
146a1d |
+ size_t idx = 0;
|
|
|
146a1d |
+ _cleanup_strv_free_ char **names = NULL;
|
|
|
146a1d |
+ int r;
|
|
|
146a1d |
+
|
|
|
146a1d |
+ if (optlen <= 1)
|
|
|
146a1d |
+ return -ENODATA;
|
|
|
146a1d |
+ if (optval[optlen - 1] != '\0')
|
|
|
146a1d |
+ return -EINVAL;
|
|
|
146a1d |
+
|
|
|
146a1d |
+ while (optlen > 0) {
|
|
|
146a1d |
+ _cleanup_free_ char *ret = NULL;
|
|
|
146a1d |
+
|
|
|
146a1d |
+ r = parse_domain(&optval, &optlen, &ret;;
|
|
|
146a1d |
+ if (r < 0)
|
|
|
146a1d |
+ return r;
|
|
|
146a1d |
+ if (r == 0)
|
|
|
146a1d |
+ continue;
|
|
|
146a1d |
|
|
|
146a1d |
r = strv_extend(&names, ret);
|
|
|
146a1d |
if (r < 0)
|
|
|
146a1d |
diff --git a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c
|
|
|
146a1d |
index d653b2571c00..b80e4e5406d9 100644
|
|
|
146a1d |
--- a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c
|
|
|
146a1d |
+++ b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c
|
|
|
146a1d |
@@ -1288,6 +1288,13 @@ static int client_parse_message(
|
|
|
146a1d |
|
|
|
146a1d |
break;
|
|
|
146a1d |
|
|
|
146a1d |
+ case SD_DHCP6_OPTION_FQDN:
|
|
|
146a1d |
+ r = dhcp6_lease_set_fqdn(lease, optval, optlen);
|
|
|
146a1d |
+ if (r < 0)
|
|
|
146a1d |
+ return r;
|
|
|
146a1d |
+
|
|
|
146a1d |
+ break;
|
|
|
146a1d |
+
|
|
|
146a1d |
case SD_DHCP6_OPTION_INFORMATION_REFRESH_TIME:
|
|
|
146a1d |
if (optlen != 4)
|
|
|
146a1d |
return -EINVAL;
|
|
|
146a1d |
diff --git a/src/systemd/src/libsystemd-network/sd-dhcp6-lease.c b/src/systemd/src/libsystemd-network/sd-dhcp6-lease.c
|
|
|
146a1d |
index b6dc02791504..5f5a7fe616fa 100644
|
|
|
146a1d |
--- a/src/systemd/src/libsystemd-network/sd-dhcp6-lease.c
|
|
|
146a1d |
+++ b/src/systemd/src/libsystemd-network/sd-dhcp6-lease.c
|
|
|
146a1d |
@@ -238,7 +238,7 @@ int dhcp6_lease_set_domains(sd_dhcp6_lease *lease, uint8_t *optval,
|
|
|
146a1d |
if (!optlen)
|
|
|
146a1d |
return 0;
|
|
|
146a1d |
|
|
|
146a1d |
- r = dhcp6_option_parse_domainname(optval, optlen, &domains);
|
|
|
146a1d |
+ r = dhcp6_option_parse_domainname_list(optval, optlen, &domains);
|
|
|
146a1d |
if (r < 0)
|
|
|
146a1d |
return 0;
|
|
|
146a1d |
|
|
|
146a1d |
@@ -296,8 +296,8 @@ int dhcp6_lease_set_ntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) {
|
|
|
146a1d |
break;
|
|
|
146a1d |
|
|
|
146a1d |
case DHCP6_NTP_SUBOPTION_SRV_FQDN:
|
|
|
146a1d |
- r = dhcp6_option_parse_domainname(subval, sublen,
|
|
|
146a1d |
- &servers);
|
|
|
146a1d |
+ r = dhcp6_option_parse_domainname_list(subval, sublen,
|
|
|
146a1d |
+ &servers);
|
|
|
146a1d |
if (r < 0)
|
|
|
146a1d |
return 0;
|
|
|
146a1d |
|
|
|
146a1d |
@@ -367,6 +367,38 @@ int sd_dhcp6_lease_get_ntp_fqdn(sd_dhcp6_lease *lease, char ***ntp_fqdn) {
|
|
|
146a1d |
return -ENOENT;
|
|
|
146a1d |
}
|
|
|
146a1d |
|
|
|
146a1d |
+int dhcp6_lease_set_fqdn(sd_dhcp6_lease *lease, const uint8_t *optval,
|
|
|
146a1d |
+ size_t optlen) {
|
|
|
146a1d |
+ int r;
|
|
|
146a1d |
+ char *fqdn;
|
|
|
146a1d |
+
|
|
|
146a1d |
+ assert_return(lease, -EINVAL);
|
|
|
146a1d |
+ assert_return(optval, -EINVAL);
|
|
|
146a1d |
+
|
|
|
146a1d |
+ if (optlen < 2)
|
|
|
146a1d |
+ return -ENODATA;
|
|
|
146a1d |
+
|
|
|
146a1d |
+ /* Ignore the flags field, it doesn't carry any useful
|
|
|
146a1d |
+ information for clients. */
|
|
|
146a1d |
+ r = dhcp6_option_parse_domainname(optval + 1, optlen - 1, &fqdn);
|
|
|
146a1d |
+ if (r < 0)
|
|
|
146a1d |
+ return r;
|
|
|
146a1d |
+
|
|
|
146a1d |
+ return free_and_replace(lease->fqdn, fqdn);
|
|
|
146a1d |
+}
|
|
|
146a1d |
+
|
|
|
146a1d |
+int sd_dhcp6_lease_get_fqdn(sd_dhcp6_lease *lease, const char **fqdn) {
|
|
|
146a1d |
+ assert_return(lease, -EINVAL);
|
|
|
146a1d |
+ assert_return(fqdn, -EINVAL);
|
|
|
146a1d |
+
|
|
|
146a1d |
+ if (lease->fqdn) {
|
|
|
146a1d |
+ *fqdn = lease->fqdn;
|
|
|
146a1d |
+ return 0;
|
|
|
146a1d |
+ }
|
|
|
146a1d |
+
|
|
|
146a1d |
+ return -ENOENT;
|
|
|
146a1d |
+}
|
|
|
146a1d |
+
|
|
|
146a1d |
static sd_dhcp6_lease *dhcp6_lease_free(sd_dhcp6_lease *lease) {
|
|
|
146a1d |
assert(lease);
|
|
|
146a1d |
|
|
|
146a1d |
@@ -375,6 +407,7 @@ static sd_dhcp6_lease *dhcp6_lease_free(sd_dhcp6_lease *lease) {
|
|
|
146a1d |
dhcp6_lease_free_ia(&lease->pd);
|
|
|
146a1d |
|
|
|
146a1d |
free(lease->dns);
|
|
|
146a1d |
+ free(lease->fqdn);
|
|
|
146a1d |
|
|
|
146a1d |
lease->domains = strv_free(lease->domains);
|
|
|
146a1d |
|
|
|
146a1d |
diff --git a/src/systemd/src/systemd/sd-dhcp6-lease.h b/src/systemd/src/systemd/sd-dhcp6-lease.h
|
|
|
146a1d |
index 4301c6db878b..240df74af8c5 100644
|
|
|
146a1d |
--- a/src/systemd/src/systemd/sd-dhcp6-lease.h
|
|
|
146a1d |
+++ b/src/systemd/src/systemd/sd-dhcp6-lease.h
|
|
|
146a1d |
@@ -43,6 +43,7 @@ int sd_dhcp6_lease_get_dns(sd_dhcp6_lease *lease, const struct in6_addr **addrs)
|
|
|
146a1d |
int sd_dhcp6_lease_get_domains(sd_dhcp6_lease *lease, char ***domains);
|
|
|
146a1d |
int sd_dhcp6_lease_get_ntp_addrs(sd_dhcp6_lease *lease, const struct in6_addr **addrs);
|
|
|
146a1d |
int sd_dhcp6_lease_get_ntp_fqdn(sd_dhcp6_lease *lease, char ***ntp_fqdn);
|
|
|
146a1d |
+int sd_dhcp6_lease_get_fqdn(sd_dhcp6_lease *lease, const char **fqdn);
|
|
|
146a1d |
|
|
|
146a1d |
sd_dhcp6_lease *sd_dhcp6_lease_ref(sd_dhcp6_lease *lease);
|
|
|
146a1d |
sd_dhcp6_lease *sd_dhcp6_lease_unref(sd_dhcp6_lease *lease);
|
|
|
146a1d |
--
|
|
|
146a1d |
2.26.2
|
|
|
146a1d |
|
|
|
146a1d |
|
|
|
146a1d |
From 98d88e272c9d49876ad2c2b1507a4fda9456531e Mon Sep 17 00:00:00 2001
|
|
|
146a1d |
From: Beniamino Galvani <bgalvani@redhat.com>
|
|
|
146a1d |
Date: Wed, 22 Jul 2020 13:56:39 +0200
|
|
|
146a1d |
Subject: [PATCH 3/4] dhcp: export the DHCPv6 FQDN option
|
|
|
146a1d |
|
|
|
146a1d |
The dhclient backend already exports all the option passed by
|
|
|
146a1d |
dhclient, including the FDQN. Export it also for the systemd backend.
|
|
|
146a1d |
|
|
|
146a1d |
(cherry picked from commit 1621a6ddb1b3f5c51ad774012150bd56cf65fcea)
|
|
|
146a1d |
(cherry picked from commit c6a7618f2be4236997362db43cf44a3fdee2d9c9)
|
|
|
146a1d |
---
|
|
|
146a1d |
src/dhcp/nm-dhcp-options.c | 1 +
|
|
|
146a1d |
src/dhcp/nm-dhcp-options.h | 2 ++
|
|
|
146a1d |
src/dhcp/nm-dhcp-systemd.c | 8 ++++++++
|
|
|
146a1d |
3 files changed, 11 insertions(+)
|
|
|
146a1d |
|
|
|
146a1d |
diff --git a/src/dhcp/nm-dhcp-options.c b/src/dhcp/nm-dhcp-options.c
|
|
|
146a1d |
index b10635fc674a..d902c77c8c21 100644
|
|
|
146a1d |
--- a/src/dhcp/nm-dhcp-options.c
|
|
|
146a1d |
+++ b/src/dhcp/nm-dhcp-options.c
|
|
|
146a1d |
@@ -183,6 +183,7 @@ const NMDhcpOption _nm_dhcp_option_dhcp6_options[] = {
|
|
|
146a1d |
REQ (NM_DHCP_OPTION_DHCP6_DNS_SERVERS, "dhcp6_name_servers", TRUE ),
|
|
|
146a1d |
REQ (NM_DHCP_OPTION_DHCP6_DOMAIN_LIST, "dhcp6_domain_search", TRUE ),
|
|
|
146a1d |
REQ (NM_DHCP_OPTION_DHCP6_SNTP_SERVERS, "dhcp6_sntp_servers", TRUE ),
|
|
|
146a1d |
+ REQ (NM_DHCP_OPTION_DHCP6_FQDN, "fqdn_fqdn", FALSE ),
|
|
|
146a1d |
REQ (NM_DHCP_OPTION_DHCP6_MUD_URL, "dhcp6_mud_url", FALSE ),
|
|
|
146a1d |
|
|
|
146a1d |
/* Internal values */
|
|
|
146a1d |
diff --git a/src/dhcp/nm-dhcp-options.h b/src/dhcp/nm-dhcp-options.h
|
|
|
146a1d |
index 7c0121702dad..bc3df5acd330 100644
|
|
|
146a1d |
--- a/src/dhcp/nm-dhcp-options.h
|
|
|
146a1d |
+++ b/src/dhcp/nm-dhcp-options.h
|
|
|
146a1d |
@@ -160,7 +160,9 @@ typedef enum {
|
|
|
146a1d |
NM_DHCP_OPTION_DHCP6_DNS_SERVERS = 23,
|
|
|
146a1d |
NM_DHCP_OPTION_DHCP6_DOMAIN_LIST = 24,
|
|
|
146a1d |
NM_DHCP_OPTION_DHCP6_SNTP_SERVERS = 31,
|
|
|
146a1d |
+ NM_DHCP_OPTION_DHCP6_FQDN = 39,
|
|
|
146a1d |
NM_DHCP_OPTION_DHCP6_MUD_URL = 112,
|
|
|
146a1d |
+
|
|
|
146a1d |
/* Internal values */
|
|
|
146a1d |
NM_DHCP_OPTION_DHCP6_NM_IP_ADDRESS = 1026,
|
|
|
146a1d |
NM_DHCP_OPTION_DHCP6_NM_PREFIXLEN = 1027,
|
|
|
146a1d |
diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c
|
|
|
146a1d |
index f65937d8e035..7ee101128b43 100644
|
|
|
146a1d |
--- a/src/dhcp/nm-dhcp-systemd.c
|
|
|
146a1d |
+++ b/src/dhcp/nm-dhcp-systemd.c
|
|
|
146a1d |
@@ -740,6 +740,7 @@ lease_to_ip6_config (NMDedupMultiIndex *multi_idx,
|
|
|
146a1d |
uint32_t lft_pref, lft_valid;
|
|
|
146a1d |
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
|
|
|
146a1d |
char **domains;
|
|
|
146a1d |
+ const char *s;
|
|
|
146a1d |
nm_auto_free_gstring GString *str = NULL;
|
|
|
146a1d |
int num, i;
|
|
|
146a1d |
|
|
|
146a1d |
@@ -808,6 +809,13 @@ lease_to_ip6_config (NMDedupMultiIndex *multi_idx,
|
|
|
146a1d |
str->str);
|
|
|
146a1d |
}
|
|
|
146a1d |
|
|
|
146a1d |
+ if (sd_dhcp6_lease_get_fqdn (lease, &s) >= 0) {
|
|
|
146a1d |
+ nm_dhcp_option_add_option (options,
|
|
|
146a1d |
+ _nm_dhcp_option_dhcp6_options,
|
|
|
146a1d |
+ NM_DHCP_OPTION_DHCP6_FQDN,
|
|
|
146a1d |
+ s);
|
|
|
146a1d |
+ }
|
|
|
146a1d |
+
|
|
|
146a1d |
NM_SET_OUT (out_options, g_steal_pointer (&options));
|
|
|
146a1d |
return g_steal_pointer (&ip6_config);
|
|
|
146a1d |
}
|
|
|
146a1d |
--
|
|
|
146a1d |
2.26.2
|
|
|
146a1d |
|
|
|
146a1d |
|
|
|
146a1d |
From bce988af55e0444a23a4c3881a075ff2387b798a Mon Sep 17 00:00:00 2001
|
|
|
146a1d |
From: Beniamino Galvani <bgalvani@redhat.com>
|
|
|
146a1d |
Date: Wed, 22 Jul 2020 13:49:42 +0200
|
|
|
146a1d |
Subject: [PATCH 4/4] policy: get the DHCPv6 hostname from the FQDN option
|
|
|
146a1d |
|
|
|
146a1d |
There isn't any 'host-name' option for DHCPv6. Read instead the
|
|
|
146a1d |
'fqdn-fqdn' option that carries the FQDN assigned by the server to the
|
|
|
146a1d |
client.
|
|
|
146a1d |
|
|
|
146a1d |
(cherry picked from commit 1f74ea52f5818c6e7d5cacd1dffdb2e1f5ee1913)
|
|
|
146a1d |
(cherry picked from commit 4e1da002a920888daf5bb3aa4bd21a2d61e3214b)
|
|
|
146a1d |
---
|
|
|
146a1d |
src/nm-policy.c | 2 +-
|
|
|
146a1d |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
146a1d |
|
|
|
146a1d |
diff --git a/src/nm-policy.c b/src/nm-policy.c
|
|
|
146a1d |
index e571034bc345..04cbace6019a 100644
|
|
|
146a1d |
--- a/src/nm-policy.c
|
|
|
146a1d |
+++ b/src/nm-policy.c
|
|
|
146a1d |
@@ -764,7 +764,7 @@ update_system_hostname (NMPolicy *self, const char *msg)
|
|
|
146a1d |
/* Grab a hostname out of the device's DHCP6 config */
|
|
|
146a1d |
dhcp_config = nm_device_get_dhcp_config (get_default_device (self, AF_INET6), AF_INET6);
|
|
|
146a1d |
if (dhcp_config) {
|
|
|
146a1d |
- dhcp_hostname = nm_dhcp_config_get_option (dhcp_config, "host_name");
|
|
|
146a1d |
+ dhcp_hostname = nm_dhcp_config_get_option (dhcp_config, "fqdn_fqdn");
|
|
|
146a1d |
if (dhcp_hostname && dhcp_hostname[0]) {
|
|
|
146a1d |
p = nm_str_skip_leading_spaces (dhcp_hostname);
|
|
|
146a1d |
if (p[0]) {
|
|
|
146a1d |
--
|
|
|
146a1d |
2.26.2
|
|
|
146a1d |
|