Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
Re: sysctl export TCP snd_cwnd for netstat -B
To:
Alexander Bluhm <bluhm@openbsd.org>
Cc:
tech@openbsd.org
Date:
Tue, 3 Jun 2025 22:22:18 +0200

Download raw body.

Thread
On Tue, Jun 03, 2025 at 09:49:27PM +0200, Alexander Bluhm wrote:
> Hi,
> 
> Export TCP send congestion window in sysctl fill_file() also for
> inet6 so netstat -B can show it.  Looks like an oversight.  While
> there replace cast with common macro.
> 
> Proto   Recv-Q Send-Q Recv-W Send-W Cgst-W  Local Address          Foreign Address        TCP-State
> before:
> tcp6         0     44  17136  16384      0  fe80::725f:caff:.ssh   fe80::fce1:baff:.11120 ESTABLISHED
> after:
> tcp6         0     60  17136  16384  29988  fe80::725f:caff:.ssh   fe80::fce1:baff:.41587 ESTABLISHED
> 
> ok?

OK claudio@
 
> bluhm
> 
> Index: kern/kern_sysctl.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/kern/kern_sysctl.c,v
> diff -u -p -r1.472 kern_sysctl.c
> --- kern/kern_sysctl.c	3 Jun 2025 17:32:42 -0000	1.472
> +++ kern/kern_sysctl.c	3 Jun 2025 19:39:35 -0000
> @@ -1576,7 +1576,8 @@ fill_file(struct kinfo_file *kf, struct 
>  			if (so->so_type == SOCK_RAW)
>  				kf->inp_proto = inpcb->inp_ip.ip_p;
>  			if (so->so_proto->pr_protocol == IPPROTO_TCP) {
> -				struct tcpcb *tcpcb = (void *)inpcb->inp_ppcb;
> +				struct tcpcb *tcpcb = intotcpcb(inpcb);
> +
>  				kf->t_rcv_wnd = tcpcb->rcv_wnd;
>  				kf->t_snd_wnd = tcpcb->snd_wnd;
>  				kf->t_snd_cwnd = tcpcb->snd_cwnd;
> @@ -1604,9 +1605,11 @@ fill_file(struct kinfo_file *kf, struct 
>  			if (so->so_type == SOCK_RAW)
>  				kf->inp_proto = inpcb->inp_ipv6.ip6_nxt;
>  			if (so->so_proto->pr_protocol == IPPROTO_TCP) {
> -				struct tcpcb *tcpcb = (void *)inpcb->inp_ppcb;
> +				struct tcpcb *tcpcb = intotcpcb(inpcb);
> +
>  				kf->t_rcv_wnd = tcpcb->rcv_wnd;
>  				kf->t_snd_wnd = tcpcb->snd_wnd;
> +				kf->t_snd_cwnd = tcpcb->snd_cwnd;
>  				kf->t_state = tcpcb->t_state;
>  			}
>  			break;
> 

-- 
:wq Claudio