From d14e214a9cd32f05f097b023baa7c4a6d8629fce Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Mon, 18 Dec 2023 21:30:32 +0800
Subject: [PATCH] fix udp multicast bind error

---
 src/lstack/api/lstack_wrap.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
index 89f54f8..5feadc3 100644
--- a/src/lstack/api/lstack_wrap.c
+++ b/src/lstack/api/lstack_wrap.c
@@ -211,6 +211,12 @@ static int32_t do_bind(int32_t s, const struct sockaddr *name, socklen_t namelen
         return posix_api->bind_fn(s, name, namelen);
     }
 
+    /* select user path when udp enable and ip addr is multicast */
+    if (IN_MULTICAST(ntohl(((struct sockaddr_in *)name)->sin_addr.s_addr))) {
+        SET_CONN_TYPE_LIBOS(sock->conn);
+        return g_wrap_api->bind_fn(s, name, namelen);
+    }
+
     if (match_host_addr(((struct sockaddr_in *)name)->sin_addr.s_addr)) {
         /* maybe kni addr */
         if (posix_api->bind_fn(s, name, namelen) != 0) {
-- 
2.27.0

