From 3761933b155a56aef42911cea07030ceb2f74c59 Mon Sep 17 00:00:00 2001 From: Andre Fernando Zanella Kantek Date: Tue, 6 Sep 2022 12:36:05 -0300 Subject: [PATCH] Debian: use DHCPv6 FQDN hostname field to set hostname It was detected on StarlingX the lack of correct hostname after address atribution by the server, if the installation is IPv6. This change makes the dhclient script read the field fqdn_hostname (if available) to set the name. Test Plan [PASS] Install AIO-DX within a IPv6 network [PASS] unlock controller-1 Story: 2009968 Task: 46211 Signed-off-by: Andre Fernando Zanella Kantek Change-Id: I9c876d00feed03720317fa4d581971b4c25f771f --- ...-FQDN-hostname-field-to-set-hostname.patch | 73 +++++++++++++++++++ base/dhcp/debian/deb_patches/series | 3 +- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 base/dhcp/debian/deb_patches/0004-use-DHCPv6-FQDN-hostname-field-to-set-hostname.patch diff --git a/base/dhcp/debian/deb_patches/0004-use-DHCPv6-FQDN-hostname-field-to-set-hostname.patch b/base/dhcp/debian/deb_patches/0004-use-DHCPv6-FQDN-hostname-field-to-set-hostname.patch new file mode 100644 index 000000000..b9dbc6f00 --- /dev/null +++ b/base/dhcp/debian/deb_patches/0004-use-DHCPv6-FQDN-hostname-field-to-set-hostname.patch @@ -0,0 +1,73 @@ +From 66726d7b42e2b36cb9707cf47a92616eaf4b454d Mon Sep 17 00:00:00 2001 +From: Andre Fernando Zanella Kantek + +Date: Tue, 6 Sep 2022 12:27:10 -0300 +Subject: [PATCH] use DHCPv6 FQDN hostname field to set hostname + +It was detected on StarlingX the lack of correct hostname after +address atribution by the server. This change makes the script read +the field fqdn_hostname to set the name. + +Also added the field to the dhclient debug script + +Signed-off-by: Andre Fernando Zanella Kantek +--- + debian/debug | 3 ++- + debian/dhclient-script.linux | 20 +++++++++++++++++++- + 2 files changed, 21 insertions(+), 2 deletions(-) + +diff --git a/debian/debug b/debian/debug +index 593e7df..a2d8cf2 100644 +--- a/debian/debug ++++ b/debian/debug +@@ -23,7 +23,8 @@ if [ "$RUN" = "yes" ]; then + netbios_name_servers netbios_scope \ + ntp_servers \ + ip6_address ip6_prefix ip6_prefixlen \ +- dhcp6_domain_search dhcp6_name_servers ; do ++ dhcp6_domain_search dhcp6_name_servers \ ++ fqdn_hostname ; do + var="${prefix}${basevar}" + eval "content=\$$var" + +diff --git a/debian/dhclient-script.linux b/debian/dhclient-script.linux +index 915cc13..68a7252 100644 +--- a/debian/dhclient-script.linux ++++ b/debian/dhclient-script.linux +@@ -142,6 +142,23 @@ set_hostname() { + fi + } + ++# set host name using DHCPv6 FQDN hostname field ++set_hostname_v6() { ++ if [ -n "$new_fqdn_hostname" ]; then ++ local current_hostname=$(hostname) ++ ++ # current host name is empty, '(none)' or 'localhost' or differs from new one from DHCP ++ if [ -z "$current_hostname" ] || ++ [ "$current_hostname" = '(none)' ] || ++ [ "$current_hostname" = 'localhost' ] || ++ [ "$current_hostname" = "$old_fqdn_hostname" ]; then ++ if [ "$old_fqdn_hostname" != "$current_hostname" ]; then ++ hostname "$new_fqdn_hostname" ++ fi ++ fi ++ fi ++} ++ + # run given script + run_hook() { + local script="$1" +@@ -399,7 +416,8 @@ case "$reason" in + ;; + + BOUND6|RENEW6|REBIND6) +- set_hostname ++ set_hostname # use if host_name is provided ++ set_hostname_v6 # use if fqdn_hostname is provided + + if [ "${new_ip6_address}" ]; then + # set leased IP +-- +2.17.1 + diff --git a/base/dhcp/debian/deb_patches/series b/base/dhcp/debian/deb_patches/series index b32eda96f..3b0e8ce3c 100644 --- a/base/dhcp/debian/deb_patches/series +++ b/base/dhcp/debian/deb_patches/series @@ -1,3 +1,4 @@ 0001-dhclient-dhcp6-set-hostname.patch 0002-Update-dn-and-dns-only-with-diff-upon-RENEW.patch -0003-Use-prefixlen-for-IPv6-address-operations.patch \ No newline at end of file +0003-Use-prefixlen-for-IPv6-address-operations.patch +0004-use-DHCPv6-FQDN-hostname-field-to-set-hostname.patch \ No newline at end of file