12 Commits
Author SHA1 Message Date
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
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
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
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
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 abd993f608 Don't pass link addresses in rx path
...as they are not used in all cases expect in the packet endpoint
which can get the link address directly from the link header.

PiperOrigin-RevId: 424427195
2022-01-26 13:24:35 -08:00
Lucas ManningandgVisor bot 4ce5c43a30 Add leak checking to qdisc and nested tests.
PiperOrigin-RevId: 422685326
2022-01-18 17:24:41 -08:00
Ting-Yu WangandgVisor bot 47515f4751 Migrate to PacketHeader API for PacketBuffer.
Formerly, when a packet is constructed or parsed, all headers are set by the
client code. This almost always involved prepending to pk.Header buffer or
trimming pk.Data portion. This is known to prone to bugs, due to the complexity
and number of the invariants assumed across netstack to maintain.

In the new PacketHeader API, client will call Push()/Consume() method to
construct/parse an outgoing/incoming packet. All invariants, such as slicing
and trimming, are maintained by the API itself.

NewPacketBuffer() is introduced to create new PacketBuffer. Zero value is no
longer valid.

PacketBuffer now assumes the packet is a concatenation of following portions:
* LinkHeader
* NetworkHeader
* TransportHeader
* Data
Any of them could be empty, or zero-length.

PiperOrigin-RevId: 326507688
2020-08-13 13:08:57 -07: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
Bruno Dal BoandgVisor bot 282a6aea1b Extract common nested LinkEndpoint pattern
... and unify logic for detached netsted endpoints.

sniffer.go caused crashes if a packet delivery is attempted when the dispatcher
is nil.

Extracted the endpoint nesting logic into a common composable type so it can be
used by the Fuchsia Netstack (the pattern is widespread there).

PiperOrigin-RevId: 317682842
2020-06-22 10:31:45 -07:00