1922 Commits
Author SHA1 Message Date
Lucas ManningandgVisor bot 9581066c30 Clone the packet during ipv6 processing.
PiperOrigin-RevId: 734359605
2025-03-06 18:22:11 -08:00
Nayana BidariandgVisor bot d01514263b Do not process ACKs when endpoint is in error state.
PiperOrigin-RevId: 734333026
2025-03-06 16:37:04 -08:00
Ayush RanjanandgVisor bot e161bec8dc Unlock fdbased.endpoint.mu before fdbased.endpoint.Wait().
This prevents the deadlock described in #11456.

Fixes #11456.

PiperOrigin-RevId: 725352718
2025-02-10 14:45:27 -08:00
Lucas ManningandgVisor bot faac8f36cd Add support for PACKET_STATISTICS.
PiperOrigin-RevId: 725271073
2025-02-10 10:46:54 -08:00
Lucas ManningandgVisor bot 9c490f813d Implement GetSockOpt PACKET_HDRLEN and add a test for tcpdump.
PiperOrigin-RevId: 724445536
2025-02-07 13:06:14 -08:00
Lucas ManningandgVisor bot da7cd03064 Lock around packet mmap fields.
Reported-by: syzbot+8c5b9e9c8d8461de5720@syzkaller.appspotmail.com
Reported-by: syzbot+c00a808d28d19d280100@syzkaller.appspotmail.com
Reported-by: syzbot+97cd0b713bc1200a6435@syzkaller.appspotmail.com
Reported-by: syzbot+818820ff483ccdfdba38@syzkaller.appspotmail.com
Reported-by: syzbot+e902091253f397e19066@syzkaller.appspotmail.com
Reported-by: syzbot+97a55be6c79e63dfdc08@syzkaller.appspotmail.com
Reported-by: syzbot+c6c25b1e0afa504bc315@syzkaller.appspotmail.com
PiperOrigin-RevId: 724055115
2025-02-06 13:34:33 -08:00
Lucas ManningandgVisor bot 6194338723 Add support for setting PACKET_VERSION for PACKET_MMAP.
tcpdump requires TPACKET_V2 to work properly.

PiperOrigin-RevId: 723670574
2025-02-05 15:19:34 -08:00
Lucas ManningandgVisor bot 83a4caf2a7 Implement MappablePacketEndpoint for PACKET_MMAP and add tests.
PiperOrigin-RevId: 723590936
2025-02-05 11:39:27 -08:00
Lucas ManningandgVisor bot 245345bddc Fix TOCTOU bug in sending packets with the experiment option header.
In cases where sendRaw runs concurrently with a setsocketopt that sets
the experiment option, it's possible to read a zero experiment option when
adjusting reserved header space and a non-zero experiment option when
sending the packet. This causes the sentry to panic when adding the IPv6
header.

PiperOrigin-RevId: 723303802
2025-02-04 18:30:02 -08:00
Lucas ManningandgVisor bot 198ac833f1 Create the interfaces for PACKET_MMAP endpoints to implement.
PiperOrigin-RevId: 721823737
2025-01-31 10:43:05 -08:00
Jing ChenandgVisor bot a500a2c751 Defalke test target pkg/tcpip/stack:bridge_test.
There is a race in the test between WritePacketToRemote and FindFDBEntry, even
though it rarely happens, we just enforce FindFDBEntry to wait for
WritePacketToRemote's completion here.

PiperOrigin-RevId: 721747159
2025-01-31 06:10:20 -08:00
Andrei Vagin f010ae01ac Fix a few typos 2025-01-29 21:16:51 -08:00
Kevin KrakauerandgVisor bot 1375c611d8 cleanup GRO TODOs
GRO is implemented. We don't need to leave TODOs for every possible
optimization.

PiperOrigin-RevId: 720613096
2025-01-28 10:02:54 -08:00
Lucas ManningandgVisor bot 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
Nayana BidariandgVisor bot cd31d0522a Enable netstack save/restore in cloud/gvisor by default.
PiperOrigin-RevId: 712978128
2025-01-07 11:19:26 -08:00
Nayana BidariandgVisor bot a3e5887415 Changes to support netstack save restore.
- Added a new Stats() method in inet.Stack to get the saved stats
during restore.
- Mark stack.nic, tcpip.Route and stack.addressState structs as "nosave".
These fields should not be saved because the IP addresses and routes can
change during restore and new configuration of routes and IP addresses will be
extracted from the restore spec and initialized in the saved stack.
- Changes in Restore() method in icmp, udp, tcp, packet and raw endpoint files
to support save restore of these endpoints. These changes are flag guarded by
the TESTONLY-save-restore-netstack flag.

