refactor max tcp port config values to uint16 to better represent their valid space

This commit is contained in:
Patricio Whittingslow
2026-04-09 20:13:45 -03:00
parent 548d96da95
commit 568ef2854f
12 changed files with 129 additions and 124 deletions
+12 -12
View File
@@ -104,11 +104,11 @@ func run() error {
var stack xnet.StackAsync
if err := stack.Reset(xnet.StackConfig{
Hostname: "berkeley-http",
RandSeed: softRand,
HardwareAddress: nicHW,
MTU: uint16(mtu),
MaxTCPConns: 1024,
Hostname: "berkeley-http",
RandSeed: softRand,
HardwareAddress: nicHW,
MTU: uint16(mtu),
MaxActiveTCPPorts: 1024,
}); err != nil {
return err
}
@@ -202,7 +202,7 @@ func run() error {
blocking := stack.StackBlocking(5 * time.Millisecond)
berkeley := blocking.StackGo(xnet.StackGoConfig{
ListenerPoolConfig: xnet.TCPPoolConfig{
PoolSize: flagPoolSize,
PoolSize: uint16(flagPoolSize),
QueueSize: 3,
TxBufSize: mtu,
RxBufSize: mtu,
@@ -328,12 +328,12 @@ func tryPoll(iface ltesto.Interface, poll time.Duration) (dataMayBeReady bool, _
func mockClient(stack *xnet.StackAsync, port uint16, subnet netip.Prefix) {
target := netip.AddrPortFrom(stack.Addr(), port)
err := mockStack.Reset(xnet.StackConfig{
StaticAddress: subnet.Addr().Next(),
MaxTCPConns: 1,
HardwareAddress: stack.Gateway6(),
Hostname: "the-other",
MTU: uint16(stack.MTU()),
RandSeed: int64(stack.Prand32()),
StaticAddress: subnet.Addr().Next(),
MaxActiveTCPPorts: 1,
HardwareAddress: stack.Gateway6(),
Hostname: "the-other",
MTU: uint16(stack.MTU()),
RandSeed: int64(stack.Prand32()),
})
if err != nil {
panic(err.Error())
+5 -5
View File
@@ -101,11 +101,11 @@ func run() (err error) {
var stack xnet.StackAsync
err = stack.Reset(xnet.StackConfig{
Hostname: "httpserver",
RandSeed: softRand,
HardwareAddress: nicHW,
MTU: uint16(mtu),
MaxTCPConns: 1000,
Hostname: "httpserver",
RandSeed: softRand,
HardwareAddress: nicHW,
MTU: uint16(mtu),
MaxActiveTCPPorts: 1000,
})
if err != nil {
return err
+1 -1
View File
@@ -64,7 +64,7 @@ func run(ctx context.Context, stack *xnet.StackAsync) error {
Hostname: "lneto-mwe",
RandSeed: time.Now().UnixNano(),
// A passive TCP listener to many remote ports takes up one spot, active TCP clients to one remote port take up a spot.
MaxTCPConns: 1,
MaxActiveTCPPorts: 1,
// MaxUDPConns: 1 , // For MDNS support.
// AcceptMulticast: true, // For MDNS.
MTU: uint16(framelen - ethernet.MaxOverheadSize),
+5 -5
View File
@@ -121,11 +121,11 @@ func run() (err error) {
var stack xnet.StackAsync
err = stack.Reset(xnet.StackConfig{
Hostname: "xnet-test",
RandSeed: softRand,
HardwareAddress: brHW,
MTU: uint16(mtu),
MaxTCPConns: 1,
Hostname: "xnet-test",
RandSeed: softRand,
HardwareAddress: brHW,
MTU: uint16(mtu),
MaxActiveTCPPorts: 1,
})
if err != nil {
return err