代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/gazelle 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From c7a9c71456844b164477f329f79f5e10de7898a4 Mon Sep 17 00:00:00 2001
From: yangchen <yangchen145@huawei.com>
Date: Wed, 15 Nov 2023 11:23:04 +0800
Subject: [PATCH] wrap: fix connect wrong port after addr bind two ports
---
src/lstack/api/lstack_wrap.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
index 5bad513..f427d33 100644
--- a/src/lstack/api/lstack_wrap.c
+++ b/src/lstack/api/lstack_wrap.c
@@ -219,7 +219,20 @@ static int32_t do_bind(int32_t s, const struct sockaddr *name, socklen_t namelen
if (match_host_addr(((struct sockaddr_in *)name)->sin_addr.s_addr)) {
/* maybe kni addr */
- posix_api->bind_fn(s, name, namelen);
+ if (posix_api->bind_fn(s, name, namelen) != 0) {
+ SET_CONN_TYPE_LIBOS(sock->conn);
+ } else {
+ /* reuse the port allocated by kernel when port == 0 */
+ if (((struct sockaddr_in *)name)->sin_port == 0) {
+ struct sockaddr_in kerneladdr;
+ socklen_t len = sizeof(kerneladdr);
+ if (posix_api->getsockname_fn(s, (struct sockaddr *)&kerneladdr, &len) < 0) {
+ LSTACK_LOG(ERR, LSTACK, "kernel getsockname failed, fd=%d, errno=%d\n", s, errno);
+ return -1;
+ }
+ ((struct sockaddr_in *)name)->sin_port = kerneladdr.sin_port;
+ }
+ }
return g_wrap_api->bind_fn(s, name, namelen);
} else {
SET_CONN_TYPE_HOST(sock->conn);
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。