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