51 Commits

Author SHA1 Message Date
Lucas Manning 25b1d71341 Add constants and types related to the implementation of PACKET_MMAP.
This is the first in a series of changes that implements PACKET_MMAP.

PiperOrigin-RevId: 716014872
2025-01-15 17:45:19 -08:00
Ayush Ranjan 9d41ac1ff0 Fix unsigned to signed integer conversion in syserr.getHostTranslation().
unix.Errno is of type `uintptr`, which is an unsigned integer. It was being
casted to `int`, which is a signed integer of the same size. This cast could
overflow due to unsigned -> signed.

Reported-by: syzbot+08e5bf6f25d7db4316b9@syzkaller.appspotmail.com
PiperOrigin-RevId: 680668525
2024-09-30 12:11:53 -07:00
Ayush Ranjan 3971ecbc6c Remove linuxerr.IsValid and use syserr.IsValid instead.
linuxerr.IsValid just checks if the errno is less than the max possible errno
value. syserr.IsValid additionally checks if the errno can be translated by the
syserr package.

Furthermore, drop the usage of linuxerr.TranslateError(), which only checks
against a map with 3 entries of sentry-internal errors. Earlier, connError()
would always fail at this step and end up returning linuxerr.EINVAL even if the
errno being returned is valid.

Reported-by: syzbot+180b8537798c091bf9fd@syzkaller.appspotmail.com
PiperOrigin-RevId: 680021716
2024-09-28 12:34:57 -07:00
Ayush Ranjan 40bde6c617 Add EHWPOISON to host_linux.go
Reported-by: syzbot+a5a17bdcbcb46c5ca38c@syzkaller.appspotmail.com
PiperOrigin-RevId: 671639531
2024-09-05 23:19:47 -07:00
Nayana Bidari e6cf09a18c Add ERFKILL errno to host_linux file.
Reported-by: syzbot+60bb099bed4694a37f61@syzkaller.appspotmail.com
PiperOrigin-RevId: 663361199
2024-08-15 10:43:38 -07:00
Ayush Ranjan 0184ec4aac Add ENAVAIL to host_linux.go.
Reported-by: syzbot+60bb099bed4694a37f61@syzkaller.appspotmail.com
PiperOrigin-RevId: 658858051
2024-08-02 11:53:26 -07:00
Ayush Ranjan ef1ca17e58 Add EISNAM to linuxHostTranslations and fix error message for ENOTNAM.
Reported-by: syzbot+2817f67abeaf8fca4427@syzkaller.appspotmail.com
PiperOrigin-RevId: 658584815
2024-08-01 16:57:38 -07:00
Adin Scannell 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Zeling Feng 611e6e1247 Handle all codes for ICMPv4 destination unreachable message for TCP
Some hosts use iptables and are configured to respond an ICMP destination
unreachable message with a {host/net/admin}prohibited code instead of a RST.
Linux handles these codes correctly by aborting the handshake. This commit
adds handling of all possible codes of an ICMPv4 destination unreachable message
to bring gVisor to parity.

PiperOrigin-RevId: 496703813
2022-12-20 11:07:27 -08:00
Bruno Dal Bo c40f8e3651 Rename ErrNoRoute to ErrHostUnreachable
ErrNoRoute gets translated to EHOSTUNREACH which causes some code paths to
produce different errors unexpectedly. Rename the error so we can clean up some
sites to return ENETUNREACH more clearly where needed.

Updates #8105

PiperOrigin-RevId: 482355099
2022-10-19 18:29:13 -07:00
Nate Hurley 006bbe78ca Implement IPv4 multicast forwarding.
This change implements AddMulticastRoute and the requisite routing logic.
Subsequent changes will still be needed to:

1. Emit events for missing route or unexpected input interface
2. Implement DelRoute
3. Implement GetRouteStats

Updates #7338.

PiperOrigin-RevId: 451026594
2022-05-25 15:18:13 -07:00
Kevin Krakauer ce194f2c1c Automated rollback of changelist 407638912
PiperOrigin-RevId: 410665707
2021-11-17 17:07:05 -08:00
Kevin Krakauer b490036d83 netstack: remove {linux,darwin}HostTranslation
It can be replaced with a simpler type.

PiperOrigin-RevId: 409533054
2021-11-12 16:24:59 -08:00
Kevin Krakauer 82793c5e90 netstack: fix Mac build error
- Stub out sighandling functions with panics on Darwin
- Put Linux-specific errors into their own syserr file

Not sure how best to get automated tests running, so I'll leave that for a later
change.

Fixes #6839.
Related to #1270.

PiperOrigin-RevId: 409516969
2021-11-12 15:24:47 -08:00
Zach Koopmans fe8e48fc6d [syserr] Move ConvertIntr function to linuxerr package
Move ConverIntr out of syserr package and delete an unused function.

