[parser] top-level action declarations (and out/inout write-back on action calls)

Aperta
#279 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
compilers

Direzione di ricerca

Start in p4/src/parser.rs at the top-level parser arm and parse_action, then inspect codegen/rust/src/statement.rs where lvalue arguments are cloned. Trace existing action parsing and code generation tests to find how top-level declarations and parameter write-back are covered. Done means top-level actions parse and out/inout mutations are reflected at call sites.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

This issue stems from oxidecomputer/sidecar-lite#152, where the IPv4 TTL decrement plus RFC 1624 incremental checksum update had to be copy-pasted into three P4 controls (router, NAT ingress, and mcast decap). In the review, @rcgoodfellow asked for a top-level action (declared once, called from each control). However, x4c does not support this today, so I was stuck with using a control ipv4_ttl_decrement(inout ipv4_h ip) with a TODO pointing here.

Two things block this fix in sidecar-lite (at aa0d3c8):

  1. The parser has no top-level action arm. The keyword falls through _ => {}, without an error, and parse_action is only reachable from inside a control body.

  2. Even once top-level actions can be parsed, an action call wouldn't write out/inout arguments back as is. When codegen'ed, the Rust output .clone()s every lvalue argument before the call, meaning that mutations inside the action exist only on the copy. Actions mutating hdr/metadata work currently because the control's own parameters are passed through by reference first. This clone only becomes an issue for an action's declared parameters.

Lingua principale
Rust
Stelle
140
Fork
14
Merge medio
3g 18h
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di oxidecomputer/p4

Tutte le issue di oxidecomputer/p4

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.