[ovs-dev] [PATCH] ovs-ofctl:To set importance of a rule for eviction(OF14)
Ben Pfaff
blp at nicira.com
Mon Nov 10 17:28:10 UTC 2014
On Fri, Nov 07, 2014 at 06:18:48PM +0530, Rishi Bamba wrote:
> From: Rishi Bamba <rishi.bamba at tcs.com>
>
> This patch enables a user to set importance for a new rule via add-flow
> OF1.4+ in the OVS and display the same via dump-flows command OF1.4+ .
> The changes are made in accordance with OpenFlow 1.4 specs to implement
> Eviction on the basis of "importance".This patch also enhances the
> diff-flows & replace-flows CLI for addition of importance parameter in
> a rule.
>
> Also changes are made to DESIGN.md,NEWS,ovs-ofctl.8.in and added test cases
> for add-flow & replace-flows.
>
> Signed-off-by: Rishi Bamba <rishi.bamba at tcs.com>
Thanks!
I applied this, with the following changes folded in.
diff --git a/AUTHORS b/AUTHORS
index 1354703..16e27e2 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -122,6 +122,7 @@ Ravi Kerur Ravi.Kerur at telekom.com
Reid Price reid at nicira.com
Remko Tronçon git at el-tramo.be
Rich Lane rlane at bigswitch.com
+Rishi Bamba rishi.bamba at tcs.com
Rob Hoes rob.hoes at citrix.com
Romain Lenglet romain.lenglet at berabera.info
Ryan Wilson wryan at nicira.com
diff --git a/NEWS b/NEWS
index 6a2ae13..bc0ff5f 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,7 @@ Post-v2.3.0
* "resubmit" actions may now be included in action sets. The resubmit
is executed last, and only if the action set has no "output" or "group"
action.
+ * OpenFlow 1.4+ flow "importance" is now maintained in the flow table.
- ovs-pki: Changed message digest algorithm from MD5 to SHA-1 because
MD5 is no longer secure and some operating systems have started to disable
it in OpenSSL.
@@ -46,9 +47,6 @@ Post-v2.3.0
- A simple wrapper script, 'ovs-docker', to integrate OVS with Docker
containers. If and when there is a native integration of Open vSwitch
with Docker, the wrapper script will be retired.
- - Add importance parameter for a rule in accordance to OpenFlow 1.4
- specifications that can only be set through add-flow OF1.4+ . This
- addition is the basis for implementing eviction on the basis of importance.
v2.3.0 - 14 Aug 2014
diff --git a/include/openflow/openflow-1.1.h b/include/openflow/openflow-1.1.h
index d951dc7..8b52b25 100644
--- a/include/openflow/openflow-1.1.h
+++ b/include/openflow/openflow-1.1.h
@@ -340,7 +340,7 @@ struct ofp11_flow_mod {
output group. A value of OFPG11_ANY
indicates no restriction. */
ovs_be16 flags; /* One of OFPFF_*. */
- ovs_be16 importance; /* Eviction Precedence */
+ ovs_be16 importance; /* Eviction precedence (OF1.4+). */
/* Followed by an ofp11_match structure. */
/* Followed by an instruction set. */
};
@@ -451,7 +451,7 @@ struct ofp11_flow_stats {
ovs_be16 idle_timeout; /* Number of seconds idle before expiration. */
ovs_be16 hard_timeout; /* Number of seconds before expiration. */
ovs_be16 flags; /* OF 1.3: Set of OFPFF*. */
- ovs_be16 importance; /* Eviction Precedence */
+ ovs_be16 importance; /* Eviction precedence (OF1.4+). */
uint8_t pad2[2]; /* Align to 64-bits. */
ovs_be64 cookie; /* Opaque controller-issued identifier. */
ovs_be64 packet_count; /* Number of packets in flow. */
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 9433913..60dc0e9 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -1700,8 +1700,7 @@ ofputil_decode_flow_mod(struct ofputil_flow_mod *fm,
fm->idle_timeout = ntohs(ofm->idle_timeout);
fm->hard_timeout = ntohs(ofm->hard_timeout);
- if (oh->version >= OFP14_VERSION
- && (ofm->command == OFPFC_ADD)) {
+ if (oh->version >= OFP14_VERSION && ofm->command == OFPFC_ADD) {
fm->importance = ntohs(ofm->importance);
} else {
fm->importance = 0;
@@ -2256,8 +2255,7 @@ ofputil_encode_flow_mod(const struct ofputil_flow_mod *fm,
ofm->out_port = ofputil_port_to_ofp11(fm->out_port);
ofm->out_group = htonl(fm->out_group);
ofm->flags = raw_flags;
- if (version >= OFP14_VERSION
- && (fm->command == OFPFC_ADD)) {
+ if (version >= OFP14_VERSION && fm->command == OFPFC_ADD) {
ofm->importance = htons(fm->importance);
} else {
ofm->importance = 0;
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index 3c32203..a5cc55a 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -306,7 +306,7 @@ struct ofputil_flow_mod {
ofp_port_t out_port;
uint32_t out_group;
enum ofputil_flow_mod_flags flags;
- uint16_t importance; /* Eviction Precedence */
+ uint16_t importance; /* Eviction precedence. */
struct ofpact *ofpacts; /* Series of "struct ofpact"s. */
size_t ofpacts_len; /* Length of ofpacts, in bytes. */
@@ -356,7 +356,7 @@ struct ofputil_flow_stats {
const struct ofpact *ofpacts;
size_t ofpacts_len;
enum ofputil_flow_mod_flags flags;
- uint16_t importance; /* Eviction Precedence */
+ uint16_t importance; /* Eviction precedence. */
};
int ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *,
diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h
index a07f8ad..94dbbe9 100644
--- a/ofproto/ofproto-provider.h
+++ b/ofproto/ofproto-provider.h
@@ -346,7 +346,7 @@ struct rule {
uint16_t hard_timeout OVS_GUARDED; /* In seconds from ->modified. */
uint16_t idle_timeout OVS_GUARDED; /* In seconds from ->used. */
- /* "Importance" is the eviction precedence of a flow */
+ /* Eviction precedence. */
uint16_t importance OVS_GUARDED;
/* Eviction groups (see comment on struct eviction_group for explanation) .
diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in
index 34d5c3b..0fe2bd4 100644
--- a/utilities/ovs-ofctl.8.in
+++ b/utilities/ovs-ofctl.8.in
@@ -1847,15 +1847,13 @@ Causes the flow to expire after the given number of seconds,
regardless of activity. A value of 0 (the default) gives the flow no
hard expiration deadline.
.
-.IP "\fBimportance\fR"
-Sets the importance of a rule which can be used by the flow entry
-eviction mechanism i.e if set it denotes the eviction precedence
-of a rule. A value of 0 (the default) makes the flow non-evictable
-on the basis of importance.
-.
+.IP "\fBimportance=\fIvalue\fR"
+Sets the importance of a flow. The flow entry eviction mechanism can
+use importance as a factor in deciding which flow to evict. A value
+of 0 (the default) makes the flow non-evictable on the basis of
+importance. Specify a value between 0 and 65535.
.IP
-This can be set only via \fBadd\-flow\fR and \fBadd-flows\fR using
-\fBOpenFlow14+.\fR
+Only OpenFlow 1.4 and later support \fBimportance\fR.
.
.IP "\fBsend_flow_rem\fR"
Marks the flow with a flag that causes the switch to generate a ``flow
More information about the dev
mailing list