145 Commits
Author SHA1 Message Date
Jing Chen a093ad0450 Simplify and format gVisor codebase.
The changes are just output of `gofmt -s -w .`.
2024-10-13 00:50:32 -07:00
Andrei VaginandgVisor bot 3546fab741 netstack: choose route by longest prefix
It has to return the most specific route.

PiperOrigin-RevId: 647421535
2024-06-27 13:12:45 -07:00
Kevin KrakauerandgVisor bot 9f11a5b375 netstack: enable SACK by default
There's no reason not to turn this on. Leaving it off makes it possible for
users to miss it.

PiperOrigin-RevId: 634026749
2024-05-15 11:51:26 -07:00
Kevin KrakauerandgVisor bot 3c75945fd6 netstack: remove PacketBuffer.IsNil()
The change was originally motivated by ticket references (cl/450976957), which
were never implemented.

PiperOrigin-RevId: 617480960
2024-03-20 05:31:48 -07:00
Peter JohnstonandgVisor bot 21edc122da NAT source ports for locally generated traffic when necessary
Currently, when a packet hits the NAT table and does not hit any NAT targets,
its connection is assigned "no-op NAT", which basically means that the
connection will not be NATed. However, this causes a problem when, for example,
locally-generated traffic chooses a local port that has already been used by
forwarded traffic that the stack is NATing. In this case, the locally-generated
traffic will simply be dropped when the connection is finalized due to a tuple
conflict.

Instead of doing nothing, the netstack must implicitly perform SNAT for the
locally-generated traffic to remap its source port to prevent that traffic from
being dropped.

Also, when setting up NAT for a connection, the netstack checks if the
connections' reply tuple is unique to see whether it needs to rewrite the
transport-layer port/ID. This logic currently doesn't account for self-connected
sockets, where the original and reply tuples are identical and point to the same
connection; add logic handling that scenario, such that the reply tuple can be
non-unique if it refers to the same connection as the original tuple.

PiperOrigin-RevId: 612969884
2024-03-05 14:30:24 -08:00
Kevin KrakauerandgVisor bot 5b4fbd06d8 netstack: remove PacketBufferPtr
PacketBufferPtr is leftover from a dead experiment. Just use *PacketBuffer.

PiperOrigin-RevId: 611531815
2024-02-29 11:10:38 -08:00
Kevin KrakauerandgVisor bot 1ac6325b3b iptables: support address-only and port-only nat
Also fix the way we return target revision numbers.

Also also change some incorrect receiver names.

PiperOrigin-RevId: 582789755
2023-11-15 13:38:48 -08:00
Kevin KrakauerandgVisor bot 03d35d400f Automated rollback of changelist 580649803
PiperOrigin-RevId: 582102498
2023-11-13 15:30:48 -08:00
Kevin KrakauerandgVisor bot 40ee36ac4c Automated rollback of changelist 580051079
PiperOrigin-RevId: 580649803
2023-11-08 14:04:04 -08:00
Kevin KrakauerandgVisor bot b988b57921 runsc: reproduce NAT table inside gVisor only when non-default
... instead of depending on a flag.

In most cases the NAT table is in an all-ACCEPT default state:

```
root@5a7ce3a6c623:/# iptables -t nat -S
-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
```

In such cases we leave iptables off in the sandbox as a performance
optimization.

But when the table contains anything else, we now install those rules inside
the sandbox.

Turns out packetdrill installes a rule, so support for that rules is also added
in this CL.

PiperOrigin-RevId: 580051079
2023-11-06 22:05:48 -08:00
Andrei Vagin 5f4abad306 Fix a few typos
It is an idea of running codespell as part of our presubmit checks.
Before enabling it for new changes, let's fix what it has found.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2023-10-25 12:13:42 -07:00
Kevin KrakauerandgVisor bot 89d6bf18c8 have gVisor use renamed buffer package
PiperOrigin-RevId: 537209194
2023-06-01 21:27:49 -07:00
Kevin KrakauerandgVisor bot c3da0e4f0d Automated rollback of changelist 531020857
PiperOrigin-RevId: 532863869
2023-05-17 12:09:12 -07:00
Kevin KrakauerandgVisor bot 792ebbff8e netstack: make tcpip.Address hold a []byte
tcp_benchmark throughput increase 2-3%, but allocations go down (25% in the
download benchmark, only 2% in the upload path).

