[P4-dev] DIfference between on_miss and default

Vladimir Gurevich vladimir.gurevich at barefootnetworks.com
Mon Oct 9 11:03:22 EDT 2017


Hello Anand,

Responses inline

On Thu, Oct 5, 2017 at 10:57 AM, Anandakumar <ananth.padfoot at gmail.com>
wrote:

> Just to confirm that my understanding is right, the keys for which the
> `on_miss` action is programmed in the table, the control
> `process_outer_multicast` is executed.
>

This is correct.


> This is inline with the guidelines shared in the p4 trainings where a
> table-apply is not to be performed in an action but instead invoked in this
> imperative style.
>

This is correct: tables cannot be applied inside an action. They can only
be applied inside a control.


> And when no such matching key is seen in the table, instead of a nop that
> is implicitly done by the compiler, here the `default` process_ipv4_vtep
> or process_ipv6_vtep control flow takes place. Right?
>

No, this is not correct. I am afraid you are still confusing table miss
with the possibility of executing any action, other than "on_miss" (which
is what the default clause represents).

>
> Also in this case, the on_miss action is a nop. So I understand that the
> `process_outer_multicast` will be performed. But what if the action has
> some modify_field operations? Is it ok to do it? If so what is the expected
> behavior? Which will be done first  - the action or the imperatively
> defined control?
>

P4 spec dictates sequential execution. The statement reads as "apply  table
"outer_mac" and then, if the executed action was "on_miss" do X, otherwise
do Y". So, the action will be executed first (or, at the very minimum, all
the effects would be as if it was executed first).

Happy Hacking,
Vladimir



On 5 October 2017 at 11:21, Anandakumar <ananth.padfoot at gmail.com> wrote:
>
>> Thank you very much for the clarification!
>>
>> On 05-Oct-2017 7:25 AM, "Vladimir Gurevich" <
>> vladimir.gurevich at barefootnetworks.com> wrote:
>>
>>> Hello Anand,
>>>
>>> The keyword "default" used in the context of the apply() statement with
>>> the case clause does not mean "the default" action. Instead it means "any
>>> action, other that those that were explicitly listed".  In that sense it is
>>> very much the "catch all" keyword, similar to "default" as used in C switch
>>> statements.
>>>
>>> So, the statement in question reads like this:
>>>
>>> If the chosen action (after the outer_rmac table has been applied) is
>>> "on_miss", then execute "process_outer_multicast" control. In all other
>>> cases, if ipv4 header is valid, then call process_ipv4_vtep() control
>>> otherwise, if ipv6 header is valid, then call (apply) process_ip6_vtep()
>>> control.
>>>
>>> Normally, you would expect the "on_miss" action to be the default action
>>> in the table outer_rmac, but individual entries can have it as well.
>>>
>>> I hope this answers the rest of your questions as well. Again, "default"
>>> does not mean "default action".
>>>
>>> Happy Hacking,
>>> Vladimir
>>>
>>> On Wed, Oct 4, 2017 at 6:01 PM, Anandakumar <ananth.padfoot at gmail.com>
>>> wrote:
>>>
>>>> Hi Everyone,
>>>>
>>>> I’m fairly new to P4 and was looking at this snippet in process_tunnel
>>>> and was wondering how the on_miss and default are different?
>>>> Can someone please help me in demystifying the following?
>>>>
>>>>    1. How the on_miss and default are different?
>>>>    2. Is the on_miss taken only if there’s an on_miss action
>>>>    programmed in the table against a specific key?
>>>>    3. What’s the behavior expected here, if on_miss is programmed as
>>>>    the default_action for the table in the program itself or from the
>>>>    control plane via the PD API?
>>>>    Would it make missed take the path of process_outer_multicast or
>>>>    the default?
>>>>    4. What’s the behavior expected here, if say an example action like
>>>>    another_action is programmed as the default_action for the table?
>>>>    Would it still execute the default block or just the action and
>>>>    nothing in this snippet?
>>>>
>>>> What’s the suggested way to easily search the whole mailing list
>>>> archive so that I don’t repeat the questions that are already probably
>>>> answered! :) Thank you very much.
>>>>
>>>>         /* outer RMAC lookup for tunnel termination */
>>>>           apply(outer_rmac) {
>>>>               on_miss {
>>>>                   process_outer_multicast();
>>>>               }
>>>>               default {
>>>>                   if (valid(ipv4)) {
>>>>                       process_ipv4_vtep();
>>>>                   } else {
>>>>                       if (valid(ipv6)) {
>>>>                           process_ipv6_vtep();
>>>>                       }
>>>>                   }
>>>>               }
>>>>           }
>>>>
>>>> Thank you very much.
>>>> -Anand
>>>>>>>>
>>>> _______________________________________________
>>>> P4-dev mailing list
>>>> P4-dev at lists.p4.org
>>>> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>>>>
>>>
>>>
>>>
>>> --
>>> *Vladimir Gurevich*
>>>
>>> *Barefoot Networks*
>>> *Technical Lead, Customer Engineering*
>>> Email: vag at barefootnetworks.com
>>> Phone: (408) 833-4505
>>>
>>>
>


-- 
*Vladimir Gurevich*

*Barefoot Networks*
*Technical Lead, Customer Engineering*
Email: vag at barefootnetworks.com
Phone: (408) 833-4505
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20171009/defc41a1/attachment-0002.html>


More information about the P4-dev mailing list