Changeset 3e2291a9 in mainline
- Timestamp:
- 2017-09-17T23:37:43Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 797dc79e
- Parents:
- 6969eea3
- Location:
- uspace/srv/net/tcp
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/Makefile
r6969eea3 r3e2291a9 64 64 test/segment.c \ 65 65 test/seq_no.c \ 66 test/tqueue.c 66 test/tqueue.c \ 67 test/ucall.c 67 68 68 69 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/net/tcp/conn.c
r6969eea3 r3e2291a9 100 100 void tcp_conns_fini(void) 101 101 { 102 assert(list_empty(&conn_list)); 103 102 104 amap_destroy(amap); 103 105 amap = NULL; 104 105 assert(list_empty(&conn_list));106 106 } 107 107 … … 458 458 459 459 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: tcp_conn_reset()", conn->name); 460 461 if (conn->cstate == st_closed) 462 return; 463 460 464 conn->reset = true; 461 465 tcp_conn_state_set(conn, st_closed); … … 910 914 return cp_done; 911 915 912 /* TODO */ 916 if (conn->fin_is_acked) { 917 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: FIN acked -> Time-Wait", 918 conn->name); 919 tcp_conn_state_set(conn, st_time_wait); 920 } 921 913 922 return cp_continue; 914 923 } … … 1107 1116 log_msg(LOG_DEFAULT, LVL_DEBUG, " - FIN found in segment."); 1108 1117 1118 conn->rcv_nxt++; 1119 conn->rcv_wnd--; 1120 1109 1121 /* Send ACK */ 1110 1122 tcp_tqueue_ctrl_seg(conn, CTL_ACK); 1111 1112 conn->rcv_nxt++;1113 conn->rcv_wnd--;1114 1123 1115 1124 /* Change connection state */ -
uspace/srv/net/tcp/test/conn.c
r6969eea3 r3e2291a9 57 57 tcp_rqueue_init(&test_rqueue_cb); 58 58 tcp_rqueue_fibril_start(); 59 60 /* Enable internal loopback */ 61 tcp_conn_lb = tcp_lb_segment; 59 62 } 60 63 … … 118 121 int rc; 119 122 120 tcp_conn_lb = tcp_lb_segment;121 122 123 inet_ep2_init(&epp); 123 124 inet_addr(&epp.local.addr, 127, 0, 0, 1); … … 146 147 } 147 148 149 /** Test establishing a connection */ 150 PCUT_TEST(conn_establish) 151 { 152 tcp_conn_t *cconn, *sconn; 153 inet_ep2_t cepp, sepp; 154 int rc; 155 156 /* Client EPP */ 157 inet_ep2_init(&cepp); 158 inet_addr(&cepp.local.addr, 127, 0, 0, 1); 159 inet_addr(&cepp.remote.addr, 127, 0, 0, 1); 160 cepp.remote.port = inet_port_user_lo; 161 162 /* Server EPP */ 163 inet_ep2_init(&sepp); 164 inet_addr(&sepp.local.addr, 127, 0, 0, 1); 165 sepp.local.port = inet_port_user_lo; 166 167 /* Client side of the connection */ 168 cconn = tcp_conn_new(&cepp); 169 PCUT_ASSERT_NOT_NULL(cconn); 170 171 rc = tcp_conn_add(cconn); 172 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 173 174 PCUT_ASSERT_INT_EQUALS(st_listen, cconn->cstate); 175 PCUT_ASSERT_FALSE(tcp_conn_got_syn(cconn)); 176 177 /* Server side of the connection */ 178 sconn = tcp_conn_new(&sepp); 179 PCUT_ASSERT_NOT_NULL(sconn); 180 181 rc = tcp_conn_add(sconn); 182 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 183 184 PCUT_ASSERT_INT_EQUALS(st_listen, sconn->cstate); 185 PCUT_ASSERT_FALSE(tcp_conn_got_syn(sconn)); 186 187 /* Start establishing the connection */ 188 189 tcp_conn_lock(cconn); 190 tcp_conn_sync(cconn); 191 PCUT_ASSERT_INT_EQUALS(st_syn_sent, cconn->cstate); 192 PCUT_ASSERT_FALSE(tcp_conn_got_syn(cconn)); 193 194 /* Wait for client-side state to transition */ 195 while (cconn->cstate == st_syn_sent) 196 fibril_condvar_wait(&cconn->cstate_cv, &cconn->lock); 197 198 PCUT_ASSERT_INT_EQUALS(st_established, cconn->cstate); 199 PCUT_ASSERT_TRUE(tcp_conn_got_syn(cconn)); 200 tcp_conn_unlock(cconn); 201 202 /* Wait for server-side state to transition */ 203 tcp_conn_lock(sconn); 204 while (sconn->cstate == st_listen || sconn->cstate == st_syn_received) 205 fibril_condvar_wait(&sconn->cstate_cv, &sconn->lock); 206 207 PCUT_ASSERT_INT_EQUALS(st_established, sconn->cstate); 208 PCUT_ASSERT_TRUE(tcp_conn_got_syn(sconn)); 209 210 /* Verify counters */ 211 PCUT_ASSERT_EQUALS(cconn->iss + 1, cconn->snd_nxt); 212 PCUT_ASSERT_EQUALS(cconn->iss + 1, cconn->snd_una); 213 PCUT_ASSERT_EQUALS(sconn->iss + 1, sconn->snd_nxt); 214 PCUT_ASSERT_EQUALS(sconn->iss + 1, sconn->snd_una); 215 216 tcp_conn_unlock(sconn); 217 218 tcp_conn_lock(cconn); 219 tcp_conn_reset(cconn); 220 tcp_conn_unlock(cconn); 221 tcp_conn_delete(cconn); 222 223 tcp_conn_lock(sconn); 224 tcp_conn_reset(sconn); 225 tcp_conn_unlock(sconn); 226 tcp_conn_delete(sconn); 227 } 228 229 PCUT_TEST(ep2_flipped) 230 { 231 inet_ep2_t a, fa; 232 233 inet_addr(&a.local.addr, 1, 2, 3, 4); 234 a.local.port = 1234; 235 inet_addr(&a.remote.addr, 5, 6, 7, 8); 236 a.remote.port = 5678; 237 238 tcp_ep2_flipped(&a, &fa); 239 240 PCUT_ASSERT_INT_EQUALS(a.local.port, fa.remote.port); 241 PCUT_ASSERT_INT_EQUALS(a.remote.port, fa.local.port); 242 243 PCUT_ASSERT_TRUE(inet_addr_compare(&a.local.addr, &fa.remote.addr)); 244 PCUT_ASSERT_TRUE(inet_addr_compare(&a.remote.addr, &fa.local.addr)); 245 } 246 148 247 PCUT_EXPORT(conn); -
uspace/srv/net/tcp/test/main.c
r6969eea3 r3e2291a9 64 64 PCUT_IMPORT(seq_no); 65 65 PCUT_IMPORT(tqueue); 66 PCUT_IMPORT(ucall); 66 67 67 68 PCUT_MAIN() -
uspace/srv/net/tcp/ucall.c
r6969eea3 r3e2291a9 108 108 assert(nconn->cstate == st_closed); 109 109 tcp_conn_unlock(nconn); 110 tcp_conn_delete(nconn); 110 111 return TCP_ERESET; 111 112 } … … 280 281 { 281 282 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_abort()"); 283 \ 284 tcp_conn_lock(conn); 285 tcp_conn_reset(conn); 286 tcp_conn_unlock(conn); 282 287 } 283 288
Note:
See TracChangeset
for help on using the changeset viewer.