287 Commits
Author SHA1 Message Date
Bhasker HariharanandgVisor bot 74a1820ceb Remove TCP endpoint goroutines.
This change removes all endpoint goroutines and all TCP processing is now done
inline in the TCP processor loop. TCP timers directly invoke handlers as
required rather than assert a waker.

UnlockUser is also simplified to just queue the endpoint to the processor
instead of trying to process segments inline. This allows us to centralize logic
for TCP state handling in the processor. This potentially could involve an extra
wakeup but now that endpoint goroutines do not exist this is not such a big
concern as in case of busy servers the processor goroutines will already be
running anyway.

This change also allows us to clean up S/R as now restoring a TCP endpoint does
not require restarting a goroutine and moving it to the right logical point but
only requires that we restart any timers that may have been running when the
save was done and restore any port bindings as required.

Endpoint.Release is now removed in favor of Endpoint.Abort by using Abort in
places where we use Endpoint.Release.

Updates #231

PiperOrigin-RevId: 442673015
2022-04-18 17:35:36 -07:00
Nayana BidariandgVisor bot 007a91a911 Silence the error log message for SO_RCVLOWAT option.
Removed the unimplemented syscall message for SO_RCVLOWAT option and added a
test for {g,s}etsockopt.

PiperOrigin-RevId: 438145815
2022-03-29 15:48:33 -07:00
Arthur SfezandgVisor bot 21dffa8f4c Support sending TTL and HopLimit
PiperOrigin-RevId: 430554985
2022-02-23 15:40:37 -08:00
Arthur SfezandgVisor bot 9d5239e714 Rename ControlMessages type to indicate the cmsg direction
With the introduction of sendable control messages, the original cmsg type
is now renamed to ReceivableControlMessages.

PiperOrigin-RevId: 430319598
2022-02-22 16:18:16 -08:00
Fabricio VoznikaandgVisor bot dfcf798425 Fix epoll_ctl(2) regular files and dirs
Linux behaves differently for regular files and dirs for poll(2)/select(2)
compared to epoll_ctl(2). The latter returns EPERM for file and dirs.
I've also changed host FDs to behave like the underlying FD in regards
to epoll to keep it compatible with docker.

Fixes #7134

PiperOrigin-RevId: 429412692
2022-02-17 15:12:36 -08:00
Arthur SfezandgVisor bot 86ad7d5b58 Support receiving ttl/hoplimit control message
PiperOrigin-RevId: 429096959
2022-02-16 11:27:21 -08:00
Jing ChenandgVisor bot 2b2f9ea914 Use network protocol default ttl instead of a hardcoded one.
PiperOrigin-RevId: 423886874
2022-01-24 12:46:25 -08:00
Ghanan GowripalanandgVisor bot b488df0a2f Support SOL_IPV6 -> IPV6_CHECKSUM
PiperOrigin-RevId: 419164074
2021-12-31 21:33:15 -08:00
Arthur SfezandgVisor bot 58b9bdfc21 Use protocol-specific options for TTL/HopLimit
The new HopLimit matches the IPV6_UNICAST_HOPS socket option.

Updates #6389

PiperOrigin-RevId: 418831844
2021-12-29 12:33:48 -08:00
Ghanan GowripalanandgVisor bot beaecd1e3c Support SOL_ICMPV6 -> ICMPV6_FILTER
PiperOrigin-RevId: 417696519
2021-12-21 15:04:13 -08:00
Ghanan GowripalanandgVisor bot 5baf7212b7 Fix error getting IPv6 option on IPv4 socket
Previously returned ENOPROTOOPT but should return EOPNOTSUPP to match
Linux.

PiperOrigin-RevId: 416680620
2021-12-15 17:12:04 -08:00
Fabricio VoznikaandgVisor bot 9768009a79 Don't eat error from epoll_ctl EPOLL_CTL_ADD
Docker maps stdin to `/dev/null` which doesn't support epoll. Host FD
was ignoring the error and suceeding the epoll_ctl call from the
container, giving false impressing that epoll would be notified.

This required plumbing failure to all waiter.Waitable.EventRegister
callers and implementers.

Closes #6795

