Commit 97de5a1
selftest: Don't reuse port for SO_INCOMING_CPU test.
Jakub reported that ASSERT_EQ(cpu, i) in so_incoming_cpu.c seems to
fire somewhat randomly.
# # RUN so_incoming_cpu.before_reuseport.test3 ...
# # so_incoming_cpu.c:191:test3:Expected cpu (32) == i (0)
# # test3: Test terminated by assertion
# # FAIL so_incoming_cpu.before_reuseport.test3
# not ok 3 so_incoming_cpu.before_reuseport.test3
When the test failed, not-yet-accepted CLOSE_WAIT sockets received
SYN with a "challenging" SEQ number, which was sent from an unexpected
CPU that did not create the receiver.
The test basically does:
1. for each cpu:
1-1. create a server
1-2. set SO_INCOMING_CPU
2. for each cpu:
2-1. set cpu affinity
2-2. create some clients
2-3. let clients connect() to the server on the same cpu
2-4. close() clients
3. for each server:
3-1. accept() all child sockets
3-2. check if all children have the same SO_INCOMING_CPU with the server
The root cause was the close() in 2-4. and net.ipv4.tcp_tw_reuse.
In a loop of 2., close() changed the client state to FIN_WAIT_2, and
the peer transitioned to CLOSE_WAIT.
In another loop of 2., connect() happened to select the same port of
the FIN_WAIT_2 socket, and it was reused as the default value of
net.ipv4.tcp_tw_reuse is 2.
As a result, the new client sent SYN to the CLOSE_WAIT socket from
a different CPU, and the receiver's sk_incoming_cpu was overwritten
with unexpected CPU ID.
Also, the SYN had a different SEQ number, so the CLOSE_WAIT socket
responded with Challenge ACK. The new client properly returned RST
and effectively killed the CLOSE_WAIT socket.
This way, all clients were created successfully, but the error was
detected later by 3-2., ASSERT_EQ(cpu, i).
To avoid the failure, let's make sure that (i) the number of clients
is less than the number of available ports and (ii) such reuse never
happens.
Fixes: 6df9614 ("selftest: Add test for SO_INCOMING_CPU.")
Reported-by: Jakub Kicinski <[email protected]>
Signed-off-by: Kuniyuki Iwashima <[email protected]>
Tested-by: Jakub Kicinski <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Abeni <[email protected]>1 parent 7267e8d commit 97de5a1
1 file changed
+50
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | 14 | | |
17 | 15 | | |
18 | | - | |
19 | 16 | | |
20 | 17 | | |
21 | 18 | | |
| |||
56 | 53 | | |
57 | 54 | | |
58 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
59 | 82 | | |
60 | 83 | | |
61 | | - | |
62 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
63 | 95 | | |
64 | | - | |
| 96 | + | |
65 | 97 | | |
66 | 98 | | |
67 | 99 | | |
| |||
74 | 106 | | |
75 | 107 | | |
76 | 108 | | |
77 | | - | |
| 109 | + | |
78 | 110 | | |
79 | 111 | | |
80 | 112 | | |
| |||
110 | 142 | | |
111 | 143 | | |
112 | 144 | | |
113 | | - | |
| 145 | + | |
114 | 146 | | |
115 | 147 | | |
116 | | - | |
| 148 | + | |
117 | 149 | | |
118 | 150 | | |
119 | 151 | | |
| |||
128 | 160 | | |
129 | 161 | | |
130 | 162 | | |
131 | | - | |
| 163 | + | |
132 | 164 | | |
133 | 165 | | |
134 | 166 | | |
| |||
138 | 170 | | |
139 | 171 | | |
140 | 172 | | |
141 | | - | |
| 173 | + | |
142 | 174 | | |
143 | 175 | | |
144 | 176 | | |
| |||
149 | 181 | | |
150 | 182 | | |
151 | 183 | | |
152 | | - | |
| 184 | + | |
153 | 185 | | |
154 | 186 | | |
155 | 187 | | |
| |||
162 | 194 | | |
163 | 195 | | |
164 | 196 | | |
165 | | - | |
| 197 | + | |
166 | 198 | | |
167 | 199 | | |
168 | 200 | | |
| |||
180 | 212 | | |
181 | 213 | | |
182 | 214 | | |
183 | | - | |
184 | | - | |
| 215 | + | |
| 216 | + | |
185 | 217 | | |
186 | 218 | | |
187 | 219 | | |
| |||
195 | 227 | | |
196 | 228 | | |
197 | 229 | | |
198 | | - | |
| 230 | + | |
199 | 231 | | |
200 | 232 | | |
201 | 233 | | |
| |||
0 commit comments