p4lang / p4runtime

Specification documents for the P4Runtime control-plane API
Apache License 2.0
140 stars 86 forks source link

P4runtime write/read requests validation #392

Closed adibrastegarnia closed 2 years ago

adibrastegarnia commented 2 years ago

I have a question about validation of read/write requests. I am wondering how read/write requests can be validated potentially based on P4info or some other information? Are there any utility functions or auto generated validate function to achieve the goal? Lets say I want to implement a controller which validates the user requests before sending them to the target, what is the best way to achieve it?

antoninbas commented 2 years ago

Yes, requests are validated based on the information in the P4Info message. Note that this validation should always be implemented server side IMO, but if you have a controller that takes raw user requests, you can also have your own validation there. This p4lang code is an example of how a server implementation can do it: https://github.com/p4lang/PI/tree/main/proto/frontend/src This p4lang project can be consumed as a library and may meet your requirements: https://github.com/p4lang/p4-constraints. I know that the scope of the project is larger than just P4Info-based validation (as it adds support for custom constraints), but I think P4Info-based validation may be a part of it. If a C++ library works for you, you could take a look at it, and ask any question you may have by opening an issue in that repository directly..

adibrastegarnia commented 2 years ago

Thanks @antoninbas that would be helpful. The reason that I am asking is because If the controller is the source of the truth then potentially NB of the controller can act like a P4Runtime server (assuming the same level of abstraction exposed to the user) and it is better to validate those requests before it hits the target.