Blame SOURCES/0417-40network-Update-iBFT-scanning-code-to-handle-IPv6.patch

712866
From bac74f05e37b5a4e9a0f2fd5e26c4a8b3546e574 Mon Sep 17 00:00:00 2001
712866
From: Hannes Reinecke <hare@suse.de>
712866
Date: Thu, 12 May 2016 20:03:28 +0200
712866
Subject: [PATCH] 40network: Update iBFT scanning code to handle IPv6
712866
712866
IPv6 addresses should be specified in brackets so that the
712866
ip= scanning code doesn't get confused.
712866
712866
References: bnc#887542
712866
712866
Signed-off-by: Hannes Reinecke <hare@suse.de>
712866
Signed-off-by: Thomas Renninger <trenn@suse.com>
712866
(cherry picked from commit c98d1756f766e49f7b457e217b0e0156d577d8b8)
712866
---
712866
 modules.d/40network/net-lib.sh | 38 ++++++++++++++++++++++++++++++++++----
712866
 1 file changed, 34 insertions(+), 4 deletions(-)
712866
712866
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
5c6c2a
index e6942a55..98dbbb63 100755
712866
--- a/modules.d/40network/net-lib.sh
712866
+++ b/modules.d/40network/net-lib.sh
712866
@@ -235,22 +235,52 @@ ibft_to_cmdline() {
712866
 
712866
             [ -e /tmp/net.${dev}.has_ibft_config ] && continue
712866
 
712866
+            [ -e ${iface}/flags ] && flags=$(read a < ${iface}/flags; echo $a)
712866
+            # Skip invalid interfaces
712866
+            (( $flags & 1 )) || continue
712866
+            # Skip interfaces not used for booting
712866
+            (( $flags & 2 )) || continue
712866
             [ -e ${iface}/dhcp ] && dhcp=$(read a < ${iface}/dhcp; echo $a)
712866
-
712866
-            if [ -n "$dhcp" ]; then
712866
-                echo "ip=$dev:dhcp"
712866
+            [ -e ${iface}/origin ] && origin=$(read a < ${iface}/origin; echo $a)
712866
+            [ -e ${iface}/ip-addr ] && ip=$(read a < ${iface}/ip-addr; echo $a)
712866
+
712866
+            if [ -n "$ip" ] ; then
712866
+                case "$ip" in
712866
+                    *.*.*.*)
712866
+                        family=ipv4
712866
+                        ;;
712866
+                    *:*)
712866
+                        family=ipv6
712866
+                        ;;
712866
+                esac
712866
+            fi
712866
+            if [ -n "$dhcp" ] || [ "$origin" -eq 3 ]; then
712866
+                if [ "$family" = "ipv6" ] ; then
712866
+                    echo "ip=$dev:dhcp6"
712866
+                else
712866
+                    echo "ip=$dev:dhcp"
712866
+                fi
712866
             elif [ -e ${iface}/ip-addr ]; then
712866
-                [ -e ${iface}/ip-addr ] && ip=$(read a < ${iface}/ip-addr; echo $a)
712866
                 # skip not assigned ip adresses
712866
                 [ "$ip" = "0.0.0.0" ] && continue
712866
                 [ -e ${iface}/gateway ] && gw=$(read a < ${iface}/gateway; echo $a)
712866
                 [ "$gateway" = "0.0.0.0" ] && unset $gateway
712866
                 [ -e ${iface}/subnet-mask ] && mask=$(read a < ${iface}/subnet-mask; echo $a)
712866
+                [ -e ${iface}/prefix-len ] && prefix=$(read a < ${iface}/prefix-len; echo $a)
712866
                 [ -e ${iface}/primary-dns ] && dns1=$(read a < ${iface}/primary-dns; echo $a)
712866
                 [ "$dns1" = "0.0.0.0" ] && unset $dns1
712866
                 [ -e ${iface}/secondary-dns ] && dns2=$(read a < ${iface}/secondary-dns; echo $a)
712866
                 [ "$dns2" = "0.0.0.0" ] && unset $dns2
712866
                 [ -e ${iface}/hostname ] && hostname=$(read a < ${iface}/hostname; echo $a)
712866
+                if [ "$family" = "ipv6" ] ; then
712866
+                    if [ -n "$ip" ] ; then
712866
+                        [ -n "$prefix" ] || prefix=64
712866
+                        mask="$prefix"
712866
+                    fi
712866
+                    if [ -n "$gw" ] ; then
712866
+                        gw="[${gw}]"
712866
+                    fi
712866
+                fi
712866
                 if [ -n "$ip" ] && [ -n "$mask" ]; then
712866
                     echo "ip=$ip::$gw:$mask:$hostname:$dev:none${dns1:+:$dns1}${dns2:+:$dns2}"
712866
                 else