14 Commits
Author SHA1 Message Date
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
Andrei VaginandgVisor bot e2e84bf5ba tcpip/link: use lockdep mutexes
PiperOrigin-RevId: 692004573
2024-10-31 18:56:13 -07:00
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
Nayana BidariandgVisor bot 979bbf238b Mark structs as savable in netstack.
PiperOrigin-RevId: 661475603
2024-08-09 18:26:06 -07:00
Andrei VaginandgVisor bot bcf4aeb94a tcpip/link/veth: don't report CapabilityTXChecksumOffload
While testing docker-in-gvisor, we found that veth devices with enabled
CapabilityTXChecksumOffload don't work as expected. Packets issued from the
gvisor sandbox have incorrect checksum-s.

PiperOrigin-RevId: 651157380
2024-07-10 14:43:54 -07:00
Lucas ManningandgVisor bot bd58900fba Change veth WritePackets to deep clone its list of packets.
The buffers from the buffer package are meant to be copy-on-write, but IP
headers still work with the underlying []byte, so writes are not tracked.
This allows data races in situations where packet buffers are shared
across goroutines.

PiperOrigin-RevId: 650429239
2024-07-08 17:49:45 -07:00
Andrei VaginandgVisor bot 9d1849029e tcpip/link/veth: don't send any packets if another end has been closed
Reported-by: syzbot+077cb394a25e5bfa4ed9@syzkaller.appspotmail.com
PiperOrigin-RevId: 650316007
2024-07-08 11:27:23 -07:00
Andrei VaginandgVisor bot b488752cba netstack: implement RTM_SETLINK/IFLA_NET_NS_FD
IFLA_NET_NS_FD specifies a file descriptor that refers to a network namespace.

PiperOrigin-RevId: 648882826
2024-07-02 16:49:27 -07:00
Jing ChenandgVisor bot 8ef3239b0b Add SetMTU to change the mtu of device.
The method will be primarily used with RTM_[NEW|SET]LINK when IFLA_MTU
is present.

PiperOrigin-RevId: 646264847
2024-06-24 16:58:13 -07:00
Andrei VaginandgVisor bot 646a033213 tcpip: destroy both ends of one veth pair together
PiperOrigin-RevId: 645562424
2024-06-21 18:50:54 -07:00
Jing ChenandgVisor bot 14c6ef6d52 Lock the mutex when reading a LinkAddress.
PiperOrigin-RevId: 645543579
2024-06-21 17:17:10 -07:00
Jing ChenandgVisor bot 2c5c7869d9 Add SetLinkAddress method to NetworkLinkEndpoint interface.
The method will be primarily used by IFLA_ADDRESS.

PiperOrigin-RevId: 642492748
2024-06-11 21:40:39 -07:00
Andrei VaginandgVisor bot 04e7902bb5 Implement veth devices
The veth devices are virtual Ethernet devices. They can act as
tunnels between network namespaces to create a bridge to a
physical network device in another namespace, but can also be
used as standalone network devices.

More information can be found here:
https://man7.org/linux/man-pages/man4/veth.4.html

PiperOrigin-RevId: 638853289
2024-05-30 18:25:30 -07:00