From 3e8116d9a3fffb480a19a47dba46154ec1b2414f Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 23 Sep 2013 21:34:37 -0700 Subject: [PATCH] ofproto: Allow ofproto_delete_flow() to delete hidden rules. Commit 97f63e57a8 (ofproto: Remove soon-to-be-invalid optimizations.) changed ofproto_delete_flow() to use the general-purpose flow_mod implementation. However, the general-purpose flow_mod never matches hidden flows, which are exactly the flows that ofproto_delete_flow()'s callers want to delete. This commit fixes the problem by allowing flow_mods that specify a priority that can only be for a hidden flow to delete a hidden flow. (This doesn't allow OpenFlow clients to meddle with hidden flows because OpenFlow uses only a 16-bit field to specify priority.) I verified that, without this commit, if I change from one controller to another with "ovs-vsctl set-controller", then the in-band rules for the old controller remain. With this commit, the old rules are removed. Reported-by: YAMAMOTO Takashi Bug #19821. Reported-by: Luca Giraudo Bug #19888. Reported-by: Ying Chen Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- ofproto/ofproto.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index cfe8d2aac..1e5319a14 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -3239,7 +3239,13 @@ collect_rule(struct rule *rule, const struct rule_criteria *c, struct rule_collection *rules) OVS_REQUIRES(ofproto_mutex) { - if (ofproto_rule_is_hidden(rule)) { + /* We ordinarily want to skip hidden rules, but there has to be a way for + * code internal to OVS to modify and delete them, so if the criteria + * specify a priority that can only be for a hidden flow, then allow hidden + * rules to be selected. (This doesn't allow OpenFlow clients to meddle + * with hidden flows because OpenFlow uses only a 16-bit field to specify + * priority.) */ + if (ofproto_rule_is_hidden(rule) && c->cr.priority <= UINT16_MAX) { return 0; } else if (rule->pending) { return OFPROTO_POSTPONE; -- 2.43.0