/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira Networks
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "openflow/openflow.h"
#include "openvswitch/types.h"
-/* The following vendor extensions, proposed by Nicira Networks, are not yet
+/* The following vendor extensions, proposed by Nicira, are not yet
* standardized, so they are not included in openflow.h. Some of them may be
* suitable for standardization; others we never expect to standardize. */
NXT_FLOW_AGE = 18,
NXT_SET_ASYNC_CONFIG = 19, /* struct nx_async_config. */
+ NXT_SET_CONTROLLER_ID = 20, /* struct nx_controller_id. */
};
/* Header for Nicira vendor stats request and reply messages. */
*/
struct nx_flow_mod_table_id {
struct ofp_header header;
- uint32_t vendor; /* NX_VENDOR_ID. */
- uint32_t subtype; /* NXT_FLOW_MOD_TABLE_ID. */
+ ovs_be32 vendor; /* NX_VENDOR_ID. */
+ ovs_be32 subtype; /* NXT_FLOW_MOD_TABLE_ID. */
uint8_t set; /* Nonzero to enable, zero to disable. */
uint8_t pad[7];
};
NXAST_LEARN, /* struct nx_action_learn */
NXAST_EXIT, /* struct nx_action_header */
NXAST_DEC_TTL, /* struct nx_action_header */
+ NXAST_FIN_TIMEOUT, /* struct nx_action_fin_timeout */
+ NXAST_CONTROLLER, /* struct nx_action_controller */
};
/* Header for Nicira-defined actions. */
* field[ofs:ofs+n_bits-1]. Actions are executed in the same order as the
* flow_mod_specs.
*
+ * A single NXAST_REG_LOAD action writes no more than 64 bits, so n_bits
+ * greater than 64 yields multiple NXAST_REG_LOAD actions.
+ *
* The flow_mod_spec destination spec for 'dst' of 2 (when 'src' is 0) is
* empty. It has the following meaning:
*
* prepared to handle this by flooding (which can be implemented as a
* low-priority flow).
*
+ * If a learned flow matches a single TCP stream with a relatively long
+ * timeout, one may make the best of resource constraints by setting
+ * 'fin_idle_timeout' or 'fin_hard_timeout' (both measured in seconds), or
+ * both, to shorter timeouts. When either of these is specified as a nonzero
+ * value, OVS adds a NXAST_FIN_TIMEOUT action, with the specified timeouts, to
+ * the learned flow.
+ *
* Examples
* --------
*
ovs_be64 cookie; /* Cookie for new flow. */
ovs_be16 flags; /* Either 0 or OFPFF_SEND_FLOW_REM. */
uint8_t table_id; /* Table to insert flow entry. */
- uint8_t pad[5]; /* Must be zero. */
+ uint8_t pad; /* Must be zero. */
+ ovs_be16 fin_idle_timeout; /* Idle timeout after FIN, if nonzero. */
+ ovs_be16 fin_hard_timeout; /* Hard timeout after FIN, if nonzero. */
/* Followed by a sequence of flow_mod_spec elements, as described above,
* until the end of the action is reached. */
};
#define NX_LEARN_DST_OUTPUT (2 << 11) /* Add OFPAT_OUTPUT action. */
#define NX_LEARN_DST_RESERVED (3 << 11) /* Not yet defined. */
#define NX_LEARN_DST_MASK (3 << 11)
+
+/* Action structure for NXAST_FIN_TIMEOUT.
+ *
+ * This action changes the idle timeout or hard timeout, or both, of this
+ * OpenFlow rule when the rule matches a TCP packet with the FIN or RST flag.
+ * When such a packet is observed, the action reduces the rule's idle timeout
+ * to 'fin_idle_timeout' and its hard timeout to 'fin_hard_timeout'. This
+ * action has no effect on an existing timeout that is already shorter than the
+ * one that the action specifies. A 'fin_idle_timeout' or 'fin_hard_timeout'
+ * of zero has no effect on the respective timeout.
+ *
+ * 'fin_idle_timeout' and 'fin_hard_timeout' are measured in seconds.
+ * 'fin_hard_timeout' specifies time since the flow's creation, not since the
+ * receipt of the FIN or RST.
+ *
+ * This is useful for quickly discarding learned TCP flows that otherwise will
+ * take a long time to expire.
+ *
+ * This action is intended for use with an OpenFlow rule that matches only a
+ * single TCP flow. If the rule matches multiple TCP flows (e.g. it wildcards
+ * all TCP traffic, or all TCP traffic to a particular port), then any FIN or
+ * RST in any of those flows will cause the entire OpenFlow rule to expire
+ * early, which is not normally desirable.
+ */
+struct nx_action_fin_timeout {
+ ovs_be16 type; /* OFPAT_VENDOR. */
+ ovs_be16 len; /* 16. */
+ ovs_be32 vendor; /* NX_VENDOR_ID. */
+ ovs_be16 subtype; /* NXAST_FIN_TIMEOUT. */
+ ovs_be16 fin_idle_timeout; /* New idle timeout, if nonzero. */
+ ovs_be16 fin_hard_timeout; /* New hard timeout, if nonzero. */
+ ovs_be16 pad; /* Must be zero. */
+};
+OFP_ASSERT(sizeof(struct nx_action_fin_timeout) == 16);
\f
/* Action structure for NXAST_AUTOPATH.
*
#define NXM_NX_REG3_W NXM_HEADER_W(0x0001, 3, 4)
#define NXM_NX_REG4 NXM_HEADER (0x0001, 4, 4)
#define NXM_NX_REG4_W NXM_HEADER_W(0x0001, 4, 4)
+#define NXM_NX_REG5 NXM_HEADER (0x0001, 5, 4)
+#define NXM_NX_REG5_W NXM_HEADER_W(0x0001, 5, 4)
+#define NXM_NX_REG6 NXM_HEADER (0x0001, 6, 4)
+#define NXM_NX_REG6_W NXM_HEADER_W(0x0001, 6, 4)
+#define NXM_NX_REG7 NXM_HEADER (0x0001, 7, 4)
+#define NXM_NX_REG7_W NXM_HEADER_W(0x0001, 7, 4)
/* Tunnel ID.
*
*
* Format: 128-bit IPv6 address.
*
- * Masking: Not maskable. */
-#define NXM_NX_ND_TARGET NXM_HEADER (0x0001, 23, 16)
+ * Masking: Only CIDR masks are allowed, that is, masks that consist of N
+ * high-order bits set to 1 and the other 128-N bits set to 0. */
+#define NXM_NX_ND_TARGET NXM_HEADER (0x0001, 23, 16)
+#define NXM_NX_ND_TARGET_W NXM_HEADER_W (0x0001, 23, 16)
/* The source link-layer address option in an IPv6 Neighbor Discovery
* message.
/* NXT_SET_FLOW_FORMAT request. */
struct nx_set_flow_format {
- struct ofp_header header;
- ovs_be32 vendor; /* NX_VENDOR_ID. */
- ovs_be32 subtype; /* NXT_SET_FLOW_FORMAT. */
+ struct nicira_header nxh;
ovs_be32 format; /* One of NXFF_*. */
};
OFP_ASSERT(sizeof(struct nx_set_flow_format) == 20);
uint8_t pad[4]; /* Align to 64 bits. */
};
OFP_ASSERT(sizeof(struct nx_aggregate_stats_reply) == 48);
+\f
+/* NXT_SET_CONTROLLER_ID.
+ *
+ * Each OpenFlow controller connection has a 16-bit identifier that is
+ * initially 0. This message changes the connection's ID to 'id'.
+ *
+ * Controller connection IDs need not be unique.
+ *
+ * The NXAST_CONTROLLER action is the only current user of controller
+ * connection IDs. */
+struct nx_controller_id {
+ struct nicira_header nxh;
+ uint8_t zero[6]; /* Must be zero. */
+ ovs_be16 controller_id; /* New controller connection ID. */
+};
+OFP_ASSERT(sizeof(struct nx_controller_id) == 24);
+
+/* Action structure for NXAST_CONTROLLER.
+ *
+ * This generalizes using OFPAT_OUTPUT to send a packet to OFPP_CONTROLLER. In
+ * addition to the 'max_len' that OFPAT_OUTPUT supports, it also allows
+ * specifying:
+ *
+ * - 'reason': The reason code to use in the ofp_packet_in or nx_packet_in.
+ *
+ * - 'controller_id': The ID of the controller connection to which the
+ * ofp_packet_in should be sent. The ofp_packet_in or nx_packet_in is
+ * sent only to controllers that have the specified controller connection
+ * ID. See "struct nx_controller_id" for more information. */
+struct nx_action_controller {
+ ovs_be16 type; /* OFPAT_VENDOR. */
+ ovs_be16 len; /* Length is 16. */
+ ovs_be32 vendor; /* NX_VENDOR_ID. */
+ ovs_be16 subtype; /* NXAST_CONTROLLER. */
+ ovs_be16 max_len; /* Maximum length to send to controller. */
+ ovs_be16 controller_id; /* Controller ID to send packet-in. */
+ uint8_t reason; /* enum ofp_packet_in_reason (OFPR_*). */
+ uint8_t zero; /* Must be zero. */
+};
+OFP_ASSERT(sizeof(struct nx_action_controller) == 16);
#endif /* openflow/nicira-ext.h */