Kaynağa Gözat

totemudpu: Export and rename UDPU_FRAME_SIZE_MAX

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Jan Friesse 8 yıl önce
ebeveyn
işleme
32535b842c
2 değiştirilmiş dosya ile 19 ekleme ve 18 silme
  1. 9 18
      exec/totemudpu.c
  2. 10 0
      include/corosync/totem/totem.h

+ 9 - 18
exec/totemudpu.c

@@ -74,16 +74,7 @@
 #define MSG_NOSIGNAL 0
 #endif
 
-/*
- * Estimation of required buffer size - it should be at least
- *   sizeof(memb_join) + PROCESSOR_MAX * 2 * sizeof(srp_addr))
- * if we want to support PROCESSOR_MAX nodes, but because we don't have
- * srp_addr and memb_join, we have to use estimation.
- * TODO: Consider moving srp_addr/memb_join into totem headers instead of totemsrp.c
- */
-#define UDPU_FRAME_SIZE_MAX	(PROCESSOR_COUNT_MAX * (INTERFACE_MAX * 2 * sizeof(struct totem_ip_address)) + 1024)
-
-#define MCAST_SOCKET_BUFFER_SIZE (TRANSMITS_ALLOWED * UDPU_FRAME_SIZE_MAX)
+#define MCAST_SOCKET_BUFFER_SIZE (TRANSMITS_ALLOWED * UDP_RECEIVE_FRAME_SIZE_MAX)
 #define NETIF_STATE_REPORT_UP		1
 #define NETIF_STATE_REPORT_DOWN		2
 
@@ -147,7 +138,7 @@ struct totemudpu_instance {
 
 	void *udpu_context;
 
-	char iov_buffer[UDPU_FRAME_SIZE_MAX];
+	char iov_buffer[UDP_RECEIVE_FRAME_SIZE_MAX];
 
 	struct iovec totemudpu_iov_recv;
 
@@ -222,7 +213,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 = UDPU_FRAME_SIZE_MAX; //sizeof (instance->iov_buffer);
+	instance->totemudpu_iov_recv.iov_len = UDP_RECEIVE_FRAME_SIZE_MAX; //sizeof (instance->iov_buffer);
 
 	/*
 	 * There is always atleast 1 processor
@@ -457,9 +448,9 @@ static int net_deliver_fn (
 #else
 	/*
 	 * We don't have MSGHDR_FLAGS, but we can (hopefully) safely make assumption that
-	 * if bytes_received == UDPU_FRAME_SIZE_MAX then packet is truncated
+	 * if bytes_received == UDP_RECEIVE_FRAME_SIZE_MAX then packet is truncated
 	 */
-	if (bytes_received == UDPU_FRAME_SIZE_MAX) {
+	if (bytes_received == UDP_RECEIVE_FRAME_SIZE_MAX) {
 		truncated_packet = 1;
 	}
 #endif
@@ -469,7 +460,7 @@ static int net_deliver_fn (
 				"Received too big message. This may be because something bad is happening"
 				"on the network (attack?), or you tried join more nodes than corosync is"
 				"compiled with (%u) or bug in the code (bad estimation of "
-				"the UDPU_FRAME_SIZE_MAX). Dropping packet.", PROCESSOR_COUNT_MAX);
+				"the UDP_RECEIVE_FRAME_SIZE_MAX). Dropping packet.", PROCESSOR_COUNT_MAX);
 		return (0);
 	}
 
@@ -483,7 +474,7 @@ static int net_deliver_fn (
 		iovec->iov_base,
 		iovec->iov_len);
 
-	iovec->iov_len = UDPU_FRAME_SIZE_MAX;
+	iovec->iov_len = UDP_RECEIVE_FRAME_SIZE_MAX;
 	return (0);
 }
 
@@ -831,7 +822,7 @@ int totemudpu_initialize (
 	 * Initialize local variables for totemudpu
 	 */
 	instance->totem_interface = &totem_config->interfaces[0];
-	memset (instance->iov_buffer, 0, UDPU_FRAME_SIZE_MAX);
+	memset (instance->iov_buffer, 0, UDP_RECEIVE_FRAME_SIZE_MAX);
 
 	instance->totemudpu_poll_handle = poll_handle;
 
@@ -866,7 +857,7 @@ int totemudpu_initialize (
 
 void *totemudpu_buffer_alloc (void)
 {
-	return malloc (UDPU_FRAME_SIZE_MAX);
+	return malloc (FRAME_SIZE_MAX);
 }
 
 void totemudpu_buffer_release (void *ptr)

+ 10 - 0
include/corosync/totem/totem.h

@@ -50,6 +50,16 @@
 #endif /* HAVE_SMALL_MEMORY_FOOTPRINT */
 
 #define FRAME_SIZE_MAX		KNET_MAX_PACKET_SIZE
+
+/*
+ * Estimation of required buffer size for totemudp and totemudpu - it should be at least
+ *   sizeof(memb_join) + PROCESSOR_MAX * 2 * sizeof(srp_addr))
+ * if we want to support PROCESSOR_MAX nodes, but because we don't have
+ * srp_addr and memb_join, we have to use estimation.
+ * TODO: Consider moving srp_addr/memb_join into totem headers instead of totemsrp.c
+ */
+#define UDP_RECEIVE_FRAME_SIZE_MAX     (PROCESSOR_COUNT_MAX * (INTERFACE_MAX * 2 * sizeof(struct totem_ip_address)) + 1024)
+
 #define TRANSMITS_ALLOWED	16
 #define SEND_THREADS_MAX	16