[P4-dev] Check equality of two header fields

Javier Blazquez jblazquez at riotgames.com
Tue Jun 28 16:35:58 EDT 2016


Not sure if this is idiomatic, but you could use a table lookup on an empty
table in order to set the flag on the default action, e.g.:

action on_ip_addresses_match() {
  mymeta.match = 1
}

table ip_addresses_match {
  // no match fields defined so lookup always fails
  actions {
    on_ip_addresses_match;
  }
}

control ip_addresses_match {
  if (ipv4.srcAddr == ipv4.dstAddr) {
    apply(ip_addresses_match);
  }
}

On Tue, Jun 28, 2016 at 1:30 PM, Ashutosh Agrawal (ashu) <ashu at cisco.com>
wrote:

> Let’s say I’ve a packet header with srcAddr and DstAddr fields. I want to
> check if src and dst addresses are same and set a metadata flag. I can then
> use this flag as a key field for a subsequent table. AFAIK, this A==B check
> can only be done in Control Flow but I can’t modify the metadata there. Any
> ideas?
>
>
>
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20160628/b93e3f36/attachment-0002.html>


More information about the P4-dev mailing list