About the behavior of tuning of tcp_reass_maxseg

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Thu, 28 Sep 2023 04:19:15 UTC
Hi,

I'm recently working on SYSCTLs features. While testing the sysctl
knob `net.inet.tcp.reass.maxsegments` I got something weird. When
I adjust `kern.ipc.nmbclusters`, the `net.inet.tcp.reass.maxsegments`
got 'auto tuned' regardless what I have set (the kernel env) in `/boot/loader.conf`.

The relevant code:

```
static int tcp_reass_maxseg = 0;
SYSCTL_INT(_net_inet_tcp_reass, OID_AUTO, maxsegments, CTLFLAG_RDTUN,
    &tcp_reass_maxseg, 0,
    "Global maximum number of TCP Segments in Reassembly Queue");

tcp_reass_global_init(void)
{

	tcp_reass_maxseg = nmbclusters / 16;
	TUNABLE_INT_FETCH("net.inet.tcp.reass.maxsegments",
	    &tcp_reass_maxseg);
	tcp_reass_zone = uma_zcreate("tcpreass", sizeof (struct tseg_qent),
	    NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
	/* Set the zone limit and read back the effective value. */
	tcp_reass_maxseg = uma_zone_set_max(tcp_reass_zone,
	    tcp_reass_maxseg);
...

	EVENTHANDLER_REGISTER(nmbclusters_change,
	    tcp_reass_zone_change, NULL, EVENTHANDLER_PRI_ANY);

}

/* Initialize TCP reassembly queue */
static void
tcp_reass_zone_change(void *tag)
{

	/* Set the zone limit and read back the effective value. */
	tcp_reass_maxseg = nmbclusters / 16;
	tcp_reass_maxseg = uma_zone_set_max(tcp_reass_zone,
	    tcp_reass_maxseg);
}
```

The above code shows clearly the current behavior.

What I expected is, kernel env has priority to the 'auto tuning', unless
the admin requested.

So comes some questions.

1. Is the above behavior expected ?
2. Is it desirable to make `net.inet.tcp.reass.maxsegments` write tunable ?
3. Is it valid to set 0 to `net.inet.tcp.reass.maxsegments` ? IIUC that will effectually disable TCP reassembly.
4. Then can we introduce a constant `-1` to explicitly enable the 'auto tuning' feature ?

Best regards,
Zhenlei