49 lines
1.9 KiB
Diff
49 lines
1.9 KiB
Diff
From bf5bf036eed0f7c15e7441c0c4ddbd5d7e48b3dd Mon Sep 17 00:00:00 2001
|
|
From: hankangkang <hankangkang5@huawei.com>
|
|
Date: Thu, 12 Dec 2024 11:40:09 +0800
|
|
Subject: [PATCH] kernerl bind: add ipv6 add check
|
|
|
|
---
|
|
src/lstack/api/lstack_wrap.c | 23 +++++++++++++++++------
|
|
1 file changed, 17 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
|
|
index 4b57e60..05fa6ef 100644
|
|
--- a/src/lstack/api/lstack_wrap.c
|
|
+++ b/src/lstack/api/lstack_wrap.c
|
|
@@ -174,14 +174,25 @@ static int kernel_bind_process(int32_t s, const struct sockaddr *name, socklen_t
|
|
struct lwip_sock *sock = lwip_get_socket(s);
|
|
int times = 10;
|
|
int ret = 0;
|
|
+ bool share_ip = true;
|
|
+
|
|
+ /* lwip and kernel share IP, and exchange mbuf through virtual-NIC.
|
|
+ * lstack not sense if ltran enable kni, so only checks use_ltran. */
|
|
+
|
|
+ if (!get_global_cfg_params()->use_ltran && !get_global_cfg_params()->kni_switch &&
|
|
+ !get_global_cfg_params()->flow_bifurcation) {
|
|
+ share_ip = false;
|
|
+ }
|
|
|
|
ret = posix_api->bind_fn(s, name, namelen);
|
|
- /* maybe kni addr, ipv6 addr maybe is tentative,need to wait a few seconds */
|
|
- if (name->sa_family == AF_INET6 && ret < 0 && errno == EADDRNOTAVAIL) {
|
|
- LSTACK_LOG(WARNING, LSTACK, "virtio_user addr is tentative, please wait... \n");
|
|
- while (ret != 0 && times-- > 0) {
|
|
- sleep(1);
|
|
- ret = posix_api->bind_fn(s, name, namelen);
|
|
+ if (ret < 0 && errno == EADDRNOTAVAIL) {
|
|
+ /* ipv6 addr of virtual-NIC maybe is tentative, need to wait a few seconds */
|
|
+ if (name->sa_family == AF_INET6 && share_ip) {
|
|
+ LSTACK_LOG(WARNING, LSTACK, "virtio_user addr is tentative, please wait... \n");
|
|
+ while (ret != 0 && times-- > 0) {
|
|
+ sleep(1);
|
|
+ ret = posix_api->bind_fn(s, name, namelen);
|
|
+ }
|
|
}
|
|
}
|
|
|
|
--
|
|
2.33.0
|
|
|