PiperOrigin-RevId: 532523146
2023-05-16 11:40:49 -07:00
Kevin KrakauerandgVisor bot 64268c8483 netstack: make tcpip.Address an opaque type
The important change here is in tcpip/tcpip.go, where tcpip.Address is defined.
The rest is updating uses of tcpip.Address.

This is preparation for netip.Addr or []byte based addresses, which should save
us a bunch of allocations. Currently, we allocate every time we want to, say,
get a tcpip.Address from a header. This is because the header is a byte slice,
but Address is a string. Strings are immutable, so Go allocates and copies.

PiperOrigin-RevId: 532284732
2023-05-15 18:07:03 -07:00
Kevin KrakauerandgVisor bot d207727b3a netstack: replace slice-based PacketBufferList with linked list
This is effectively a rollback of cl/450976957. The original motivation never
panned out, and it's easier to work with the lists. They also are easier to
avoid allocations with.

PiperOrigin-RevId: 531020857
2023-05-10 15:43:59 -07:00
Ghanan GowripalanandgVisor bot 44a287f858 Deflake TestWritePacketsLinkResolution
...by only sending one packet.

The stack does not guard against re-ordering and the test asserted on a
specific order of packets so only send one packet.

Note that this test does not need to send two packets so only sending
one is fine to test link resolution.

PiperOrigin-RevId: 514852179
2023-03-07 15:13:48 -08:00
Adin ScannellandgVisor bot 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Ghanan GowripalanandgVisor bot 34ff3ebe05 Help deflake TestTCPConfirmNeighborReachability
...by making sure all endpoints created by the test is properly closed
before the test fn returns. Previously, the listener endpoint was not.

PiperOrigin-RevId: 512129775
2023-02-24 12:06:04 -08:00
Ghanan GowripalanandgVisor bot 6526c169cd Help deflake TestTCPConfirmNeighborReachability
...by not assuming that the NUD event is available immediately after
receiving the readable signal from the TCP endpoint. The readable
signal may be triggered before the NUD event is sent.

PiperOrigin-RevId: 512120289
2023-02-24 11:30:25 -08:00
Lucas ManningandgVisor bot d3c86781ab Fix flaky link resolution test.
mointorableEndpoint was flaking because of a race between the
pending packet from the failed write and the new write. We don't
actually need the new write to show that link resolution worked.

PiperOrigin-RevId: 502699348
2023-01-17 15:08:27 -08:00
Ghanan GowripalanandgVisor bot 4632d45dd8 Perform MLDv2/IGMPv3 without SSM
This change introduces support for MLDv2/IGMPv3. Note that this change
does not yet introduce APIs to perform source filtering so SSM is not
yet supported. Also note that this change does not yet coalesce records
in a report as that will come in a follow-up.

Updates #8346

PiperOrigin-RevId: 501336347
2023-01-11 11:39:25 -08:00
Ghanan GowripalanandgVisor bot 8ebc4d767a Accept no buffer space errors when forwarding
The outgoing device queue may be full when forwarding packets and those
errors should not result in a panic.

PiperOrigin-RevId: 499946528
2023-01-05 11:16:56 -08:00
Andrei VaginandgVisor bot 1338761211 Fix reference leaks
PiperOrigin-RevId: 494027351
2022-12-08 16:38:26 -08:00
Ayush RanjanandgVisor bot 175db901ca Replace pkg/refs with pkg/refsvfs2.
All VFS1 only bits have been deleted.

Updates #1624

PiperOrigin-RevId: 492273183
2022-12-01 12:46:11 -08:00