• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From ec2f5414c6c98b63376e4bce9534abc5c01ce13c Mon Sep 17 00:00:00 2001
2From: wuchangsheng <wuchangsheng2@huawei.com>
3Date: Thu, 6 Oct 2022 18:47:06 +0800
4Subject: [PATCH] fix EISCONN err and remove same customized modification
5
6---
7 src/api/api_msg.c      | 22 ++--------------------
8 src/include/lwipsock.h | 33 ++++-----------------------------
9 2 files changed, 6 insertions(+), 49 deletions(-)
10
11diff --git a/src/api/api_msg.c b/src/api/api_msg.c
12index 2dded75..1fedaad 100644
13--- a/src/api/api_msg.c
14+++ b/src/api/api_msg.c
15@@ -1334,25 +1334,7 @@ lwip_netconn_do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
16   }
17
18 #if USE_LIBOS
19-  if (CONN_TYPE_IS_HOST(conn)) {
20-    LWIP_DEBUGF(API_MSG_DEBUG,
21-        ("libos outgoing connection abort fd=%d\n", conn->socket));
22-    return ERR_ABRT;
23-  }
24-
25-  LWIP_DEBUGF(API_MSG_DEBUG, ("libos outgoing connection established\n"));
26-  if (CONN_TYPE_HAS_INPRG(conn) && CONN_TYPE_HAS_HOST(conn)) {
27-    int s = conn->socket;
28-    struct lwip_sock *sock = get_socket_without_errno(s);
29-
30-    if (!!sock) {
31-      posix_api->shutdown_fn(s, SHUT_RDWR);
32-      LWIP_DEBUGF(API_MSG_DEBUG,
33-          ("linux outgoing connection abort fd=%d\n", s));
34-    }
35-  }
36-  SET_CONN_TYPE_LIBOS(conn);
37-  add_epoll_event(conn, EPOLLOUT);
38+  gazelle_connected_callback(conn);
39 #endif
40
41   LWIP_ASSERT("conn->state == NETCONN_CONNECT", conn->state == NETCONN_CONNECT);
42@@ -1417,7 +1399,7 @@ lwip_netconn_do_connect(void *m)
43         /* Prevent connect while doing any other action. */
44         if (msg->conn->state == NETCONN_CONNECT) {
45           err = ERR_ALREADY;
46-        } else if (msg->conn->pcb.tcp->state != ESTABLISHED) {
47+        } else if (msg->conn->pcb.tcp->state == ESTABLISHED) {
48           err = ERR_ISCONN;
49         } else {
50           setup_tcp(msg->conn);
51diff --git a/src/include/lwipsock.h b/src/include/lwipsock.h
52index 3c5c44b..912d471 100644
53--- a/src/include/lwipsock.h
54+++ b/src/include/lwipsock.h
55@@ -93,13 +93,14 @@ struct lwip_sock {
56 #endif
57
58 #if USE_LIBOS
59+  struct pbuf *send_lastdata;
60+  uint16_t send_datalen;
61   volatile uint32_t events __rte_cache_aligned; /* available events */
62   struct pbuf *recv_lastdata __rte_cache_aligned; /* unread data in one pbuf */
63   struct list_node recv_list __rte_cache_aligned;
64   struct list_node event_list __rte_cache_aligned;
65   struct list_node send_list __rte_cache_aligned;
66   uint32_t in_send __rte_cache_aligned; /* avoid sock too much send rpc msg*/
67-  uint32_t send_flag __rte_cache_aligned; /* avoid sock too much send rpc msg*/
68   uint32_t epoll_events; /* registered events, EPOLLONESHOT write frequently */
69   char pad __rte_cache_aligned;
70
71@@ -124,38 +125,12 @@ struct lwip_sock {
72 #if USE_LIBOS
73 extern uint32_t sockets_num;
74 extern struct lwip_sock *sockets;
75-/**
76- * Map a externally used socket index to the internal socket representation.
77- *
78- * @param s externally used socket index
79- * @return struct lwip_sock for the socket or NULL if not found
80- */
81-static inline struct lwip_sock *
82-get_socket_without_errno(int s)
83-{
84-  struct lwip_sock *sock = NULL;
85-
86-  s -= LWIP_SOCKET_OFFSET;
87-
88-  if ((s < 0) || (s >= sockets_num)) {
89-    LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): invalid\n", s + LWIP_SOCKET_OFFSET));
90-    return NULL;
91-  }
92-
93-  sock = &sockets[s];
94-
95-  if (!sock->conn) {
96-    LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): not active\n", s + LWIP_SOCKET_OFFSET));
97-    return NULL;
98-  }
99-
100-  return sock;
101-}
102-
103+extern void gazelle_connected_callback(struct netconn *conn);
104 extern void add_recv_list(int32_t fd);
105 extern ssize_t read_lwip_data(struct lwip_sock *sock, int32_t flags, u8_t apiflags);
106 extern struct pbuf *write_lwip_data(struct lwip_sock *sock, uint16_t remain_size, uint8_t *apiflags);
107 extern void gazelle_init_sock(int32_t fd);
108+extern void write_lwip_over(struct lwip_sock *sock, uint32_t n);
109 #endif /* USE_LIBOS */
110
111 struct lwip_sock *get_socket(int s);
112--
1132.27.0
114
115