From b3a058a46a27beadb5976d4618e2f33a69909c9b Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Tue, 18 Jun 2024 09:31:12 +0800
Subject: [PATCH] distinguish tcp/udp get_from_sendring

---
 src/core/tcp_out.c      | 3 ++-
 src/core/udp.c          | 4 +---
 src/include/lwip/pbuf.h | 2 +-
 src/include/lwipsock.h  | 3 ++-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c
index 8a9016b..839e904 100644
--- a/src/core/tcp_out.c
+++ b/src/core/tcp_out.c
@@ -907,8 +907,9 @@ tcp_write_from_stack(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apifl
     u16_t max_len = mss_local - optlen;
     u16_t seglen = LWIP_MIN(left, max_len);
 
-    p = do_lwip_get_from_sendring((struct lwip_sock *)arg, len - pos, &apiflags);
+    p = do_lwip_tcp_get_from_sendring((struct lwip_sock *)arg, len - pos);
     if (p == NULL) {
+      apiflags &= ~TCP_WRITE_FLAG_MORE;
       break;
     }
     seglen = p->tot_len;
diff --git a/src/core/udp.c b/src/core/udp.c
index 1fae8b6..086e7e0 100644
--- a/src/core/udp.c
+++ b/src/core/udp.c
@@ -702,9 +702,7 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
     return ERR_RTE;
   }
 #if GAZELLE_UDP_ENABLE
-  uint8_t apiflags = 0;
-
-  struct pbuf *udp_pbuf = do_lwip_get_from_sendring((struct lwip_sock *)(p->payload), p->tot_len, &apiflags);
+  struct pbuf *udp_pbuf = do_lwip_udp_get_from_sendring((struct lwip_sock *)(p->payload), p->tot_len);
   do_lwip_get_from_sendring_over((struct lwip_sock *)(p->payload));
 
   p = udp_pbuf;
diff --git a/src/include/lwip/pbuf.h b/src/include/lwip/pbuf.h
index d84c9da..2bb9675 100644
--- a/src/include/lwip/pbuf.h
+++ b/src/include/lwip/pbuf.h
@@ -225,7 +225,7 @@ struct pbuf {
   u8_t if_idx;
 
 #if GAZELLE_ENABLE && CHECKSUM_OFFLOAD_ALL
-  volatile u8_t allow_in;
+  volatile u8_t allow_append;
   pthread_spinlock_t pbuf_lock;
   struct tcp_pcb *pcb;
 #if GAZELLE_UDP_ENABLE
diff --git a/src/include/lwipsock.h b/src/include/lwipsock.h
index d700cee..7ba685a 100644
--- a/src/include/lwipsock.h
+++ b/src/include/lwipsock.h
@@ -174,7 +174,8 @@ extern struct lwip_sock *sockets;
 extern void do_lwip_init_sock(int32_t fd);
 extern void do_lwip_clean_sock(int32_t fd);
 extern void do_lwip_connected_callback(struct netconn *conn);
-extern struct pbuf *do_lwip_get_from_sendring(struct lwip_sock *sock, uint16_t remain_size, uint8_t *apiflags);
+extern struct pbuf *do_lwip_udp_get_from_sendring(struct lwip_sock *sock, uint16_t remain_size);
+extern struct pbuf *do_lwip_tcp_get_from_sendring(struct lwip_sock *sock, uint16_t remain_size);
 extern void do_lwip_get_from_sendring_over(struct lwip_sock *sock);
 extern ssize_t do_lwip_read_from_lwip(struct lwip_sock *sock, int32_t flags, u8_t apiflags);
 extern void do_lwip_add_recvlist(int32_t fd);
-- 
2.33.0

