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:01:38 +0200
commit6a94fc44e95735b9f6bd4fc162c3775b902dc0eb (patch)
treea45f85e850f946f49f3b37fa33e40533799eda75 /scripts
parent8d7267114762c488cd180b087cc865af94b946b0 (diff)
downloadvyatta-cfg-6a94fc44e95735b9f6bd4fc162c3775b902dc0eb.tar.gz
vyatta-cfg-6a94fc44e95735b9f6bd4fc162c3775b902dc0eb.zip
vyos-router: dhcpv6: T3885: generate persistent DUID based on system UUID
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/init/vyos-router31
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/init/vyos-router b/scripts/init/vyos-router
index 316321c..bc0517c 100755
--- a/scripts/init/vyos-router
+++ b/scripts/init/vyos-router
@@ -226,6 +226,34 @@ security_reset ()
find /etc/swanctl -type f | xargs rm -f
}
+# 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 ()
{
# some legacy directories migrated over from old rl-system.init
@@ -249,6 +277,9 @@ start ()
# Clear out Debian APT source config file
empty /etc/apt/sources.list
+ # 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
# a requirement for netns support