[P4-dev] how to add forwarding state to a behavior model

Antonin Bas antonin at barefootnetworks.com
Thu Jul 23 20:53:43 EDT 2015

Replying to the whole list, please don't forget to hit reply all :)

On Thu, Jul 23, 2015 at 5:52 PM, Antonin Bas <antonin at barefootnetworks.com>

> Hi Brian,
> Pretty much everything you said here was correct. I'm sorry that there is
> no more documentation. Every P4 program is unique and we do not provide any
> detailed description of the control flow. l2_switch is pretty basic and
> easy to understand. It will work right out of the box providing you set up
> the default actions and configure the multicast engine (for broadcast).
> I believe Sandor contributed the necessary CLI commands to configure the
> switch here:
> https://github.com/p4lang/p4factory/blob/master/targets/l2_switch/add_demo_entries.bash
> One more thing that I did not mention in my previous email. Although using
> the CLI can be convenient, it is sometimes more convenient to just write a
> Python script to do the same thing. This script (that we use for testing)
> is a good starting point:
> https://github.com/p4lang/p4factory/blob/master/targets/l2_switch/of-tests/tests/l2_switch.py
> And one last thing. These commands alone give you a very basic L2 switch:
> all received packets are broadcast out of every port save the receiving
> port. But the P4 program also supports mac address learning:
> https://github.com/p4lang/p4factory/blob/master/targets/l2_switch/p4src/l2_switch.p4#L45
> To leverage this however, you need to write a Python script which queries
> the PD server for newly learned mac addresses and inject them in the
> tables. If you are interested in doing this but can't find how to do it,
> I'd be happy to help.
> On Thu, Jul 23, 2015 at 3:06 PM, brian fiegen <brianfiegen at gmail.com>
> wrote:
>> Hi Antonin,
>> Thanks-- your response was very helpful.  I'm using the switch target and
>> I'm running the run_cli.bash that's in the l2_switch target.  It seems to
>> work as when i start the run_cli.bash script I see "In client_init" appear
>> in the behavioral model output and running a "show_tables" returns three
>> table names.
>> So how would I go about figuring out what information I need to stick
>> into each table?    Is the process to look at the table names, then go into
>> the p4 code and see how the tables are being used, and then entering
>> "add_entry table name <info>".
>> Is there any other documentation on these commands other than doing a
>> "help dump_table"?
>> Thanks
>> On Thu, Jul 23, 2015 at 2:30 PM, Antonin Bas <
>> antonin at barefootnetworks.com> wrote:
>>> Hi Brian,
>>> switch-control.sh was created only for the sake of the demo. It only
>>> worked for one specific P4 program (I believe it was simple_router.p4). In
>>> the general case, you don't know which features are implemented in a P4
>>> program, what are the tables names, what are the action names... so you
>>> cannot provide an API "add_arp" that will work for any arbitrary P4
>>> program. This is why you have to use the CLI. The CLI code calls into the
>>> PD API, which is generated from the P4 program. To start the CLI, you have
>>> to run run_cli.bash. You can then populate the tables with commands
>>> like:
>>> add_entry *table_name* *match_parameters* *action_names*
>>> *action_parameters*
>>> In the demo you refer to, I believe add_arp was actually invoking the
>>> CLI with a command like this:
>>> add_entry send_frame 1 rewrite_mac 00:aa:bb:00:00:00
>>> Let us know if you need more help,
>>> Antonin
>>> On Thu, Jul 23, 2015 at 1:13 PM, brian fiegen <brianfiegen at gmail.com>
>>> wrote:
>>>> I've pulled the p4factory code and have setup two name spaces.  I've
>>>> created and configured an interface in each name space that are in the same
>>>> L3 subnet.  I've then gone into the switch target and run make and thus
>>>> created the behavior-model.  I then start the behavior-model with the
>>>> interfaces for each name space.   If I then ping from one name space to the
>>>> other, my pings time out-- which is expected given that I haven't pushed
>>>> and forwarding state into the model.
>>>> I was watching the video that shows a similar setup though using
>>>> mininet and LJ uses a command called "switch-control.sh" which takes as
>>>> stdin commands called "add_arp", "set_iface_mac" etc.  I was hoping to use
>>>> this mechanism to load the state in my behavior model but the
>>>> switch-control.sh does not seem to be part of the p4factory distro.   I
>>>> know there's a process listening on port 9090 that I'm guessing can be used
>>>> to install state into the model but haven't figured out the syntax for
>>>> talking to that process.  I also found a script in the distro (run_cli.bash
>>>> or something) that will get me to a CLI but the commands there don't match
>>>> the ones being feed into this switch_control.sh script.
>>>> So what would be a simple / easy way for me to push forwarding info
>>>> into a behavior model?
>>>> Thanks
>>>> _______________________________________________
>>>> P4-dev mailing list
>>>> P4-dev at p4.org
>>>> Listinfo - http://mail.p4.org/mailman/listinfo/p4-dev_p4.org
>>>> Archives - http://mail.p4.org/pipermail/p4-dev_p4.org/
>>> --
>>> Antonin
> --
> Antonin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20150723/29ccc111/attachment-0001.html>

More information about the P4-dev mailing list