Hello everyone,
I just started learning the p4 and I have some trouble. Firstly, I started using the tutorials that I found on GitHub and they are very helpful but I need someone to explain/ confirm if I understand right how the JSON files work.
For instance, the basic exercise (tutorials/exercises/basic at master · p4lang/tutorials · GitHub) inside the s1-runtime has this:
{
"table": "MyIngress.ipv4_lpm",
"match": {
"hdr.ipv4.dstAddr": ["10.0.2.2", 32]
},
"action_name": "MyIngress.ipv4_forward",
"action_params": {
"dstAddr": "08:00:00:00:02:00",
"port": 2
}
}
So, if I’m right whenever a packet arrives at the switch it “searches” (in the basic.p4) for the table that is inside the MyIngress controller with the name “ipv4_lpm”. Then if the “hdr.ipv4.dstAddr” matches with the “10.0.2.2” it enables the action MyIngress.ipv4_forward which has some parameters.
If my assumption of how the JSON file works is correct, I have two questions:
- what is the initial value of the hdr.ipv4.dstAddr so the tables can match it with the “10.0.2.2”?
- Are these parameters used as variables for the action ipv4_forward? To be more clear here:
action ipv4_forward(macAddr_t **dstAddr**, egressSpec_t port) {
standard_metadata.egress_spec = port;
hdr.ethernet.srcAddr = hdr.ethernet.dstAddr;
hdr.ethernet.dstAddr = dstAddr;
hdr.ipv4.ttl = hdr.ipv4.ttl - 1;
}
The dstAddr = 08:00:00:00:02:00 because of the “action_params”: {…} and thus hdr.ethernet.srcAddr = 08:00:00:00:02:00?
Thanks in advance!