Browse Source

network: support macaddr in brackets []

ip=ens3:dhcp:1000
ip=ens3:dhcp::54:52:00:abπŸ’Ώef
ip=ens3:dhcp::[54:52:00πŸ†Žcd:ef]
ip=ens3:dhcp:1000:54:52:00:abπŸ’Ώef
ip=ens3:dhcp:1000:[54:52:00πŸ†Žcd:ef]

ip=192.168.122.20::192.168.122.1:24:test:ens3:none:1000
ip=192.168.122.20::192.168.122.1:24:test:ens3:none::54:52:00:abπŸ’Ώef
ip=192.168.122.20::192.168.122.1:24:test:ens3:none::[54:52:00πŸ†Žcd:ef]
ip=192.168.122.20::192.168.122.1:24:test:ens3:none:1000:54:52:00πŸ†Žcd:ef
ip=192.168.122.20::192.168.122.1:24:test:ens3:none:1000:[54:52:00πŸ†Žcd:ef]

ip=::::test:ens3:dhcp:1000
ip=::::test:ens3:dhcp::54:52:00:abπŸ’Ώef
ip=::::test:ens3:dhcp::[54:52:00πŸ†Žcd:ef]
ip=::::test:ens3:dhcp:1000:54:52:00:abπŸ’Ώef
ip=::::test:ens3:dhcp:1000:[54:52:00πŸ†Žcd:ef]

(cherry picked from commit 53e4ab7174)
master
Harald Hoyer 8 years ago
parent
commit
740c46c022
  1. 124
      modules.d/40network/net-lib.sh

124
modules.d/40network/net-lib.sh

@ -447,60 +447,84 @@ ip_to_var() {
done done


unset ip srv gw mask hostname dev autoconf macaddr mtu dns1 dns2 unset ip srv gw mask hostname dev autoconf macaddr mtu dns1 dns2
case $# in
0) autoconf="error" ;; if [ $# -eq 0 ]; then
1) autoconf=$1 ;; autoconf="error"
2) [ -n "$1" ] && dev=$1; [ -n "$2" ] && autoconf=$2 ;; return 0
3) [ -n "$1" ] && dev=$1; [ -n "$2" ] && autoconf=$2; [ -n "$3" ] && mtu=$3 ;; fi
4) [ -n "$1" ] && dev=$1; [ -n "$2" ] && autoconf=$2; [ -n "$3" ] && mtu=$3; [ -n "$4" ] && macaddr=$4 ;;
*) [ -n "$1" ] && ip=$1; [ -n "$2" ] && srv=$2; [ -n "$3" ] && gw=$3; [ -n "$4" ] && mask=$4; if [ $# -eq 1 ]; then
[ -n "$5" ] && hostname=$5; [ -n "$6" ] && dev=$6; [ -n "$7" ] && autoconf=$7; # format: ip={dhcp|on|any|dhcp6|auto6}
case "$8" in # or
[0-9]*:*|[0-9]*.[0-9]*.[0-9]*.[0-9]*) # ip=<ipv4-address> means anaconda-style static config argument cluster
dns1="$8" autoconf="$1"
[ -n "$9" ] && dns2="$9"
;; if strstr "$autoconf" "*.*.*.*"; then
[0-9]*) # ip=<ipv4-address> means anaconda-style static config argument cluster:
mtu="$8" # ip=<ip> gateway=<gw> netmask=<nm> hostname=<host> mtu=<mtu>
if [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then # ksdevice={link|bootif|ibft|<MAC>|<ifname>}
macaddr="${9}:${10}:${11}:${12}:${13}:${14}" ip="$autoconf"
fi gw=$(getarg gateway=)
;; mask=$(getarg netmask=)
*) hostname=$(getarg hostname=)
if [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then dev=$(getarg ksdevice=)
macaddr="${9}:${10}:${11}:${12}:${13}:${14}" autoconf="none"
fi mtu=$(getarg mtu=)
;;
# handle special values for ksdevice
case "$dev" in
bootif|BOOTIF) dev=$(fix_bootif $(getarg BOOTIF=)) ;;
link) dev="" ;; # FIXME: do something useful with this
ibft) dev="" ;; # ignore - ibft is handled elsewhere
esac esac
fi
return 0
fi

if [ "$2" = "dhcp" -o "$2" = "on" -o "$2" = "any" -o "$2" = "dhcp6" -o "$2" = "auto6" ]; then
# format: ip=<interface>:{dhcp|on|any|dhcp6|auto6}[:[<mtu>][:<macaddr>]]
[ -n "$1" ] && dev="$1"
[ -n "$2" ] && autoconf="$2"
[ -n "$3" ] && mtu=$3
if [ -z "$5" ]; then
macaddr="$4"
else
macaddr="${4}:${5}:${6}:${7}:${8}:${9}"
fi
return 0
fi

# format: ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>:<interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}:[:[<mtu>][:<macaddr>]]

[ -n "$1" ] && ip=$1
[ -n "$2" ] && srv=$2
[ -n "$3" ] && gw=$3
[ -n "$4" ] && mask=$4
[ -n "$5" ] && hostname=$5
[ -n "$6" ] && dev=$6
[ -n "$7" ] && autoconf=$7
case "$8" in
[0-9]*:*|[0-9]*.[0-9]*.[0-9]*.[0-9]*)
dns1="$8"
[ -n "$9" ] && dns2="$9"
;; ;;
esac [0-9]*)
# Extract prefix length from CIDR notation mtu="$8"
case $ip in if [ -n "${9}" -a -z "${10}" ]; then
*/*) macaddr="${9}"
mask=${ip##*/} elif [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then
ip=${ip%/*} macaddr="${9}:${10}:${11}:${12}:${13}:${14}"
fi
;; ;;
*)
if [ -n "${9}" -a -z "${10}" ]; then
macaddr="${9}"
elif [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then
macaddr="${9}:${10}:${11}:${12}:${13}:${14}"
fi
;;
esac esac

return 0
# ip=<ipv4-address> means anaconda-style static config argument cluster:
# ip=<ip> gateway=<gw> netmask=<nm> hostname=<host> mtu=<mtu>
# ksdevice={link|bootif|ibft|<MAC>|<ifname>}
if strglob "$autoconf" "*.*.*.*"; then
ip="$autoconf"
gw=$(getarg gateway=)
mask=$(getarg netmask=)
hostname=$(getarg hostname=)
dev=$(getarg ksdevice=)
autoconf="none"
mtu=$(getarg mtu=)

# handle special values for ksdevice
case "$dev" in
bootif|BOOTIF) dev=$(fix_bootif $(getarg BOOTIF=)) ;;
link) dev="" ;; # FIXME: do something useful with this
ibft) dev="" ;; # ignore - ibft is handled elsewhere
esac
fi
} }


route_to_var() { route_to_var() {

Loading…
Cancel
Save