From 0a9dd47dd817904ec2b4a80b551e6050218ee8a6 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Tue, 22 Sep 2020 09:30:31 +0700 Subject: net: reflect TCP backlog size update of uint16->uint32 on Linux The sk_max_ack_backlog was increased from uint16 to uint32 in kernel version 4.1 and above, so adopt that change to maxListenerBacklog. See https://github.com/torvalds/linux/commit/becb74f0acca19b5abfcb24dc602530f3deea66a Fixes #41470 Change-Id: I63a142eb28f3ac3acaca57f0903c085c6cb15a6e Reviewed-on: https://go-review.googlesource.com/c/go/+/255898 Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Trust: Cuong Manh Le Trust: Emmanuel Odeke Reviewed-by: Ian Lance Taylor Reviewed-by: Emmanuel Odeke --- src/net/sock_linux_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/net/sock_linux_test.go (limited to 'src/net/sock_linux_test.go') diff --git a/src/net/sock_linux_test.go b/src/net/sock_linux_test.go new file mode 100644 index 0000000000..5df02935c3 --- /dev/null +++ b/src/net/sock_linux_test.go @@ -0,0 +1,22 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package net + +import ( + "testing" +) + +func TestMaxAckBacklog(t *testing.T) { + n := 196602 + major, minor := kernelVersion() + backlog := maxAckBacklog(n) + expected := 1<<16 - 1 + if major > 4 || (major == 4 && minor >= 1) { + expected = n + } + if backlog != expected { + t.Fatalf(`Kernel version: "%d.%d", sk_max_ack_backlog mismatch, got %d, want %d`, major, minor, backlog, expected) + } +} -- cgit v1.3