From 7154e51ff225d7521120b57e9acf77d52793b3a7 Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Fri, 12 Oct 2018 22:13:28 +0200 Subject: [PATCH] Revert "tcp_abandon: no need to buffer pcb->local_port" This reverts commit 1570dd8ad1c6afd2438dcb8b18d9eed794f78baa. Buffering pcb->local_port is needed because TCP_PCB_REMOVE_ACTIVE() sets it to 0 via tcp_pcb_remove() (comment: "reset the local port to prevent the pcb from being 'bound'"). Signed-off-by: Simon Goldschmidt --- src/core/tcp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/tcp.c b/src/core/tcp.c index d478c945..2abe0b6a 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -583,6 +583,7 @@ tcp_abandon(struct tcp_pcb *pcb, int reset) tcp_free(pcb); } else { int send_rst = 0; + u16_t local_port = 0; enum tcp_state last_state; seqno = pcb->snd_nxt; ackno = pcb->rcv_nxt; @@ -597,6 +598,7 @@ tcp_abandon(struct tcp_pcb *pcb, int reset) } } else { send_rst = reset; + local_port = pcb->local_port; TCP_PCB_REMOVE_ACTIVE(pcb); } if (pcb->unacked != NULL) { @@ -613,7 +615,7 @@ tcp_abandon(struct tcp_pcb *pcb, int reset) tcp_backlog_accepted(pcb); if (send_rst) { LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_abandon: sending RST\n")); - tcp_rst(pcb, seqno, ackno, &pcb->local_ip, &pcb->remote_ip, pcb->local_port, pcb->remote_port); + tcp_rst(pcb, seqno, ackno, &pcb->local_ip, &pcb->remote_ip, local_port, pcb->remote_port); } last_state = pcb->state; tcp_free(pcb);