287 Commits
Author SHA1 Message Date
Rahat MahmoodandgVisor bot f54d87b9ec Remove uses of the binary package from networking code.
Co-Author: ayushranjan
PiperOrigin-RevId: 370785009
2021-04-27 16:20:01 -07:00
Nayana BidariandgVisor bot 3fff4c4a0f Move SO_RCVBUF to socketops.
Fixes #2926, #674

PiperOrigin-RevId: 369457123
2021-04-20 09:32:54 -07:00
Kevin KrakauerandgVisor bot 32c18f443f Enlarge port range and fix integer overflow
Also count failed TCP port allocations

PiperOrigin-RevId: 368939619
2021-04-16 16:28:56 -07:00
Zach KoopmansandgVisor bot 8a2f7e716d [syserror] Split usermem package
Split usermem package to help remove syserror dependency in go_marshal.
New hostarch package contains code not dependent on syserror.

PiperOrigin-RevId: 365651233
2021-03-29 13:30:21 -07:00
Bhasker HariharanandgVisor bot e7ca2a51a8 Add POLLRDNORM/POLLWRNORM support.
On Linux these are meant to be equivalent to POLLIN/POLLOUT. Rather
than hack these on in sys_poll etc it felt cleaner to just cleanup
the call sites to notify for both events. This is what linux does
as well.

Fixes #5544

