summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-10-10 18:01:38 +0200
committerChristian Poessinger <christian@poessinger.com>2021-10-10 18:04:40 +0200
commit71d9aca5c4d898649bbba429c7337eaf5514f2e0 (patch)
tree897f07a6feb53e890fb95c30d0365598ea21ff56 /scripts
parent96f685de6d45b0ca376ad87b7d33d07de0da8b9d (diff)
downloadvyatta-cfg-71d9aca5c4d898649bbba429c7337eaf5514f2e0.tar.gz
vyatta-cfg-71d9aca5c4d898649bbba429c7337eaf5514f2e0.zip
vyos-router: dhcpv6: T3885: generate persistent DUID based on system UUID
(cherry picked from commit 6a94fc44e95735b9f6bd4fc162c3775b902dc0eb)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/init/vyos-router32
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/init/vyos-router b/scripts/init/vyos-router
index ed71379..7863bd9 100755
--- a/scripts/init/vyos-router
+++ b/scripts/init/vyos-router
@@ -173,6 +173,34 @@ bind_mount_boot ()
fi
}
+# XXX: T3885 - generate persistend DHCPv6 DUID (Type4 - UUID based)
+gen_duid ()
+{
+ DUID_FILE="/var/lib/dhcpv6/dhcp6c_duid"
+ UUID_FILE="/sys/class/dmi/id/product_uuid"
+ if [ ! -f ${UUID_FILE} ]; then
+ return 1
+ fi
+
+ # DUID is based on the BIOS/EFI UUID. We omit additional - characters
+ UUID=$(cat ${UUID_FILE} | tr -d -)
+ # Add DUID type4 (UUID) information
+ DUID_TYPE="0004"
+
+ # The length-information (as per RFC6355 UUID is 128 bits long) is in big-endian
+ # format - beware when porting to ARM64. The length field consists out of the
+ # UUID (128 bit + 16 bits DUID type) resulting in hex 12.
+ DUID_LEN="0012"
+ if [ "$(echo -n I | od -to2 | head -n1 | cut -f2 -d" " | cut -c6 )" -eq 1 ]; then
+ # true on little-endian (x86) systems
+ DUID_LEN="1200"
+ fi
+
+ for i in $(echo -n ${DUID_LEN}${DUID_TYPE}${UUID} | sed 's/../& /g'); do
+ echo -ne "\x$i"
+ done > ${DUID_FILE}
+}
+
start ()
{
log_daemon_msg "Waiting for NICs to settle down"
@@ -184,6 +212,10 @@ start ()
STATUS=$?
log_progress_msg "settled in ${SECONDS}sec."
log_end_msg ${STATUS}
+
+ # Generate DHCPv6 DUID
+ gen_duid || log_failure_msg "could not generate DUID"
+
# Fixup for FRR
# In 5.1 master, zebra thinks existence of /var/run/netns is