aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJesse Gross <jesse@nicira.com>2010-04-12 11:49:16 -0400
committerJesse Gross <jesse@nicira.com>2010-04-19 09:11:51 -0400
commit659586efcf6f9539282da9447007897907c41112 (patch)
treebaffec5ba051a06cfb2a6fa84d0837068aca54f3 /include
parentdb0e2ad101f10288c002bd537047f3d9e1979c9f (diff)
tunneling: Add support for tunnel ID.
Add a tun_id field which contains the ID of the encapsulating tunnel on which a packet was received (0 if not received on a tunnel). Also add an action which allows the tunnel ID to be set for outgoing packets. At this point there aren't any tunnel implementations so these fields don't have any effect. The matching is exposed to OpenFlow by overloading the high 32 bits of the cookie as the tunnel ID. ovs-ofctl is capable of turning on this special behavior using a new "tun-cookie" command but this command is intentially undocumented to avoid it being used without a full understanding of the consequences.
Diffstat (limited to 'include')
-rw-r--r--include/openflow/nicira-ext.h37
-rw-r--r--include/openvswitch/datapath-protocol.h14
2 files changed, 46 insertions, 5 deletions
diff --git a/include/openflow/nicira-ext.h b/include/openflow/nicira-ext.h
index 17d86a86..5ec009a7 100644
--- a/include/openflow/nicira-ext.h
+++ b/include/openflow/nicira-ext.h
@@ -45,6 +45,10 @@ enum nicira_type {
NXT_FLOW_END_CONFIG__OBSOLETE,
NXT_FLOW_END__OBSOLETE,
NXT_MGMT__OBSOLETE,
+
+ /* Use the high 32 bits of the cookie field as the tunnel ID in the flow
+ * match. */
+ NXT_TUN_ID_FROM_COOKIE,
};
struct nicira_header {
@@ -54,6 +58,14 @@ struct nicira_header {
};
OFP_ASSERT(sizeof(struct nicira_header) == 16);
+struct nxt_tun_id_cookie {
+ struct ofp_header header;
+ uint32_t vendor; /* NX_VENDOR_ID. */
+ uint32_t subtype; /* NXT_TUN_ID_FROM_COOKIE */
+ uint8_t set; /* Nonzero to enable, zero to disable. */
+ uint8_t pad[7];
+};
+OFP_ASSERT(sizeof(struct nxt_tun_id_cookie) == 24);
enum nx_action_subtype {
NXAST_SNAT__OBSOLETE, /* No longer used. */
@@ -80,13 +92,15 @@ enum nx_action_subtype {
*
* NXAST_RESUBMIT may be used any number of times within a set of actions.
*/
- NXAST_RESUBMIT
+ NXAST_RESUBMIT,
+
+ NXAST_SET_TUNNEL /* Set encapsulating tunnel ID. */
};
/* Action structure for NXAST_RESUBMIT. */
struct nx_action_resubmit {
uint16_t type; /* OFPAT_VENDOR. */
- uint16_t len; /* Length is 8. */
+ uint16_t len; /* Length is 16. */
uint32_t vendor; /* NX_VENDOR_ID. */
uint16_t subtype; /* NXAST_RESUBMIT. */
uint16_t in_port; /* New in_port for checking flow table. */
@@ -94,14 +108,31 @@ struct nx_action_resubmit {
};
OFP_ASSERT(sizeof(struct nx_action_resubmit) == 16);
+/* Action structure for NXAST_SET_TUNNEL. */
+struct nx_action_set_tunnel {
+ uint16_t type; /* OFPAT_VENDOR. */
+ uint16_t len; /* Length is 16. */
+ uint32_t vendor; /* NX_VENDOR_ID. */
+ uint16_t subtype; /* NXAST_SET_TUNNEL. */
+ uint8_t pad[2];
+ uint32_t tun_id; /* Tunnel ID. */
+};
+OFP_ASSERT(sizeof(struct nx_action_set_tunnel) == 16);
+
/* Header for Nicira-defined actions. */
struct nx_action_header {
uint16_t type; /* OFPAT_VENDOR. */
- uint16_t len; /* Length is 8. */
+ uint16_t len; /* Length is 16. */
uint32_t vendor; /* NX_VENDOR_ID. */
uint16_t subtype; /* NXAST_*. */
uint8_t pad[6];
};
OFP_ASSERT(sizeof(struct nx_action_header) == 16);
+/* Wildcard for tunnel ID. */
+#define NXFW_TUN_ID (1 << 25)
+
+#define NXFW_ALL NXFW_TUN_ID
+#define OVSFW_ALL (OFPFW_ALL | NXFW_ALL)
+
#endif /* openflow/nicira-ext.h */
diff --git a/include/openvswitch/datapath-protocol.h b/include/openvswitch/datapath-protocol.h
index 6c535454..6ddff014 100644
--- a/include/openvswitch/datapath-protocol.h
+++ b/include/openvswitch/datapath-protocol.h
@@ -127,7 +127,8 @@ struct odp_stats {
* @arg: Argument value whose meaning depends on @type.
*
* For @type == %_ODPL_MISS_NR, the header is followed by packet data. The
- * @arg member is unused and set to 0.
+ * @arg member is the ID (in network byte order) of the tunnel that
+ * encapsulated this packet. It is 0 if the packet was not received on a tunnel.
*
* For @type == %_ODPL_ACTION_NR, the header is followed by packet data. The
* @arg member is copied from the &struct odp_action_controller that caused
@@ -191,6 +192,7 @@ struct odp_flow_stats {
};
struct odp_flow_key {
+ __be32 tun_id; /* Encapsulating tunnel ID. */
__be32 nw_src; /* IP source address. */
__be32 nw_dst; /* IP destination address. */
__u16 in_port; /* Input switch port. */
@@ -253,7 +255,8 @@ struct odp_flowvec {
#define ODPAT_SET_NW_TOS 10 /* IP ToS/DSCP field (6 bits). */
#define ODPAT_SET_TP_SRC 11 /* TCP/UDP source port. */
#define ODPAT_SET_TP_DST 12 /* TCP/UDP destination port. */
-#define ODPAT_N_ACTIONS 13
+#define ODPAT_SET_TUNNEL 13 /* Set the encapsulating tunnel ID. */
+#define ODPAT_N_ACTIONS 14
struct odp_action_output {
__u16 type; /* ODPAT_OUTPUT. */
@@ -275,6 +278,12 @@ struct odp_action_controller {
__u32 arg; /* Copied to struct odp_msg 'arg' member. */
};
+struct odp_action_tunnel {
+ __u16 type; /* ODPAT_SET_TUNNEL. */
+ __u16 reserved;
+ __be32 tun_id; /* Tunnel ID. */
+};
+
/* Action structure for ODPAT_SET_VLAN_VID. */
struct odp_action_vlan_vid {
__u16 type; /* ODPAT_SET_VLAN_VID. */
@@ -326,6 +335,7 @@ union odp_action {
struct odp_action_output output;
struct odp_action_output_group output_group;
struct odp_action_controller controller;
+ struct odp_action_tunnel tunnel;
struct odp_action_vlan_vid vlan_vid;
struct odp_action_vlan_pcp vlan_pcp;
struct odp_action_dl_addr dl_addr;