Blame SOURCES/bz1528365-IPaddr2-1-sanitize-IPv6-IPs.patch

011c77
From 8ecfa95fff384ed047fd804016abdbbdcdd96d27 Mon Sep 17 00:00:00 2001
011c77
From: Keisuke MORI <kskmori@intellilink.co.jp>
011c77
Date: Wed, 11 Sep 2019 15:33:37 +0900
011c77
Subject: [PATCH] Low: IPaddr2: fix to work properly with unsanitized IPv6
011c77
 addresses
011c77
011c77
`ip route get` shows the sanitized address at $1 or $2 depending on
011c77
the address is already assigned to the node or not.
011c77
```
011c77
[root@centos73-1 ~]# /sbin/ip route get 2001:db8:101::0001
011c77
2001:db8:101::1 dev eth1  proto ra  src 2001:db8:101:0:XXXX:XXXX:XXXX:XXXX  metric 100
011c77
[root@centos73-1 ~]# /sbin/ip addr add 2001:db8:101::0001/64 dev eth1
011c77
[root@centos73-1 ~]# /sbin/ip route get 2001:db8:101::0001
011c77
local 2001:db8:101::1 dev lo  table local  proto none  src 2001:db8:101::1  metric 0
011c77
```
011c77
011c77
It can not be sanitized if the address is unreachable and on the recent distributions
011c77
(probably depending on the iproute package version)
011c77
```
011c77
[root@centos73-1 ~]# /sbin/ip route get 2001:db8:201::0001
011c77
unreachable 2001:db8:201::1 dev lo  table unspec  proto kernel  src 2001:db8:101:0:XXXX:XXXX:XXXX:XXXX  metric 429496
011c77
```
011c77
```
011c77
[root@rhel80-1 ~]# /sbin/ip route get 200:db8:201::0001
011c77
RTNETLINK answers: Network is unreachable
011c77
```
011c77
---
011c77
 heartbeat/IPaddr2 | 6 ++++++
011c77
 1 file changed, 6 insertions(+)
011c77
011c77
diff --git a/heartbeat/IPaddr2 b/heartbeat/IPaddr2
011c77
index 041ace3a2..4f28ddab6 100755
011c77
--- a/heartbeat/IPaddr2
011c77
+++ b/heartbeat/IPaddr2
011c77
@@ -477,6 +477,12 @@ ip_init() {
011c77
 		fi
011c77
 	else
011c77
 		FAMILY=inet6
011c77
+		# address sanitization defined in RFC5952
011c77
+		SANITIZED_IP=$($IP2UTIL route get $OCF_RESKEY_ip | awk '$1~/:/ {print $1}  $2~/:/ {print $2}')
011c77
+                if [ -n "$SANITIZED_IP" ]; then
011c77
+                    OCF_RESKEY_ip="$SANITIZED_IP"
011c77
+                fi
011c77
+
011c77
 		if ocf_is_true $OCF_RESKEY_lvs_support ;then
011c77
 			ocf_exit_reason "The IPv6 does not support lvs_support"
011c77
 			exit $OCF_ERR_CONFIGURED