git: 9453ec661961 - main - tcp: increment tcpstats in tcp_respond()

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Wed, 21 Sep 2022 21:04:52 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=9453ec661961d19919ec3927a5c90fc69bf23b4d

commit 9453ec661961d19919ec3927a5c90fc69bf23b4d
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2022-09-21 21:03:33 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2022-09-21 21:03:33 +0000

    tcp: increment tcpstats in tcp_respond()
    
    tcp_respond() crafts a packet and sends it directly to ip[6]output(),
    bypassing tcp_output().  Hence it must increment TCP send statistics.
    
    Reviewed by:            rscheff, tuexen, rrs (implicitly)
    Differential revision:  https://reviews.freebsd.org/D36641
---
 sys/netinet/tcp_subr.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index f2dc1b0b2836..f9dc57e1df66 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -2174,6 +2174,12 @@ tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m,
 		}
 	}
 
+	if (flags & TH_ACK)
+		TCPSTAT_INC(tcps_sndacks);
+	else if (flags & (TH_SYN|TH_FIN|TH_RST))
+		TCPSTAT_INC(tcps_sndctrl);
+	TCPSTAT_INC(tcps_sndtotal);
+
 #ifdef INET6
 	if (isipv6) {
 		TCP_PROBE5(send, NULL, tp, ip6, tp, nth);