From f30c7d56546b9f36e42351fb385d96e37dbac1d5 Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Mon, 29 Jan 2024 18:41:24 +0100 Subject: [PATCH] TCP LRO: convert TCP header fields to host byte order earlier This is a preparation for adding dtrace hooks in a follow-up commit, which are missing in the code path, where packets are directly queued to the tcpcb. The dtrace hooks expect the fields to be in host byte order. This only applies when TCP HPTS is used. No functional change intended. Reviewed by: rscheff MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D43594 --- sys/netinet/tcp_lro_hpts.c | 7 ++++--- sys/netinet/tcp_stacks/rack_bbr_common.c | 4 ---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/sys/netinet/tcp_lro_hpts.c b/sys/netinet/tcp_lro_hpts.c index 7724e727d5c..84944c8db1c 100644 --- a/sys/netinet/tcp_lro_hpts.c +++ b/sys/netinet/tcp_lro_hpts.c @@ -74,15 +74,15 @@ build_ack_entry(struct tcp_ackent *ae, struct tcphdr *th, struct mbuf *m, ae->flags |= TSTMP_LRO; else if (m->m_flags & M_TSTMP) ae->flags |= TSTMP_HDWR; - ae->seq = ntohl(th->th_seq); - ae->ack = ntohl(th->th_ack); + ae->seq = th->th_seq; + ae->ack = th->th_ack; ae->flags |= tcp_get_flags(th); if (ts_ptr != NULL) { ae->ts_value = ntohl(ts_ptr[1]); ae->ts_echo = ntohl(ts_ptr[2]); ae->flags |= HAS_TSTMP; } - ae->win = ntohs(th->th_win); + ae->win = th->th_win; ae->codepoint = iptos; } @@ -310,6 +310,7 @@ do_bpf_strip_and_compress(struct tcpcb *tp, struct lro_ctrl *lc, th = tcp_lro_get_th(m); th->th_sum = 0; /* TCP checksum is valid. */ + tcp_fields_to_host(th); /* Check if ACK can be compressed */ can_compress = tcp_lro_ack_valid(m, th, &ts_ptr, &other_opts); diff --git a/sys/netinet/tcp_stacks/rack_bbr_common.c b/sys/netinet/tcp_stacks/rack_bbr_common.c index b265e8e6f20..4a4a8af2bd7 100644 --- a/sys/netinet/tcp_stacks/rack_bbr_common.c +++ b/sys/netinet/tcp_stacks/rack_bbr_common.c @@ -415,10 +415,6 @@ skip_vnet: break; #endif } /* end switch */ - /* - * Convert TCP protocol specific fields to host format. - */ - tcp_fields_to_host(th); off = th->th_off << 2; if (off < sizeof (struct tcphdr) || off > tlen) { printf("off:%d < hdrlen:%zu || > tlen:%u -- dump\n",