[P4-dev] detect port status changes in the dataplane?
hemant at mnkcg.com
hemant at mnkcg.com
Tue Jun 27 17:14:59 EDT 2017
For a router/switch running a hardware-assisted data plane, the data
plane must detect any link-up/down event. The control plane learns of
such events via the ARP protocol for IPv4.
Quoting Roshan Sedar <roshan.sedar at student.uclouvain.be>:
> Hi Antonin,
> thanks a lot for the detail answer. Yes, I managed to catch port status
> updates which send to the control plane (nanomsg broadcasts). But what I
> try to test is a local rerouting approach in p4 during link failures. So I
> look for a trivial work around simple_switch implementation if possible. Is
> it possible to capture bm_apps/notifications<Port Statuses> inside the
> existing simple_switch implementation?
> 2017-06-27 19:51 GMT+02:00 Antonin Bas <antonin at barefootnetworks.com>:
>> There is no mechanism in the P4 v1model to query port status. This is the
>> architecture (to use the P4_16 terminology) which bmv2 simple_switch tries
>> to support, so the short answer to your question is no. There is however a
>> mechanism to send port status updates to the control plane.
>> AFAIK, the Portable Switch Architecture (PSA), which aims to replace
>> v1model as the de facto architecture to write portable P4 programs, will
>> not include such a mechanism either.
>> That being said, bmv2 itself is supposed to be a framework for
>> implementing various P4_16 architectures. So were you inclined to define
>> your own architecture and include an extern type that enables you to query
>> the status of a port, it should not be too hard to implement your
>> architecture using the bmv2 C++ library. The major issue I see here is that
>> the p4c compiler bmv2 backend is still a work in progress and doesn't
>> support arbitrary architectures with arbitrary externs at this stage. So
>> you would not be able to compile your programs easily. Once the backend is
>> more stable (which IMO means once the backend supports PSA), you should be
>> able to do what you are trying to do with some amount of work.
>> If you are using P4_14 and the legacy compiler for bmv2 (
>> https://github.com/p4lang/p4c-bm), it may be much easier to achieve
>> support for this. You would simply need to define your own primitive action
>> and implement it in C++ in bmv2 simple_switch. Your primitive action could
>> look like this: query_port_status(<dest field>, <port number>). Now the C++
>> implementation may not be trivial, as you would need to get a handler on
>> the bmv2 PortMonitor object, but that wouldn't be too hard either. If you
>> are interested in trying this, there should be quite a few email threads on
>> the mailing list that cover how to add a custom primitive action to the
>> P4_14 compiler and implement it in bmv2.
More information about the P4-dev