Blame 0094-40network-Update-iBFT-scanning-code-to-handle-IPv6.patch

Harald Hoyer 414eba
From c98d1756f766e49f7b457e217b0e0156d577d8b8 Mon Sep 17 00:00:00 2001
Harald Hoyer 414eba
From: Hannes Reinecke <hare@suse.de>
Harald Hoyer 414eba
Date: Thu, 12 May 2016 20:03:28 +0200
Harald Hoyer 414eba
Subject: [PATCH] 40network: Update iBFT scanning code to handle IPv6
Harald Hoyer 414eba
Harald Hoyer 414eba
IPv6 addresses should be specified in brackets so that the
Harald Hoyer 414eba
ip= scanning code doesn't get confused.
Harald Hoyer 414eba
Harald Hoyer 414eba
References: bnc#887542
Harald Hoyer 414eba
Harald Hoyer 414eba
Signed-off-by: Hannes Reinecke <hare@suse.de>
Harald Hoyer 414eba
Signed-off-by: Thomas Renninger <trenn@suse.com>
Harald Hoyer 414eba
---
Harald Hoyer 414eba
 modules.d/40network/net-lib.sh | 48 +++++++++++++++++++++++++++++++++++++-----
Harald Hoyer 414eba
 1 file changed, 43 insertions(+), 5 deletions(-)
Harald Hoyer 414eba
Harald Hoyer 414eba
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
Harald Hoyer 414eba
index 005ad1b..9c1448d 100755
Harald Hoyer 414eba
--- a/modules.d/40network/net-lib.sh
Harald Hoyer 414eba
+++ b/modules.d/40network/net-lib.sh
Harald Hoyer 414eba
@@ -241,23 +241,54 @@ ibft_to_cmdline() {
Harald Hoyer 414eba
 
Harald Hoyer 414eba
             [ -e /tmp/net.${dev}.has_ibft_config ] && continue
Harald Hoyer 414eba
 
Harald Hoyer 414eba
+            [ -e ${iface}/flags ] && flags=$(read a < ${iface}/flags; echo $a)
Harald Hoyer 414eba
+            # Skip invalid interfaces
Harald Hoyer 414eba
+            (( $flags & 1 )) || continue
Harald Hoyer 414eba
+            # Skip interfaces not used for booting
Harald Hoyer 414eba
+            (( $flags & 2 )) || continue
Harald Hoyer 414eba
             [ -e ${iface}/dhcp ] && dhcp=$(read a < ${iface}/dhcp; echo $a)
Harald Hoyer 414eba
-
Harald Hoyer 414eba
-            if [ -n "$dhcp" ]; then
Harald Hoyer 414eba
-                echo "ip=$dev:dhcp"
Harald Hoyer 414eba
+            [ -e ${iface}/origin ] && origin=$(read a < ${iface}/origin; echo $a)
Harald Hoyer 414eba
+            [ -e ${iface}/ip-addr ] && ip=$(read a < ${iface}/ip-addr; echo $a)
Harald Hoyer 414eba
+
Harald Hoyer 414eba
+            if [ -n "$ip" ] ; then
Harald Hoyer 414eba
+                case "$ip" in
Harald Hoyer 414eba
+                    *.*.*.*)
Harald Hoyer 414eba
+                        family=ipv4
Harald Hoyer 414eba
+                        ;;
Harald Hoyer 414eba
+                    *:*)
Harald Hoyer 414eba
+                        family=ipv6
Harald Hoyer 414eba
+                        ;;
Harald Hoyer 414eba
+                esac
Harald Hoyer 414eba
+            fi
Harald Hoyer 414eba
+            if [ -n "$dhcp" ] || [ "$origin" -eq 3 ]; then
Harald Hoyer 414eba
+                if [ "$family" = "ipv6" ] ; then
Harald Hoyer 414eba
+                    echo "ip=$dev:dhcp6"
Harald Hoyer 414eba
+                else
Harald Hoyer 414eba
+                    echo "ip=$dev:dhcp"
Harald Hoyer 414eba
+                fi
Harald Hoyer 414eba
             elif [ -e ${iface}/ip-addr ]; then
