-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try to implement invalidation for the parser, too.
Signed-off-by: fruffy <[email protected]>
- Loading branch information
Showing
3 changed files
with
144 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
backends/p4tools/modules/testgen/targets/bmv2/test/p4-programs/bmv2_invalid_hu_2.p4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#include <v1model.p4> | ||
|
||
header opt_t { | ||
bit<8> opt; | ||
} | ||
|
||
header ethernet_t { | ||
bit<48> dst_addr; | ||
bit<48> src_addr; | ||
bit<16> eth_type; | ||
} | ||
|
||
header H { | ||
bit<8> a; | ||
bit<8> a1; | ||
bit<8> b; | ||
} | ||
|
||
header_union U { | ||
ethernet_t e; | ||
H h; | ||
} | ||
|
||
struct Headers { | ||
opt_t opt; | ||
U u; | ||
} | ||
|
||
struct Meta {} | ||
|
||
parser p(packet_in pkt, out Headers h, inout Meta meta, inout standard_metadata_t stdmeta) { | ||
state start { | ||
pkt.extract(h.opt); | ||
transition select(h.opt.opt) { | ||
0x0: parse_e; | ||
0x1: parse_h; | ||
default: accept; | ||
} | ||
} | ||
|
||
state parse_e { | ||
pkt.extract(h.u.e); | ||
transition invalidate; | ||
} | ||
|
||
state parse_h { | ||
pkt.extract(h.u.h); | ||
transition invalidate; | ||
} | ||
|
||
state invalidate { | ||
h.u.e.setInvalid(); | ||
transition accept; | ||
} | ||
} | ||
|
||
control vrfy(inout Headers h, inout Meta meta) { | ||
apply { } | ||
} | ||
|
||
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t s) { | ||
apply { | ||
} | ||
} | ||
|
||
control egress(inout Headers h, inout Meta m, inout standard_metadata_t s) { | ||
apply { } | ||
} | ||
|
||
control update(inout Headers h, inout Meta m) { | ||
apply { } | ||
} | ||
|
||
control deparser(packet_out pkt, in Headers h) { | ||
apply { | ||
pkt.emit(h); | ||
} | ||
} | ||
|
||
V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; |