Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ModifyTableEntry method for modifying table entries in P4Runtime #601

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions utils/p4runtime_lib/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ def WriteTableEntry(self, table_entry, dry_run=False):
else:
self.client_stub.Write(request)

def ModifyTableEntry(self, table_entry, dry_run=False):
request = p4runtime_pb2.WriteRequest()
request.device_id = self.device_id
request.election_id.low = 1
update = request.updates.add()
update.type = p4runtime_pb2.Update.MODIFY
update.entity.table_entry.CopyFrom(table_entry)
if dry_run:
print("P4Runtime Modify: ", request)
else:
self.client_stub.Write(request)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested it?

It would be good to test not only for modifying a normal entry of a table, but also test it to see if it works when modifying a default action of a table.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please provide an approach on how to effectively test the ModifyTableEntry method to ensure it handles modifications of both normal entries and default actions?

def ReadTableEntries(self, table_id=None, dry_run=False):
request = p4runtime_pb2.ReadRequest()
request.device_id = self.device_id
Expand Down