代码拉取完成,页面将自动刷新
From 7e6a5d97430f0d178c5e2b211c0c194fdea0c00a Mon Sep 17 00:00:00 2001
From: yangchen <yangchen145@huawei.com>
Date: Fri, 27 Sep 2024 06:32:41 +0800
Subject: [PATCH] af_xdp: set rlimit unlimit when gazelle init
---
src/lstack/core/lstack_init.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/lstack/core/lstack_init.c b/src/lstack/core/lstack_init.c
index 37264a1..1d27f68 100644
--- a/src/lstack/core/lstack_init.c
+++ b/src/lstack/core/lstack_init.c
@@ -17,6 +17,7 @@
#include <semaphore.h>
#include <sys/ioctl.h>
#include <sys/file.h>
+#include <sys/resource.h>
#include <securec.h>
#include <numa.h>
#include <pthread.h>
@@ -104,6 +105,20 @@ static int32_t check_process_conflict(void)
return 0;
}
+/* Remove the memory resource limit of the current process.
+ * if the number of locked memory resources is exceeded, xdp_umem_create fails.
+ */
+static int set_rlimit_unlimited(void)
+{
+ struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
+
+ if (setrlimit(RLIMIT_MEMLOCK, &r) != 0) {
+ return -1;
+ }
+
+ return 0;
+}
+
void gazelle_exit(void)
{
wrap_api_exit();
@@ -240,6 +255,11 @@ __attribute__((constructor)) void gazelle_network_init(void)
wrap_api_init();
+ if (set_rlimit_unlimited() != 0) {
+ LSTACK_PRE_LOG(LSTACK_INFO, "set rlimit unlimited failed\n");
+ LSTACK_EXIT(1, "set rlimit unlimited failed\n");
+ }
+
/* check primary process start */
check_process_start();
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。