Browse Source

tcp_proxy: не слать данные в lwip после закрытия TUN-стороны (tun_closed)

- handle_data: добавить pc->tun_closed в проверку сброса данных от exit
- proxy_feed_from_transport: не писать в PCB после tun_closed
- предотвращает ERR_RST (-14) при записи в TIME_WAIT PCB
etcp-inflight-fix
Evgeny 4 months ago
parent
commit
60800a7f35
  1. 4
      src/tcp_proxy.c

4
src/tcp_proxy.c

@ -157,7 +157,7 @@ static int tcp_proxy_handle_non_tcp(struct tcp_proxy* p, uint8_t* buf, size_t le
// Помощник: передача данных из очереди to_lwip в lwIP TCP // Помощник: передача данных из очереди to_lwip в lwIP TCP
// ==================================================================== // ====================================================================
static void proxy_feed_from_transport(struct proxy_conn *pc) { static void proxy_feed_from_transport(struct proxy_conn *pc) {
if (!pc->to_lwip || !pc->pcb) return; if (!pc->to_lwip || !pc->pcb || pc->tun_closed) return;
int sent_any = 0; int sent_any = 0;
uint32_t q_pre = queue_entry_count(pc->to_lwip); uint32_t q_pre = queue_entry_count(pc->to_lwip);
while (1) { while (1) {
@ -410,7 +410,7 @@ static void handle_data(struct tcp_proxy* p, struct ETCP_CONN* conn, uint32_t st
if (conn) proxy_send_msg(p->inst, conn->peer_node_id, TCP_PROXY_SUBCMD_CLOSE, stream_id, NULL, 0); if (conn) proxy_send_msg(p->inst, conn->peer_node_id, TCP_PROXY_SUBCMD_CLOSE, stream_id, NULL, 0);
queue_dgram_free(entry); queue_entry_free(entry); return; queue_dgram_free(entry); queue_entry_free(entry); return;
} }
if (pc->rem_closed || pc->error) { queue_dgram_free(entry); queue_entry_free(entry); return; } if (pc->rem_closed || pc->error || pc->tun_closed) { queue_dgram_free(entry); queue_entry_free(entry); return; }
size_t data_len = entry->len - TCP_PROXY_HDR_SIZE; size_t data_len = entry->len - TCP_PROXY_HDR_SIZE;
DEBUG_INFO(DEBUG_CATEGORY_TRAFFIC, "PROXY DATA <- sid=%08x len=%zu", stream_id, data_len); DEBUG_INFO(DEBUG_CATEGORY_TRAFFIC, "PROXY DATA <- sid=%08x len=%zu", stream_id, data_len);
if (data_len > 0) { if (data_len > 0) {

Loading…
Cancel
Save