Implement serializing the state of packet traversal in "continuations".
authorBen Pfaff <blp@ovn.org>
Sat, 20 Feb 2016 00:10:06 +0000 (16:10 -0800)
committerBen Pfaff <blp@ovn.org>
Sat, 20 Feb 2016 00:15:45 +0000 (16:15 -0800)
commit77ab5fd2a95ba2fef5bbe25aaa429776b9e29ea3
tree66279d96396631e8c92f55a4b589bfbe0dfc1090
parent5d10476a12dd3df756e15c9bcae0061bef787379
Implement serializing the state of packet traversal in "continuations".

One purpose of OpenFlow packet-in messages is to allow a controller to
interpose on the path of a packet through the flow tables.  If, for
example, the controller needs to modify a packet in some way that the
switch doesn't directly support, the controller should be able to
program the switch to send it the packet, then modify the packet and
send it back to the switch to continue through the flow table.

That's the theory.  In practice, this doesn't work with any but the
simplest flow tables.  Packet-in messages simply don't include enough
context to allow the flow table traversal to continue.  For example:

    * Via "resubmit" actions, an Open vSwitch packet can have an
      effective "call stack", but a packet-in can't describe it, and
      so it would be lost.

    * A packet-in can't preserve the stack used by NXAST_PUSH and
      NXAST_POP actions.

    * A packet-in can't preserve the OpenFlow 1.1+ action set.

    * A packet-in can't preserve the state of Open vSwitch mirroring
      or connection tracking.

This commit introduces a solution called "continuations".  A continuation
is the state of a packet's traversal through OpenFlow flow tables.  A
"controller" action with the "pause" flag, which is newly implemented in
this commit, generates a continuation and sends it to the OpenFlow
controller in a packet-in asynchronous message (only NXT_PACKET_IN2
supports continuations, so the controller must configure them with
NXT_SET_PACKET_IN_FORMAT).  The controller processes the packet-in,
possibly modifying some of its data, and sends it back to the switch with
an NXT_RESUME request, which causes flow table traversal to continue.  In
principle, a single packet can be paused and resumed multiple times.

Another way to look at it is:

    - "pause" is an extension of the existing OFPAT_CONTROLLER
      action.  It sends the packet to the controller, with full
      pipeline context (some of which is switch implementation
      dependent, and may thus vary from switch to switch).

    - A continuation is an extension of OFPT_PACKET_IN, allowing for
      implementation dependent metadata.

    - NXT_RESUME is an extension of OFPT_PACKET_OUT, with the
      semantics that the pipeline processing is continued with the
      original translation context from where it was left at the time
      it was paused.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
29 files changed:
NEWS
include/openflow/nicira-ext.h
lib/learning-switch.c
lib/meta-flow.c
lib/meta-flow.h
lib/ofp-actions.c
lib/ofp-actions.h
lib/ofp-errors.h
lib/ofp-msgs.h
lib/ofp-print.c
lib/ofp-util.c
lib/ofp-util.h
lib/rconn.c
ofproto/connmgr.c
ofproto/connmgr.h
ofproto/fail-open.c
ofproto/ofproto-dpif-xlate.c
ofproto/ofproto-dpif-xlate.h
ofproto/ofproto-dpif.c
ofproto/ofproto-provider.h
ofproto/ofproto.c
ovn/TODO
ovn/controller/pinctrl.c
tests/ofp-actions.at
tests/ofp-print.at
tests/ofproto-dpif.at
tests/ofproto-macros.at
utilities/ovs-ofctl.8.in
utilities/ovs-ofctl.c