Browse code

ifup: apring applies only to IPv4

Change-Id: I8e368fa8811d0082df49eef88aaf6c21d626f7a1
Reviewed-on: http://photon-jenkins.eng.vmware.com/671
Reviewed-by: Sharath George
Tested-by: Sharath George

Vinay Kulkarni authored on 2016/03/30 05:14:14
Showing 2 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:       Set of scripts and tools to get compatbility with other distributions.
2 2
 Name:          distrib-compat
3 3
 Version:       0.1
4
-Release:       5%{?dist}
4
+Release:       6%{?dist}
5 5
 License:       GPLv2
6 6
 URL:           http://photon.org
7 7
 Group:         System Environment/Base
... ...
@@ -35,6 +35,8 @@ ln -s sysctl.d/99-compat.conf %{buildroot}/%{_sysconfdir}/sysctl.conf
35 35
 %{_sysconfdir}/*
36 36
 /sbin/*
37 37
 %changelog
38
+*    Tue Mar 29 2016 Vinay Kulkarni <kulkarniv@vmware.com> 0.1-6
39
+-    Do arping only for IPv4 addresses.
38 40
 *    Thu Feb 11 2016 Mahmoud Bassiouny <mbassiouny@vmware.com> 0.1-5
39 41
 -    Move ifup and ifdown outside the sources tar.gz
40 42
 *    Wed Feb 10 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 0.2-2
... ...
@@ -64,12 +64,16 @@ ip addr flush $interface || fail "Cannot flush IP address for $interface"
64 64
 ip link set dev $interface up || fail "Cannot bring $interface up"
65 65
 
66 66
 if [[ -n  $address ]] ; then
67
-    #Check for duplicates
68
-    arping -D -q -I $interface -c 2 $address
69
-    retval=$?
70
-    [ $retval -eq 1 ] && success "IP already exists in the network, will exit gracefully"
71
-    [ $retval -eq 2 ] && fail "Cannot procceed. $interface is down"
72
-    [ $retval -ne 0 ] && fail "Unknown error!"
67
+    if [[ $address =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
68
+        echo "Performing duplicate address check for IPv4 address $address"
69
+        arping -D -q -I $interface -c 2 $address
70
+        retval=$?
71
+        [ $retval -eq 1 ] && success "IP already exists in the network, will exit gracefully"
72
+        [ $retval -eq 2 ] && fail "Cannot procceed. $interface is down"
73
+        [ $retval -ne 0 ] && fail "Unknown error!"
74
+    else
75
+        echo "Skipping duplicate address check for IPv6 address $address"
76
+    fi
73 77
 fi
74 78
 
75 79
 print_message "Everything is good, IP is not assigned elsewhere, will restart systemd-networkd"