Can I install rules like this?

I’m a beginner of P4 and here is my question.
I want to check the match-action table if the rule is exist when the first packet of a new flow arrives. If the rule is not there, I want to send the packet to control plane and the control plane to parse the packet then install new rules. Can P4 do this?
Thank you


You should be able to do that. You can find some examples at jafingerhut/p4-guide like this one or this one. It is always good to search for controller_header in P4 programs to identify similar examples. You then need the control plane that can receive those packets and process them. I generally recommend ONOS, which has a nice tutorial here but there is a steep learning curve if you have never used it before. Else, you can try to use the Python control plane included in the P4 tutorials. It needs some modifications, but I just searched on Github and you can find some code here by Kevin Cyu, here by Belma Turkovicor some I did some time ago.

I hope it helps

Thank you very much!!! I will check these for more. : )