1 Star 0 Fork 32

Ren Zhijie/gazelle

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0145-add-limit-with-level-for-sockopt.patch 2.83 KB
一键复制 编辑 原始数据 按行查看 历史
jinag12 提交于 2024-03-14 16:57 . sync fix rpc_pool create failed coredump
From 5e4b2366417b5f951ffd5ee45c0917ae67bd502e Mon Sep 17 00:00:00 2001
From: hantwofish <hankangkang5@huawei.com>
Date: Sun, 3 Mar 2024 21:40:23 +0800
Subject: [PATCH] add limit with level for sockopt
---
src/lstack/api/lstack_wrap.c | 49 +++++++++++++++++++++++++-----------
2 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
index 1e36d3d..49bbf91 100644
--- a/src/lstack/api/lstack_wrap.c
+++ b/src/lstack/api/lstack_wrap.c
@@ -364,27 +364,46 @@ static inline int32_t do_getsockname(int32_t s, struct sockaddr *name, socklen_t
return posix_api->getsockname_fn(s, name, namelen);
}
-static bool unsupport_optname(int32_t optname)
-{
- if (optname == SO_BROADCAST ||
- optname == SO_PROTOCOL ||
- optname == TCP_QUICKACK ||
- optname == SO_SNDTIMEO ||
- optname == SO_RCVTIMEO ||
- optname == SO_SNDBUF ||
- optname == SO_RCVBUF ||
- optname == TCP_INFO ||
- optname == TCP_MAXSEG ||
- optname == SO_DONTROUTE ||
- optname == TCP_CONGESTION) {
+static bool unsupport_tcp_optname(int32_t optname)
+{
+ if ((optname == TCP_QUICKACK) ||
+ (optname == TCP_INFO) ||
+ (optname == TCP_MAXSEG) ||
+ (optname == TCP_CONGESTION)) {
+ return true;
+ }
+ return false;
+}
+
+static bool unsupport_socket_optname(int32_t optname)
+{
+ if ((optname == SO_BROADCAST) ||
+ (optname == SO_PROTOCOL) ||
+ (optname == SO_SNDTIMEO) ||
+ (optname == SO_RCVTIMEO) ||
+ (optname == SO_SNDBUF) ||
+ (optname == SO_RCVBUF) ||
+ (optname == SO_DONTROUTE)) {
return true;
}
return false;
}
+static bool unsupport_optname(int32_t level, int32_t optname)
+{
+ if (level == SOL_TCP) {
+ return unsupport_tcp_optname(optname);
+ }
+
+ if (level == SOL_SOCKET) {
+ return unsupport_socket_optname(optname);
+ }
+ return false;
+}
+
static inline int32_t do_getsockopt(int32_t s, int32_t level, int32_t optname, void *optval, socklen_t *optlen)
{
- if (select_fd_posix_path(s, NULL) == PATH_LWIP && !unsupport_optname(optname)) {
+ if (select_fd_posix_path(s, NULL) == PATH_LWIP && !unsupport_optname(level, optname)) {
return g_wrap_api->getsockopt_fn(s, level, optname, optval, optlen);
}
@@ -393,7 +412,7 @@ static inline int32_t do_getsockopt(int32_t s, int32_t level, int32_t optname, v
static inline int32_t do_setsockopt(int32_t s, int32_t level, int32_t optname, const void *optval, socklen_t optlen)
{
- if (select_fd_posix_path(s, NULL) == PATH_KERNEL || unsupport_optname(optname)) {
+ if (select_fd_posix_path(s, NULL) == PATH_KERNEL || unsupport_optname(level, optname)) {
return posix_api->setsockopt_fn(s, level, optname, optval, optlen);
}
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/byterzj/gazelle.git
git@gitee.com:byterzj/gazelle.git
byterzj
gazelle
gazelle
master

搜索帮助