[ovs-dev] [PATCH v2 ovn] ovn-nbctl: dump next-hop for router policies
Lorenzo Bianconi
lorenzo.bianconi at redhat.com
Tue Apr 20 18:11:02 UTC 2021
Commit 35b00c7e79 ('northd: Add ECMP support to router policies.')
introduced 'nexthops' column in the Logical_Router_Policy table to
support ECMP for router policies however print_routing_policy() still
dumps legacy 'nexthop' column as policy next hop.
Fix the issue dumping 'nexthops' columns.
Fixes: 35b00c7e79 ('northd: Add ECMP support to router policies.')
Acked-by: Mark Michelson <mmichels at redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi at redhat.com>
---
Changes since v1:
- remove typo in ovn-northd.at
---
tests/ovn-northd.at | 7 +++++++
utilities/ovn-nbctl.c | 14 +++++++++-----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
index eef360802..6ece56d6f 100644
--- a/tests/ovn-northd.at
+++ b/tests/ovn-northd.at
@@ -2485,6 +2485,13 @@ check ovn-nbctl lsp-set-options public-lr0 router-port=lr0-public
check ovn-nbctl --wait=sb lr-policy-add lr0 10 "ip4.src == 10.0.0.3" reroute 172.168.0.101,172.168.0.102
+ovn-nbctl lr-policy-list lr0 > policy-list
+AT_CAPTURE_FILE([policy-list])
+AT_CHECK([cat policy-list], [0], [dnl
+Routing Policies
+ 10 ip4.src == 10.0.0.3 reroute 172.168.0.101, 172.168.0.102
+])
+
ovn-sbctl dump-flows lr0 > lr0flows3
AT_CAPTURE_FILE([lr0flows3])
diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c
index 184058356..042c21002 100644
--- a/utilities/ovn-nbctl.c
+++ b/utilities/ovn-nbctl.c
@@ -3865,11 +3865,15 @@ static void
print_routing_policy(const struct nbrec_logical_router_policy *policy,
struct ds *s)
{
- if (policy->nexthop != NULL) {
- char *next_hop = normalize_prefix_str(policy->nexthop);
- ds_put_format(s, "%10"PRId64" %50s %15s %25s", policy->priority,
- policy->match, policy->action, next_hop);
- free(next_hop);
+ if (policy->n_nexthops) {
+ ds_put_format(s, "%10"PRId64" %50s %15s", policy->priority,
+ policy->match, policy->action);
+ for (int i = 0; i < policy->n_nexthops; i++) {
+ char *next_hop = normalize_prefix_str(policy->nexthops[i]);
+ char *fmt = i ? ", %s" : " %25s";
+ ds_put_format(s, fmt, next_hop);
+ free(next_hop);
+ }
} else {
ds_put_format(s, "%10"PRId64" %50s %15s", policy->priority,
policy->match, policy->action);
--
2.30.2
More information about the dev
mailing list