diff options
author | Daniil Baturin <daniil@baturin.org> | 2018-11-05 03:03:54 +0100 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2018-11-05 03:03:54 +0100 |
commit | 018860f21eb4151df5e0b719ad9b66331786ac4e (patch) | |
tree | 641881ca34e7f1f555699efe7261a27327bf63ac | |
parent | 7de05b2de4f1b57115fd7593bfaa79f0042c10f4 (diff) | |
download | vyatta-cfg-system-018860f21eb4151df5e0b719ad9b66331786ac4e.tar.gz vyatta-cfg-system-018860f21eb4151df5e0b719ad9b66331786ac4e.zip |
T288: normalize IP(v6) addresses before passing them to iproute2.
-rwxr-xr-x | scripts/vyatta-address | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/scripts/vyatta-address b/scripts/vyatta-address index 4491c3f0..c3e57856 100755 --- a/scripts/vyatta-address +++ b/scripts/vyatta-address @@ -32,11 +32,13 @@ case $1 in ip_address=$(sed -n 's/^\s\sfixed-address\s\(.*\);/\1/p' $lease_file | sed -n '$p'); elif [[ "$3" = "dhcpv6" ]]; then lease_file=/var/lib/dhcp/dhclient_v6_"$2".leases; - ip_address=$(sed -n 's/^\s\s\s\siaaddr\s\(.*\)\s{/\1/p' $lease_file | sed -n '$p'); + ip_address=$(sed -n 's/^\s\s\s\siaaddr\s\(.*\)\s{/\1/p' $lease_file | sed -n '$p'); else ip_address=$3; fi - + + ip_address=$(/usr/libexec/vyos/system/normalize-ip $ip_address) + if ! ip address show dev $2 2>/dev/null | grep -q "$ip_address"; then # Address doesn't exist there, nothing to delete exit 0 @@ -50,9 +52,9 @@ case $1 in elif [[ "$3" = "dhcpv6" ]]; then exec /opt/vyatta/sbin/vyatta-dhcpv6-client.pl --stop --ifname "$2" elif [[ "$3" =~ ":" ]]; then - exec sudo ip -6 addr del "$3" dev "$2" + exec sudo ip -6 addr del "$ip_address" dev "$2" else - exec sudo ip addr del "$3" dev "$2" + exec sudo ip addr del "$ip_address" dev "$2" fi ;; *) echo "Unknown option $1" |