[ovs-dev] [PATCH] ofproto: fix incorrect replacement semantics when modifying rules

wangyunjian wangyunjian at huawei.com
Fri Nov 6 08:44:24 UTC 2020


From: Yunjian Wang <wangyunjian at huawei.com>

Currently we copy values from old rule for modify variables(idle_timeout,
hard_timeout, importance, flags) in new rule, which causes a failure to
modify flow. We should not override these variables. This commit fixes
this issue.

The steps to reproduce the problem are as follows.
1. ovs-ofctl add-flow br0 "table=0,in_port=1,hard_timeout=200 actions=learn
   (table=0,in_port=2,hard_timeout=20 output:OXM_OF_IN_PORT[]),output:2"
2. ovs-ofctl mod-flows br0 "table=0,in_port=1,hard_timeout=100 actions=learn
   (table=0,in_port=2,hard_timeout=20 output:OXM_OF_IN_PORT[]),output:2"
3. ovs-ofctl dump-flows br0
    cookie=0x0, duration=16.505s, table=0, n_packets=0, n_bytes=0,
    hard_timeout=200, in_port=vnet0 actions=learn(table=0,hard_timeout=20,
	in_port=vnet1,output:OXM_OF_IN_PORT[]),output:vnet1
Step 2 will modify the rule of flow created in step 1, however, the dump
result of step 3 is still the old one.

Fixes: 39c9459355 ("Use classifier versioning.")

Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
---
 ofproto/ofproto.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index b91517cd2..81680c6c1 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -5544,10 +5544,6 @@ replace_rule_start(struct ofproto *ofproto, struct ofproto_flow_mod *ofm,
             ovs_mutex_lock(&new_rule->mutex);
             ovs_mutex_lock(&old_rule->mutex);
             if (ofm->command != OFPFC_ADD) {
-                new_rule->idle_timeout = old_rule->idle_timeout;
-                new_rule->hard_timeout = old_rule->hard_timeout;
-                *CONST_CAST(uint16_t *, &new_rule->importance) = old_rule->importance;
-                new_rule->flags = old_rule->flags;
                 new_rule->created = old_rule->created;
             }
             if (!change_cookie) {
-- 
2.18.1



More information about the dev mailing list