[PATCH] Adjust MTU for IPv6 correctly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



MTU for IPv6 is 20 bytes larger then IPv4. This fact was not taken into
account so IPv6 packets were larger then MTU resulting in fragmentation.

Solution is to substract correct IP header size.

Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 exec/totemip.c                   |   22 ++++++++++++++++++++++
 exec/totemudp.c                  |    6 ++++--
 exec/totemudpu.c                 |    6 ++++--
 include/corosync/totem/totemip.h |    2 ++
 4 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/exec/totemip.c b/exec/totemip.c
index 7ba746e..28a8836 100644
--- a/exec/totemip.c
+++ b/exec/totemip.c
@@ -488,3 +488,25 @@ finished:
 	totemip_freeifaddrs(&addrs);
 	return (res);
 }
+
+#define TOTEMIP_UDP_HEADER_SIZE		8
+#define TOTEMIP_IPV4_HEADER_SIZE	20
+#define TOTEMIP_IPV6_HEADER_SIZE	40
+
+size_t totemip_udpip_header_size(int family)
+{
+	size_t header_size;
+
+	header_size = 0;
+
+	switch (family) {
+	case AF_INET:
+		header_size = TOTEMIP_UDP_HEADER_SIZE + TOTEMIP_IPV4_HEADER_SIZE;
+		break;
+	case AF_INET6:
+		header_size = TOTEMIP_UDP_HEADER_SIZE + TOTEMIP_IPV6_HEADER_SIZE;
+		break;
+	}
+
+	return (header_size);
+}
diff --git a/exec/totemudp.c b/exec/totemudp.c
index 4577107..86059af 100644
--- a/exec/totemudp.c
+++ b/exec/totemudp.c
@@ -1316,10 +1316,12 @@ extern int totemudp_iface_check (void *udp_context)
 
 extern void totemudp_net_mtu_adjust (void *udp_context, struct totem_config *totem_config)
 {
-#define UDPIP_HEADER_SIZE (20 + 8) /* 20 bytes for ip 8 bytes for udp */
+
+	assert(totem_config->interface_count > 0);
+
 	totem_config->net_mtu -= crypto_sec_header_size(totem_config->crypto_cipher_type,
 							totem_config->crypto_hash_type) +
-				 UDPIP_HEADER_SIZE;
+				 totemip_udpip_header_size(totem_config->interfaces[0].bindnet.family);
 }
 
 const char *totemudp_iface_print (void *udp_context)  {
diff --git a/exec/totemudpu.c b/exec/totemudpu.c
index 69837c7..037f82b 100644
--- a/exec/totemudpu.c
+++ b/exec/totemudpu.c
@@ -952,10 +952,12 @@ extern int totemudpu_iface_check (void *udpu_context)
 
 extern void totemudpu_net_mtu_adjust (void *udpu_context, struct totem_config *totem_config)
 {
-#define UDPIP_HEADER_SIZE (20 + 8) /* 20 bytes for ip 8 bytes for udp */
+
+	assert(totem_config->interface_count > 0);
+
 	totem_config->net_mtu -= crypto_sec_header_size(totem_config->crypto_cipher_type,
 							totem_config->crypto_hash_type) +
-				 UDPIP_HEADER_SIZE;
+				 totemip_udpip_header_size(totem_config->interfaces[0].bindnet.family);
 }
 
 const char *totemudpu_iface_print (void *udpu_context)  {
diff --git a/include/corosync/totem/totemip.h b/include/corosync/totem/totemip.h
index 533735a..0168e66 100644
--- a/include/corosync/totem/totemip.h
+++ b/include/corosync/totem/totemip.h
@@ -114,6 +114,8 @@ static inline int totemip_zero_check(const struct totem_ip_address *addr)
 	return (addr->family == 0);
 }
 
+extern size_t totemip_udpip_header_size(int family);
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.1

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss




[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux