Blame SOURCES/bz1276699-ipaddr2-use-ipv6-dad-for-collision-detection.patch

937446
diff -uNr a/heartbeat/IPaddr2 b/heartbeat/IPaddr2
937446
--- a/heartbeat/IPaddr2	2016-02-29 10:54:21.909786575 +0100
937446
+++ b/heartbeat/IPaddr2	2016-02-29 14:38:48.502852067 +0100
937446
@@ -673,19 +673,35 @@
937446
 #
937446
 run_send_ua() {
937446
 	local i
937446
-	# Wait until the allocated IPv6 address gets ready by checking
937446
-	# "tentative" flag is disappeared, otherwise send_ua can not
937446
-	# send the unsolicited advertisement requests.
937446
-	for i in 1 2 3 4 5; do
937446
-		$IP2UTIL -o -f $FAMILY addr show dev $NIC \
937446
-			| grep -q -e "$OCF_RESKEY_ip/$NETMASK .* tentative"
937446
-		[ $? -ne 0 ] && break
937446
-		if [ $i -eq 5 ]; then
937446
-			ocf_log warn "$OCF_RESKEY_ip still has 'tentative' status. (ignored)"
937446
+
937446
+	# Duplicate Address Detection [DAD]
937446
+	# Kernel will flag the IP as 'tentative' until it ensured that
937446
+	# there is no duplicates.
937446
+	# If there is, it will flag it as 'dadfailed'
937446
+	for i in $(seq 1 10); do
937446
+		ipstatus=$($IP2UTIL -o -f $FAMILY addr show dev $NIC to $OCF_RESKEY_ip/$NETMASK)
937446
+		case "$ipstatus" in
937446
+		*dadfailed*)
937446
+			ocf_log err "IPv6 address collision $OCF_RESKEY_ip [DAD]"
937446
+			$IP2UTIL -f $FAMILY addr del dev $NIC $OCF_RESKEY_ip/$NETMASK
937446
+			if [ $? -ne 0 ]; then
937446
+				ocf_log err "Could not delete IPv6 address"
937446
+			fi
937446
+			return $OCF_ERR_GENERIC
937446
+			;;
937446
+		*tentative*)
937446
+			if [ $i -eq 10 ]; then
937446
+				ofc_log warn "IPv6 address : DAD is still in tentative"
937446
+			fi
937446
+			;;
937446
+		*)
937446
 			break
937446
-		fi
937446
+			;;
937446
+		esac
937446
 		sleep 1
937446
 	done
937446
+	# Now the address should be usable
937446
+
937446
 	ARGS="-i $OCF_RESKEY_arp_interval -c $OCF_RESKEY_arp_count $OCF_RESKEY_ip $NETMASK $NIC"
937446
 	ocf_log info "$SENDUA $ARGS"
937446
 	$SENDUA $ARGS || ocf_log err "Could not send ICMPv6 Unsolicited Neighbor Advertisements."
937446
@@ -838,6 +854,10 @@
937446
 		else
937446
 		    if [ -x $SENDUA ]; then
937446
 			run_send_ua
937446
+			if [ $? -ne 0 ]; then
937446
+				ocf_exit_reason "run_send_ua failed."
937446
+				exit $OCF_ERR_GENERIC
937446
+			fi
937446
 		    fi
937446
 		fi
937446
 		;;