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

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