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

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