Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion codegen/rust/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,9 +1000,11 @@ impl<'a> PipelineGenerator<'a> {
#(#parameter_refs),*
)
});
// Upserting an entry replaces any previous entry with a
// matching key
self.#tname
.entries
.insert(p4rs::table::TableEntry::<
.replace(p4rs::table::TableEntry::<
#n,
std::sync::Arc<dyn Fn(
#(#control_param_types),*
Expand Down
28 changes: 28 additions & 0 deletions test/src/mcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,34 @@ fn bitmap_ports_beyond_radix_ignored() -> Result<(), anyhow::Error> {
Ok(())
}

#[test]
fn upserting_key_replaces_action_and_params() {
let mut pipeline = main_pipeline::new(4);
let key = 0u16.to_le_bytes();

pipeline.add_ingress_bitmap_table_entry(
"set_bitmap",
&key,
&port_bitmap(16, &[1, 2]),
0,
);
pipeline.add_ingress_bitmap_table_entry(
"set_bitmap",
&key,
&port_bitmap(16, &[3]),
0,
);
assert_egress_ports(&mut pipeline, 0, &[3]);

pipeline.add_ingress_bitmap_table_entry(
"forward",
&key,
&1u16.to_le_bytes(),
0,
);
assert_egress_ports(&mut pipeline, 0, &[1]);
}

fn unicast_mac(port: u16) -> [u8; 6] {
let id = 0x20 + port as u8;
[0x02, 0x00, id, id, 0x00, 0x02]
Expand Down
Loading