[ovs-dev] [RFC PATCH 13/14] Add "pop_nsh/push_nsh" flow action for OVS control plane
Johnson Li
johnson.li at intel.com
Tue Jun 7 18:09:55 UTC 2016
This patch adds pop_nsh and push_nsh Openflow action for control
plane, these actions will strip or push NSH header for packets.
The data plane implementation will be added in following
patches.
How to use:
1) Creation of VxLAN-GPE tunnel port:
ovs-vsctl add-port br-int vxlan0 -- set interface vxlan0 \
type=vxlan options:remote_ip=172.168.1.101 options:key=flow \
options:dst_port=4790 options:exts=gpe
2) Flow rule VxLAN-GPE encapsulation:
ovs-ofctl add-flow br-int "table=0, priority=260, \
in_port=1, ip, nw_src=192.168.0.1 \
actions=push_nsh,output:${GPE_PORT}"
3) Match rules for VxLAN-GPE extension
ovs-ofctl add-flow br-int "table=0, priority=260, \
in_port=${GPE_PORT},actions=pop_nsh,output:LOCAL"
Signed-off-by: Johnson Li <johnson.li at intel.com>
diff --git a/include/openvswitch/ofp-actions.h b/include/openvswitch/ofp-actions.h
index 038ef87..b1d7a67 100644
--- a/include/openvswitch/ofp-actions.h
+++ b/include/openvswitch/ofp-actions.h
@@ -93,6 +93,10 @@
OFPACT(POP_QUEUE, ofpact_null, ofpact, "pop_queue") \
OFPACT(FIN_TIMEOUT, ofpact_fin_timeout, ofpact, "fin_timeout") \
\
+ /* Network Service Header */ \
+ OFPACT(PUSH_NSH, ofpact_null, ofpact, "push_nsh") \
+ OFPACT(POP_NSH, ofpact_null, ofpact, "pop_nsh") \
+ \
/* Flow table interaction. */ \
OFPACT(RESUBMIT, ofpact_resubmit, ofpact, "resubmit") \
OFPACT(LEARN, ofpact_learn, specs, "learn") \
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index 7ddadb8..f8a098d 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -299,6 +299,12 @@ enum ofp_raw_action_type {
/* NX1.0+(36): struct nx_action_nat, ... */
NXAST_RAW_NAT,
+ /* NX1.0+(38): void */
+ NXAST_RAW_PUSH_NSH,
+
+ /* NX1.0+(39): void */
+ NXAST_RAW_POP_NSH,
+
/* ## ------------------ ## */
/* ## Debugging actions. ## */
/* ## ------------------ ## */
@@ -422,6 +428,8 @@ ofpact_next_flattened(const struct ofpact *ofpact)
case OFPACT_WRITE_METADATA:
case OFPACT_GOTO_TABLE:
case OFPACT_NAT:
+ case OFPACT_PUSH_NSH:
+ case OFPACT_POP_NSH:
return ofpact_next(ofpact);
case OFPACT_CT:
@@ -1624,6 +1632,66 @@ format_PUSH_VLAN(const struct ofpact_null *a OVS_UNUSED, struct ds *s)
ds_put_format(s, "%spush_vlan:%s%#"PRIx16,
colors.param, colors.end, ETH_TYPE_VLAN_8021Q);
}
+
+
+/* Network Service Header. */
+static enum ofperr
+decode_NXAST_RAW_PUSH_NSH(struct ofpbuf * out)
+{
+ ofpact_put_PUSH_NSH(out);
+ return 0;
+}
+
+static void
+encode_PUSH_NSH(const struct ofpact_null *null OVS_UNUSED,
+ enum ofp_version ofp_version OVS_UNUSED, struct ofpbuf *out)
+{
+ put_NXAST_PUSH_NSH(out);
+}
+
+static char * OVS_WARN_UNUSED_RESULT
+parse_PUSH_NSH(char *arg OVS_UNUSED, struct ofpbuf *ofpacts,
+ enum ofputil_protocol *usable_protocols OVS_UNUSED)
+{
+ ofpact_put_PUSH_NSH(ofpacts)->ofpact.raw = NXAST_RAW_PUSH_NSH;
+ return NULL;
+}
+
+static void
+format_PUSH_NSH(const struct ofpact_null *a OVS_UNUSED, struct ds *s)
+{
+ ds_put_format(s, "push_nsh");
+}
+
+/* Pop NSH header actions. */
+static enum ofperr
+decode_NXAST_RAW_POP_NSH(struct ofpbuf * out)
+{
+ ofpact_put_POP_NSH(out)->ofpact.raw = NXAST_RAW_POP_NSH;
+ return 0;
+}
+
+static void
+encode_POP_NSH(const struct ofpact_null *null OVS_UNUSED,
+ enum ofp_version ofp_version OVS_UNUSED, struct ofpbuf *out)
+{
+ put_NXAST_POP_NSH(out);
+}
+
+static char * OVS_WARN_UNUSED_RESULT
+parse_POP_NSH(char *arg OVS_UNUSED, struct ofpbuf *ofpacts,
+ enum ofputil_protocol *usable_protocols OVS_UNUSED)
+{
+ ofpact_put_POP_NSH(ofpacts)->ofpact.raw = NXAST_RAW_POP_NSH;
+ return NULL;
+}
+
+static void
+format_POP_NSH(const struct ofpact_null *a OVS_UNUSED, struct ds *s)
+{
+ ds_put_format(s, "pop_nsh");
+}
+
/* Action structure for OFPAT10_SET_DL_SRC/DST and OFPAT11_SET_DL_SRC/DST. */
struct ofp_action_dl_addr {
@@ -5946,6 +6014,8 @@ ofpact_is_set_or_move_action(const struct ofpact *a)
case OFPACT_WRITE_ACTIONS:
case OFPACT_WRITE_METADATA:
case OFPACT_DEBUG_RECIRC:
+ case OFPACT_PUSH_NSH:
+ case OFPACT_POP_NSH:
return false;
default:
OVS_NOT_REACHED();
@@ -6017,6 +6087,8 @@ ofpact_is_allowed_in_actions_set(const struct ofpact *a)
case OFPACT_METER:
case OFPACT_WRITE_ACTIONS:
case OFPACT_WRITE_METADATA:
+ case OFPACT_PUSH_NSH:
+ case OFPACT_POP_NSH:
return false;
default:
OVS_NOT_REACHED();
@@ -6226,6 +6298,8 @@ ovs_instruction_type_from_ofpact_type(enum ofpact_type type)
case OFPACT_DEBUG_RECIRC:
case OFPACT_CT:
case OFPACT_NAT:
+ case OFPACT_PUSH_NSH:
+ case OFPACT_POP_NSH:
default:
return OVSINST_OFPIT11_APPLY_ACTIONS;
}
@@ -6852,6 +6926,10 @@ ofpact_check__(enum ofputil_protocol *usable_protocols, struct ofpact *a,
case OFPACT_DEBUG_RECIRC:
return 0;
+ case OFPACT_PUSH_NSH:
+ case OFPACT_POP_NSH:
+ return 0;
+
default:
OVS_NOT_REACHED();
}
@@ -7337,6 +7415,8 @@ ofpact_outputs_to_port(const struct ofpact *ofpact, ofp_port_t port)
case OFPACT_DEBUG_RECIRC:
case OFPACT_CT:
case OFPACT_NAT:
+ case OFPACT_PUSH_NSH:
+ case OFPACT_POP_NSH:
default:
return false;
}
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index cca5c5c..e0d08eb 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -4333,6 +4333,8 @@ freeze_unroll_actions(const struct ofpact *a, const struct ofpact *end,
case OFPACT_DEBUG_RECIRC:
case OFPACT_CT:
case OFPACT_NAT:
+ case OFPACT_PUSH_NSH:
+ case OFPACT_POP_NSH:
/* These may not generate PACKET INs. */
break;
@@ -4952,6 +4954,11 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
ctx_trigger_freeze(ctx);
a = ofpact_next(a);
break;
+
+ /* Network Service Header */
+ case OFPACT_PUSH_NSH:
+ case OFPACT_POP_NSH:
+ break;
}
/* Check if need to store this and the remaining actions for later
--
1.8.4.2
More information about the dev
mailing list