-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test programs that had errors in their name annotations
and for some others, update the error messages we expect to see. Signed-off-by: Andy Fingerhut <[email protected]>
- Loading branch information
1 parent
bfa62ff
commit b062eaa
Showing
7 changed files
with
170 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
struct routing_metadata_t { | ||
bit<32> nhop_ipv4; | ||
} | ||
|
||
header ethernet_t { | ||
bit<48> dstAddr; | ||
bit<48> srcAddr; | ||
bit<16> etherType; | ||
} | ||
|
||
header ipv4_t { | ||
bit<4> version; | ||
bit<4> ihl; | ||
bit<8> diffserv; | ||
bit<16> totalLen; | ||
bit<16> identification; | ||
bit<3> flags; | ||
bit<13> fragOffset; | ||
bit<8> ttl; | ||
bit<8> protocol; | ||
bit<16> hdrChecksum; | ||
bit<32> srcAddr; | ||
bit<32> dstAddr; | ||
} | ||
|
||
struct metadata { | ||
@name("routing_metadata") | ||
routing_metadata_t routing_metadata; | ||
} | ||
|
||
struct headers { | ||
@name("ethernet") | ||
ethernet_t ethernet; | ||
@name("ipv4") | ||
ipv4_t ipv4; | ||
} | ||
|
||
parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { | ||
@name("parse_ethernet") state parse_ethernet { | ||
packet.extract(hdr.ethernet); | ||
transition select(hdr.ethernet.etherType) { | ||
16w0x800: parse_ipv4; | ||
default: accept; | ||
} | ||
} | ||
@name("parse_ipv4") state parse_ipv4 { | ||
packet.extract(hdr.ipv4); | ||
transition accept; | ||
} | ||
@name("start") state start { | ||
transition parse_ethernet; | ||
} | ||
} | ||
|
||
control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { | ||
@name(".rewrite_mac") action rewrite_mac(bit<48> smac) { | ||
hdr.ethernet.srcAddr = smac; | ||
} | ||
@name("._drop") action _drop() { | ||
mark_to_drop(standard_metadata); | ||
} | ||
@name("send_frame") table send_frame { | ||
actions = { | ||
rewrite_mac; | ||
_drop; | ||
} | ||
key = { | ||
standard_metadata.egress_port: exact; | ||
} | ||
size = 256; | ||
} | ||
apply { | ||
send_frame.apply(); | ||
} | ||
} | ||
|
||
control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { | ||
@name(".bcast") action bcast() { | ||
standard_metadata.mcast_grp = 1; | ||
} | ||
@name(".set_dmac") action set_dmac(bit<48> dmac) { | ||
hdr.ethernet.dstAddr = dmac; | ||
} | ||
@name("._drop") action _drop() { | ||
mark_to_drop(standard_metadata); | ||
} | ||
@name(".set_nhop") action set_nhop(bit<32> nhop_ipv4, bit<9> port) { | ||
meta.routing_metadata.nhop_ipv4 = nhop_ipv4; | ||
standard_metadata.egress_spec = port; | ||
hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; | ||
} | ||
@name(".set_nhop_redirect") action set_nhop_redirect(bit<32> nhop_ipv4, bit<9> port) { | ||
meta.routing_metadata.nhop_ipv4 = nhop_ipv4; | ||
standard_metadata.egress_spec = port; | ||
hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; | ||
} | ||
@name("broadcast") table broadcast { | ||
actions = { | ||
bcast; | ||
} | ||
size = 1; | ||
} | ||
@name("forward") table forward { | ||
actions = { | ||
set_dmac; | ||
_drop; | ||
} | ||
key = { | ||
meta.routing_metadata.nhop_ipv4: exact; | ||
} | ||
size = 512; | ||
} | ||
@name("ipv4_lpm") table ipv4_lpm { | ||
actions = { | ||
set_nhop; | ||
_drop; | ||
} | ||
key = { | ||
hdr.ipv4.dstAddr: lpm; | ||
} | ||
size = 1024; | ||
} | ||
apply { | ||
if (hdr.ipv4.isValid()) { | ||
ipv4_lpm.apply(); | ||
forward.apply(); | ||
} | ||
else { | ||
broadcast.apply(); | ||
} | ||
} | ||
} | ||
|
||
control DeparserImpl(packet_out packet, in headers hdr) { | ||
apply { | ||
packet.emit(hdr.ethernet); | ||
packet.emit(hdr.ipv4); | ||
} | ||
} | ||
|
||
control verifyChecksum(inout headers hdr, inout metadata meta) { | ||
apply { } | ||
} | ||
|
||
control computeChecksum(inout headers hdr, inout metadata meta) { | ||
apply { } | ||
} | ||
|
||
V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; |
8 changes: 6 additions & 2 deletions
8
testdata/p4_16_errors_outputs/issue1803_same_table_name.p4-stderr
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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
[--Werror=duplicate] error: Name 't0' is used for multiple table objects in the P4Info message | ||
[--Werror=duplicate] error: Found 1 duplicate name(s) in the P4Info | ||
issue1803_same_table_name.p4(19): [--Werror=duplicate] error: .t0: conflicting control plane name: .t0 | ||
table t0 { | ||
^^ | ||
issue1803_same_table_name.p4(19) | ||
table t0 { | ||
^^ |
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,6 @@ | ||
multicast-bmv2.p4(87): [--Werror=duplicate] error: ._drop: conflicting control plane name: ._drop | ||
@name("._drop") action _drop() { | ||
^^^^^ | ||
multicast-bmv2.p4(62) | ||
@name("._drop") action _drop() { | ||
^^^^^ |
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
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