PiperOrigin-RevId: 407676258
2021-11-04 14:55:52 -07:00
Zach Koopmans 23a115dae8 [syserr] Reverse dependency for tcpip.Error
PiperOrigin-RevId: 407638912
2021-11-04 12:11:41 -07:00
Zach Koopmans dfbcb8903a [syserr] Fix SIGBUS on syserr.FromError
Fix syzcaller panic SIGBUS on error handling. Done by
adding an interface, errors.GuestError, which errors can
implement in order to be compared against each other.

PiperOrigin-RevId: 393867554
2021-08-30 15:35:02 -07:00
Zach Koopmans ce58d71fd5 [syserror] Remove pkg syserror.
Removes package syserror and moves still relevant code to either linuxerr
or to syserr (to be later removed).

Internal errors are converted from random types to *errors.Error types used
in linuxerr. Internal errors are in linuxerr/internal.go.

PiperOrigin-RevId: 390724202
2021-08-13 17:16:52 -07:00
Jamie Liu 1ad3822200 Add go:build directives as required by Go 1.17's gofmt.
PiperOrigin-RevId: 385894869
2021-07-20 16:28:45 -07:00
Zach Koopmans 590b8d3e99 [syserror] Update several syserror errors to linuxerr equivalents.
Update/remove most syserror errors to linuxerr equivalents. For list
of removed errors, see //pkg/syserror/syserror.go.

PiperOrigin-RevId: 382574582
2021-07-01 12:05:19 -07:00
Zach Koopmans 54b71221c0 [syserror] Change syserror to linuxerr for E2BIG, EADDRINUSE, and EINVAL
Remove three syserror entries duplicated in linuxerr. Because of the
linuxerr.Equals method, this is a mere change of return values from
syserror to linuxerr definitions.

Done with only these three errnos as CLs removing all grow to a significantly
large size.

PiperOrigin-RevId: 382173835
2021-06-29 15:08:46 -07:00
Zach Koopmans e1dc1c78e7 [syserror] Add conversions to linuxerr with temporary Equals method.
Add Equals method to compare syserror and unix.Errno errors to linuxerr errors.
This will facilitate removal of syserror definitions in a followup, and
finding needed conversions from unix.Errno to linuxerr.

PiperOrigin-RevId: 380909667
2021-06-22 15:53:32 -07:00
Zach Koopmans 63b4f6e296 [syserror] Refactor linuxerr and error package.
Move Error struct to pkg/errors package for use in multiple places.
Move linuxerr static definitions under pkg/errors/linuxerr.
Add a lookup list for quick lookup of *errors.Error by errno. This is useful
when converting syserror errors and unix.Errno/syscall.Errrno values to
*errors.Error.
Update benchmarks routines to include conversions.

The below benchmarks show *errors.Error usage to be comparable to using
unix.Errno.

BenchmarkAssignUnix
BenchmarkAssignUnix-32                 	787875022	         1.284 ns/op
BenchmarkAssignLinuxerr
BenchmarkAssignLinuxerr-32             	1000000000	         1.209 ns/op
BenchmarkAssignSyserror
BenchmarkAssignSyserror-32             	759269229	         1.429 ns/op
BenchmarkCompareUnix
BenchmarkCompareUnix-32                	1000000000	         1.310 ns/op
BenchmarkCompareLinuxerr
BenchmarkCompareLinuxerr-32            	1000000000	         1.241 ns/op
BenchmarkCompareSyserror
BenchmarkCompareSyserror-32            	147196165	         8.248 ns/op
BenchmarkSwitchUnix
BenchmarkSwitchUnix-32                 	373233556	         3.664 ns/op
BenchmarkSwitchLinuxerr
BenchmarkSwitchLinuxerr-32             	476323929	         3.294 ns/op
BenchmarkSwitchSyserror
BenchmarkSwitchSyserror-32             	39293408	        29.62 ns/op
BenchmarkReturnUnix
BenchmarkReturnUnix-32                 	1000000000	         0.5042 ns/op
BenchmarkReturnLinuxerr
BenchmarkReturnLinuxerr-32             	1000000000	         0.8152 ns/op
BenchmarkConvertUnixLinuxerr
BenchmarkConvertUnixLinuxerr-32        	739948875	         1.547 ns/op
BenchmarkConvertUnixLinuxerrZero
BenchmarkConvertUnixLinuxerrZero-32    	977733974	         1.489 ns/op

PiperOrigin-RevId: 379806801
2021-06-16 14:08:52 -07:00
Zach Koopmans 49eb3da98a [syserror] Refactor abi/linux.Errno
PiperOrigin-RevId: 373265454
2021-05-11 17:23:08 -07:00
Kevin Krakauer abbdcebc54 Implement /proc/sys/net/ipv4/ip_local_port_range
Speeds up the socket stress tests by a couple orders of magnitude.

PiperOrigin-RevId: 361721050
2021-03-08 20:40:34 -08:00