Explorar el Código

Adjust MTU for IPv6 correctly

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@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Jan Friesse hace 11 años
padre
commit
03f95ddaa1
Se han modificado 4 ficheros con 32 adiciones y 4 borrados
  1. 22 0
      exec/totemip.c
  2. 4 2
      exec/totemudp.c
  3. 4 2
      exec/totemudpu.c
  4. 2 0
      include/corosync/totem/totemip.h

+ 22 - 0
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);
+}

+ 4 - 2
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)  {

+ 4 - 2
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)  {

+ 2 - 0
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