maxInFlightConnectionAttempts returns the global number of in-flight connection attempts that we allow for a single netstack Impl. Any new forwarded TCP connections that are opened after the limit has been hit are rejected until the number of in-flight connections drops below the limit again. Each
()
| 82 | // connection, so we want to ensure that we don't allow an unbounded number of |
| 83 | // connections. |
| 84 | func maxInFlightConnectionAttempts() int { |
| 85 | if n := maxInFlightConnectionAttemptsForTest.Load(); n > 0 { |
| 86 | return int(n) |
| 87 | } |
| 88 | |
| 89 | if version.IsMobile() { |
| 90 | return 1024 // previous global value |
| 91 | } |
| 92 | switch version.OS() { |
| 93 | case "linux": |
| 94 | // On the assumption that most subnet routers deployed in |
| 95 | // production are running on Linux, we return a higher value. |
| 96 | // |
| 97 | // TODO(andrew-d): tune this based on the amount of system |
| 98 | // memory instead of a fixed limit. |
| 99 | return 8192 |
| 100 | default: |
| 101 | // On all other platforms, return a reasonably high value that |
| 102 | // most users won't hit. |
| 103 | return 2048 |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | // maxInFlightConnectionAttemptsPerClient is the same as |
| 108 | // maxInFlightConnectionAttempts, but applies on a per-client basis |