Преглед на файлове

totem: Fix buffer sizes

knet needs buffers to be KNET_MAX_PACKET_SIZE or messages will
get lost or corrupted.

UDPU packets shouldn't be that big so I introduced UDP_FRAME_SIZE_MAX
for that transport.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Christine Caulfield преди 9 години
родител
ревизия
16770a4153
променени са 3 файла, в които са добавени 11 реда и са изтрити 8 реда
  1. 1 1
      exec/totemknet.c
  2. 8 6
      exec/totemudpu.c
  3. 2 1
      include/corosync/totem/totem.h

+ 1 - 1
exec/totemknet.c

@@ -144,7 +144,7 @@ struct totemknet_instance {
 
 	void *knet_context;
 
-	char iov_buffer[MAX_BUFFERS][FRAME_SIZE_MAX];
+	char iov_buffer[MAX_BUFFERS][KNET_MAX_PACKET_SIZE];
 
 	int stats_sent;
 

+ 8 - 6
exec/totemudpu.c

@@ -79,7 +79,9 @@
 #define MSG_NOSIGNAL 0
 #endif
 
-#define MCAST_SOCKET_BUFFER_SIZE (TRANSMITS_ALLOWED * FRAME_SIZE_MAX)
+#define UDPU_FRAME_SIZE_MAX 10000
+
+#define MCAST_SOCKET_BUFFER_SIZE (TRANSMITS_ALLOWED * UDPU_FRAME_SIZE_MAX)
 #define NETIF_STATE_REPORT_UP		1
 #define NETIF_STATE_REPORT_DOWN		2
 
@@ -143,7 +145,7 @@ struct totemudpu_instance {
 
 	void *udpu_context;
 
-	char iov_buffer[FRAME_SIZE_MAX];
+	char iov_buffer[UDPU_FRAME_SIZE_MAX];
 
 	struct iovec totemudpu_iov_recv;
 
@@ -218,7 +220,7 @@ static void totemudpu_instance_initialize (struct totemudpu_instance *instance)
 
 	instance->totemudpu_iov_recv.iov_base = instance->iov_buffer;
 
-	instance->totemudpu_iov_recv.iov_len = FRAME_SIZE_MAX; //sizeof (instance->iov_buffer);
+	instance->totemudpu_iov_recv.iov_len = UDPU_FRAME_SIZE_MAX; //sizeof (instance->iov_buffer);
 
 	/*
 	 * There is always atleast 1 processor
@@ -453,7 +455,7 @@ static int net_deliver_fn (
 		iovec->iov_base,
 		iovec->iov_len);
 
-	iovec->iov_len = FRAME_SIZE_MAX;
+	iovec->iov_len = UDPU_FRAME_SIZE_MAX;
 	return (0);
 }
 
@@ -779,7 +781,7 @@ int totemudpu_initialize (
 	 * Initialize local variables for totemudpu
 	 */
 	instance->totem_interface = &totem_config->interfaces[0];
-	memset (instance->iov_buffer, 0, FRAME_SIZE_MAX);
+	memset (instance->iov_buffer, 0, UDPU_FRAME_SIZE_MAX);
 
 	instance->totemudpu_poll_handle = poll_handle;
 
@@ -814,7 +816,7 @@ int totemudpu_initialize (
 
 void *totemudpu_buffer_alloc (void)
 {
-	return malloc (FRAME_SIZE_MAX);
+	return malloc (UDPU_FRAME_SIZE_MAX);
 }
 
 void totemudpu_buffer_release (void *ptr)

+ 2 - 1
include/corosync/totem/totem.h

@@ -35,6 +35,7 @@
 #ifndef TOTEM_H_DEFINED
 #define TOTEM_H_DEFINED
 #include "totemip.h"
+#include "libknet.h"
 #include <corosync/hdb.h>
 
 #ifdef HAVE_SMALL_MEMORY_FOOTPRINT
@@ -47,7 +48,7 @@
 #define MESSAGE_QUEUE_MAX	((4 * MESSAGE_SIZE_MAX) / totem_config->net_mtu)
 #endif /* HAVE_SMALL_MEMORY_FOOTPRINT */
 
-#define FRAME_SIZE_MAX		10000
+#define FRAME_SIZE_MAX		KNET_MAX_PACKET_SIZE
 #define TRANSMITS_ALLOWED	16
 #define SEND_THREADS_MAX	16