Просмотр исходного кода

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.

(backported from master 03f95ddaa1d223e1e93788a307dc1b36d86b22b5)

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Jan Friesse 11 лет назад
Родитель
Сommit
6fc58377d9
4 измененных файлов с 33 добавлено и 6 удалено
  1. 22 0
      exec/totemip.c
  2. 4 3
      exec/totemudp.c
  3. 5 3
      exec/totemudpu.c
  4. 2 0
      include/corosync/totem/totemip.h

+ 22 - 0
exec/totemip.c

@@ -695,3 +695,25 @@ finished:
 	return res;
 }
 #endif /* COROSYNC_LINUX */
+
+#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 - 3
exec/totemudp.c

@@ -2091,12 +2091,13 @@ 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);
+
 	if (totem_config->secauth == 1) {
 		totem_config->net_mtu -= sizeof (struct security_header) +
-			UDPIP_HEADER_SIZE;
+			totemip_udpip_header_size(totem_config->interfaces[0].bindnet.family);
 	} else {
-		totem_config->net_mtu -= UDPIP_HEADER_SIZE;
+		totem_config->net_mtu -= totemip_udpip_header_size(totem_config->interfaces[0].bindnet.family);
 	}
 }
 

+ 5 - 3
exec/totemudpu.c

@@ -1584,12 +1584,14 @@ 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);
+
 	if (totem_config->secauth == 1) {
 		totem_config->net_mtu -= sizeof (struct security_header) +
-			UDPIP_HEADER_SIZE;
+			totemip_udpip_header_size(totem_config->interfaces[0].bindnet.family);
 	} else {
-		totem_config->net_mtu -= UDPIP_HEADER_SIZE;
+		totem_config->net_mtu -= totemip_udpip_header_size(totem_config->interfaces[0].bindnet.family);
 	}
 }
 

+ 2 - 0
include/corosync/totem/totemip.h

@@ -99,6 +99,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