mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
OF support and translation of generic encap and decap
This commit adds support for the OpenFlow actions generic encap and decap (as specified in ONF EXT-382) to the OVS control plane. CLI syntax for encap action with properties: encap(<header>) encap(<header>(<prop>=<value>,<tlv>(<class>,<type>,<value>),...)) For example: encap(ethernet) encap(nsh(md_type=1)) encap(nsh(md_type=2,tlv(0x1000,10,0x12345678),tlv(0x2000,20,0xfedcba9876543210))) CLI syntax for decap action: decap() decap(packet_type(ns=<pt_ns>,type=<pt_type>)) For example: decap() decap(packet_type(ns=0,type=0xfffe)) decap(packet_type(ns=1,type=0x894f)) The first header supported for encap and decap is "ethernet" to convert packets between packet_type (1,Ethertype) and (0,0). This commit also implements a skeleton for the translation of generic encap and decap actions in ofproto-dpif and adds support to encap and decap an Ethernet header. In general translation of encap commits pending actions and then rewrites struct flow in accordance with the new packet type and header. In the case of encap(ethernet) it suffices to change the packet type from (1, Ethertype) to (0,0) and set the dl_type accordingly. A new pending_encap flag in xlate ctx is set to mark that an corresponding datapath encap action must be triggered at the next commit. In the case of encap(ethernet) ofproto generetas a push_eth action. The general case for translation of decap() is to emit a datapath action to decap the current outermost header and then recirculate the packet to reparse the inner headers. In the special case of an Ethernet packet, decap() just changes the packet type from (0,0) to (1, dl_type) without a need to recirculate. The emission of the pop_eth action for the datapath is postponed to the next commit. Hence encap(ethernet) and decap() on an Ethernet packet are OF octions that only incur a cost in the dataplane when a modifed packet is actually committed, e.g. because it is sent out. They can freely be used for normalizing the packet type in the OF pipeline without degrading performance. Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com> Signed-off-by: Yi Yang <yi.y.yang@intel.com> Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com> Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "openvswitch/ofp-util.h"
|
||||
#include "openvswitch/ofp-errors.h"
|
||||
#include "openvswitch/types.h"
|
||||
#include "openvswitch/ofp-ed-props.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -93,6 +94,10 @@ struct vl_mff_map;
|
||||
OFPACT(PUSH_MPLS, ofpact_push_mpls, ofpact, "push_mpls") \
|
||||
OFPACT(POP_MPLS, ofpact_pop_mpls, ofpact, "pop_mpls") \
|
||||
\
|
||||
/* Generic encap & decap */ \
|
||||
OFPACT(ENCAP, ofpact_encap, props, "encap") \
|
||||
OFPACT(DECAP, ofpact_decap, ofpact, "decap") \
|
||||
\
|
||||
/* Metadata. */ \
|
||||
OFPACT(SET_TUNNEL, ofpact_tunnel, ofpact, "set_tunnel") \
|
||||
OFPACT(SET_QUEUE, ofpact_queue, ofpact, "set_queue") \
|
||||
@@ -974,6 +979,33 @@ struct ofpact_unroll_xlate {
|
||||
ovs_be64 rule_cookie; /* OVS_BE64_MAX if none. */
|
||||
};
|
||||
|
||||
/* OFPACT_ENCAP.
|
||||
*
|
||||
* Used for NXAST_ENCAP. */
|
||||
|
||||
struct ofpact_encap {
|
||||
struct ofpact ofpact;
|
||||
ovs_be32 new_pkt_type; /* Packet type of the header to add. */
|
||||
uint16_t hdr_size; /* New header size in bytes. */
|
||||
uint16_t n_props; /* Number of encap properties. */
|
||||
struct ofpact_ed_prop props[]; /* Properties in internal format. */
|
||||
};
|
||||
|
||||
/* OFPACT_DECAP.
|
||||
*
|
||||
* Used for NXAST_DECAP. */
|
||||
struct ofpact_decap {
|
||||
struct ofpact ofpact;
|
||||
|
||||
/* New packet type.
|
||||
*
|
||||
* The special value (0,0xFFFE) "Use next proto" is used to request OVS to
|
||||
* automatically set the new packet type based on the decap'ed header's
|
||||
* next protocol.
|
||||
*/
|
||||
ovs_be32 new_pkt_type;
|
||||
};
|
||||
|
||||
/* Converting OpenFlow to ofpacts. */
|
||||
enum ofperr ofpacts_pull_openflow_actions(struct ofpbuf *openflow,
|
||||
unsigned int actions_len,
|
||||
|
Reference in New Issue
Block a user