Harald Hoyer 414eba
-                [ -e ${iface}/ip-addr ] && ip=$(read a < ${iface}/ip-addr; echo $a)
Harald Hoyer 414eba
                 # skip not assigned ip adresses
Harald Hoyer 414eba
                 [ "$ip" = "0.0.0.0" ] && continue
Harald Hoyer 414eba
                 [ -e ${iface}/gateway ] && gw=$(read a < ${iface}/gateway; echo $a)
Harald Hoyer 414eba
                 [ "$gateway" = "0.0.0.0" ] && unset $gateway
Harald Hoyer 414eba
                 [ -e ${iface}/subnet-mask ] && mask=$(read a < ${iface}/subnet-mask; echo $a)
Harald Hoyer 414eba
+                [ -e ${iface}/prefix-len ] && prefix=$(read a < ${iface}/prefix-len; echo $a)
Harald Hoyer 414eba
                 [ -e ${iface}/primary-dns ] && dns1=$(read a < ${iface}/primary-dns; echo $a)
Harald Hoyer 414eba
                 [ "$dns1" = "0.0.0.0" ] && unset $dns1
Harald Hoyer 414eba
                 [ -e ${iface}/secondary-dns ] && dns2=$(read a < ${iface}/secondary-dns; echo $a)
Harald Hoyer 414eba
                 [ "$dns2" = "0.0.0.0" ] && unset $dns2
Harald Hoyer 414eba
                 [ -e ${iface}/hostname ] && hostname=$(read a < ${iface}/hostname; echo $a)
Harald Hoyer 414eba
-                if [ -n "$ip" ] && [ -n "$mask" ]; then
Harald Hoyer 414eba
+                if [ "$family" = "ipv6" ] ; then
Harald Hoyer 414eba
+                    if [ -n "$ip" ] ; then
Harald Hoyer 414eba
+                        [ -n "$prefix" ] || prefix=64
Harald Hoyer 414eba
+                        ip="[${ip}/${prefix}]"
Harald Hoyer 414eba
+                        mask=
Harald Hoyer 414eba
+                    fi
Harald Hoyer 414eba
+                    if [ -n "$gw" ] ; then
Harald Hoyer 414eba
+                        gw="[${gw}]"
Harald Hoyer 414eba
+                    fi
Harald Hoyer 414eba
+                fi
Harald Hoyer 414eba
+                if [ -n "$ip" ] && [ -n "$mask" -o -n "$prefix" ]; then
Harald Hoyer 414eba
                     echo "ip=$ip::$gw:$mask:$hostname:$dev:none${dns1:+:$dns1}${dns2:+:$dns2}"
Harald Hoyer 414eba
                 else
Harald Hoyer 414eba
                     warn "${iface} does not contain a valid iBFT configuration"
Harald Hoyer 414eba
@@ -439,6 +470,13 @@ ip_to_var() {
Harald Hoyer 414eba
             esac
Harald Hoyer 414eba
             ;;
Harald Hoyer 414eba
     esac
Harald Hoyer 414eba
+    # Extract prefix length from CIDR notation
Harald Hoyer 414eba
+    case $ip in
Harald Hoyer 414eba
+        */*)
Harald Hoyer 414eba
+            mask=${ip##*/}
Harald Hoyer 414eba
+            ip=${ip%/*}
Harald Hoyer 414eba
+            ;;
Harald Hoyer 414eba
+    esac
Harald Hoyer 414eba
 
Harald Hoyer 414eba
     # ip=<ipv4-address> means anaconda-style static config argument cluster:
Harald Hoyer 414eba
     # ip=<ip> gateway=<gw> netmask=<nm> hostname=<host> mtu=<mtu>