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

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