Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Jun 2021 23:59:00 GMT
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: f5d0badc7007 - stable/13 - Fix a UDP tunneling issue with rack. Basically there are two issues. A) Not enough hdrlen was being calculated when a UDP tunnel is in place. and B) Not enough memory is allocated in racks fsb. We need to overbook the fsb to include a udphdr just in case.
Message-ID:  <202106082359.158Nx0JI044101@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by tuexen:

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

commit f5d0badc7007b32d1ed42c9a2d7aa0de29ab0ea0
Author:     Randall Stewart <rrs@FreeBSD.org>
AuthorDate: 2021-05-07 18:06:43 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2021-06-08 23:58:06 +0000

    Fix a UDP tunneling issue with rack. Basically there are two
    issues.
    A) Not enough hdrlen was being calculated when a UDP tunnel is
       in place.
    and
    B) Not enough memory is allocated in racks fsb. We need to
       overbook the fsb to include a udphdr just in case.
    
    Submitted by: Peter Lei
    Reviewed by: Michael Tuexen
    Sponsored by: Netflix Inc
    Differential Revision: https://reviews.freebsd.org/D30157
    
    (cherry picked from commit a16cee0218652230d94a73690201e76baab0bba1)
---
 sys/netinet/tcp_stacks/rack.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c
index dd60091bbbc0..110304d29cc0 100644
--- a/sys/netinet/tcp_stacks/rack.c
+++ b/sys/netinet/tcp_stacks/rack.c
@@ -11875,6 +11875,7 @@ rack_init_fsb_block(struct tcpcb *tp, struct tcp_rack *rack)
 		rack->r_ctl.fsb.tcp_ip_hdr_len = sizeof(struct ip6_hdr) + sizeof(struct tcphdr);
 		ip6 = (struct ip6_hdr *)rack->r_ctl.fsb.tcp_ip_hdr;
 		if (tp->t_port) {
+			rack->r_ctl.fsb.tcp_ip_hdr_len += sizeof(struct udphdr);
 			udp = (struct udphdr *)((caddr_t)ip6 + sizeof(struct ip6_hdr));
 			udp->uh_sport = htons(V_tcp_udp_tunneling_port);
 			udp->uh_dport = tp->t_port;
@@ -11894,6 +11895,7 @@ rack_init_fsb_block(struct tcpcb *tp, struct tcp_rack *rack)
 		rack->r_ctl.fsb.tcp_ip_hdr_len = sizeof(struct tcpiphdr);
 		ip = (struct ip *)rack->r_ctl.fsb.tcp_ip_hdr;
 		if (tp->t_port) {
+			rack->r_ctl.fsb.tcp_ip_hdr_len += sizeof(struct udphdr);
 			udp = (struct udphdr *)((caddr_t)ip + sizeof(struct ip));
 			udp->uh_sport = htons(V_tcp_udp_tunneling_port);
 			udp->uh_dport = tp->t_port;
@@ -11914,10 +11916,14 @@ rack_init_fsb_block(struct tcpcb *tp, struct tcp_rack *rack)
 static int
 rack_init_fsb(struct tcpcb *tp, struct tcp_rack *rack)
 {
-	/* Allocate the larger of spaces V6 if available else just V4 */
-	rack->r_ctl.fsb.tcp_ip_hdr_len = sizeof(struct tcpiphdr);
+	/* 
+	 * Allocate the larger of spaces V6 if available else just 
+	 * V4 and include udphdr (overbook) 
+	 */
 #ifdef INET6
-	rack->r_ctl.fsb.tcp_ip_hdr_len = sizeof(struct ip6_hdr) + sizeof(struct tcphdr);
+	rack->r_ctl.fsb.tcp_ip_hdr_len = sizeof(struct ip6_hdr) + sizeof(struct tcphdr) + sizeof(struct udphdr);
+#else
+	rack->r_ctl.fsb.tcp_ip_hdr_len = sizeof(struct tcpiphdr) + sizeof(struct udphdr);
 #endif
 	rack->r_ctl.fsb.tcp_ip_hdr = malloc(rack->r_ctl.fsb.tcp_ip_hdr_len,
 					    M_TCPFSB, M_NOWAIT|M_ZERO);
@@ -15078,6 +15084,8 @@ rack_fast_rsm_output(struct tcpcb *tp, struct tcp_rack *rack, struct rack_sendma
 	optlen = tcp_addoptions(&to, opt);
 	hdrlen += optlen;
 	udp = rack->r_ctl.fsb.udp;
+	if (udp)
+		hdrlen += sizeof(struct udphdr);
 	if (rack->r_ctl.rc_pace_max_segs)
 		max_val = rack->r_ctl.rc_pace_max_segs;
 	else if (rack->rc_user_set_max_segs)
@@ -15530,6 +15538,8 @@ rack_fast_output(struct tcpcb *tp, struct tcp_rack *rack, uint64_t ts_val,
 	optlen = tcp_addoptions(&to, opt);
 	hdrlen += optlen;
 	udp = rack->r_ctl.fsb.udp;
+	if (udp)
+		hdrlen += sizeof(struct udphdr);
 	if (rack->r_ctl.rc_pace_max_segs)
 		max_val = rack->r_ctl.rc_pace_max_segs;
 	else if (rack->rc_user_set_max_segs)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106082359.158Nx0JI044101>