Use OFPRR_GROUP_DELETE as the reason for deleting flows due
to the removal of a group that they use.

This implementation adds an delete_reason member to struct ofputil_flow_mod
as a convenient way to set the reason used by delete_flows__() when it is
called indirectly from delete_group__().

Signed-off-by: Simon Horman <ho...@verge.net.au>
---
 lib/ofp-util.c    | 3 +++
 lib/ofp-util.h    | 3 +++
 ofproto/ofproto.c | 8 ++++++--
 tests/ofproto.at  | 9 +++++++++
 4 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 09e4438..03fc978 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -1596,6 +1596,9 @@ ofputil_decode_flow_mod(struct ofputil_flow_mod *fm,
     struct ofpbuf b;
     enum ofpraw raw;
 
+    /* Ignored for non-delete actions */
+    fm->delete_reason = OFPRR_DELETE;
+
     ofpbuf_use_const(&b, oh, ntohs(oh->length));
     raw = ofpraw_pull_assert(&b);
     if (raw == OFPRAW_OFPT11_FLOW_MOD) {
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index 552b006..878bcf8 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -307,6 +307,9 @@ struct ofputil_flow_mod {
     enum ofputil_flow_mod_flags flags;
     struct ofpact *ofpacts;  /* Series of "struct ofpact"s. */
     size_t ofpacts_len;      /* Length of ofpacts, in bytes. */
+
+    /* Reason for delete; ignored for non-delete commands */
+    enum ofp_flow_removed_reason delete_reason;
 };
 
 enum ofperr ofputil_decode_flow_mod(struct ofputil_flow_mod *,
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 24a709b..df4d176 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -1865,6 +1865,7 @@ flow_mod_init(struct ofputil_flow_mod *fm,
     fm->flags = 0;
     fm->ofpacts = CONST_CAST(struct ofpact *, ofpacts);
     fm->ofpacts_len = ofpacts_len;
+    fm->delete_reason = OFPRR_DELETE;
 }
 
 static int
@@ -4376,7 +4377,8 @@ delete_flows_loose(struct ofproto *ofproto, struct ofconn 
*ofconn,
     rule_criteria_destroy(&criteria);
 
     if (!error && rules.n > 0) {
-        error = delete_flows__(ofproto, ofconn, request, &rules, OFPRR_DELETE);
+        error = delete_flows__(ofproto, ofconn, request, &rules,
+                               fm->delete_reason);
     }
     rule_collection_destroy(&rules);
 
@@ -4401,7 +4403,8 @@ delete_flow_strict(struct ofproto *ofproto, struct ofconn 
*ofconn,
     rule_criteria_destroy(&criteria);
 
     if (!error && rules.n > 0) {
-        error = delete_flows__(ofproto, ofconn, request, &rules, OFPRR_DELETE);
+        error = delete_flows__(ofproto, ofconn, request, &rules,
+                               fm->delete_reason);
     }
     rule_collection_destroy(&rules);
 
@@ -5743,6 +5746,7 @@ delete_group__(struct ofproto *ofproto, struct ofgroup 
*ofgroup)
     /* Delete all flow entries containing this group in a group action */
     match_init_catchall(&match);
     flow_mod_init(&fm, &match, 0, NULL, 0, OFPFC_DELETE);
+    fm.delete_reason = OFPRR_GROUP_DELETE;
     fm.out_group = ofgroup->group_id;
     handle_flow_mod__(ofproto, NULL, &fm, NULL);
 
diff --git a/tests/ofproto.at b/tests/ofproto.at
index 2f1df2d..be0bcfe 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -1818,6 +1818,15 @@ 
udp,metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:26:b9:8c:b0:f9,dl_dst=00:25:8
     if test X"$1" = X"OFPRR_DELETE"; then shift;
         echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=delete table_id=0"
     fi
+
+    # OFPT_FLOW_REMOVED, OFPRR_GROUP_DELETE
+    ovs-ofctl -O OpenFlow13 add-group br0 
group_id=1234,type=all,bucket=output:10
+    ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=group:1234
+    ovs-ofctl -O OpenFlow13 --strict del-groups br0 group_id=1234
+    if test X"$1" = X"OFPRR_DELETE"; then shift;
+        echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=gropu_delete 
table_id=0"
+    fi
+
     AT_FAIL_IF([test X"$1" != X])
 
     ovs-appctl -t ovs-ofctl ofctl/barrier
-- 
1.8.5.2

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to