diff --git a/README.md b/README.md index 14dcc47..bd445f7 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ you get started with P4 programming, organized into several modules: * [P4Runtime](./exercises/p4runtime) 3. Monitoring and Debugging -* [Explicit Congestion Notification](./exercises/other/ecn) +* [Explicit Congestion Notification](./exercises/ecn) * [Multi-Hop Route Inspection](./exercises/mri) 4. Advanced Behavior diff --git a/exercises/basic/Makefile b/exercises/basic/Makefile index 463ae07..cfbeb16 100644 --- a/exercises/basic/Makefile +++ b/exercises/basic/Makefile @@ -1,5 +1,5 @@ BMV2_SWITCH_EXE = simple_switch_grpc NO_P4 = true -P4C_ARGS = --p4runtime-file $(basename $@).p4info --p4runtime-format text +P4C_ARGS = --p4runtime-files $(basename $@).p4.p4info.txt include ../../utils/Makefile diff --git a/exercises/basic/basic.p4 b/exercises/basic/basic.p4 index 8b89237..23307e7 100644 --- a/exercises/basic/basic.p4 +++ b/exercises/basic/basic.p4 @@ -75,7 +75,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { action drop() { - mark_to_drop(); + mark_to_drop(standard_metadata); } action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) { diff --git a/exercises/basic/s1-runtime.json b/exercises/basic/s1-runtime.json index c773b63..7500c80 100644 --- a/exercises/basic/s1-runtime.json +++ b/exercises/basic/s1-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/basic.p4info", + "p4info": "build/basic.p4.p4info.txt", "bmv2_json": "build/basic.json", "table_entries": [ { diff --git a/exercises/basic/s2-runtime.json b/exercises/basic/s2-runtime.json index 554992e..a8a4e9b 100644 --- a/exercises/basic/s2-runtime.json +++ b/exercises/basic/s2-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/basic.p4info", + "p4info": "build/basic.p4.p4info.txt", "bmv2_json": "build/basic.json", "table_entries": [ { diff --git a/exercises/basic/s3-runtime.json b/exercises/basic/s3-runtime.json index 52ea470..0d7f0bd 100644 --- a/exercises/basic/s3-runtime.json +++ b/exercises/basic/s3-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/basic.p4info", + "p4info": "build/basic.p4.p4info.txt", "bmv2_json": "build/basic.json", "table_entries": [ { diff --git a/exercises/basic/solution/basic.p4 b/exercises/basic/solution/basic.p4 index 02a5cab..09899f3 100644 --- a/exercises/basic/solution/basic.p4 +++ b/exercises/basic/solution/basic.p4 @@ -87,7 +87,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { action drop() { - mark_to_drop(); + mark_to_drop(standard_metadata); } action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) { diff --git a/exercises/basic_tunnel/Makefile b/exercises/basic_tunnel/Makefile index 463ae07..cfbeb16 100644 --- a/exercises/basic_tunnel/Makefile +++ b/exercises/basic_tunnel/Makefile @@ -1,5 +1,5 @@ BMV2_SWITCH_EXE = simple_switch_grpc NO_P4 = true -P4C_ARGS = --p4runtime-file $(basename $@).p4info --p4runtime-format text +P4C_ARGS = --p4runtime-files $(basename $@).p4.p4info.txt include ../../utils/Makefile diff --git a/exercises/basic_tunnel/basic_tunnel.p4 b/exercises/basic_tunnel/basic_tunnel.p4 index bc31b4c..a8b1bc5 100644 --- a/exercises/basic_tunnel/basic_tunnel.p4 +++ b/exercises/basic_tunnel/basic_tunnel.p4 @@ -99,7 +99,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { action drop() { - mark_to_drop(); + mark_to_drop(standard_metadata); } action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) { diff --git a/exercises/basic_tunnel/s1-runtime.json b/exercises/basic_tunnel/s1-runtime.json index 2d3feaf..d54bfa6 100644 --- a/exercises/basic_tunnel/s1-runtime.json +++ b/exercises/basic_tunnel/s1-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/basic_tunnel.p4info", + "p4info": "build/basic_tunnel.p4.p4info.txt", "bmv2_json": "build/basic_tunnel.json", "table_entries": [ { diff --git a/exercises/basic_tunnel/s2-runtime.json b/exercises/basic_tunnel/s2-runtime.json index 62a7c52..74e3716 100644 --- a/exercises/basic_tunnel/s2-runtime.json +++ b/exercises/basic_tunnel/s2-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/basic_tunnel.p4info", + "p4info": "build/basic_tunnel.p4.p4info.txt", "bmv2_json": "build/basic_tunnel.json", "table_entries": [ { diff --git a/exercises/basic_tunnel/s3-runtime.json b/exercises/basic_tunnel/s3-runtime.json index f5e1b8c..6bd82dc 100644 --- a/exercises/basic_tunnel/s3-runtime.json +++ b/exercises/basic_tunnel/s3-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/basic_tunnel.p4info", + "p4info": "build/basic_tunnel.p4.p4info.txt", "bmv2_json": "build/basic_tunnel.json", "table_entries": [ { diff --git a/exercises/basic_tunnel/solution/basic_tunnel.p4 b/exercises/basic_tunnel/solution/basic_tunnel.p4 index de1afd2..3402307 100644 --- a/exercises/basic_tunnel/solution/basic_tunnel.p4 +++ b/exercises/basic_tunnel/solution/basic_tunnel.p4 @@ -103,7 +103,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { action drop() { - mark_to_drop(); + mark_to_drop(standard_metadata); } action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) { diff --git a/exercises/other/ecn/Makefile b/exercises/ecn/Makefile similarity index 51% rename from exercises/other/ecn/Makefile rename to exercises/ecn/Makefile index 463ae07..cfbeb16 100644 --- a/exercises/other/ecn/Makefile +++ b/exercises/ecn/Makefile @@ -1,5 +1,5 @@ BMV2_SWITCH_EXE = simple_switch_grpc NO_P4 = true -P4C_ARGS = --p4runtime-file $(basename $@).p4info --p4runtime-format text +P4C_ARGS = --p4runtime-files $(basename $@).p4.p4info.txt include ../../utils/Makefile diff --git a/exercises/other/ecn/README.md b/exercises/ecn/README.md similarity index 100% rename from exercises/other/ecn/README.md rename to exercises/ecn/README.md diff --git a/exercises/other/ecn/ecn.p4 b/exercises/ecn/ecn.p4 similarity index 99% rename from exercises/other/ecn/ecn.p4 rename to exercises/ecn/ecn.p4 index 112c652..2b2a346 100644 --- a/exercises/other/ecn/ecn.p4 +++ b/exercises/ecn/ecn.p4 @@ -91,7 +91,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { action drop() { - mark_to_drop(); + mark_to_drop(standard_metadata); } action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) { diff --git a/exercises/other/ecn/receive.py b/exercises/ecn/receive.py similarity index 100% rename from exercises/other/ecn/receive.py rename to exercises/ecn/receive.py diff --git a/exercises/other/ecn/s1-runtime.json b/exercises/ecn/s1-runtime.json similarity index 96% rename from exercises/other/ecn/s1-runtime.json rename to exercises/ecn/s1-runtime.json index d0774dc..1fe6368 100644 --- a/exercises/other/ecn/s1-runtime.json +++ b/exercises/ecn/s1-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/ecn.p4info", + "p4info": "build/ecn.p4.p4info.txt", "bmv2_json": "build/ecn.json", "table_entries": [ { diff --git a/exercises/other/ecn/s2-runtime.json b/exercises/ecn/s2-runtime.json similarity index 96% rename from exercises/other/ecn/s2-runtime.json rename to exercises/ecn/s2-runtime.json index e87b726..1b5b218 100644 --- a/exercises/other/ecn/s2-runtime.json +++ b/exercises/ecn/s2-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/ecn.p4info", + "p4info": "build/ecn.p4.p4info.txt", "bmv2_json": "build/ecn.json", "table_entries": [ { diff --git a/exercises/other/ecn/s3-runtime.json b/exercises/ecn/s3-runtime.json similarity index 95% rename from exercises/other/ecn/s3-runtime.json rename to exercises/ecn/s3-runtime.json index f0d3d5c..8a7af79 100644 --- a/exercises/other/ecn/s3-runtime.json +++ b/exercises/ecn/s3-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/ecn.p4info", + "p4info": "build/ecn.p4.p4info.txt", "bmv2_json": "build/ecn.json", "table_entries": [ { diff --git a/exercises/other/ecn/send.py b/exercises/ecn/send.py similarity index 100% rename from exercises/other/ecn/send.py rename to exercises/ecn/send.py diff --git a/exercises/other/ecn/setup.png b/exercises/ecn/setup.png similarity index 100% rename from exercises/other/ecn/setup.png rename to exercises/ecn/setup.png diff --git a/exercises/other/ecn/solution/ecn.p4 b/exercises/ecn/solution/ecn.p4 similarity index 99% rename from exercises/other/ecn/solution/ecn.p4 rename to exercises/ecn/solution/ecn.p4 index 2aebe20..b18fa16 100644 --- a/exercises/other/ecn/solution/ecn.p4 +++ b/exercises/ecn/solution/ecn.p4 @@ -89,7 +89,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { action drop() { - mark_to_drop(); + mark_to_drop(standard_metadata); } action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) { diff --git a/exercises/other/ecn/topology.json b/exercises/ecn/topology.json similarity index 100% rename from exercises/other/ecn/topology.json rename to exercises/ecn/topology.json diff --git a/exercises/load_balance/Makefile b/exercises/load_balance/Makefile index 463ae07..cfbeb16 100644 --- a/exercises/load_balance/Makefile +++ b/exercises/load_balance/Makefile @@ -1,5 +1,5 @@ BMV2_SWITCH_EXE = simple_switch_grpc NO_P4 = true -P4C_ARGS = --p4runtime-file $(basename $@).p4info --p4runtime-format text +P4C_ARGS = --p4runtime-files $(basename $@).p4.p4info.txt include ../../utils/Makefile diff --git a/exercises/load_balance/load_balance.p4 b/exercises/load_balance/load_balance.p4 index 54dfed6..ce8456c 100644 --- a/exercises/load_balance/load_balance.p4 +++ b/exercises/load_balance/load_balance.p4 @@ -99,7 +99,7 @@ control MyIngress(inout headers hdr, inout standard_metadata_t standard_metadata) { action drop() { - mark_to_drop(); + mark_to_drop(standard_metadata); } action set_ecmp_select(bit<16> ecmp_base, bit<32> ecmp_count) { /* TODO: hash on 5-tuple and save the hash result in meta.ecmp_select @@ -151,7 +151,7 @@ control MyEgress(inout headers hdr, hdr.ethernet.srcAddr = smac; } action drop() { - mark_to_drop(); + mark_to_drop(standard_metadata); } table send_frame { key = { diff --git a/exercises/load_balance/s1-runtime.json b/exercises/load_balance/s1-runtime.json index b5aebd7..6df3b38 100644 --- a/exercises/load_balance/s1-runtime.json +++ b/exercises/load_balance/s1-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/load_balance.p4info", + "p4info": "build/load_balance.p4.p4info.txt", "bmv2_json": "build/load_balance.json", "table_entries": [ { diff --git a/exercises/load_balance/s2-runtime.json b/exercises/load_balance/s2-runtime.json index c53ff39..0ac9046 100644 --- a/exercises/load_balance/s2-runtime.json +++ b/exercises/load_balance/s2-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/load_balance.p4info", + "p4info": "build/load_balance.p4.p4info.txt", "bmv2_json": "build/load_balance.json", "table_entries": [ { diff --git a/exercises/load_balance/s3-runtime.json b/exercises/load_balance/s3-runtime.json index 9292efd..daad210 100644 --- a/exercises/load_balance/s3-runtime.json +++ b/exercises/load_balance/s3-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/load_balance.p4info", + "p4info": "build/load_balance.p4.p4info.txt", "bmv2_json": "build/load_balance.json", "table_entries": [ { diff --git a/exercises/load_balance/solution/load_balance.p4 b/exercises/load_balance/solution/load_balance.p4 index 64d9bcb..ebfbc12 100644 --- a/exercises/load_balance/solution/load_balance.p4 +++ b/exercises/load_balance/solution/load_balance.p4 @@ -99,7 +99,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { action drop() { - mark_to_drop(); + mark_to_drop(standard_metadata); } action set_ecmp_select(bit<16> ecmp_base, bit<32> ecmp_count) { hash(meta.ecmp_select, @@ -158,7 +158,7 @@ control MyEgress(inout headers hdr, hdr.ethernet.srcAddr = smac; } action drop() { - mark_to_drop(); + mark_to_drop(standard_metadata); } table send_frame { key = { diff --git a/exercises/mri/Makefile b/exercises/mri/Makefile index 463ae07..cfbeb16 100644 --- a/exercises/mri/Makefile +++ b/exercises/mri/Makefile @@ -1,5 +1,5 @@ BMV2_SWITCH_EXE = simple_switch_grpc NO_P4 = true -P4C_ARGS = --p4runtime-file $(basename $@).p4info --p4runtime-format text +P4C_ARGS = --p4runtime-files $(basename $@).p4.p4info.txt include ../../utils/Makefile diff --git a/exercises/mri/mri.p4 b/exercises/mri/mri.p4 index bdc238d..1d4bee4 100644 --- a/exercises/mri/mri.p4 +++ b/exercises/mri/mri.p4 @@ -161,7 +161,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { action drop() { - mark_to_drop(); + mark_to_drop(standard_metadata); } action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) { diff --git a/exercises/mri/s1-runtime.json b/exercises/mri/s1-runtime.json index 2105f52..ed5651f 100644 --- a/exercises/mri/s1-runtime.json +++ b/exercises/mri/s1-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/mri.p4info", + "p4info": "build/mri.p4.p4info.txt", "bmv2_json": "build/mri.json", "table_entries": [ { diff --git a/exercises/mri/s2-runtime.json b/exercises/mri/s2-runtime.json index 9e9b945..75a38d5 100644 --- a/exercises/mri/s2-runtime.json +++ b/exercises/mri/s2-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/mri.p4info", + "p4info": "build/mri.p4.p4info.txt", "bmv2_json": "build/mri.json", "table_entries": [ { diff --git a/exercises/mri/s3-runtime.json b/exercises/mri/s3-runtime.json index c1ceef9..2b91bca 100644 --- a/exercises/mri/s3-runtime.json +++ b/exercises/mri/s3-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/mri.p4info", + "p4info": "build/mri.p4.p4info.txt", "bmv2_json": "build/mri.json", "table_entries": [ { diff --git a/exercises/mri/solution/mri.p4 b/exercises/mri/solution/mri.p4 index 9827ffb..6b108b5 100644 --- a/exercises/mri/solution/mri.p4 +++ b/exercises/mri/solution/mri.p4 @@ -153,7 +153,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { action drop() { - mark_to_drop(); + mark_to_drop(standard_metadata); } action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) { diff --git a/exercises/p4runtime/Makefile b/exercises/p4runtime/Makefile index 463ae07..cfbeb16 100644 --- a/exercises/p4runtime/Makefile +++ b/exercises/p4runtime/Makefile @@ -1,5 +1,5 @@ BMV2_SWITCH_EXE = simple_switch_grpc NO_P4 = true -P4C_ARGS = --p4runtime-file $(basename $@).p4info --p4runtime-format text +P4C_ARGS = --p4runtime-files $(basename $@).p4.p4info.txt include ../../utils/Makefile diff --git a/exercises/p4runtime/advanced_tunnel.p4 b/exercises/p4runtime/advanced_tunnel.p4 index 5ea8fc0..f049468 100755 --- a/exercises/p4runtime/advanced_tunnel.p4 +++ b/exercises/p4runtime/advanced_tunnel.p4 @@ -108,7 +108,7 @@ control MyIngress(inout headers hdr, counter(MAX_TUNNEL_ID, CounterType.packets_and_bytes) egressTunnelCounter; action drop() { - mark_to_drop(); + mark_to_drop(standard_metadata); } action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) { diff --git a/exercises/p4runtime/mycontroller.py b/exercises/p4runtime/mycontroller.py index 8c82460..866d668 100755 --- a/exercises/p4runtime/mycontroller.py +++ b/exercises/p4runtime/mycontroller.py @@ -190,7 +190,7 @@ if __name__ == '__main__': parser = argparse.ArgumentParser(description='P4Runtime Controller') parser.add_argument('--p4info', help='p4info proto in text format from p4c', type=str, action="store", required=False, - default='./build/advanced_tunnel.p4info') + default='./build/advanced_tunnel.p4.p4info.txt') parser.add_argument('--bmv2-json', help='BMv2 JSON file from p4c', type=str, action="store", required=False, default='./build/advanced_tunnel.json') diff --git a/exercises/p4runtime/solution/mycontroller.py b/exercises/p4runtime/solution/mycontroller.py index 40bba5a..1add68a 100755 --- a/exercises/p4runtime/solution/mycontroller.py +++ b/exercises/p4runtime/solution/mycontroller.py @@ -215,7 +215,7 @@ if __name__ == '__main__': parser = argparse.ArgumentParser(description='P4Runtime Controller') parser.add_argument('--p4info', help='p4info proto in text format from p4c', type=str, action="store", required=False, - default='./build/advanced_tunnel.p4info') + default='./build/advanced_tunnel.p4.p4info.txt') parser.add_argument('--bmv2-json', help='BMv2 JSON file from p4c', type=str, action="store", required=False, default='./build/advanced_tunnel.json') diff --git a/exercises/source_routing/Makefile b/exercises/source_routing/Makefile index 463ae07..cfbeb16 100644 --- a/exercises/source_routing/Makefile +++ b/exercises/source_routing/Makefile @@ -1,5 +1,5 @@ BMV2_SWITCH_EXE = simple_switch_grpc NO_P4 = true -P4C_ARGS = --p4runtime-file $(basename $@).p4info --p4runtime-format text +P4C_ARGS = --p4runtime-files $(basename $@).p4.p4info.txt include ../../utils/Makefile diff --git a/exercises/source_routing/s1-runtime.json b/exercises/source_routing/s1-runtime.json index a8ed4c0..6408c0c 100644 --- a/exercises/source_routing/s1-runtime.json +++ b/exercises/source_routing/s1-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/source_routing.p4info", + "p4info": "build/source_routing.p4.p4info.txt", "bmv2_json": "build/source_routing.json", "table_entries": [ ] } diff --git a/exercises/source_routing/s2-runtime.json b/exercises/source_routing/s2-runtime.json index a8ed4c0..6408c0c 100644 --- a/exercises/source_routing/s2-runtime.json +++ b/exercises/source_routing/s2-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/source_routing.p4info", + "p4info": "build/source_routing.p4.p4info.txt", "bmv2_json": "build/source_routing.json", "table_entries": [ ] } diff --git a/exercises/source_routing/s3-runtime.json b/exercises/source_routing/s3-runtime.json index a8ed4c0..6408c0c 100644 --- a/exercises/source_routing/s3-runtime.json +++ b/exercises/source_routing/s3-runtime.json @@ -1,6 +1,6 @@ { "target": "bmv2", - "p4info": "build/source_routing.p4info", + "p4info": "build/source_routing.p4.p4info.txt", "bmv2_json": "build/source_routing.json", "table_entries": [ ] } diff --git a/exercises/source_routing/solution/source_routing.p4 b/exercises/source_routing/solution/source_routing.p4 index 30c497b..31db3bb 100644 --- a/exercises/source_routing/solution/source_routing.p4 +++ b/exercises/source_routing/solution/source_routing.p4 @@ -106,7 +106,7 @@ control MyIngress(inout headers hdr, inout standard_metadata_t standard_metadata) { action drop() { - mark_to_drop(); + mark_to_drop(standard_metadata); } action srcRoute_nhop() { diff --git a/exercises/source_routing/source_routing.p4 b/exercises/source_routing/source_routing.p4 index a84479e..4c3b754 100644 --- a/exercises/source_routing/source_routing.p4 +++ b/exercises/source_routing/source_routing.p4 @@ -110,7 +110,7 @@ control MyIngress(inout headers hdr, inout standard_metadata_t standard_metadata) { action drop() { - mark_to_drop(); + mark_to_drop(standard_metadata); } action srcRoute_nhop() { diff --git a/utils/p4runtime_lib/error_utils.py b/utils/p4runtime_lib/error_utils.py index c3d523d..487c98e 100644 --- a/utils/p4runtime_lib/error_utils.py +++ b/utils/p4runtime_lib/error_utils.py @@ -17,7 +17,8 @@ import sys from google.rpc import status_pb2, code_pb2 import grpc -from p4 import p4runtime_pb2 +from p4.v1 import p4runtime_pb2 +from p4.v1 import p4runtime_pb2_grpc # Used to indicate that the gRPC error Status object returned by the server has # an incorrect format. diff --git a/utils/p4runtime_lib/helper.py b/utils/p4runtime_lib/helper.py index 235b8d1..e2dc2f7 100644 --- a/utils/p4runtime_lib/helper.py +++ b/utils/p4runtime_lib/helper.py @@ -15,8 +15,8 @@ import re import google.protobuf.text_format -from p4 import p4runtime_pb2 -from p4.config import p4info_pb2 +from p4.v1 import p4runtime_pb2 +from p4.config.v1 import p4info_pb2 from convert import encode @@ -97,10 +97,7 @@ class P4InfoHelper(object): p4runtime_match = p4runtime_pb2.FieldMatch() p4runtime_match.field_id = p4info_match.id match_type = p4info_match.match_type - if match_type == p4info_pb2.MatchField.VALID: - valid = p4runtime_match.valid - valid.value = bool(value) - elif match_type == p4info_pb2.MatchField.EXACT: + if match_type == p4info_pb2.MatchField.EXACT: exact = p4runtime_match.exact exact.value = encode(value, bitwidth) elif match_type == p4info_pb2.MatchField.LPM: diff --git a/utils/p4runtime_lib/switch.py b/utils/p4runtime_lib/switch.py index be330c3..3f662f2 100644 --- a/utils/p4runtime_lib/switch.py +++ b/utils/p4runtime_lib/switch.py @@ -17,7 +17,8 @@ from abc import abstractmethod from datetime import datetime import grpc -from p4 import p4runtime_pb2 +from p4.v1 import p4runtime_pb2 +from p4.v1 import p4runtime_pb2_grpc from p4.tmp import p4config_pb2 MSG_LOG_MAX_LEN = 1024 @@ -41,7 +42,7 @@ class SwitchConnection(object): if proto_dump_file is not None: interceptor = GrpcRequestLogger(proto_dump_file) self.channel = grpc.intercept_channel(self.channel, interceptor) - self.client_stub = p4runtime_pb2.P4RuntimeStub(self.channel) + self.client_stub = p4runtime_pb2_grpc.P4RuntimeStub(self.channel) self.requests_stream = IterableQueue() self.stream_msg_resp = self.client_stub.StreamChannel(iter(self.requests_stream)) self.proto_dump_file = proto_dump_file @@ -89,7 +90,10 @@ class SwitchConnection(object): request.device_id = self.device_id request.election_id.low = 1 update = request.updates.add() - update.type = p4runtime_pb2.Update.INSERT + if table_entry.is_default_action: + update.type = p4runtime_pb2.Update.MODIFY + else: + update.type = p4runtime_pb2.Update.INSERT update.entity.table_entry.CopyFrom(table_entry) if dry_run: print "P4Runtime Write:", request diff --git a/vm/user-bootstrap.sh b/vm/user-bootstrap.sh index c33784a..3332f4c 100755 --- a/vm/user-bootstrap.sh +++ b/vm/user-bootstrap.sh @@ -5,9 +5,9 @@ set -x # Exit on errors. set -e -BMV2_COMMIT="7e25eeb19d01eee1a8e982dc7ee90ee438c10a05" -PI_COMMIT="219b3d67299ec09b49f433d7341049256ab5f512" -P4C_COMMIT="48a57a6ae4f96961b74bd13f6bdeac5add7bb815" +BMV2_COMMIT="884e01b531c6fd078cc2438a40258ecae011a65b" # Apr 24, 2019 +PI_COMMIT="19de33e83bae7b737a3f8a1c9507c6e84173d96f" # Apr 24, 2019 +P4C_COMMIT="61409c890c58d14ec7d6790f263eb44f393e542a" # Apr 24, 2019 PROTOBUF_COMMIT="v3.2.0" GRPC_COMMIT="v1.3.2" @@ -106,7 +106,7 @@ mkdir -p build cd build cmake .. make -j${NUM_CORES} -make -j${NUM_CORES} check +# make -j${NUM_CORES} check <- skip tests as p4c tests are failing currently sudo make install sudo ldconfig cd ..