131 Commits
Author SHA1 Message Date
Nayana BidariandgVisor bot 90266aa28a Netstack S/R: Mark all the structs in netstack as savable.
Marks the structs in netstack as savable. This does not change or break any
existing behavior as the netstack itself is not savable yet.

PiperOrigin-RevId: 635943481
2024-05-21 15:19:07 -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
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 83f75082e5 nestack: use cryptographically secure RNG when appropriate
This addresses an issue discovered by Inon Kaplan (PhD candidate in the
Hebrew University School of Computer Science and Engineering), Ron Even (BSc
graduate of Bar Ilan University) and Amit Klein (faculty member in the Hebrew
University School of Computer Science and Engineering). Details will be
provided in their paper, to be presented in a forthcoming academic conference.

Also:
- Add a secure RNG type to prevent mixing up with the default PRNG
- Give the PRNG the name `InsecureRNG` to make it more obvious to future
  contributors that some RNGs are inappropriate in certain instances.
- Some tests were injecting fake RNGs and had to be relaxed: they relied on the
  stack calling the RNG a specific number of times and in a specific order.
  That order is now changed, and is too brittle to unit test.
- Remove the double package comment in pkg/rand. The linter complains.
PiperOrigin-RevId: 577513723
2023-10-28 16:14:07 -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 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
Adin ScannellandgVisor bot 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Bruno Dal BoandgVisor bot a6fe4d1d8f Handle gratuitous ARP as unsolicited reply
A gratuitous ARP does not infer two-way connectivity and must not move neighbor
state to reachable.

PiperOrigin-RevId: 501645481
2023-01-12 13:07:15 -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
Kevin KrakauerandgVisor bot 4eca206fa4 netstack: introduce PacketBufferPtr
PiperOrigin-RevId: 479437464
2022-10-06 16:16:54 -07:00
Lucas ManningandgVisor bot 1f2b30d70c Refactor netstack to use bufferv2 instead of buffer.
This change has significant performance implications. bufferv2 is reference
counted and pooled, which alleviates heap/GC pressure. Below are the results
from running the iperf benchmark.

HEAD:
BenchmarkIperf/operation.Upload-16    1552  ns/op   46.6GiB total allocations
BenchmarkIperf/operation.Download-16  1114  ns/op   68.6GiB total allocations

w/ change:
BenchmarkIperf/operation.Upload-16    1139  ns/op (-27%)   1.41GiB total allocations (-97%)
BenchmarkIperf/operation.Download-16  753.2 ns/op (-33%)   706MiB  total allocations (-99%)

PiperOrigin-RevId: 462453185
2022-07-21 13:09:31 -07:00
Lucas ManningandgVisor bot e64458ff08 Remove VectorisedView everywhere.
PiperOrigin-RevId: 453471156
2022-06-07 10:36:23 -07:00
Lucas ManningandgVisor bot 6103b4b3b6 Replace VectorisedView in network endpoints.
PiperOrigin-RevId: 451267391
2022-05-26 16:25:30 -07:00
Kevin KrakauerandgVisor bot ef9e8d9131 netstack: switch from sync/atomic to atomicbitops for 32 bit values
PiperOrigin-RevId: 444446109
2022-04-25 20:41:26 -07:00
bemascandgVisor bot f375784d83 Add reference counting for packets in channel.Endpoint
This reduces GC pressure when using a TUN device or similar link.

Updates #6910

PiperOrigin-RevId: 431441991
2022-02-28 08:33:36 -08:00
Bhasker HariharanandgVisor bot 2822b56f30 Add Leak checking to arp tests.
Updates #6910

PiperOrigin-RevId: 429325291
2022-02-17 09:17:27 -08:00
Adin ScannellandgVisor bot 06ffd8eaa6 Add checklocks annotations for arp.
PiperOrigin-RevId: 423980993
2022-01-24 20:49:16 -08:00
Ghanan GowripalanandgVisor bot 196baa62ca Don't pass route info and net proto to write fns
...as the packet buffer already holds that information.

Updates #3810.
Fixes #6537.

PiperOrigin-RevId: 421898143
2022-01-14 13:23:22 -08:00
Lucas ManningandgVisor bot e511fc9092 Remove WritePacket from LinkEndpoint.
PiperOrigin-RevId: 418672809
2021-12-28 13:45:13 -08:00
Tamir DubersteinandgVisor bot b91cc35b40 Delete channel.PacketInfo
Updates #6537.

PiperOrigin-RevId: 417507096
2021-12-20 17:16:37 -08:00
Lucas ManningandgVisor bot fd89c0892b Remove WritePackets() from LinkEndpoint and NetworkEndpoint.
WritePackets ownership is hard to get right, especially when packets can
belong to multiple PacketBufferLists, and these lists are modified
concurrently. For example, in SendTCPBatch when the qdisc link layer was
enabled, packets could belong to multiple lists, like the batch list and the
original packet list.

If gvisor is concurrently processing a packet in a qdisc
batch and that same packet is in a list that is being DecRef'd in the original
SendTCPBatch() call, then that packet's entry can point to packets in the
batch rather than the ones in the original list. Since this is the only place
WritePackets() is used, it is reasonable to just use WritePacket instead.

PiperOrigin-RevId: 417432389
2021-12-20 10:22:17 -08:00
Lucas ManningandgVisor bot 84b38f4c6e Add reference counting to packet buffers.
PiperOrigin-RevId: 408426639
2021-11-08 13:28:38 -08: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
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
Tamir DubersteinandgVisor bot 30bca3270b Clean up warnings
- Typos
- Unused arguments
- Useless conversions

PiperOrigin-RevId: 376362730
2021-05-28 08:06:05 -07:00