Debian Codegraph @

tcpip/errors.go

raw symbols SCIP
1 // Copyright 2021 The gVisor Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package tcpip
16
17 import (
18 "fmt"
19 )
20
21 // Error represents an error in the netstack error space.
22 //
23 // The error interface is intentionally omitted to avoid loss of type
24 // information that would occur if these errors were passed as error.
25 type Error interface {
26 isError()
27
28 // IgnoreStats indicates whether this error should be included in failure
29 // counts in tcpip.Stats structs.
30 IgnoreStats() bool
31
32 fmt.Stringer
33 }
34
35 // LINT.IfChange
36
37 // ErrAborted indicates the operation was aborted.
38 //
39 // +stateify savable
40 type ErrAborted struct{}
41
42 func (*ErrAborted) isError() {}
43
44 // IgnoreStats implements Error.
45 func (*ErrAborted) IgnoreStats() bool {
46 return false
47 }
48 func (*ErrAborted) String() string {
49 return "operation aborted"
50 }
51
52 // ErrAddressFamilyNotSupported indicates the operation does not support the
53 // given address family.
54 //
55 // +stateify savable
56 type ErrAddressFamilyNotSupported struct{}
57
58 func (*ErrAddressFamilyNotSupported) isError() {}
59
60 // IgnoreStats implements Error.
61 func (*ErrAddressFamilyNotSupported) IgnoreStats() bool {
62 return false
63 }
64 func (*ErrAddressFamilyNotSupported) String() string {
65 return "address family not supported by protocol"
66 }
67
68 // ErrAlreadyBound indicates the endpoint is already bound.
69 //
70 // +stateify savable
71 type ErrAlreadyBound struct{}
72
73 func (*ErrAlreadyBound) isError() {}
74
75 // IgnoreStats implements Error.
76 func (*ErrAlreadyBound) IgnoreStats() bool {
77 return true
78 }
79 func (*ErrAlreadyBound) String() string { return "endpoint already bound" }
80
81 // ErrAlreadyConnected indicates the endpoint is already connected.
82 //
83 // +stateify savable
84 type ErrAlreadyConnected struct{}
85
86 func (*ErrAlreadyConnected) isError() {}
87
88 // IgnoreStats implements Error.
89 func (*ErrAlreadyConnected) IgnoreStats() bool {
90 return true
91 }
92 func (*ErrAlreadyConnected) String() string { return "endpoint is already connected" }
93
94 // ErrAlreadyConnecting indicates the endpoint is already connecting.
95 //
96 // +stateify savable
97 type ErrAlreadyConnecting struct{}
98
99 func (*ErrAlreadyConnecting) isError() {}
100
101 // IgnoreStats implements Error.
102 func (*ErrAlreadyConnecting) IgnoreStats() bool {
103 return true
104 }
105 func (*ErrAlreadyConnecting) String() string { return "endpoint is already connecting" }
106
107 // ErrBadAddress indicates a bad address was provided.
108 //
109 // +stateify savable
110 type ErrBadAddress struct{}
111
112 func (*ErrBadAddress) isError() {}
113
114 // IgnoreStats implements Error.
115 func (*ErrBadAddress) IgnoreStats() bool {
116 return false
117 }
118 func (*ErrBadAddress) String() string { return "bad address" }
119
120 // ErrBadBuffer indicates a bad buffer was provided.
121 //
122 // +stateify savable
123 type ErrBadBuffer struct{}
124
125 func (*ErrBadBuffer) isError() {}
126
127 // IgnoreStats implements Error.
128 func (*ErrBadBuffer) IgnoreStats() bool {
129 return false
130 }
131 func (*ErrBadBuffer) String() string { return "bad buffer" }
132
133 // ErrBadLocalAddress indicates a bad local address was provided.
134 //
135 // +stateify savable
136 type ErrBadLocalAddress struct{}
137
138 func (*ErrBadLocalAddress) isError() {}
139
140 // IgnoreStats implements Error.
141 func (*ErrBadLocalAddress) IgnoreStats() bool {
142 return false
143 }
144 func (*ErrBadLocalAddress) String() string { return "bad local address" }
145
146 // ErrBroadcastDisabled indicates broadcast is not enabled on the endpoint.
147 //
148 // +stateify savable
149 type ErrBroadcastDisabled struct{}
150
151 func (*ErrBroadcastDisabled) isError() {}
152
153 // IgnoreStats implements Error.
154 func (*ErrBroadcastDisabled) IgnoreStats() bool {
155 return false
156 }
157 func (*ErrBroadcastDisabled) String() string { return "broadcast socket option disabled" }
158
159 // ErrClosedForReceive indicates the endpoint is closed for incoming data.
160 //
161 // +stateify savable
162 type ErrClosedForReceive struct{}
163
164 func (*ErrClosedForReceive) isError() {}
165
166 // IgnoreStats implements Error.
167 func (*ErrClosedForReceive) IgnoreStats() bool {
168 return false
169 }
170 func (*ErrClosedForReceive) String() string { return "endpoint is closed for receive" }
171
172 // ErrClosedForSend indicates the endpoint is closed for outgoing data.
173 //
174 // +stateify savable
175 type ErrClosedForSend struct{}
176
177 func (*ErrClosedForSend) isError() {}
178
179 // IgnoreStats implements Error.
180 func (*ErrClosedForSend) IgnoreStats() bool {
181 return false
182 }
183 func (*ErrClosedForSend) String() string { return "endpoint is closed for send" }
184
185 // ErrConnectStarted indicates the endpoint is connecting asynchronously.
186 //
187 // +stateify savable
188 type ErrConnectStarted struct{}
189
190 func (*ErrConnectStarted) isError() {}
191
192 // IgnoreStats implements Error.
193 func (*ErrConnectStarted) IgnoreStats() bool {
194 return true
195 }
196 func (*ErrConnectStarted) String() string { return "connection attempt started" }
197
198 // ErrConnectionAborted indicates the connection was aborted.
199 //
200 // +stateify savable
201 type ErrConnectionAborted struct{}
202
203 func (*ErrConnectionAborted) isError() {}
204
205 // IgnoreStats implements Error.
206 func (*ErrConnectionAborted) IgnoreStats() bool {
207 return false
208 }
209 func (*ErrConnectionAborted) String() string { return "connection aborted" }
210
211 // ErrConnectionRefused indicates the connection was refused.
212 //
213 // +stateify savable
214 type ErrConnectionRefused struct{}
215
216 func (*ErrConnectionRefused) isError() {}
217
218 // IgnoreStats implements Error.
219 func (*ErrConnectionRefused) IgnoreStats() bool {
220 return false
221 }
222 func (*ErrConnectionRefused) String() string { return "connection was refused" }
223
224 // ErrConnectionReset indicates the connection was reset.
225 //
226 // +stateify savable
227 type ErrConnectionReset struct{}
228
229 func (*ErrConnectionReset) isError() {}
230
231 // IgnoreStats implements Error.
232 func (*ErrConnectionReset) IgnoreStats() bool {
233 return false
234 }
235 func (*ErrConnectionReset) String() string { return "connection reset by peer" }
236
237 // ErrDestinationRequired indicates the operation requires a destination
238 // address, and one was not provided.
239 //
240 // +stateify savable
241 type ErrDestinationRequired struct{}
242
243 func (*ErrDestinationRequired) isError() {}
244
245 // IgnoreStats implements Error.
246 func (*ErrDestinationRequired) IgnoreStats() bool {
247 return false
248 }
249 func (*ErrDestinationRequired) String() string { return "destination address is required" }
250
251 // ErrDuplicateAddress indicates the operation encountered a duplicate address.
252 //
253 // +stateify savable
254 type ErrDuplicateAddress struct{}
255
256 func (*ErrDuplicateAddress) isError() {}
257
258 // IgnoreStats implements Error.
259 func (*ErrDuplicateAddress) IgnoreStats() bool {
260 return false
261 }
262 func (*ErrDuplicateAddress) String() string { return "duplicate address" }
263
264 // ErrDuplicateNICID indicates the operation encountered a duplicate NIC ID.
265 //
266 // +stateify savable
267 type ErrDuplicateNICID struct{}
268
269 func (*ErrDuplicateNICID) isError() {}
270
271 // IgnoreStats implements Error.
272 func (*ErrDuplicateNICID) IgnoreStats() bool {
273 return false
274 }
275 func (*ErrDuplicateNICID) String() string { return "duplicate nic id" }
276
277 // ErrInvalidEndpointState indicates the endpoint is in an invalid state.
278 //
279 // +stateify savable
280 type ErrInvalidEndpointState struct{}
281
282 func (*ErrInvalidEndpointState) isError() {}
283
284 // IgnoreStats implements Error.
285 func (*ErrInvalidEndpointState) IgnoreStats() bool {
286 return false
287 }
288 func (*ErrInvalidEndpointState) String() string { return "endpoint is in invalid state" }
289
290 // ErrInvalidOptionValue indicates an invalid option value was provided.
291 //
292 // +stateify savable
293 type ErrInvalidOptionValue struct{}
294
295 func (*ErrInvalidOptionValue) isError() {}
296
297 // IgnoreStats implements Error.
298 func (*ErrInvalidOptionValue) IgnoreStats() bool {
299 return false
300 }
301 func (*ErrInvalidOptionValue) String() string { return "invalid option value specified" }
302
303 // ErrInvalidPortRange indicates an attempt to set an invalid port range.
304 //
305 // +stateify savable
306 type ErrInvalidPortRange struct{}
307
308 func (*ErrInvalidPortRange) isError() {}
309
310 // IgnoreStats implements Error.
311 func (*ErrInvalidPortRange) IgnoreStats() bool {
312 return true
313 }
314 func (*ErrInvalidPortRange) String() string { return "invalid port range" }
315
316 // ErrMalformedHeader indicates the operation encountered a malformed header.
317 //
318 // +stateify savable
319 type ErrMalformedHeader struct{}
320
321 func (*ErrMalformedHeader) isError() {}
322
323 // IgnoreStats implements Error.
324 func (*ErrMalformedHeader) IgnoreStats() bool {
325 return false
326 }
327 func (*ErrMalformedHeader) String() string { return "header is malformed" }
328
329 // ErrMessageTooLong indicates the operation encountered a message whose length
330 // exceeds the maximum permitted.
331 //
332 // +stateify savable
333 type ErrMessageTooLong struct{}
334
335 func (*ErrMessageTooLong) isError() {}
336
337 // IgnoreStats implements Error.
338 func (*ErrMessageTooLong) IgnoreStats() bool {
339 return false
340 }
341 func (*ErrMessageTooLong) String() string { return "message too long" }
342
343 // ErrNetworkUnreachable indicates the operation is not able to reach the
344 // destination network.
345 //
346 // +stateify savable
347 type ErrNetworkUnreachable struct{}
348
349 func (*ErrNetworkUnreachable) isError() {}
350
351 // IgnoreStats implements Error.
352 func (*ErrNetworkUnreachable) IgnoreStats() bool {
353 return false
354 }
355 func (*ErrNetworkUnreachable) String() string { return "network is unreachable" }
356
357 // ErrNoBufferSpace indicates no buffer space is available.
358 //
359 // +stateify savable
360 type ErrNoBufferSpace struct{}
361
362 func (*ErrNoBufferSpace) isError() {}
363
364 // IgnoreStats implements Error.
365 func (*ErrNoBufferSpace) IgnoreStats() bool {
366 return false
367 }
368 func (*ErrNoBufferSpace) String() string { return "no buffer space available" }
369
370 // ErrNoPortAvailable indicates no port could be allocated for the operation.
371 //
372 // +stateify savable
373 type ErrNoPortAvailable struct{}
374
375 func (*ErrNoPortAvailable) isError() {}
376
377 // IgnoreStats implements Error.
378 func (*ErrNoPortAvailable) IgnoreStats() bool {
379 return false
380 }
381 func (*ErrNoPortAvailable) String() string { return "no ports are available" }
382
383 // ErrNoRoute indicates the operation is not able to find a route to the
384 // destination.
385 //
386 // +stateify savable
387 type ErrNoRoute struct{}
388
389 func (*ErrNoRoute) isError() {}
390
391 // IgnoreStats implements Error.
392 func (*ErrNoRoute) IgnoreStats() bool {
393 return false
394 }
395 func (*ErrNoRoute) String() string { return "no route" }
396
397 // ErrNoSuchFile is used to indicate that ENOENT should be returned the to
398 // calling application.
399 //
400 // +stateify savable
401 type ErrNoSuchFile struct{}
402
403 func (*ErrNoSuchFile) isError() {}
404
405 // IgnoreStats implements Error.
406 func (*ErrNoSuchFile) IgnoreStats() bool {
407 return false
408 }
409 func (*ErrNoSuchFile) String() string { return "no such file" }
410
411 // ErrNotConnected indicates the endpoint is not connected.
412 //
413 // +stateify savable
414 type ErrNotConnected struct{}
415
416 func (*ErrNotConnected) isError() {}
417
418 // IgnoreStats implements Error.
419 func (*ErrNotConnected) IgnoreStats() bool {
420 return false
421 }
422 func (*ErrNotConnected) String() string { return "endpoint not connected" }
423
424 // ErrNotPermitted indicates the operation is not permitted.
425 //
426 // +stateify savable
427 type ErrNotPermitted struct{}
428
429 func (*ErrNotPermitted) isError() {}
430
431 // IgnoreStats implements Error.
432 func (*ErrNotPermitted) IgnoreStats() bool {
433 return false
434 }
435 func (*ErrNotPermitted) String() string { return "operation not permitted" }
436
437 // ErrNotSupported indicates the operation is not supported.
438 //
439 // +stateify savable
440 type ErrNotSupported struct{}
441
442 func (*ErrNotSupported) isError() {}
443
444 // IgnoreStats implements Error.
445 func (*ErrNotSupported) IgnoreStats() bool {
446 return false
447 }
448 func (*ErrNotSupported) String() string { return "operation not supported" }
449
450 // ErrPortInUse indicates the provided port is in use.
451 //
452 // +stateify savable
453 type ErrPortInUse struct{}
454
455 func (*ErrPortInUse) isError() {}
456
457 // IgnoreStats implements Error.
458 func (*ErrPortInUse) IgnoreStats() bool {
459 return false
460 }
461 func (*ErrPortInUse) String() string { return "port is in use" }
462
463 // ErrQueueSizeNotSupported indicates the endpoint does not allow queue size
464 // operation.
465 //
466 // +stateify savable
467 type ErrQueueSizeNotSupported struct{}
468
469 func (*ErrQueueSizeNotSupported) isError() {}
470
471 // IgnoreStats implements Error.
472 func (*ErrQueueSizeNotSupported) IgnoreStats() bool {
473 return false
474 }
475 func (*ErrQueueSizeNotSupported) String() string { return "queue size querying not supported" }
476
477 // ErrTimeout indicates the operation timed out.
478 //
479 // +stateify savable
480 type ErrTimeout struct{}
481
482 func (*ErrTimeout) isError() {}
483
484 // IgnoreStats implements Error.
485 func (*ErrTimeout) IgnoreStats() bool {
486 return false
487 }
488 func (*ErrTimeout) String() string { return "operation timed out" }
489
490 // ErrUnknownDevice indicates an unknown device identifier was provided.
491 //
492 // +stateify savable
493 type ErrUnknownDevice struct{}
494
495 func (*ErrUnknownDevice) isError() {}
496
497 // IgnoreStats implements Error.
498 func (*ErrUnknownDevice) IgnoreStats() bool {
499 return false
500 }
501 func (*ErrUnknownDevice) String() string { return "unknown device" }
502
503 // ErrUnknownNICID indicates an unknown NIC ID was provided.
504 //
505 // +stateify savable
506 type ErrUnknownNICID struct{}
507
508 func (*ErrUnknownNICID) isError() {}
509
510 // IgnoreStats implements Error.
511 func (*ErrUnknownNICID) IgnoreStats() bool {
512 return false
513 }
514 func (*ErrUnknownNICID) String() string { return "unknown nic id" }
515
516 // ErrUnknownProtocol indicates an unknown protocol was requested.
517 //
518 // +stateify savable
519 type ErrUnknownProtocol struct{}
520
521 func (*ErrUnknownProtocol) isError() {}
522
523 // IgnoreStats implements Error.
524 func (*ErrUnknownProtocol) IgnoreStats() bool {
525 return false
526 }
527 func (*ErrUnknownProtocol) String() string { return "unknown protocol" }
528
529 // ErrUnknownProtocolOption indicates an unknown protocol option was provided.
530 //
531 // +stateify savable
532 type ErrUnknownProtocolOption struct{}
533
534 func (*ErrUnknownProtocolOption) isError() {}
535
536 // IgnoreStats implements Error.
537 func (*ErrUnknownProtocolOption) IgnoreStats() bool {
538 return false
539 }
540 func (*ErrUnknownProtocolOption) String() string { return "unknown option for protocol" }
541
542 // ErrWouldBlock indicates the operation would block.
543 //
544 // +stateify savable
545 type ErrWouldBlock struct{}
546
547 func (*ErrWouldBlock) isError() {}
548
549 // IgnoreStats implements Error.
550 func (*ErrWouldBlock) IgnoreStats() bool {
551 return true
552 }
553 func (*ErrWouldBlock) String() string { return "operation would block" }
554
555 // LINT.ThenChange(../syserr/netstack.go)