Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for cloning packets whose underlying data is a B: ByteSlice. #1599

Open
Jeff-A-Martin opened this issue Aug 23, 2024 · 0 comments
Open
Labels
customer-request Documents customer requests.

Comments

@Jeff-A-Martin
Copy link

What is the name of your project?
Fuchsia netstack3

Please provide a link to your project (GitHub repository, crates.io page, etc).
https://cs.opensource.google/fuchsia/fuchsia/+/main:src/connectivity/network/netstack3/

What features would you like from zerocopy?
Netstack3 uses the packet-formats crate for parsing of various packet types, including IP Packets. For example, Ipv4Packet<B: Byteslice>, is a known-to-be-valid IPv4 packet backed by an underlying byte slice. There are instances in Netstack3 where an IP packet must be multiplexed, such as supporting multicast routing, where a received IP packet may need to be forwarded out of multiple interfaces. Each send needs the ability to mutate the packet (E.g. for things like Network Address Translation), so I'd like each send to get their own unique copy of the original packet.

I can do this today with something similar to:

let packet: Ipv4Packet<&mut [u8]> = {...};

let copy_of_data = packet.to_vec();
let new_buffer = packet::serialize::Buf::new(copy_of_data.as_mut(), ..);
let new_packet: Ipv4Packet<&mut [u8]> = packet::serialize::ParseBufferMut::parse_mut(new_buffer);

However, the parse on the final line is wasted work: we already know the bytes encompass a valid Ipv4Packet. I'd like to be able to clone the underlying data and construct a new Ipv4Packet that simply adopts the new data as assumed to be valid.

@Jeff-A-Martin Jeff-A-Martin added the customer-request Documents customer requests. label Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-request Documents customer requests.
Projects
None yet
Development

No branches or pull requests

1 participant