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

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