Do not report an error adding a duplicated ecmp route if --may-exist
parameter is provided.
Related bz: https://bugzilla.redhat.com/show_bug.cgi?id=1959909

Signed-off-by: Lorenzo Bianconi <[email protected]>
---
 tests/ovn-nbctl.at    | 2 ++
 utilities/ovn-nbctl.c | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at
index 6d91aa4c5..8af55161f 100644
--- a/tests/ovn-nbctl.at
+++ b/tests/ovn-nbctl.at
@@ -1551,6 +1551,7 @@ IPv4 Routes
 AT_CHECK([ovn-nbctl --ecmp lr-route-add lr0 10.0.0.0/24 11.0.0.2], [1], [],
   [ovn-nbctl: duplicate nexthop for the same ECMP route
 ])
+AT_CHECK([ovn-nbctl --may-exist --ecmp lr-route-add lr0 10.0.0.0/24 11.0.0.2])
 
 dnl Delete ecmp routes
 AT_CHECK([ovn-nbctl lr-route-del lr0 10.0.0.0/24 11.0.0.1])
@@ -1614,6 +1615,7 @@ AT_CHECK([ovn-nbctl --ecmp-symmetric-reply lr-route-add 
lr0 2003:0db8:1::/64 200
 AT_CHECK([ovn-nbctl --ecmp-symmetric-reply lr-route-add lr0 2003:0db8:1::/64 
2001:0db8:0:f103::6], [1], [],
   [ovn-nbctl: duplicate nexthop for the same ECMP route
 ])
+AT_CHECK([ovn-nbctl --may-exist --ecmp-symmetric-reply lr-route-add lr0 
2003:0db8:1::/64 2001:0db8:0:f103::6])
 
 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
 IPv4 Routes
diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c
index 48fd0b7ee..84e228f02 100644
--- a/utilities/ovn-nbctl.c
+++ b/utilities/ovn-nbctl.c
@@ -4073,7 +4073,9 @@ nbctl_lr_route_add(struct ctl_context *ctx)
             goto cleanup;
         }
     } else if (route) {
-        ctl_error(ctx, "duplicate nexthop for the same ECMP route");
+        if (!may_exist) {
+            ctl_error(ctx, "duplicate nexthop for the same ECMP route");
+        }
         goto cleanup;
     }
 
-- 
2.31.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to