@@ -78,6 +78,7 @@ for P4Runtime switches:
78
78
add-meter-config SWITCH MTR_TBL MTR_FLOW add packet mod meter config table entry
79
79
get-packet-mod-meter SWITCH MTR_TBL MTR_FLOW gets packet mod meter table entry
80
80
get-direct-pkt-mod-meter SWITCH MTR_TBL MTR_FLOW gets direct packet mod meter table entry
81
+ del-meter-config SWITCH MTR_TBL MTR_FLOW delete packet mod meter config table entry
81
82
"""
82
83
83
84
def usage():
@@ -1909,6 +1910,34 @@ def p4ctl_get_direct_pkt_mod_meter_entry(client, bridge, tbl_name, flow):
1909
1910
if entity.direct_meter_entry.table_entry.table_id == ce.table_entry.table_id:
1910
1911
print(_format_dme(entry.direct_meter_entry))
1911
1912
1913
+ @with_client
1914
+ def p4ctl_del_meter_config(client, bridge, tbl_name, flow):
1915
+ """
1916
+ del-meter-config SWITCH MTR_TBL MTR_FLOW
1917
+ Example:
1918
+ p4rt-ctl del-meter-config br0 my_control.meter1 "meter_id=2244878476,meter_index=10"
1919
+ """
1920
+ p4info = client.get_p4info()
1921
+ if not p4info:
1922
+ raise Exception("cannot retrieve P4Info from device {}".format(bridge))
1923
+
1924
+ helper = P4InfoHelper(p4info)
1925
+ entity = p4runtime_pb2.Entity()
1926
+ ce = entity.meter_entry
1927
+
1928
+ if ce is None:
1929
+ raise Exception("Cannot find meter_entry field in entity")
1930
+
1931
+ meter_id, index = parse_get_meter_flow(flow)
1932
+ ce.index.index = int(index)
1933
+ ce.meter_id = int(meter_id)
1934
+
1935
+ update = p4runtime_pb2.Update()
1936
+ update.type = p4runtime_pb2.Update.DELETE
1937
+ update.entity.meter_entry.CopyFrom(ce)
1938
+
1939
+ client.write_update(update)
1940
+
1912
1941
all_commands = {
1913
1942
"show": (p4ctl_show, 1),
1914
1943
"set-pipe": (p4ctl_set_pipe, 3),
@@ -1933,6 +1962,7 @@ all_commands = {
1933
1962
"add-meter-config" : (p4ctl_add_meter_config, 3),
1934
1963
"get-packet-mod-meter" : (p4ctl_get_packet_mod_meter_entry, 2),
1935
1964
"get-direct-pkt-mod-meter" : (p4ctl_get_direct_pkt_mod_meter_entry, 2)
1965
+ "del-meter-config" : (p4ctl_del_meter_config, 2)
1936
1966
}
1937
1967
1938
1968
0 commit comments