git: b47dcb4b1ff1 - main - TCP BBR: fix getsockopt() for TCP_BBR_USEDEL_RATE

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Tue, 31 Dec 2024 16:32:08 UTC
The branch main has been updated by tuexen:

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

commit b47dcb4b1ff16e6af2e07798f6fe06580b4eddf0
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2024-12-31 16:29:04 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2024-12-31 16:29:04 +0000

    TCP BBR: fix getsockopt() for TCP_BBR_USEDEL_RATE
    
    Actually implement the IPPROTO_TCP-level socket option
    TCP_BBR_USEDEL_RATE.
    
    Reviewed by:            rrs
    CID:                    1523813
    CID:                    1523814
    MFC after:              1 week
    Sponsored by:           Netflix, Inc.
    Differential Revision:  https://reviews.freebsd.org/D48261
---
 sys/netinet/tcp_stacks/bbr.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c
index 24c3685f139a..f440573ace30 100644
--- a/sys/netinet/tcp_stacks/bbr.c
+++ b/sys/netinet/tcp_stacks/bbr.c
@@ -14587,6 +14587,7 @@ bbr_get_sockopt(struct tcpcb *tp, struct sockopt *sopt)
 {
 	struct inpcb *inp = tptoinpcb(tp);
 	struct tcp_bbr *bbr;
+	uint64_t loptval;
 	int32_t error, optval;
 
 	bbr = (struct tcp_bbr *)tp->t_fb_ptr;
@@ -14647,7 +14648,7 @@ bbr_get_sockopt(struct tcpcb *tp, struct sockopt *sopt)
 		optval = bbr->rc_loss_exit;
 		break;
 	case TCP_BBR_USEDEL_RATE:
-		error = EINVAL;
+		loptval = get_filter_value(&bbr->r_ctl.rc_delrate);
 		break;
 	case TCP_BBR_MIN_RTO:
 		optval = bbr->r_ctl.rc_min_rto_ms;
@@ -14731,7 +14732,10 @@ bbr_get_sockopt(struct tcpcb *tp, struct sockopt *sopt)
 		break;
 	}
 	INP_WUNLOCK(inp);
-	error = sooptcopyout(sopt, &optval, sizeof optval);
+	if (sopt->sopt_name == TCP_BBR_USEDEL_RATE)
+		error = sooptcopyout(sopt, &loptval, sizeof loptval);
+	else
+		error = sooptcopyout(sopt, &optval, sizeof optval);
 	return (error);
 }