[P4-dev] ingress_port with simple_router

Vladimir Gurevich vladimir.gurevich at barefootnetworks.com
Sun May 28 02:14:52 EDT 2017


Hello Aldo,

This is correct: the only fields that simple_router target supports are
standard_metadata.egress_spec and standard_metadata.egress_port (see
https://github.com/p4lang/behavioral-model/blob/master/targets/simple_router/simple_router.cpp#L53
).

Simple router not really the target designed for serous P4 Program
development. The target that generally follows the P4_14 specification is
called simple_switch and that's what I recommend you use. The other targets
are more useful for learning how to create your own, but not for the real
P4 program development.

Happy hacking,
Vladimir

On Sat, May 27, 2017 at 9:42 PM, Aldo Febro <af12abw at gmail.com> wrote:

> Thanks Andy for your suggestion. I enabled --log-console option and found
> that standard_metadata.ingress_port always has value of 0000 regardless of
> which port the packet was received (e.g. port 2 or port 3)
>
> e.g.
> [21:28:05.268] [bmv2] [D] [thread 3157] [3.0] [cxt 0] Processing packet
> received on port 2
> [deleted some lines for brevity]
> [21:28:05.269] [bmv2] [D] [thread 3157] [3.0] [cxt 0] Looking up key:
> * standard_metadata.ingress_port: 0000
>
>
> [21:34:11.110] [bmv2] [D] [thread 3157] [21.0] [cxt 0] Processing packet
> received on port 3
> [deleted some lines for brevity]
> [21:34:11.115] [bmv2] [D] [thread 3157] [22.0] [cxt 0] Looking up key:
> * standard_metadata.ingress_port: 0000
>
>
>
> why standard_metadata.ingress_port always showing the value of 0000? Is
> ingress_port metadata not available with simple_router target?
>
>
> On Sat, May 27, 2017 at 3:19 PM, Andy Fingerhut <andy.fingerhut at gmail.com>
> wrote:
>
>> If you use the --log-console option to the simple_switch command, you
>> should see extra debug information such as the names of tables, and the
>> names of search key fields and their values, every time a table is applied
>> (plus other useful trace info).
>>
>> Note that if a packet arrives that has no 802.1Q header, the vlan_tag.vid
>> field value is undefined, and thus is not easy to predict what its actual
>> binary value will be, and unlikely to match any entries in your table
>> unless you insert all possible entries.
>>
>> One way to handle this with an exact match table is, before apply'ing the
>> table, check whether the vlan_tag header is valid.  If it is, assign the
>> vid value to some similarly named field in metadata, e.g. my_meta.vid.  If
>> vlan_tag is not valid, assign some default valid to my_meta.vid, e.g.
>> 0xfff.  Then the value of my_meta.vid will be predictable.  You may also
>> want to add the valid bit of the vlan_tag header to your table's search
>> key, to distinguish the packets that have an 802.1Q header from those that
>> do not.
>>
>> Andy
>>
>> On Fri, May 26, 2017 at 6:56 PM, Aldo Febro <af12abw at gmail.com> wrote:
>>
>>> Hi All,
>>>
>>> I think I'm missing something simple here that I kept getting "table
>>> miss" when I try to match with 2 conditions i.e. ingress_port and VLAN ID.
>>>
>>> I'm using simple_router and I'm trying drop packets that are coming from
>>> ingress_port 5 with VLAN ID 10.
>>>
>>> To populate the table, I used the following command:
>>> "table_add port_vlan_check _drop 5 10 =>"
>>>
>>>
>>> P4 code:
>>> table port_vlan_check {
>>>  reads {
>>> standard_metadata.ingress_port : exact;
>>> vlan_tag.vid : exact;
>>> }
>>> actions {
>>> _drop;
>>> _nop;
>>>  }
>>>  size 16384;
>>> }
>>>
>>>
>>> Is there special syntax required for ingress_port  when used in command
>>> line?
>>>
>>> How do I debug the value used during the "reads" in match-action table?
>>>
>>> Thank you,
>>> Aldo
>>>
>>>
>>> _______________________________________________
>>> P4-dev mailing list
>>> P4-dev at lists.p4.org
>>> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>>>
>>
>>
>
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20170527/d888524d/attachment-0002.html>


More information about the P4-dev mailing list