Changeset 2c4bb828 in mainline
- Timestamp:
- 2015-06-03T15:53:12Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1ede059
- Parents:
- 8d48c7e
- Location:
- uspace/srv/net/tcp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/conn.c
r8d48c7e r2c4bb828 58 58 59 59 static LIST_INITIALIZE(conn_list); 60 /** Taken after tcp_conn_t lock */ 60 61 static FIBRIL_MUTEX_INITIALIZE(conn_list_lock); 61 62 static amap_t *amap; … … 1176 1177 * 1177 1178 * @param conn Connection 1178 * @param seg Segment 1179 */ 1180 void tcp_conn_segment_arrived(tcp_conn_t *conn, tcp_segment_t *seg) 1181 { 1179 * @param epp Endpoint pair on which segment was received 1180 * @param seg Segment 1181 */ 1182 void tcp_conn_segment_arrived(tcp_conn_t *conn, inet_ep2_t *epp, 1183 tcp_segment_t *seg) 1184 { 1185 inet_ep2_t aepp; 1186 inet_ep2_t oldepp; 1187 int rc; 1188 1182 1189 log_msg(LOG_DEFAULT, LVL_NOTE, "conn=%p", conn); 1183 1190 log_msg(LOG_DEFAULT, LVL_NOTE, "conn->name=%p", conn->name); … … 1185 1192 conn->name, seg); 1186 1193 1194 tcp_conn_lock(conn); 1195 1196 if (conn->cstate == st_closed) { 1197 log_msg(LOG_DEFAULT, LVL_WARN, "Connection is closed."); 1198 tcp_unexpected_segment(epp, seg); 1199 tcp_conn_unlock(conn); 1200 return; 1201 } 1202 1203 if (inet_addr_is_any(&conn->ident.remote.addr) || 1204 conn->ident.remote.port == inet_port_any || 1205 inet_addr_is_any(&conn->ident.local.addr)) { 1206 1207 log_msg(LOG_DEFAULT, LVL_NOTE, "tcp_conn_segment_arrived: " 1208 "Changing connection ID, updating amap."); 1209 oldepp = conn->ident; 1210 1211 /* Need to remove and re-insert connection with new identity */ 1212 fibril_mutex_lock(&conn_list_lock); 1213 1214 if (inet_addr_is_any(&conn->ident.remote.addr)) 1215 conn->ident.remote.addr = epp->remote.addr; 1216 1217 if (conn->ident.remote.port == inet_port_any) 1218 conn->ident.remote.port = epp->remote.port; 1219 1220 if (inet_addr_is_any(&conn->ident.local.addr)) 1221 conn->ident.local.addr = epp->local.addr; 1222 1223 rc = amap_insert(amap, &conn->ident, conn, af_allow_system, &aepp); 1224 if (rc != EOK) { 1225 assert(rc != EEXISTS); 1226 assert(rc == ENOMEM); 1227 log_msg(LOG_DEFAULT, LVL_ERROR, "Out of memory."); 1228 fibril_mutex_unlock(&conn_list_lock); 1229 tcp_conn_unlock(conn); 1230 return; 1231 } 1232 1233 amap_remove(amap, &oldepp); 1234 fibril_mutex_unlock(&conn_list_lock); 1235 1236 conn->name = (char *) "a"; 1237 } 1238 1187 1239 switch (conn->cstate) { 1188 1240 case st_listen: 1189 tcp_conn_sa_listen(conn, seg); break; 1241 tcp_conn_sa_listen(conn, seg); 1242 break; 1190 1243 case st_syn_sent: 1191 tcp_conn_sa_syn_sent(conn, seg); break; 1244 tcp_conn_sa_syn_sent(conn, seg); 1245 break; 1192 1246 case st_syn_received: 1193 1247 case st_established: … … 1199 1253 case st_time_wait: 1200 1254 /* Process segments in order of sequence number */ 1201 tcp_conn_sa_queue(conn, seg); break; 1255 tcp_conn_sa_queue(conn, seg); 1256 break; 1202 1257 case st_closed: 1203 1258 log_msg(LOG_DEFAULT, LVL_DEBUG, "state=%d", (int) conn->cstate); 1204 1259 assert(false); 1205 1260 } 1261 1262 tcp_conn_unlock(conn); 1206 1263 } 1207 1264 -
uspace/srv/net/tcp/conn.h
r8d48c7e r2c4bb828 55 55 extern void tcp_conn_unlock(tcp_conn_t *); 56 56 extern bool tcp_conn_got_syn(tcp_conn_t *); 57 extern void tcp_conn_segment_arrived(tcp_conn_t *, tcp_segment_t *); 57 extern void tcp_conn_segment_arrived(tcp_conn_t *, inet_ep2_t *, 58 tcp_segment_t *); 58 59 extern void tcp_conn_trim_seg_to_wnd(tcp_conn_t *, tcp_segment_t *); 59 60 extern void tcp_unexpected_segment(inet_ep2_t *, tcp_segment_t *); -
uspace/srv/net/tcp/ucall.c
r8d48c7e r2c4bb828 336 336 } 337 337 338 tcp_conn_lock(conn); 339 340 if (conn->cstate == st_closed) { 341 log_msg(LOG_DEFAULT, LVL_WARN, "Connection is closed."); 342 tcp_unexpected_segment(epp, seg); 343 tcp_conn_unlock(conn); 344 tcp_conn_delref(conn); 345 return; 346 } 347 348 if (inet_addr_is_any(&conn->ident.remote.addr)) 349 conn->ident.remote.addr = epp->remote.addr; 350 351 if (conn->ident.remote.port == inet_port_any) 352 conn->ident.remote.port = epp->remote.port; 353 354 if (inet_addr_is_any(&conn->ident.local.addr)) 355 conn->ident.local.addr = epp->local.addr; 356 357 tcp_conn_segment_arrived(conn, seg); 358 359 tcp_conn_unlock(conn); 338 tcp_conn_segment_arrived(conn, epp, seg); 360 339 tcp_conn_delref(conn); 361 340 }
Note:
See TracChangeset
for help on using the changeset viewer.