PiperOrigin-RevId: 707639274
2024-12-18 12:52:22 -08:00
Lucas ManningandgVisor bot afa323bd30 Replace most instances of IncRef with Clone.
Incrementing the reference count of a packet as a means of granting ownership
is unsafe when the packet is shared across gorountines. The underlying buffer's
reference count is unchanged since it "technically" has the same owning
PacketBuffer, which means different goroutines operating on the underlying
buffer (and packet itself) race.

Clones are roughly as fast as IncRefs because the PacketBuffers allocate from
a pool and the underlying buffers are cloned with copy-on-write
semantics.

I've left IncRef in places where the original packet in obviously going out of
scope at the end of the function or in some tests.

Reported-by: syzbot+e026046f4bf8ad09ae1f@syzkaller.appspotmail.com
Reported-by: syzbot+559365d6050db4b30e0f@syzkaller.appspotmail.com
Reported-by: syzbot+63c78a2c88a5744c636b@syzkaller.appspotmail.com
PiperOrigin-RevId: 705676806
2024-12-12 17:09:40 -08:00
Jing ChenandgVisor bot c88ffa321e Returns ENOBUFS when writing to a veth device whose buffer is full.
A task is stuck when it keeps sendMsg w/o any recvMsg  until  the number of
message exceeds the buffer limit. The change also significantly bumps the
limit from 64 to 1000 for a larger buffer.

Reported-by: syzbot+8788f5c1ba95e12ab07d@syzkaller.appspotmail.com
Reported-by: syzbot+67759fceac0c30ece991@syzkaller.appspotmail.com
PiperOrigin-RevId: 704904404
2024-12-10 17:35:54 -08:00
Nayana BidariandgVisor bot 0335cf778d Remove TODOs for fields which are restored in netstack.
insecureRNG and secureRNG stack fields are restored in stack.afterLoad()
tcp processor fields are restored in tcp endpoint.Restore()

PiperOrigin-RevId: 704477536
2024-12-09 17:37:04 -08:00
Kevin KrakauerandgVisor bot 39406b00bf netstack: add checklocks to TCPSenderState and write list
The annotations are a bit messy, but:

- It's worth it for the safety.
- Annotations could be removed by flattening tcp.Endpoint. Its current layout
  is, I believe, related to the old "protocol goroutine" architecture.
- The annotations could be cut down by improving checklocksalias.

PiperOrigin-RevId: 704315794
2024-12-09 09:36:10 -08:00
Jing ChenandgVisor bot 54eb79b6e8 Acquire rlock when reading link address from the bridge.
It happens along with the other issue when the veth device buffer is full,
then the task is stuck and still have the bridge's lock (RLock) via
DeliverNetworkPacket. When the second task reads the bridge's MAC address,
it waits forever for the first task to release the rlock. Using RLock can
allow the concurrent access to the MAC address, it dones't have to be
blocked until the messages are sent.

Reported-by: syzbot+1d6d1d8f47eae4e308dc@syzkaller.appspotmail.com
PiperOrigin-RevId: 704163976
2024-12-08 23:47:51 -08:00
Lucas ManningandgVisor bot d16d0c71e1 Add method to forwarder to handle experiment option values.
PiperOrigin-RevId: 703625219
2024-12-06 14:59:02 -08:00
Lucas ManningandgVisor bot ddaa99e5d4 Ignore the length field when processing the experiment extension header.
Reported-by: syzbot+9970c3c1f330bc544966@syzkaller.appspotmail.com
PiperOrigin-RevId: 703588249
2024-12-06 12:57:06 -08:00
Kevin KrakauerandgVisor bot 70dc6ea4ce netstack: re-enable checkescape
This was enabled in cl/452137751 and accidentally turned back off in
cl/479437464 (probably me messing up a rebase).

PiperOrigin-RevId: 703146788
2024-12-05 09:46:14 -08:00
Lucas ManningandgVisor bot cd70b0a4c0 Add support for the experiment option header in IPv6.
PiperOrigin-RevId: 702771719
2024-12-04 10:25:30 -08:00