Blame SOURCES/0408-network-support-macaddr-in-brackets.patch

18971c
From 53e4ab71742fc1e5d8112c719c0d154d08815fa1 Mon Sep 17 00:00:00 2001
18971c
From: Harald Hoyer <harald@redhat.com>
18971c
Date: Wed, 29 Jun 2016 12:27:37 +0200
18971c
Subject: [PATCH] network: support macaddr in brackets []
18971c
18971c
ip=ens3:dhcp:1000
18971c
ip=ens3:dhcp::54:52:00:ab:cd:ef
18971c
ip=ens3:dhcp::[54:52:00:ab:cd:ef]
18971c
ip=ens3:dhcp:1000:54:52:00:ab:cd:ef
18971c
ip=ens3:dhcp:1000:[54:52:00:ab:cd:ef]
18971c
18971c
ip=192.168.122.20::192.168.122.1:24:test:ens3:none:1000
18971c
ip=192.168.122.20::192.168.122.1:24:test:ens3:none::54:52:00:ab:cd:ef
18971c
ip=192.168.122.20::192.168.122.1:24:test:ens3:none::[54:52:00:ab:cd:ef]
18971c
ip=192.168.122.20::192.168.122.1:24:test:ens3:none:1000:54:52:00:ab:cd:ef
18971c
ip=192.168.122.20::192.168.122.1:24:test:ens3:none:1000:[54:52:00:ab:cd:ef]
18971c
18971c
ip=::::test:ens3:dhcp:1000
18971c
ip=::::test:ens3:dhcp::54:52:00:ab:cd:ef
18971c
ip=::::test:ens3:dhcp::[54:52:00:ab:cd:ef]
18971c
ip=::::test:ens3:dhcp:1000:54:52:00:ab:cd:ef
18971c
ip=::::test:ens3:dhcp:1000:[54:52:00:ab:cd:ef]
18971c
---
18971c
 modules.d/40network/net-lib.sh | 119 +++++++++++++++++++++------------
18971c
 1 file changed, 75 insertions(+), 44 deletions(-)
18971c
18971c
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
18971c
index 5a07b4ee..0c00f925 100755
18971c
--- a/modules.d/40network/net-lib.sh
18971c
+++ b/modules.d/40network/net-lib.sh
18971c
@@ -406,53 +406,84 @@ ip_to_var() {
18971c
     done
18971c
 
18971c
     unset ip srv gw mask hostname dev autoconf macaddr mtu dns1 dns2
18971c
-    case $# in
18971c
-        0)  autoconf="error" ;;
18971c
-        1)  autoconf=$1 ;;
18971c
-        2)  [ -n "$1" ] && dev=$1; [ -n "$2" ] && autoconf=$2 ;;
18971c
-        3)  [ -n "$1" ] && dev=$1; [ -n "$2" ] && autoconf=$2; [ -n "$3" ] && mtu=$3 ;;
18971c
-        4)  [ -n "$1" ] && dev=$1; [ -n "$2" ] && autoconf=$2; [ -n "$3" ] && mtu=$3; [ -n "$4" ] && macaddr=$4 ;;
18971c
-        *)  [ -n "$1" ] && ip=$1; [ -n "$2" ] && srv=$2; [ -n "$3" ] && gw=$3; [ -n "$4" ] && mask=$4;
18971c
-            [ -n "$5" ] && hostname=$5; [ -n "$6" ] && dev=$6; [ -n "$7" ] && autoconf=$7;
18971c
-            case "$8" in
18971c
-                [0-9]*:*|[0-9]*.[0-9]*.[0-9]*.[0-9]*)
18971c
-                    dns1="$8"
18971c
-                    [ -n "$9" ] && dns2="$9"
18971c
-                    ;;
18971c
-                [0-9]*)
18971c
-                    mtu="$8"
18971c
-                    if [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then
18971c
-                        macaddr="${9}:${10}:${11}:${12}:${13}:${14}"
18971c
-                    fi
18971c
-                    ;;
18971c
-                *)
18971c
-                    if [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then
18971c
-                        macaddr="${9}:${10}:${11}:${12}:${13}:${14}"
18971c
-                    fi
18971c
-	            ;;
18971c
+
18971c
+    if [ $# -eq 0 ]; then
18971c
+        autoconf="error"
18971c
+        return 0
18971c
+    fi
18971c
+
18971c
+    if [ $# -eq 1 ]; then
18971c
+        # format: ip={dhcp|on|any|dhcp6|auto6}
18971c
+        # or
18971c
+        #         ip=<ipv4-address> means anaconda-style static config argument cluster
18971c
+        autoconf="$1"
18971c
+
18971c
+        if strstr "$autoconf" "*.*.*.*"; then
18971c
+            # ip=<ipv4-address> means anaconda-style static config argument cluster:
18971c
+            # ip=<ip> gateway=<gw> netmask=<nm> hostname=<host> mtu=<mtu>
18971c
+            # ksdevice={link|bootif|ibft|<MAC>|<ifname>}
18971c
+            ip="$autoconf"
18971c
+            gw=$(getarg gateway=)
18971c
+            mask=$(getarg netmask=)
18971c
+            hostname=$(getarg hostname=)
18971c
+            dev=$(getarg ksdevice=)
18971c
+            autoconf="none"
18971c
+            mtu=$(getarg mtu=)
18971c
+
18971c
+            # handle special values for ksdevice
18971c
+            case "$dev" in
18971c
+                bootif|BOOTIF) dev=$(fix_bootif $(getarg BOOTIF=)) ;;
18971c
+                link) dev="" ;; # FIXME: do something useful with this
18971c
+                ibft) dev="" ;; # ignore - ibft is handled elsewhere
18971c
             esac
