[tcp] Report TCP statistics via the "ipstat" command

Gather some basic statistics on TCP connections to allow out-of-order
packets and duplicate packets to be observed even in non-debug builds.

Report these statistics via the existing "ipstat" command, rather than
introducing a separate "tcpstat" command, on the basis that we do not
need the additional overhead of a separate command.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2026-01-09 16:36:52 +00:00
parent a8c89276cc
commit 2110afb351
3 changed files with 49 additions and 2 deletions

View File

@@ -439,6 +439,23 @@ static inline int tcp_in_window ( uint32_t seq, uint32_t start,
*/
#define TCP_FINISH_TIMEOUT ( 1 * TICKS_PER_SEC )
/** TCP statistics */
struct tcp_statistics {
/** Number of packets received */
unsigned long in_segs;
/** Total number of packets discarded due to lack of memory */
unsigned long in_discards;
/** Total number of packets received out of order */
unsigned long in_out_of_order;
/** Number of octets received (including duplicate data) */
unsigned long in_octets;
/** Number of octets processed and passed to upper layer */
unsigned long in_octets_good;
};
extern struct tcpip_protocol tcp_protocol __tcpip_protocol;
extern struct tcp_statistics tcp_stats;
#endif /* _IPXE_TCP_H */