gazelle/0003-set-localhost-ip-when-bind-ip-is-same-as-ip-in-lstac.patch
jiangheng12 36a18c3c25 sync add lstack_preload.c to makefile fix compile failure
(cherry picked from commit c2dbec5c1167505f5458dc9070b2700882e23583)
2023-09-26 21:55:03 +08:00

28 lines
896 B
Diff

From c13dd0c6ae71dd7547b9c1c6240585ae0f5c7c6b Mon Sep 17 00:00:00 2001
From: chengyechun <chengyechun1@huawei.com>
Date: Tue, 11 Jul 2023 10:57:35 +0800
Subject: [PATCH] set localhost ip when bind ip is same as ip in lstack.conf
---
src/lstack/api/lstack_wrap.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
index 6a1a2c4..956d661 100644
--- a/src/lstack/api/lstack_wrap.c
+++ b/src/lstack/api/lstack_wrap.c
@@ -245,6 +245,10 @@ bool is_dst_ip_localhost(const struct sockaddr *addr)
char *p;
size_t linel = 0;
int linenum = 0;
+ if (get_global_cfg_params()->host_addr.addr == servaddr->sin_addr.s_addr) {
+ return true;
+ }
+
FILE *ifh = fopen("/proc/net/dev", "r");
if (ifh == NULL) {
LSTACK_LOG(ERR, LSTACK, "failed to open /proc/net/dev, errno is %d\n", errno);
--
2.23.0