On 1/29/21 12:10 AM, Lorenzo Bianconi wrote:
Introduce the --bfd option to lr-route-add-bfd.
If the BFD session UUID is provided, it will be used for the OVN route
otherwise the next-hop will be used to perform a lookup in the OVN BFD
table.
If the lookup fails and outport is specified, a new entry in the BFD table
will be created using the nexthop as dst_ip and outport as logical_port.

Signed-off-by: Lorenzo Bianconi <[email protected]>
---

Hi Lorenzo,

Changes since v1:
- introduce the capability to create the BFD entry if route outport has been
   specified
---
  tests/ovn-northd.at       | 17 +++++++++++-----
  tests/system-ovn.at       |  5 ++---
  utilities/ovn-nbctl.8.xml | 11 ++++++++++
  utilities/ovn-nbctl.c     | 43 ++++++++++++++++++++++++++++++++++++++-
  4 files changed, 67 insertions(+), 9 deletions(-)

diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
index 8597ca1b9..c00225e99 100644
--- a/tests/ovn-northd.at
+++ b/tests/ovn-northd.at
@@ -2342,7 +2342,7 @@ AT_KEYWORDS([northd-bfd])
  ovn_start
check ovn-nbctl --wait=sb lr-add r0
-for i in $(seq 1 4); do
+for i in $(seq 1 5); do
      check ovn-nbctl --wait=sb lrp-add r0 r0-sw$i 00:00:00:00:00:0$i 
192.168.$i.1/24
      check ovn-nbctl --wait=sb ls-add sw$i
      check ovn-nbctl --wait=sb lsp-add sw$i sw$i-r0
@@ -2387,17 +2387,24 @@ check_column 1000 bfd min_tx logical_port=r0-sw1
  check_column 1000 bfd min_rx logical_port=r0-sw1
  check_column 100 bfd detect_mult logical_port=r0-sw1
-check ovn-nbctl lr-route-add r0 100.0.0.0/8 192.168.10.2
-route_uuid=$(fetch_column nb:logical_router_static_route _uuid 
ip_prefix="100.0.0.0/8")
-check ovn-nbctl set logical_router_static_route $route_uuid bfd=$uuid
+check ovn-nbctl --bfd=$uuid lr-route-add r0 100.0.0.0/8 192.168.10.2
  check_column down bfd status logical_port=r0-sw1
  AT_CHECK([ovn-nbctl lr-route-list r0 | grep 192.168.10.2 | grep -q bfd],[0])
+check ovn-nbctl --bfd lr-route-add r0 200.0.0.0/8 192.168.20.2
+check_column down bfd status logical_port=r0-sw2
+AT_CHECK([ovn-nbctl lr-route-list r0 | grep 192.168.20.2 | grep -q bfd],[0])
+
+check ovn-nbctl --bfd lr-route-add r0 240.0.0.0/8 192.168.50.2 r0-sw5
+check_column down bfd status logical_port=r0-sw5
+AT_CHECK([ovn-nbctl lr-route-list r0 | grep 192.168.50.2 | grep -q bfd],[0])
+
+route_uuid=$(fetch_column nb:logical_router_static_route _uuid 
ip_prefix="100.0.0.0/8")
  check ovn-nbctl clear logical_router_static_route $route_uuid bfd
  check_column admin_down bfd status logical_port=r0-sw1
ovn-nbctl destroy bfd $uuid
-check_row_count bfd 2
+check_row_count bfd 3
AT_CLEANUP diff --git a/tests/system-ovn.at b/tests/system-ovn.at
index 4580c05e7..05ccd861a 100644
--- a/tests/system-ovn.at
+++ b/tests/system-ovn.at
@@ -5606,10 +5606,9 @@ NS_CHECK_EXEC([server], [bfdd-control allow 172.16.1.1], 
[0], [dnl
  Allowing connections from 172.16.1.1
  ])
-uuid=$(ovn-nbctl create bfd logical_port=rp-public dst_ip=172.16.1.50 min_tx=250 min_rx=250 detect_mult=10)
-check ovn-nbctl lr-route-add R1 100.0.0.0/8 172.16.1.50
+check ovn-nbctl --bfd lr-route-add R1 100.0.0.0/8 172.16.1.50 rp-public
+uuid=$(fetch_column nb:bfd _uuid logical_port="rp-public")
  route_uuid=$(fetch_column nb:logical_router_static_route _uuid 
ip_prefix="100.0.0.0/8")
-check ovn-nbctl set logical_router_static_route $route_uuid bfd=$uuid
  check ovn-nbctl --wait=hv sync
wait_column "up" nb:bfd status logical_port=rp-public
diff --git a/utilities/ovn-nbctl.8.xml b/utilities/ovn-nbctl.8.xml
index 6ed8bcb75..249a17344 100644
--- a/utilities/ovn-nbctl.8.xml
+++ b/utilities/ovn-nbctl.8.xml
@@ -659,6 +659,7 @@
      <dl>
        <dt>[<code>--may-exist</code>] [<code>--policy</code>=<var>POLICY</var>]
          [<code>--ecmp</code>] [<code>--ecmp-symmetric-reply</code>]
+        [<code>--bfd=<var>UUID</var></code>]
          <code>lr-route-add</code> <var>router</var>
          <var>prefix</var> <var>nexthop</var> [<var>port</var>]</dt>
        <dd>
@@ -695,6 +696,16 @@
            it is not necessary to set both.
          </p>
+ <p>
+          <code>--bfd</code> option is used to link a BFD session to the
+          OVN route. If the BFD session UUID is provided, it will be used
+          for the OVN route otherwise the next-hop will be used to perform
+          a lookup in the OVN BFD table.
+          If the lookup fails and <var>port</var> is specified, a new entry
+          in the BFD table will be created using the <var>nexthop</var> as
+          <var>dst_ip</var> and <var>port</var> as <var>logical_port</var>.
+        </p>
+
          <p>
            It is an error if a route with <var>prefix</var> and
            <var>POLICY</var> already exists, unless <code>--may-exist</code>,
diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c
index 1b7be1ef9..b5bf59e0b 100644
--- a/utilities/ovn-nbctl.c
+++ b/utilities/ovn-nbctl.c
@@ -3960,6 +3960,41 @@ nbctl_lr_route_add(struct ctl_context *ctx)
          goto cleanup;
      }
+ struct shash_node *bfd = shash_find(&ctx->options, "--bfd");
+    const struct nbrec_bfd *nb_bt = NULL;
+    if (bfd) {
+        if (bfd->data) {
+            char *data = xstrdup(bfd->data);
+            struct uuid bfd_uuid;
+            if (uuid_from_string(&bfd_uuid, data)) {

There's no need to xstrdup(bfd->data) above, we can just pass it directly:

uuid_from_string(&bfd_uuid, data)

Regards,
Dumitru

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

Reply via email to