PiperOrigin-RevId: 364859977
2021-03-24 12:11:44 -07:00
Kevin KrakauerandgVisor bot b1d5787726 Make netstack (//pkg/tcpip) buildable for 32 bit
Doing so involved breaking dependencies between //pkg/tcpip and the rest
of gVisor, which are discouraged anyways.

Tested on the Go branch via:
  gvisor.dev/gvisor/pkg/tcpip/...

Addresses #1446.

PiperOrigin-RevId: 363081778
2021-03-15 18:49:59 -07:00
Kevin KrakauerandgVisor bot 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
Arthur SfezandgVisor bot 80bc67c268 Export stats that were forgotten
While I'm here, simplify the comments and unify naming of certain stats
across protocols.

PiperOrigin-RevId: 360728849
2021-03-03 12:18:55 -08:00
Ayush RanjanandgVisor bot a9441aea27 [op] Replace syscall package usage with golang.org/x/sys/unix in pkg/.
The syscall package has been deprecated in favor of golang.org/x/sys.

Note that syscall is still used in the following places:
- pkg/sentry/socket/hostinet/stack.go: some netlink related functionalities
  are not yet available in golang.org/x/sys.
- syscall.Stat_t is still used in some places because os.FileInfo.Sys() still
  returns it and not unix.Stat_t.

Updates #214

PiperOrigin-RevId: 360701387
2021-03-03 10:25:58 -08:00
Arthur SfezandgVisor bot 2a2cb29e1c Validate IGMP packets
This change also adds support for Router Alert option processing on
incoming packets, a new stat for Router Alert option, and exports
all the IP-option related stats.

Fixes #5491

PiperOrigin-RevId: 358238123
2021-02-18 12:29:54 -08:00
Ayush RanjanandgVisor bot 845d0a65f4 [rack] TLP: ACK Processing and PTO scheduling.
This change implements TLP details enumerated in
https://tools.ietf.org/html/draft-ietf-tcpm-rack-08#section-7.5.3

Fixes #5085

PiperOrigin-RevId: 357125037
2021-02-11 22:06:09 -08:00
Bhasker HariharanandgVisor bot 298c129cc1 Add support for setting SO_SNDBUF for unix domain sockets.
The limits for snd/rcv buffers for unix domain socket is controlled by the
following sysctls on linux

 - net.core.rmem_default
 - net.core.rmem_max
 - net.core.wmem_default
 - net.core.wmem_max

Today in gVisor we do not expose these sysctls but we do support setting the
equivalent in netstack via stack.Options() method. But AF_UNIX sockets in gVisor
can be used without netstack, with hostinet or even without any networking stack
at all. Which means ideally these sysctls need to live as globals in gVisor.

But rather than make this a big change for now we hardcode the limits in the
AF_UNIX implementation itself (which in itself is better than where we were
before) where it SO_SNDBUF was hardcoded to 16KiB. Further we bump the initial
limit to a default value of 208 KiB to match linux from the paltry 16 KiB we use
today.

Updates #5132

PiperOrigin-RevId: 356665498
2021-02-09 21:55:16 -08:00
Ting-Yu WangandgVisor bot 120c8e3468 Replace TaskFromContext(ctx).Kernel() with KernelFromContext(ctx)
Panic seen at some code path like control.ExecAsync where
ctx does not have a Task.

Reported-by: syzbot+55ce727161cf94a7b7d6@syzkaller.appspotmail.com
PiperOrigin-RevId: 355960596
2021-02-05 17:28:01 -08:00
Ghanan GowripalanandgVisor bot ebd3912c0f Refactor HandleControlPacket/SockError
...to remove the need for the transport layer to deduce the type of
error it received.

Rename HandleControlPacket to HandleError as HandleControlPacket only
handles errors.

tcpip.SockError now holds a tcpip.SockErrorCause interface that
different errors can implement.

PiperOrigin-RevId: 354994306
2021-02-01 12:04:03 -08:00
Tamir DubersteinandgVisor bot 8d1afb4185 Change tcpip.Error to an interface
This makes it possible to add data to types that implement tcpip.Error.
ErrBadLinkEndpoint is removed as it is unused.

PiperOrigin-RevId: 354437314
2021-01-28 17:59:58 -08:00
Tamir DubersteinandgVisor bot c99e092a3b Propagate reader error in ReadFrom
This was removed in 6c0e1d9cfe but turns
out to be crucial to prevent flaky behaviour in sendfile.

PiperOrigin-RevId: 354434144
2021-01-28 17:41:02 -08:00
Nayana BidariandgVisor bot 99988e45ed Add support for more fields in netstack for TCP_INFO
This CL adds support for the following fields:
- RTT, RTTVar, RTO
- send congestion window (sndCwnd) and send slow start threshold (sndSsthresh)
- congestion control state(CaState)
- ReorderSeen

PiperOrigin-RevId: 354195361
2021-01-27 16:14:50 -08:00
Nayana BidariandgVisor bot 8e66044741 Initialize the send buffer handler in endpoint creation.
- This CL will initialize the function handler used for getting the send
buffer size limits during endpoint creation and does not require the caller of
SetSendBufferSize(..) to know the endpoint type(tcp/udp/..)

PiperOrigin-RevId: 353992634
2021-01-26 18:05:29 -08:00
Nayana BidariandgVisor bot daf0d3f6ca Move SO_SNDBUF to socketops.
This CL moves {S,G}etsockopt of SO_SNDBUF from all endpoints to socketops. For
unix sockets, we do not support setting of this option.

PiperOrigin-RevId: 353871484
2021-01-26 08:25:34 -08:00
Arthur SfezandgVisor bot 39db3b9355 Add per endpoint ARP statistics
The ARP stat NetworkUnreachable was removed, and was replaced by
InterfaceHasNoLocalAddress. No stats are recorded when dealing with an
missing endpoint (ErrNotConnected) (because if there is no endpoint,
there is no valid per-endpoint stats).

PiperOrigin-RevId: 353759462
2021-01-25 16:52:05 -08:00
Tamir DubersteinandgVisor bot 6c0e1d9cfe Define tcpip.Payloader in terms of io.Reader
Fixes #1509.

PiperOrigin-RevId: 353295589
2021-01-22 12:26:09 -08:00
Nayana BidariandgVisor bot b0136253e6 Remove unimplemented message for SO_LINGER
- Removes the unimplemented message for SO_LINGER
- Fix the length for IP_PKTINFO option

PiperOrigin-RevId: 352917611
2021-01-20 18:16:51 -08:00
Dean DengandgVisor bot 55332aca95 Move Lock/UnlockPOSIX into LockFD util.
PiperOrigin-RevId: 352904728
2021-01-20 16:55:07 -08:00
Tamir DubersteinandgVisor bot 12d9790833 Remove count argument from tcpip.Endpoint.Read
The same intent can be specified via the io.Writer.

PiperOrigin-RevId: 352098747
2021-01-15 15:49:15 -08:00
Arthur SfezandgVisor bot 833516c139 Add stats for ARP
Fixes #4963

Startblock:
  has LGTM from sbalana
  and then
  add reviewer ghanan
PiperOrigin-RevId: 351886320
2021-01-14 15:16:24 -08:00