summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJan Scheurich <jan.scheurich@ericsson.com>2017-08-02 16:04:12 +0800
committerBen Pfaff <blp@ovn.org>2017-08-02 11:17:22 -0700
commitf839892a206abd7adbc0845f772b9f3c58945af5 (patch)
tree73a81773461a93e1c0495952eb54bed21fddd4e4 /include
parent46a54ce7114f2caf9367dbc142d37c813adf9db6 (diff)
downloadopenvswitch-f839892a206abd7adbc0845f772b9f3c58945af5.tar.gz
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>
Diffstat (limited to 'include')
-rw-r--r--include/openflow/openflow-common.h1
-rw-r--r--include/openvswitch/automake.mk1
-rw-r--r--include/openvswitch/ofp-actions.h32
-rw-r--r--include/openvswitch/ofp-ed-props.h77
-rw-r--r--include/openvswitch/ofp-errors.h9
5 files changed, 120 insertions, 0 deletions
diff --git a/include/openflow/openflow-common.h b/include/openflow/openflow-common.h
index 5f1e22589..d66551997 100644
--- a/include/openflow/openflow-common.h
+++ b/include/openflow/openflow-common.h
@@ -466,6 +466,7 @@ enum ofp_header_type_namespaces {
OFPHTN_IP_PROTO = 2, /* ns_type is a IP protocol number. */
OFPHTN_UDP_TCP_PORT = 3, /* ns_type is a TCP or UDP port. */
OFPHTN_IPV4_OPTION = 4, /* ns_type is an IPv4 option number. */
+ OFPHTN_N_TYPES
};
#endif /* openflow/openflow-common.h */
diff --git a/include/openvswitch/automake.mk b/include/openvswitch/automake.mk
index 6bace6159..0a139d007 100644
--- a/include/openvswitch/automake.mk
+++ b/include/openvswitch/automake.mk
@@ -12,6 +12,7 @@ openvswitchinclude_HEADERS = \
include/openvswitch/meta-flow.h \
include/openvswitch/ofpbuf.h \
include/openvswitch/ofp-actions.h \
+ include/openvswitch/ofp-ed-props.h \
include/openvswitch/ofp-errors.h \
include/openvswitch/ofp-msgs.h \
include/openvswitch/ofp-parse.h \
diff --git a/include/openvswitch/ofp-actions.h b/include/openvswitch/ofp-actions.h
index 198107e9c..4357f4e28 100644
--- a/include/openvswitch/ofp-actions.h
+++ b/include/openvswitch/ofp-actions.h
@@ -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,
diff --git a/include/openvswitch/ofp-ed-props.h b/include/openvswitch/ofp-ed-props.h
new file mode 100644
index 000000000..cf2fa628b
--- /dev/null
+++ b/include/openvswitch/ofp-ed-props.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2017 Intel, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OPENVSWITCH_OFP_ED_PROPS_H
+#define OPENVSWITCH_OFP_ED_PROPS_H 1
+
+#include "openvswitch/ofp-errors.h"
+#include "openvswitch/types.h"
+#include "openvswitch/ofpbuf.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum ofp_ed_prop_class {
+ OFPPPC_BASIC = 0, /* ONF Basic class. */
+ OFPPPC_MPLS = 1, /* MPLS property class. */
+ OFPPPC_GRE = 2, /* GRE property class. */
+ OFPPPC_GTP = 3, /* GTP property class. */
+
+ /* Experimenter property class.
+ *
+ * First 32 bits of property data
+ * is exp id after that is the experimenter property data.
+ */
+ OFPPPC_EXPERIMENTER=0xffff
+};
+
+/*
+ * External representation of encap/decap properties.
+ * These must be padded to a multiple of 8 bytes.
+ */
+struct ofp_ed_prop_header {
+ ovs_be16 prop_class;
+ uint8_t type;
+ uint8_t len;
+};
+
+/*
+ * Internal representation of encap/decap properties
+ */
+struct ofpact_ed_prop {
+ uint16_t prop_class;
+ uint8_t type;
+ uint8_t len;
+};
+
+enum ofperr decode_ed_prop(const struct ofp_ed_prop_header **ofp_prop,
+ struct ofpbuf *out, size_t *remaining);
+enum ofperr encode_ed_prop(const struct ofpact_ed_prop **prop,
+ struct ofpbuf *out);
+bool parse_ed_prop_class(const char *str, uint16_t *prop_class);
+bool parse_ed_prop_type(uint16_t prop_class, const char *str, uint8_t *type);
+char *parse_ed_prop_value(uint16_t prop_class, uint8_t prop_type,
+ const char *str, struct ofpbuf *out);
+char *format_ed_prop_class(const struct ofpact_ed_prop *prop);
+char *format_ed_prop_type(const struct ofpact_ed_prop *prop);
+void format_ed_prop(struct ds *s, const struct ofpact_ed_prop *prop);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ofp-ed-props.h */
diff --git a/include/openvswitch/ofp-errors.h b/include/openvswitch/ofp-errors.h
index b551ce677..3d09be354 100644
--- a/include/openvswitch/ofp-errors.h
+++ b/include/openvswitch/ofp-errors.h
@@ -276,6 +276,15 @@ enum ofperr {
* 64. */
OFPERR_NXBAC_BAD_CONJUNCTION,
+ /* NX1.3+(39). Unsupported packet type in encap or decap. */
+ OFPERR_NXBAC_BAD_HEADER_TYPE,
+
+ /* NX1.3+(40). Unrecognized encap or decap property. */
+ OFPERR_NXBAC_UNKNOWN_ED_PROP,
+
+ /* NX1.3+(41). Error in encap or decap property. */
+ OFPERR_NXBAC_BAD_ED_PROP,
+
/* ## --------------------- ## */
/* ## OFPET_BAD_INSTRUCTION ## */
/* ## --------------------- ## */