Blob Blame History Raw
From 012f82f7ef99881ce41c231c774f838f49e59781 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Tue, 25 Feb 2014 14:04:05 +0100
Subject: [PATCH] network/dhclient-script.sh:DHCP IPv6 interface setup

configure IPv6 interface for DHCP6

https://bugzilla.redhat.com/show_bug.cgi?id=1064365
---
 modules.d/40network/dhclient-script.sh | 49 ++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/modules.d/40network/dhclient-script.sh b/modules.d/40network/dhclient-script.sh
index 70a2b71..a9c2523 100755
--- a/modules.d/40network/dhclient-script.sh
+++ b/modules.d/40network/dhclient-script.sh
@@ -48,6 +48,31 @@ setup_interface() {
     [ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
 }
 
+setup_interface6() {
+    domain=$new_domain_name
+    search=$(printf -- "$new_domain_search")
+    namesrv=$new_domain_name_servers
+    hostname=$new_host_name
+    lease_time=$new_dhcp_lease_time
+
+    [ -f /tmp/net.$netif.override ] && . /tmp/net.$netif.override
+
+    ip -6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
+        dev ${netif} scope global valid_lft ${lease_time} \
+        preferred_lft ${lease_time}
+
+    [ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf
+    if  [ -n "$namesrv" ] ; then
+        for s in $namesrv; do
+            echo nameserver $s
+        done
+    fi >> /tmp/net.$netif.resolv.conf
+
+    # Note: hostname can be fqdn OR short hostname, so chop off any
+    # trailing domain name and explicity add any domain if set.
+    [ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
+}
+
 PATH=/usr/sbin:/usr/bin:/sbin:/bin
 
 export PS4="dhclient.$interface.$$ + "
@@ -66,6 +91,7 @@ case $reason in
         echo "dhcp: PREINIT $netif up"
         linkup $netif
         ;;
+
     BOUND)
         echo "dhcp: BOND setting $netif"
         unset layer2
@@ -98,6 +124,29 @@ case $reason in
         echo "[ -f /tmp/setup_net_$netif.ok ]" > $hookdir/initqueue/finished/dhclient-$netif.sh
         >/tmp/net.$netif.up
         ;;
+
+    BOUND6)
+        echo "dhcp: BOND6 setting $netif"
+        setup_interface6
+
+        set | while read line; do
+            [ "${line#new_}" = "$line" ] && continue
+            echo "$line"
+        done >/tmp/dhclient.$netif.dhcpopts
+
+        {
+            echo '. /lib/net-lib.sh'
+            echo "setup_net $netif"
+            echo "source_hook initqueue/online $netif"
+            [ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif"
+            echo "> /tmp/setup_net_$netif.ok"
+            echo "> /tmp/setup_net_\$(cat /sys/class/net/$netif/address).ok"
+            echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh"
+        } > $hookdir/initqueue/setup_net_$netif.sh
+
+        echo "[ -f /tmp/setup_net_$netif.ok ]" > $hookdir/initqueue/finished/dhclient-$netif.sh
+        >/tmp/net.$netif.up
+        ;;
     *) echo "dhcp: $reason";;
 esac