18971c
-            ;;
18971c
-    esac
18971c
+        fi
18971c
+        return 0
18971c
+    fi
18971c
 
18971c
-    # ip=<ipv4-address> means anaconda-style static config argument cluster:
18971c
-    # ip=<ip> gateway=<gw> netmask=<nm> hostname=<host> mtu=<mtu>
18971c
-    # ksdevice={link|bootif|ibft|<MAC>|<ifname>}
18971c
-    if strstr "$autoconf" "*.*.*.*"; then
18971c
-        ip="$autoconf"
18971c
-        gw=$(getarg gateway=)
18971c
-        mask=$(getarg netmask=)
18971c
-        hostname=$(getarg hostname=)
18971c
-        dev=$(getarg ksdevice=)
18971c
-        autoconf="none"
18971c
-        mtu=$(getarg mtu=)
18971c
-
18971c
-        # handle special values for ksdevice
18971c
-        case "$dev" in
18971c
-            bootif|BOOTIF) dev=$(fix_bootif $(getarg BOOTIF=)) ;;
18971c
-            link) dev="" ;; # FIXME: do something useful with this
18971c
-            ibft) dev="" ;; # ignore - ibft is handled elsewhere
18971c
-        esac
18971c
+    if [ "$2" = "dhcp" -o "$2" = "on" -o "$2" = "any" -o "$2" = "dhcp6" -o "$2" = "auto6" ]; then
18971c
+        # format: ip=<interface>:{dhcp|on|any|dhcp6|auto6}[:[<mtu>][:<macaddr>]]
18971c
+        [ -n "$1" ] && dev="$1"
18971c
+        [ -n "$2" ] && autoconf="$2"
18971c
+        [ -n "$3" ] && mtu=$3
18971c
+        if [ -z "$5" ]; then
18971c
+            macaddr="$4"
18971c
+        else
18971c
+            macaddr="${4}:${5}:${6}:${7}:${8}:${9}"
18971c
+        fi
18971c
+        return 0
18971c
     fi
18971c
+
18971c
+    # format: ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>:<interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}:[:[<mtu>][:<macaddr>]]
18971c
+
18971c
+    [ -n "$1" ] && ip=$1
18971c
+    [ -n "$2" ] && srv=$2
18971c
+    [ -n "$3" ] && gw=$3
18971c
+    [ -n "$4" ] && mask=$4
18971c
+    [ -n "$5" ] && hostname=$5
18971c
+    [ -n "$6" ] && dev=$6
18971c
+    [ -n "$7" ] && autoconf=$7
18971c
+    case "$8" in
18971c
+        [0-9]*:*|[0-9]*.[0-9]*.[0-9]*.[0-9]*)
18971c
+            dns1="$8"
18971c
+            [ -n "$9" ] && dns2="$9"
18971c
+            ;;
18971c
+        [0-9]*)
18971c
+            mtu="$8"
18971c
+            if [ -n "${9}" -a -z "${10}" ]; then
18971c
+                macaddr="${9}"
18971c
+            elif [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then
18971c
+                macaddr="${9}:${10}:${11}:${12}:${13}:${14}"
18971c
+            fi
18971c
+            ;;
18971c
+        *)
18971c
+            if [ -n "${9}" -a -z "${10}" ]; then
18971c
+                macaddr="${9}"
18971c
+            elif [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then
18971c
+                macaddr="${9}:${10}:${11}:${12}:${13}:${14}"
18971c
+            fi
18971c
+	    ;;
18971c
+    esac
18971c
+    return 0
18971c
 }
18971c
 
18971c
 route_to_var() {