From e5eb062f050d96a70f72ee78f431f774c98b24e2 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Wed, 21 Dec 2011 07:44:53 +0000 Subject: net/iproute2: iproute2 flag handling Several of the optional flags were not being handled correctly, they were being passed as values only, without the keyword before them. Affected keywords: anycast, label, scope, valid_lft, preferred_lft Also change the handling of keywords to a common setup now, making broadcast and peer strings the same as the above keywords. Signed-off-by: Robin H. Johnson --- net/iproute2.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'net') diff --git a/net/iproute2.sh b/net/iproute2.sh index c8f670c..c3bb9c8 100644 --- a/net/iproute2.sh +++ b/net/iproute2.sh @@ -113,31 +113,35 @@ _add_address() local address netmask broadcast peer anycast label scope local valid_lft preferred_lft home nodad + local confflaglist address="$1" ; shift while [ -n "$*" ]; do case "$1" in netmask) netmask="/$(_netmask2cidr "$2")" ; shift ; shift ;; broadcast|brd) - broadcast="broadcast $2" ; shift ; shift ;; + broadcast="$2" ; shift ; shift ;; pointopoint|pointtopoint|peer) - peer="peer $2" ; shift ; shift ;; + peer="$2" ; shift ; shift ;; anycast|label|scope|valid_lft|preferred_lft) eval "$1=$2" ; shift ; shift ;; home|nodad) - eval "$1=$1" ; shift ;; + # FIXME: If we need to reorder these, this will take more code + confflaglist="${confflaglist} $1" ; shift ;; esac done # Always scope lo addresses as host unless specified otherwise if [ "${IFACE}" = "lo" ]; then - [ -z "$scope" ] && scope="scope host" + [ -z "$scope" ] && scope="host" fi # figure out the broadcast address if it is not specified - [ -z "$broadcast" ] && broadcast="broadcast +" + # FIXME: I'm not sure if this should be set if we are passing a peer arg + [ -z "$broadcast" ] && broadcast="+" - set -- "${address}${netmask}" $peer $broadcast $anycast $label $scope dev "${IFACE}" $valid_lft $preferred_lft $home $nodad + # This must appear on a single line, continuations cannot be used + set -- "${address}${netmask}" ${peer:+peer} ${peer} ${broadcast:+broadcast} ${broadcast} ${anycast:+anycast} ${anycast} ${label:+label} ${label} ${scope:+scope} ${scope} dev "${IFACE}" ${valid_lft:+valid_lft} $valid_lft ${preferred_lft:+preferred_lft} $preferred_lft $confflaglist veinfo ip addr add "$@" ip addr add "$@" } -- cgit v1.2.3