[P4-dev] Don't care for exact match key

Vladimir Gurevich vladimir.gurevich at barefootnetworks.com
Sun Feb 17 02:26:03 EST 2019


Hello Kentaro,

Generally speaking, if you want to have an ability to specify "don't care"
you have to use ternary match.

In your particular case, given that IPv4 and IPv6 headers are mutually
exclusive (unless you designed a new protocol where they aren't), using
ternary match seems like a big waste. I would suggest having two separate
exact match tables, one for IPv4 and another one for IPv6 and use an if
statement to choose between them like so:

table test_table_ipv4 {
     key = {
         hdr.ipv4.dstAddr: exact;
     }
...

table test_table_ipv6 {
     key = {
         hdr.ipv6.dstAddr: exact;
     }
...

*if* (hdr.ipv4.isValid()) {
    test_table_ipv4.*apply*();
} *else if* (hdr.ipv6.isValid()) {
    test_table_ipv6.*apply*();
} *else* {
    . . .
}

Happy hacking,
Vladimir

*Vladimir Gurevich*
*Barefoot Networks*
*Director, Customer Training and Education*
Email: vgurevich at barefootnetworks.com
Phone: (408) 833-4505




On Sat, Feb 16, 2019 at 11:10 PM Kentaro Ebisawa <ebiken.g at gmail.com> wrote:

> Hi,
>
> Are there a way to set "don't care" for exact match key?
> Or do I have to use lpm or ternary to ignore some of the match keys in
> the table.
>
> For example, I want to have a table which has 2 exact match keys and set
> below kind of entries.
> * Exact match IPv4 dst address and don't care IPv6 dst address
> * Exact match IPv6 dst address and don't care IPv4 dst address
>
> table test_table {
>      key = {
>          hdr.ipv4.dstAddr: exact;
>          hdr.ipv6.dstAddr: exact;
>      }
> ...
>
> --
> Kentaro Ebisawa <ebiken.g at gmail.com>
>
>
> _______________________________________________
> 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/20190216/b2eaa7ee/attachment.html>


More information about the P4-dev mailing list