[netstack] Apply overhead factor before limits

Fixes TCPSocketPairTest.SetTCPWindowClampBelowMinRcvBufConnectedSocket.

See https://github.com/google/gvisor/blob/9a96e00/test/syscalls/linux/socket_ip_tcp_generic.cc#L1087

Change-Id: I45a312339ce0c326773a7099a9259472a165501c
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/560805
Fuchsia-Auto-Submit: Tamir Duberstein <tamird@google.com>
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Reviewed-by: Ghanan Gowripalan <ghanan@google.com>
diff --git a/src/connectivity/network/netstack/fuchsia_posix_socket.go b/src/connectivity/network/netstack/fuchsia_posix_socket.go
index 96be70a..9c85c90 100644
--- a/src/connectivity/network/netstack/fuchsia_posix_socket.go
+++ b/src/connectivity/network/netstack/fuchsia_posix_socket.go
@@ -516,13 +516,6 @@
 
 	{
 		size := int64(size)
-		min, max := limits()
-		if size > max {
-			size = max
-		}
-		if size < min {
-			size = min
-		}
 
 		// packetOverheadFactor is used to multiply the value provided by the user on
 		// a setsockopt(2) for setting the send/receive buffer sizes sockets.
@@ -532,6 +525,15 @@
 		} else {
 			size *= packetOverheadFactor
 		}
+
+		min, max := limits()
+		if size > max {
+			size = max
+		}
+		if size < min {
+			size = min
+		}
+
 		set(size, true /* notify */)
 	}
 }