diff mbox series

[ovs-dev] ofproto: Fix mod flow table name not to take effect.

Message ID 20240403070319.43836-1-zhouyuhao.philozhou@bytedance.com
State Superseded
Delegated to: Simon Horman
Headers show
Series [ovs-dev] ofproto: Fix mod flow table name not to take effect. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Yuhao zhou April 3, 2024, 7:03 a.m. UTC
From: "zhouyuhao.philozhou" <zhouyuhao.philozhou@bytedance.com>

When mod a flow table's name with table's prefix name, there
will be no change. Because when check whether the new and old
name are the same, only compare the length of the new name.

Case:
  table 10: "good"
  There will be no change if mod the table's name with "g" "go" "goo".

Signed-off-by: zhouyuhao.philozhou <zhouyuhao.philozhou@bytedance.com>
---
 ofproto/ofproto.c |  4 +++-
 tests/ofproto.at  | 12 ++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 122a06f30..bf7ed91b1 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -9293,7 +9293,9 @@  oftable_set_name(struct oftable *table, const char *name, int level)
     if (level >= table->name_level) {
         if (name) {
             if (name[0]) {
-                if (!table->name || strncmp(name, table->name, len)) {
+                if (!table->name
+                    || strncmp(name, table->name, len)
+                    || len != strlen(table->name)) {
                     free(table->name);
                     table->name = xmemdup0(name, len);
                 }
diff --git a/tests/ofproto.at b/tests/ofproto.at
index 2889f81fb..09c57b292 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -2523,6 +2523,18 @@  AT_CHECK([ovs-ofctl -O OpenFlow15 dump-table-features br0 |grep '^  table'],
   table 253:
 ])
 
+# Make sure that the new name is old table's name prefix can also take effect.
+AT_CHECK([ovs-ofctl -O OpenFlow13 mod-table br0 3 name:thr])
+AT_CHECK([ovs-ofctl -O OpenFlow15 dump-table-features br0 |grep '^  table'],
+  [0], [dnl
+  table 0 ("zero"):
+  table 1 ("one"): ditto
+  table 2: ditto
+  table 3 ("thr"): ditto
+  tables 4...252: ditto
+  table 253:
+])
+
 OVS_VSWITCHD_STOP
 AT_CLEANUP