add lwip log: tcp_rst & tcp_abandon & tcp_abort
This commit is contained in:
parent
af1a468715
commit
abe03672dd
192
0085-add-lwip-log-tcp_rst-tcp_abandon-tcp_abort.patch
Normal file
192
0085-add-lwip-log-tcp_rst-tcp_abandon-tcp_abort.patch
Normal file
@ -0,0 +1,192 @@
|
||||
From 4ab4406f6e59ee09d893e31104236518fc81e991 Mon Sep 17 00:00:00 2001
|
||||
From: yangchen <yangchen145@huawei.com>
|
||||
Date: Tue, 28 Nov 2023 16:11:09 +0800
|
||||
Subject: [PATCH] add lwip log: tcp_rst & tcp_abandon & tcp_abort
|
||||
|
||||
---
|
||||
src/core/tcp.c | 24 ++++++++++++++++--------
|
||||
src/core/tcp_in.c | 19 +++++++++++++++++--
|
||||
src/include/lwip/debug.h | 4 ++--
|
||||
3 files changed, 35 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/src/core/tcp.c b/src/core/tcp.c
|
||||
index 963b8a4..a4f82a3 100644
|
||||
--- a/src/core/tcp.c
|
||||
+++ b/src/core/tcp.c
|
||||
@@ -415,6 +415,9 @@ tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data)
|
||||
|
||||
/* don't call tcp_abort here: we must not deallocate the pcb since
|
||||
that might not be expected when calling tcp_close */
|
||||
+ LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS,
|
||||
+ ("tcp_close_shutdown: Not all data received by app, send RST, local_port=%d, remote_port=%d\n",
|
||||
+ pcb->local_port, pcb->remote_port));
|
||||
tcp_rst(pcb, pcb->snd_nxt, pcb->rcv_nxt, &pcb->local_ip, &pcb->remote_ip,
|
||||
pcb->local_port, pcb->remote_port);
|
||||
|
||||
@@ -682,7 +685,8 @@ tcp_abandon(struct tcp_pcb *pcb, int reset)
|
||||
#endif /* TCP_QUEUE_OOSEQ */
|
||||
tcp_backlog_accepted(pcb);
|
||||
if (send_rst) {
|
||||
- LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_abandon: sending RST\n"));
|
||||
+ LWIP_DEBUGF(TCP_RST_DEBUG | GAZELLE_DEBUG_SERIOUS,
|
||||
+ ("tcp_abandon: send RST, local port=%d, remote port=%d\n", 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;
|
||||
@@ -1574,6 +1578,9 @@ tcp_slowtmr_start:
|
||||
#endif
|
||||
|
||||
if (pcb_reset) {
|
||||
+ LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS,
|
||||
+ ("tcp_slowtmr: KEEPALIVE timeout, send RST, local port=%d, remote port=%d\n",
|
||||
+ pcb->local_port, pcb->remote_port));
|
||||
tcp_rst(pcb, pcb->snd_nxt, pcb->rcv_nxt, &pcb->local_ip, &pcb->remote_ip,
|
||||
pcb->local_port, pcb->remote_port);
|
||||
}
|
||||
@@ -1941,8 +1948,8 @@ tcp_kill_prio(u8_t prio)
|
||||
}
|
||||
}
|
||||
if (inactive != NULL) {
|
||||
- LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_prio: killing oldest PCB %p (%"S32_F")\n",
|
||||
- (void *)inactive, inactivity));
|
||||
+ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS,
|
||||
+ ("tcp_kill_prio: killing oldest PCB (%"S32_F")\n", inactivity));
|
||||
tcp_abort(inactive);
|
||||
}
|
||||
}
|
||||
@@ -1972,8 +1979,8 @@ tcp_kill_state(enum tcp_state state)
|
||||
}
|
||||
}
|
||||
if (inactive != NULL) {
|
||||
- LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_closing: killing oldest %s PCB %p (%"S32_F")\n",
|
||||
- tcp_state_str[state], (void *)inactive, inactivity));
|
||||
+ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS,
|
||||
+ ("tcp_kill_closing: killing oldest %s PCB (%"S32_F")\n", tcp_state_str[state], inactivity));
|
||||
/* Don't send a RST, since no data is lost. */
|
||||
tcp_abandon(inactive, 0);
|
||||
}
|
||||
@@ -1999,8 +2006,8 @@ tcp_kill_timewait(void)
|
||||
}
|
||||
}
|
||||
if (inactive != NULL) {
|
||||
- LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_timewait: killing oldest TIME-WAIT PCB %p (%"S32_F")\n",
|
||||
- (void *)inactive, inactivity));
|
||||
+ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS,
|
||||
+ ("tcp_kill_timewait: killing oldest TIME-WAIT PCB (%"S32_F")\n", inactivity));
|
||||
tcp_abort(inactive);
|
||||
}
|
||||
}
|
||||
@@ -2540,7 +2547,8 @@ tcp_netif_ip_addr_changed_pcblist(const ip_addr_t *old_addr, struct tcp_pcb *pcb
|
||||
) {
|
||||
/* this connection must be aborted */
|
||||
struct tcp_pcb *next = pcb->next;
|
||||
- LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: aborting TCP pcb %p\n", (void *)pcb));
|
||||
+ LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE | GAZELLE_DEBUG_SERIOUS,
|
||||
+ ("netif_set_ipaddr: aborting TCP\n"));
|
||||
tcp_abort(pcb);
|
||||
pcb = next;
|
||||
} else {
|
||||
diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c
|
||||
index 7154659..700a64c 100644
|
||||
--- a/src/core/tcp_in.c
|
||||
+++ b/src/core/tcp_in.c
|
||||
@@ -592,6 +592,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
||||
pbuf_free(rest);
|
||||
}
|
||||
#endif /* TCP_QUEUE_OOSEQ && LWIP_WND_SCALE */
|
||||
+ LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("tcp_input: received data although already closed, send RST\n"));
|
||||
tcp_abort(pcb);
|
||||
goto aborted;
|
||||
}
|
||||
@@ -683,10 +684,12 @@ aborted:
|
||||
} else {
|
||||
/* If no matching PCB was found, send a TCP RST (reset) to the
|
||||
sender. */
|
||||
- LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_input: no PCB match found, resetting.\n"));
|
||||
if (!(TCPH_FLAGS(tcphdr) & TCP_RST)) {
|
||||
TCP_STATS_INC(tcp.proterr);
|
||||
TCP_STATS_INC(tcp.drop);
|
||||
+ LWIP_DEBUGF(TCP_RST_DEBUG | GAZELLE_DEBUG_SERIOUS,
|
||||
+ ("tcp_input: no PCB match found, send RST, dest port=%d, src port=%d\n",
|
||||
+ lwip_ntohs(tcphdr->dest), lwip_ntohs(tcphdr->src)));
|
||||
tcp_rst(NULL, ackno, seqno + tcplen, ip_current_dest_addr(),
|
||||
ip_current_src_addr(), tcphdr->dest, tcphdr->src);
|
||||
}
|
||||
@@ -761,7 +764,9 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
|
||||
if (flags & TCP_ACK) {
|
||||
/* For incoming segments with the ACK flag set, respond with a
|
||||
RST. */
|
||||
- LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_listen_input: ACK in LISTEN, sending reset\n"));
|
||||
+ LWIP_DEBUGF(TCP_RST_DEBUG | GAZELLE_DEBUG_SERIOUS,
|
||||
+ ("tcp_listen_input: ACK in LISTEN, send reset, dest port=%d, src port=%d\n",
|
||||
+ lwip_ntohs(tcphdr->dest), lwip_ntohs(tcphdr->src)));
|
||||
tcp_rst((const struct tcp_pcb *)pcb, ackno, seqno + tcplen, ip_current_dest_addr(),
|
||||
ip_current_src_addr(), tcphdr->dest, tcphdr->src);
|
||||
} else if (flags & TCP_SYN) {
|
||||
@@ -852,6 +857,7 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
|
||||
/* Send a SYN|ACK together with the MSS option. */
|
||||
rc = tcp_enqueue_flags(npcb, TCP_SYN | TCP_ACK);
|
||||
if (rc != ERR_OK) {
|
||||
+ LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("tcp_listen_input: send SYN or ACK failed\n"));
|
||||
tcp_abandon(npcb, 0);
|
||||
PERF_RESUME(PERF_LAYER_TCP, PERF_POINT_TCP_SYN_RECV);
|
||||
return;
|
||||
@@ -892,6 +898,9 @@ tcp_timewait_input(struct tcp_pcb *pcb)
|
||||
should be sent in reply */
|
||||
if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt + pcb->rcv_wnd)) {
|
||||
/* If the SYN is in the window it is an error, send a reset */
|
||||
+ LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS,
|
||||
+ ("tcp_timewait_input: SYN in TIME_WAIT, send RST, dest port=%d, src port=%d\n",
|
||||
+ lwip_ntohs(tcphdr->dest), lwip_ntohs(tcphdr->src)));
|
||||
tcp_rst(pcb, ackno, seqno + tcplen, ip_current_dest_addr(),
|
||||
ip_current_src_addr(), tcphdr->dest, tcphdr->src);
|
||||
return;
|
||||
@@ -1060,6 +1069,8 @@ tcp_process(struct tcp_pcb *pcb)
|
||||
/* received ACK? possibly a half-open connection */
|
||||
else if (flags & TCP_ACK) {
|
||||
/* send a RST to bring the other side in a non-synchronized state. */
|
||||
+ LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("tcp_process: ACK in SYN_SENT, send RST, dest port=%d, src port=%d\n",
|
||||
+ lwip_ntohs(tcphdr->dest), lwip_ntohs(tcphdr->src)));
|
||||
tcp_rst(pcb, ackno, seqno + tcplen, ip_current_dest_addr(),
|
||||
ip_current_src_addr(), tcphdr->dest, tcphdr->src);
|
||||
/* Resend SYN immediately (don't wait for rto timeout) to establish
|
||||
@@ -1102,6 +1113,7 @@ tcp_process(struct tcp_pcb *pcb)
|
||||
* the connection. */
|
||||
/* Already aborted? */
|
||||
if (err != ERR_ABRT) {
|
||||
+ LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("tcp_process: accept function returns with an error %d, send RST\n", err));
|
||||
tcp_abort(pcb);
|
||||
}
|
||||
return ERR_ABRT;
|
||||
@@ -1129,6 +1141,9 @@ tcp_process(struct tcp_pcb *pcb)
|
||||
}
|
||||
} else {
|
||||
/* incorrect ACK number, send RST */
|
||||
+ LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS,
|
||||
+ ("tcp_process: incorrect ACK number in SYN_RCVD, send RST, ackno=%d, lastack=%d, snd_nxt=%d, dest port=%d, src port=%d\n",
|
||||
+ ackno, pcb->lastack, pcb->snd_nxt, lwip_ntohs(tcphdr->dest), lwip_ntohs(tcphdr->src)));
|
||||
tcp_rst(pcb, ackno, seqno + tcplen, ip_current_dest_addr(),
|
||||
ip_current_src_addr(), tcphdr->dest, tcphdr->src);
|
||||
}
|
||||
diff --git a/src/include/lwip/debug.h b/src/include/lwip/debug.h
|
||||
index f47cbfe..6abed9f 100644
|
||||
--- a/src/include/lwip/debug.h
|
||||
+++ b/src/include/lwip/debug.h
|
||||
@@ -56,12 +56,12 @@
|
||||
/** Debug level: Serious. memory allocation failures, ... */
|
||||
#define LWIP_DBG_LEVEL_SERIOUS 0x02
|
||||
/** Debug level: Severe */
|
||||
-#define LWIP_DBG_LEVEL_SEVERE 0x03
|
||||
+#define LWIP_DBG_LEVEL_SEVERE 0x04
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
-#define LWIP_DBG_MASK_LEVEL 0x03
|
||||
+#define LWIP_DBG_MASK_LEVEL 0x07
|
||||
/* compatibility define only */
|
||||
#define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
Summary: lwip is a small independent implementation of the TCP/IP protocol suite
|
||||
Name: lwip
|
||||
Version: 2.1.3
|
||||
Release: 87
|
||||
Release: 88
|
||||
License: BSD
|
||||
URL: http://savannah.nongnu.org/projects/lwip/
|
||||
Source0: http://download.savannah.nongnu.org/releases/lwip/%{name}-%{version}.zip
|
||||
@ -98,6 +98,7 @@ Patch9080: 0081-ip6-hdr.patch
|
||||
Patch9081: 0082-add-vlanid-in-netif.patch
|
||||
Patch9082: 0083-lwipopts-add-lwip-debug-log-macro.patch
|
||||
Patch9083: 0084-add-tcpslowtmr-log-and-tcpfasttmr-cnt.patch
|
||||
Patch9084: 0085-add-lwip-log-tcp_rst-tcp_abandon-tcp_abort.patch
|
||||
|
||||
BuildRequires: gcc-c++ dos2unix dpdk-devel
|
||||
|
||||
@ -128,6 +129,9 @@ cd %{_builddir}/%{name}-%{version}/src
|
||||
%{_libdir}/liblwip.a
|
||||
|
||||
%changelog
|
||||
* Tue Nov 28 2023 yangchen <yangchen145@huawei.com> - 2.1.3-88
|
||||
- add lwip log: tcp_rst & tcp_abandon & tcp_abort
|
||||
|
||||
* Tue Nov 28 2023 hankangkang <hankangkang5@huawei.com> - 2.1.3-87
|
||||
- lwipopts: add tcpslowtmr log and tcpfasttmr cnt
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user