p4lang / tutorials

P4 language tutorials
Apache License 2.0
1.31k stars 875 forks source link

For the header of ipv4_t, why not use bit<32> srcIp instead of the bit<32> srcAddr ? #609

Closed hugo0819 closed 1 month ago

hugo0819 commented 2 months ago

I think it would be clearer to use the bit<48> srcAddr/dstAddr for ethernet and bit<32> srcIp/dstIp for IPv4.

jafingerhut commented 2 months ago

Note that just about everywhere that a P4 field is used, it contains the name of the header variable that it is part of, and the header variables are typically named things like mac or ethernet or ipv4, so the most common context where one would see an IPv4 address would be an expression like ipv4.srcAddr.

Note also that a common consequence of such changes is that they can ripple into changes required in the control plane code that modifies table entries, if the field is used as a key in any of the tables.

I agree that names are important. I also believe that once a program is written, working, and stable, changes should meet a fairly high bar of justification, and I am not confident that such changes meet that.