Blame SOURCES/bz1157702-2-Adjust-MTU-for-IPv6-correctly.patch

2c8186
From 03f95ddaa1d223e1e93788a307dc1b36d86b22b5 Mon Sep 17 00:00:00 2001
2c8186
From: Jan Friesse <jfriesse@redhat.com>
2c8186
Date: Tue, 30 Sep 2014 17:06:36 +0200
2c8186
Subject: [PATCH] Adjust MTU for IPv6 correctly
2c8186
2c8186
MTU for IPv6 is 20 bytes larger then IPv4. This fact was not taken into
2c8186
account so IPv6 packets were larger then MTU resulting in fragmentation.
2c8186
2c8186
Solution is to substract correct IP header size.
2c8186
2c8186
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2c8186
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2c8186
---
2c8186
 exec/totemip.c                   |   22 ++++++++++++++++++++++
2c8186
 exec/totemudp.c                  |    6 ++++--
2c8186
 exec/totemudpu.c                 |    6 ++++--
2c8186
 include/corosync/totem/totemip.h |    2 ++
2c8186
 4 files changed, 32 insertions(+), 4 deletions(-)
2c8186
2c8186
diff --git a/exec/totemip.c b/exec/totemip.c
2c8186
index 7ba746e..28a8836 100644
2c8186
--- a/exec/totemip.c
2c8186
+++ b/exec/totemip.c
2c8186
@@ -488,3 +488,25 @@ finished:
2c8186
 	totemip_freeifaddrs(&addrs);
2c8186
 	return (res);
2c8186
 }
2c8186
+
2c8186
+#define TOTEMIP_UDP_HEADER_SIZE		8
2c8186
+#define TOTEMIP_IPV4_HEADER_SIZE	20
2c8186
+#define TOTEMIP_IPV6_HEADER_SIZE	40
2c8186
+
2c8186
+size_t totemip_udpip_header_size(int family)
2c8186
+{
2c8186
+	size_t header_size;
2c8186
+
2c8186
+	header_size = 0;
2c8186
+
2c8186
+	switch (family) {
2c8186
+	case AF_INET:
2c8186
+		header_size = TOTEMIP_UDP_HEADER_SIZE + TOTEMIP_IPV4_HEADER_SIZE;
2c8186
+		break;
2c8186
+	case AF_INET6:
2c8186
+		header_size = TOTEMIP_UDP_HEADER_SIZE + TOTEMIP_IPV6_HEADER_SIZE;
2c8186
+		break;
2c8186
+	}
2c8186
+
2c8186
+	return (header_size);
2c8186
+}
2c8186
diff --git a/exec/totemudp.c b/exec/totemudp.c
2c8186
index 4577107..86059af 100644
2c8186
--- a/exec/totemudp.c
2c8186
+++ b/exec/totemudp.c
2c8186
@@ -1316,10 +1316,12 @@ extern int totemudp_iface_check (void *udp_context)
2c8186
 
2c8186
 extern void totemudp_net_mtu_adjust (void *udp_context, struct totem_config *totem_config)
2c8186
 {
2c8186
-#define UDPIP_HEADER_SIZE (20 + 8) /* 20 bytes for ip 8 bytes for udp */
2c8186
+
2c8186
+	assert(totem_config->interface_count > 0);
2c8186
+
2c8186
 	totem_config->net_mtu -= crypto_sec_header_size(totem_config->crypto_cipher_type,
2c8186
 							totem_config->crypto_hash_type) +
2c8186
-				 UDPIP_HEADER_SIZE;
2c8186
+				 totemip_udpip_header_size(totem_config->interfaces[0].bindnet.family);
2c8186
 }
2c8186
 
2c8186
 const char *totemudp_iface_print (void *udp_context)  {
2c8186
diff --git a/exec/totemudpu.c b/exec/totemudpu.c
2c8186
index 69837c7..037f82b 100644
2c8186
--- a/exec/totemudpu.c
2c8186
+++ b/exec/totemudpu.c
2c8186
@@ -952,10 +952,12 @@ extern int totemudpu_iface_check (void *udpu_context)
2c8186
 
2c8186
 extern void totemudpu_net_mtu_adjust (void *udpu_context, struct totem_config *totem_config)
2c8186
 {
2c8186
-#define UDPIP_HEADER_SIZE (20 + 8) /* 20 bytes for ip 8 bytes for udp */
2c8186
+
2c8186
+	assert(totem_config->interface_count > 0);
2c8186
+
2c8186
 	totem_config->net_mtu -= crypto_sec_header_size(totem_config->crypto_cipher_type,
2c8186
 							totem_config->crypto_hash_type) +
2c8186
-				 UDPIP_HEADER_SIZE;
2c8186
+				 totemip_udpip_header_size(totem_config->interfaces[0].bindnet.family);
2c8186
 }
2c8186
 
2c8186
 const char *totemudpu_iface_print (void *udpu_context)  {
2c8186
diff --git a/include/corosync/totem/totemip.h b/include/corosync/totem/totemip.h
2c8186
index 533735a..0168e66 100644
2c8186
--- a/include/corosync/totem/totemip.h
2c8186
+++ b/include/corosync/totem/totemip.h
2c8186
@@ -114,6 +114,8 @@ static inline int totemip_zero_check(const struct totem_ip_address *addr)
2c8186
 	return (addr->family == 0);
2c8186
 }
2c8186
 
2c8186
+extern size_t totemip_udpip_header_size(int family);
2c8186
+
2c8186
 #ifdef __cplusplus
2c8186
 }
2c8186
 #endif
2c8186
-- 
2c8186
1.7.1
2c8186