代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/gazelle 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。