24 Commits
Author SHA1 Message Date
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 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
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
Ghanan GowripalanandgVisor bot a7d4a785b5 Set LinkHeader for pkts sent by raw packet socket
Previously, when a packet was sent from a raw packet socket, the packet
buffer's link header was left unpopulated and the link header was only
found in the packet buffer's payload. This breaks the expectations of
LinkEndpoints which expect the link layer header to always be populated
when the link requires a header.

PiperOrigin-RevId: 542349445
2023-06-21 13:41:22 -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 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
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 2b208ac832 Set PktType for all Ethernet Packets
In preparation for improving ARP handling of gratuitous ARPs, set PktType in
regular inbound flow instead of only when handling packet sockets.

PiperOrigin-RevId: 501562322
2023-01-12 07:43:18 -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
Kevin KrakauerandgVisor bot 2b52af3592 netstack: have IncRef() return *PacketBuffer
This makes it clearer where the new ownership is occuring.

PiperOrigin-RevId: 450987161
2022-05-25 12:26:18 -07:00
Kevin KrakauerandgVisor bot 657b52920d netstack: replace PacketBufferList with slices
This has no impact on performance. It is in preparation for ticket references
(see final CL in the diffbase chain).

PiperOrigin-RevId: 450976957
2022-05-25 11:45:42 -07:00
Ghanan GowripalanandgVisor bot 4fcd3c77ea (Re)introduce packetsocket link endpoint
The packetsocket link endpoint is used to enable a packet endpoint to
receive packets right before they are sent to the driver for outgoing
packets or right after they are recieved from the driver for incoming
packets.

Before this change, only packets that are sent/received by the
`stack.nic` were delivered to packet endpoints. However, the packet
endpoint should also receive packets that don't reach `stack.nic`.
Such an example can be when the interface is bridged and an incoming
packet is sent out through a sibling bridge port instead of being
delivered to a `stack.nic`.

The packetsocket link endpoint must wrap a link endpoint that
populates the link headers for ingress packets. It should ideally
be placed as low in the link endpoint heirarchy as possible so that
packets are probed as close to device drivers as possible.

https://github.com/google/gvisor/commit/2d9b33c0fd7d812a7296cd71f14c03925f815f28
removed the original packetsocket link endpoint which only allowed
low-level capturing of outbound packets but not inbound packets.

The CL mentioned above is cl/395761629.

PiperOrigin-RevId: 424947620
2022-01-28 13:43:55 -08:00
Ghanan GowripalanandgVisor bot 2d9b33c0fd Remove link/packetsocket
This change removes NetworkDispatcher.DeliverOutboundPacket.

Since all packet writes go through the NIC (the only NetworkDispatcher),
we can deliver outgoing packets to interested packet endpoints before
writing the packet to the link endpoint as the stack expects that all
packets that get delivered to a link endpoint are transmitted on the
wire. That is, link endpoints no longer need to let the stack know when
it writes a packet as the stack already knows about the packet it writes
through a link endpoint.

PiperOrigin-RevId: 395761629
2021-09-09 12:34:54 -07:00
Ghanan GowripalanandgVisor bot 47bc115158 Only carry GSO options in the packet buffer
With this change, GSO options no longer needs to be passed around as
a function argument in the write path.

This change is done in preparation for a later change that defers
segmentation, and may change GSO options for a packet as it flows
down the stack.

Updates #170.

PiperOrigin-RevId: 369774872
2021-04-21 18:09:27 -07:00
Tamir DubersteinandgVisor bot 8d1afb4185 Change tcpip.Error to an interface
This makes it possible to add data to types that implement tcpip.Error.
ErrBadLinkEndpoint is removed as it is unused.

PiperOrigin-RevId: 354437314
2021-01-28 17:59:58 -08:00
Ghanan GowripalanandgVisor bot fd5b52c87f Only pass stack.Route's fields to LinkEndpoints
stack.Route is used to send network packets and resolve link addresses.
A LinkEndpoint does not need to do either of these and only needs the
route's fields at the time of the packet write request.

Since LinkEndpoints only need the route's fields when writing packets,
pass a stack.RouteInfo instead.

PiperOrigin-RevId: 352108405
2021-01-15 16:49:15 -08:00
Ghanan GowripalanandgVisor bot 55c7fe48d2 Populate EgressRoute, GSO, Netproto for batch writes
We loop over the list of packets anyways so setting these aren't
expensive.

Now that they are populated only by the link endpoint that uses them,
TCP does not need to.

PiperOrigin-RevId: 352090853
2021-01-15 15:03:47 -08:00
Peter JohnstonandgVisor bot 3ff1aef544 Make stack.Route thread safe
Currently we rely on the user to take the lock on the endpoint that owns the
route, in order to modify it safely. We can instead move
`Route.RemoteLinkAddress` under `Route`'s mutex, and allow non-locking and
thread-safe access to other fields of `Route`.

PiperOrigin-RevId: 345461586
2020-12-03 08:54:24 -08:00
Bhasker HariharanandgVisor bot 71bf90c55b Support for receiving outbound packets in AF_PACKET.
Updates #173

PiperOrigin-RevId: 322665518
2020-07-22 15:33:33 -07:00