Skip to content

Commit ddbe49f

Browse files
authored
Merge branch 'main' into fix_docs
2 parents 45ded65 + 997dc0f commit ddbe49f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

clients/p4rt-ctl/p4rt-ctl.in

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ for P4Runtime switches:
7878
add-meter-config SWITCH MTR_TBL MTR_FLOW add packet mod meter config table entry
7979
get-packet-mod-meter SWITCH MTR_TBL MTR_FLOW gets packet mod meter table entry
8080
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
8182
"""
8283

8384
def usage():
@@ -1909,6 +1910,34 @@ def p4ctl_get_direct_pkt_mod_meter_entry(client, bridge, tbl_name, flow):
19091910
if entity.direct_meter_entry.table_entry.table_id == ce.table_entry.table_id:
19101911
print(_format_dme(entry.direct_meter_entry))
19111912

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+
19121941
all_commands = {
19131942
"show": (p4ctl_show, 1),
19141943
"set-pipe": (p4ctl_set_pipe, 3),
@@ -1933,6 +1962,7 @@ all_commands = {
19331962
"add-meter-config" : (p4ctl_add_meter_config, 3),
19341963
"get-packet-mod-meter" : (p4ctl_get_packet_mod_meter_entry, 2),
19351964
"get-direct-pkt-mod-meter" : (p4ctl_get_direct_pkt_mod_meter_entry, 2)
1965+
"del-meter-config" : (p4ctl_del_meter_config, 2)
19361966
}
19371967

19381968

0 commit comments

Comments
 (0)