google / gvisor

Application Kernel for Containers
https://gvisor.dev
Apache License 2.0
15.53k stars 1.28k forks source link

Improve type safety for packet buffer #4549

Open ghananigans opened 3 years ago

ghananigans commented 3 years ago

The Packet buffer currently holds only fields that are only set by some layer and then read by layers above it. Lower layers "promise" to never touch upper layers' fields.

E.g. Network layer adds network layer information and transport layer uses that when processing a packet. The link layer never touches those fields.

We should consider improving the type safety of the packet buffer by wrapping lower layer types with a new type that has its layer's information.

E.g. Instead of

struct Packet {
    NetworkLayerInfo
    LinkLayerInfo

    pkt
}

We can use

struct LinkPacket {
    LinkLayerInfo

    pkt
}

struct NetworkPacket {
    NetworkLayerInfo
    LinkLayerInfo

    pkt
}

An alternative is to wrap lower layer types with another layer's type (LinkPacket in a NetworkPacket) or some other idea.

cc @tamird @hbhasker

github-actions[bot] commented 11 months ago

A friendly reminder that this issue had no activity for 120 days.

ayushr2 commented 11 months ago

@manninglucas is this still relevant?

manninglucas commented 11 months ago

I think it's more appropriate to have the enhancement label here. It's not really an issue right now, but could be a good idea to implement in the future. This idea also probably needs more detailed design work.