PiperOrigin-RevId: 414797621
2021-12-07 12:36:00 -08:00
Nayana BidariandgVisor bot 8777a4f8c6 Increment spurious recovery metric only for RTO.
PiperOrigin-RevId: 413504208
2021-12-01 14:00:10 -08:00
Kevin KrakauerandgVisor bot ce194f2c1c Automated rollback of changelist 407638912
PiperOrigin-RevId: 410665707
2021-11-17 17:07:05 -08:00
Adin ScannellandgVisor bot 91f58d2cc8 Update Waitable API.
Instead of passing the event mask at registratrion time, pass the mask as part
of the waiter. This makes the mask immutable and simplifies the architecture of
waiters. This is also necessary for a future fix that will allow the fdnotifier
to keep persistent entries, as opposed to requiring constant updates.

This change is intended to be a no-op in terms of function. The only exception
is signalfd, where this mask was abused. To handle this case, the operation of
signalfd changed to allow one layer of indirection.

PiperOrigin-RevId: 409702998
2021-11-13 12:54:39 -08:00
Ayush RanjanandgVisor bot ce4f4283ba Make {Un}Marshal{Bytes/Unsafe} return remaining buffer.
Change marshal.Marshallable method signatures to return the remaining buffer.
This makes it easier to implement these method manually. Without this, we would
have to manually do buffer shifting which is error prone.

tools/go_marshal/test:benchmark test does not show change in performance.
Additionally fixed some marshalling bugs in fsimpl/fuse.

Updated multiple callpoints to get rid of redundant slice indexing work and
simplified code using this new signature.

Updates #6450

PiperOrigin-RevId: 407857019
2021-11-05 10:43:49 -07:00
Zach KoopmansandgVisor bot 23a115dae8 [syserr] Reverse dependency for tcpip.Error
PiperOrigin-RevId: 407638912
2021-11-04 12:11:41 -07:00
Nick BrownandgVisor bot 22a6a37079 Record counts of packets with unknown L3/L4 numbers
Previously, we recorded a single aggregated count. These per-protocol counts
can help us debug field issues when frames are dropped for this reason.

PiperOrigin-RevId: 405913911
2021-10-27 10:06:55 -07:00
Nayana BidariandgVisor bot 487651ac46 Add a new metric to detect the number of spurious loss recoveries.
- Implements RFC 3522 (Eifel detection algorithm) to detect if the connection
entered loss recovery unnecessarily.
- Added a new metric to count the total number of spurious loss recoveries.
- Added tests to verify the new metric.

PiperOrigin-RevId: 401637359
2021-10-07 16:51:06 -07:00
Tamir DubersteinandgVisor bot a7045f051f Store timestamps as time.Time
Rather than boiling down to an integer eagerly, do it as late as possible.

PiperOrigin-RevId: 401599308
2021-10-07 14:04:55 -07:00
Ghanan GowripalanandgVisor bot 89a0011c10 Support IPV6_RECVPKTINFO on UDP sockets
PiperOrigin-RevId: 397631833
2021-09-19 13:15:28 -07:00
Ghanan GowripalanandgVisor bot 7dacdbef52 Allow rebinding packet socket protocol
...to change the network protocol a packet socket may receive packets
from.

This CL is a portion of an originally larger CL that was split with
https://github.com/google/gvisor/commit/a8ad692fd36cbaf7f5a6b9af39d601053dbee338
being the dependent CL. That CL (accidentally) included the change in
the endpoint's `afterLoad` method to take the required lock when
accessing the endpoint's netProto field. That change should have been in
this CL.

The CL that made the change mentioned in the commit message is
cl/396946187.

PiperOrigin-RevId: 397412582
2021-09-17 15:37:08 -07:00
Tony GongandgVisor bot 8b56b6b83b Pass address properties in a single struct
Replaced the current AddAddressWithOptions method with
AddAddressWithProperties which passes all address properties in
a single AddressProperties type. More properties that need to be
configured in the future are expected, so adding a type makes adding
them easier.

PiperOrigin-RevId: 396930729
2021-09-15 15:00:01 -07:00
Ghanan GowripalanandgVisor bot 149ca00967 [bind] Return EINVAL for under sized address
...and EAFNOSUPPORT for unexpected address family.

To comply with Linux.

Updates #6021, #6575.

PiperOrigin-RevId: 396893590
2021-09-15 12:20:51 -07:00
Ghanan GowripalanandgVisor bot ae3bd32011 Extract network datagram endpoint common facilities
...from the UDP endpoint.

Datagram-based transport endpoints (e.g. UDP, RAW IP) can share a lot
of their write path due to the datagram-based nature of these endpoints.
Extract the common facilities from UDP so they can be shared with other
transport endpoints (in a later change).

Test: UDP syscall tests.
PiperOrigin-RevId: 394347774
2021-09-01 17:12:24 -07:00