43 lines
1.3 KiB
Diff
43 lines
1.3 KiB
Diff
From a37c451e63bed06a70e887aba6364183d71f414f Mon Sep 17 00:00:00 2001
|
|
From: yangchen <yangchen145@huawei.com>
|
|
Date: Mon, 11 Mar 2024 11:18:54 +0800
|
|
Subject: [PATCH] udp add restriction: message too long
|
|
|
|
---
|
|
src/common/gazelle_opt.h | 2 ++
|
|
src/lstack/core/lstack_lwip.c | 5 +++++
|
|
2 files changed, 7 insertions(+)
|
|
|
|
diff --git a/src/common/gazelle_opt.h b/src/common/gazelle_opt.h
|
|
index 1d1c5f5..6d787b9 100644
|
|
--- a/src/common/gazelle_opt.h
|
|
+++ b/src/common/gazelle_opt.h
|
|
@@ -60,6 +60,8 @@
|
|
|
|
#define DPDK_PKT_BURST_SIZE 512
|
|
|
|
+#define GAZELLE_UDP_PKGLEN_MAX (65535 - IP_HLEN - UDP_HLEN)
|
|
+
|
|
/* total:33 client, index 32 is invaild client */
|
|
#define GAZELLE_CLIENT_NUM_ALL 33
|
|
#define GAZELLE_NULL_CLIENT (GAZELLE_CLIENT_NUM_ALL - 1)
|
|
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
|
|
index f4199f8..8aae433 100644
|
|
--- a/src/lstack/core/lstack_lwip.c
|
|
+++ b/src/lstack/core/lstack_lwip.c
|
|
@@ -779,6 +779,11 @@ ssize_t do_lwip_send_to_stack(int32_t fd, const void *buf, size_t len, int32_t f
|
|
return 0;
|
|
}
|
|
|
|
+ if (NETCONN_IS_UDP(sock) && (len > GAZELLE_UDP_PKGLEN_MAX)) {
|
|
+ LSTACK_LOG(ERR, LSTACK, "Message too long\n");
|
|
+ GAZELLE_RETURN(EMSGSIZE);
|
|
+ }
|
|
+
|
|
thread_bind_stack(sock);
|
|
|
|
if (sock->same_node_tx_ring != NULL) {
|
|
--
|
|
2.27.0
|
|
|