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
Catch tcpip.ErrClosedForSend errors while forwarding. This may occur if
an endpoint is being shutdown at the same time as it's being used to
forward a packet.
PiperOrigin-RevId: 695452542
Martian packets are dropped by default, but some setups require accepting them.
A rate limited log will help users quickly hone in on the issue, which is
otherwise unclear and time-consuming to debug.
PiperOrigin-RevId: 693487838
The helper function is deprecated. The package gvisor.dev/gvisor/pkg/rand
depends on crypto/rand which performs worse thatn math/rand, the changes
are fine since they are not at any gVisor's hot path.
The ultimate goal is to migrate math/rand to math/rand/v2.
Support for multicast forwarding was finished by nahurley@google.com in
commit 7d3a75fa60. These TODOs are no
longer applicable and can be removed
Updates #7338
PiperOrigin-RevId: 650748952
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
This new method allows checking for the existence of assigned addresses without
taking an extra reference that needs to be DecRefed. DecRef takes exclusive
locks. Contention on the addressState lock causes performance issues when
multiple goroutines are processing IP packets simultaneously. This isn't the
case today since IP processing is single threaded, but will be eventually.
PiperOrigin-RevId: 623567408
Cancel the delayed report job when operating in V2 mode (this already
happens in V1 mode) in MakeAllNonMemberLocked, which is called on
endpoint Disable. This prevents a panic inside the delayed report
job where it asserts that the protocol is enabled.
PiperOrigin-RevId: 588113303