oxidecomputer / oxidecomputer/ingot

`control` functions in parsers should take the innermost type

Open
#37 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
13
Forks
2
PR merge metrics
No merged PRs in 30d

Description

In parser specs like:

#[derive(Parse)]
pub struct GeneveOverV6<Q: ByteSlice> {
    pub outer_eth: EthernetPacket<Q>,
    pub outer_v6: Ipv6Packet<Q>,
    #[ingot(from = "L4<Q>", control = my_control_a)]
    pub outer_udp: UdpPacket<Q>,
    pub outer_encap: GenevePacket<Q>,

    pub inner_eth: EthernetPacket<Q>,
    pub inner_l3: L3<Q>,
    pub inner_ulp: Ulp<Q>,
}

#[derive(Parse)]
pub struct NoEncap<Q: ByteSlice> {
    #[ingot(control = exit_on_arp)]
    pub inner_eth: EthernetPacket<Q>,
    #[ingot(control = my_control_b)]
    pub inner_l3: Option<L3<Q>>,
    pub inner_ulp: Option<Ulp<Q>>,
}

my_control_a operates on a &ValidL4<V>, whereas my_control_b operates on a &Option<ValidL3<V>>. It would make more sense if these were &ValidUdp<V> and &ValidL3<V> respectively -- in the former case because we have filtered all other protocols in the from tag, and in the latter because we can only be called when the layer is Some().

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the derive(Parse) implementation and the parser-spec handling for the control and from attributes; trace how the control argument type is selected for direct and Option fields. Done means control functions receive the innermost valid type, such as &ValidUdp<V> and &ValidL3<V>, for both examples, with coverage for these cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.