Add IPv6 support
authorAmitay Isaacs <amitay@gmail.com>
Thu, 20 Nov 2014 03:16:15 +0000 (14:16 +1100)
committerMartin Schwenke <martin@meltin.net>
Tue, 25 Nov 2014 00:24:56 +0000 (11:24 +1100)
New configuration variable NETWORK_STACK.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
autocluster
config.d/00base.defconf
host_setup/setup_networks.sh

index 0eb26f5076a603a723c60c5d69e4ef1260d109b9..0ae0f1221589336c7394f2a6758a40c6cb6ab48e 100755 (executable)
@@ -352,12 +352,14 @@ make_network_map ()
 
        local ip="${net%.*}.${IPNUM}/${ip_bits#*/}"
 
+       local ipv6="fc00:${net//./:}::${IPNUM}/64"
+
        # This can be used to override the variables in the echo
        # statement below.  The hook can use any other variables
        # available in this function.
        run_hooks hack_network_map_hooks
 
-       echo "${netname} ${dev} ${ip} ${mac} ${opts}"
+       echo "${netname} ${dev} ${ip} ${ipv6} ${mac} ${opts}"
        count=$(($count + 1))
     done >"$network_map"
 }
@@ -718,8 +720,8 @@ guess_install_network ()
     # specified then use the IP address associated with it.
     INSTALL_IP=""
     INSTALL_GW=""
-    local netname dev ip mac opts
-    while read netname dev ip mac opts; do
+    local netname dev ip ipv6 mac opts
+    while read netname dev ip ipv6 mac opts; do
        local o
        for o in $opts ; do
            case "$o" in
@@ -1007,8 +1009,8 @@ setup_network()
     diskimage rm_rf "/etc/udev/rules.d/70-persistent-net.rules"
 
     echo "Setting up network interfaces: "
-    local netname dev ip mac opts
-    while read netname dev ip mac opts; do
+    local netname dev ip ipv6 mac opts
+    while read netname dev ip ipv6 mac opts; do
        echo "  $dev"
 
        local o gw addr mask
@@ -1031,6 +1033,8 @@ TYPE=Ethernet
 IPADDR=$addr
 NETMASK=$mask
 HWADDR=$mac
+IPV6INIT=yes
+IPV6ADDR=$ipv6
 ${gw:+GATEWAY=}${gw}
 EOF
 
index f366f1ee42625b5f21c775cff656a7a8357d966e..1196b07d83d3ff4d3ca63b0132140dfaeccab475 100644 (file)
@@ -228,6 +228,9 @@ defconf DNSSEARCH "$DOMAIN" \
 defconf NETWORKS "10.0.0.0/24,eth0,gw=10.0.0.1 10.0.1.0/24,eth1 10.0.2.0/24,eth2" \
        "<list>" "description of IP networks"
 
+defconf NETWORK_STACK "ipv4" \
+       "ipv4|dual|ipv6" "Configure IPv4/IPv6 stacks"
+
 make_public_addresses()
 {
        local firstip="${1:-$[${FIRSTIP} + ${PUBLIC_IP_OFFSET}]}"
@@ -279,8 +282,8 @@ defconf NETWORK_TEMPLATE "|network_template" \
 
 network_template ()
 {
-    local netname dev ip mac opts
-    while read netname dev ip mac opts ; do
+    local netname dev ip ipv6 mac opts
+    while read netname dev ip ipv6 mac opts ; do
        cat <<EOF
     <interface type='network'>
       <mac address='${mac}'/>
index 52dc29fae524e2ed28eb29edd9c5c249e2849245..65c19fb398ea2cbde7c445880b522922f5304956 100755 (executable)
@@ -21,7 +21,8 @@ gen_xml ()
 {
     local netname="$1"
     local ip="$2"
-    local opts="$3"
+    local ipv6="$3"
+    local opts="$4"
 
     local uuid=$(uuidgen)
 
@@ -55,9 +56,13 @@ EOF
     ip_addr=${ip%/*}
     ip_mask=${ip#*/}
 
+    ipv6_addr=${ipv6%/*}
+    ipv6_mask=${ipv6#*/}
+
     cat <<EOF
   <bridge name='${netname}' stp='on' forwardDelay='0' />
   <ip address='${ip_addr}' prefix='${ip_mask}' />
+  <ip family='ipv6' address='${ipv6_addr}' prefix='${ipv6_mask}' />
 </network>
 EOF
 }
@@ -78,10 +83,10 @@ if [ $? -ne 0 -o -z "$network_map" ]; then
 fi
 
 
-while read netname dev ip mac opts ; do
+while read netname dev ip ipv6 mac opts ; do
     echo "Setting up network \"${netname}\""
     t=$(mktemp)
-    gen_xml "$netname" "$ip" "$opts" >"$t"
+    gen_xml "$netname" "$ip" "$ipv6" "$opts" >"$t"
     if $dry_run ; then
        cat "$t"
     else