Introduce the bfd reference in logical_router_static_router table in order to check if the next-hop is properly running using the BFD protocol. The CMS is supposed to populate bfd column with the proper reference otherwise the BFD status is set to admin_down. Add BFD tests in system-ovn.at.
Signed-off-by: Lorenzo Bianconi <[email protected]> --- NEWS | 3 +- northd/ovn-northd.c | 11 +++++ ovn-nb.ovsschema | 6 ++- ovn-nb.xml | 7 +++ tests/atlocal.in | 3 ++ tests/ovn-nbctl.at | 8 +++- tests/system-ovn.at | 104 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 139 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 306a7ccda..2f535f9a5 100644 --- a/NEWS +++ b/NEWS @@ -24,7 +24,8 @@ OVN v20.12.0 - xx xxx xxxx significantly decrease size of a Southbound DB. However, in some cases, it could have performance penalty for ovn-controller. Disabled by default. - - BFD protocol support according to RFC880 [0] + - BFD protocol support according to RFC880 [0]. Introduce next-hop BFD + availability check for OVN static routes. [0] https://tools.ietf.org/html/rfc5880) OVN v20.09.0 - 28 Sep 2020 diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index f15e1513e..8068e5cbf 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -7783,6 +7783,17 @@ parsed_routes_add(struct ovs_list *routes, return NULL; } + const struct nbrec_bfd *nb_bt = route->bfd; + if (nb_bt && !strcmp(nb_bt->dst_ip, route->nexthop)) { + if (!strcmp(nb_bt->status, "admin_down")) { + nbrec_bfd_set_status(nb_bt, "down"); + } + + if (!strcmp(nb_bt->status, "down")) { + return NULL; + } + } + struct parsed_route *pr = xzalloc(sizeof *pr); pr->prefix = prefix; pr->plen = plen; diff --git a/ovn-nb.ovsschema b/ovn-nb.ovsschema index a880482a4..06253991c 100644 --- a/ovn-nb.ovsschema +++ b/ovn-nb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_Northbound", "version": "5.31.0", - "cksum": "3663844734 28178", + "cksum": "1772556706 28406", "tables": { "NB_Global": { "columns": { @@ -374,6 +374,10 @@ "min": 0, "max": 1}}, "nexthop": {"type": "string"}, "output_port": {"type": {"key": "string", "min": 0, "max": 1}}, + "bfd": {"type": {"key": {"type": "uuid", "refTable": "BFD", + "refType": "weak"}, + "min": 0, + "max": 1}}, "options": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}, diff --git a/ovn-nb.xml b/ovn-nb.xml index 4a28d3f0d..8c0ff0b72 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -2644,6 +2644,13 @@ </p> </column> + <column name="bfd"> + <p> + Reference to <ref table="BFD"/> row if the route has associated a + BFD session + </p> + </column> + <column name="external_ids" key="ic-learned-route"> <code>ovn-ic</code> populates this key if the route is learned from the global <ref db="OVN_IC_Southbound"/> database. In this case the value diff --git a/tests/atlocal.in b/tests/atlocal.in index d9a4c91d4..5ebc8e117 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -181,6 +181,9 @@ fi # Set HAVE_DIBBLER-SERVER find_command dibbler-server +# Set HAVE_BFDD_BEACON +find_command bfdd-beacon + # Turn off proxies. unset http_proxy unset https_proxy diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at index 01edfcbc1..2827b223c 100644 --- a/tests/ovn-nbctl.at +++ b/tests/ovn-nbctl.at @@ -1617,7 +1617,13 @@ IPv6 Routes 2001:db8::/64 2001:db8:0:f102::1 dst-ip lp0 2001:db8:1::/64 2001:db8:0:f103::1 dst-ip ::/0 2001:db8:0:f101::1 dst-ip -])]) +]) + +AT_CHECK([ovn-nbctl lrp-add lr0 lr0-p0 00:00:01:01:02:03 192.168.10.1/24]) +bfd_uuid=$(ovn-nbctl create bfd logical_port=lr0-p0 dst_ip=100.0.0.50 status=down min_tx=250 min_rx=250 detect_mult=10) +AT_CHECK([ovn-nbctl lr-route-add lr0 100.0.0.0/24 192.168.0.1]) +route_uuid=$(fetch_column nb:logical_router_static_route _uuid ip_prefix="100.0.0.0/24") +AT_CHECK([ovn-nbctl set logical_router_static_route $route_uuid bfd=$bfd_uuid])]) dnl --------------------------------------------------------------------- diff --git a/tests/system-ovn.at b/tests/system-ovn.at index 1e73001ab..27a67e12d 100644 --- a/tests/system-ovn.at +++ b/tests/system-ovn.at @@ -5531,3 +5531,107 @@ as OVS_TRAFFIC_VSWITCHD_STOP(["/.*error receiving.*/d /.*terminating with signal 15.*/d"]) AT_CLEANUP + +AT_SETUP([ovn -- BFD]) +AT_SKIP_IF([test $HAVE_BFDD_BEACON = no]) +AT_KEYWORDS([ovn-bfd]) + +ovn_start +OVS_TRAFFIC_VSWITCHD_START() + +ADD_BR([br-int]) +ADD_BR([br-ext]) + +check ovs-ofctl add-flow br-ext action=normal +# Set external-ids in br-int needed for ovn-controller +check ovs-vsctl \ + -- set Open_vSwitch . external-ids:system-id=hv1 \ + -- set Open_vSwitch . external-ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock \ + -- set Open_vSwitch . external-ids:ovn-encap-type=geneve \ + -- set Open_vSwitch . external-ids:ovn-encap-ip=169.0.0.1 \ + -- set bridge br-int fail-mode=secure other-config:disable-in-band=true + +# Start ovn-controller +start_daemon ovn-controller + +check ovn-nbctl lr-add R1 + +check ovn-nbctl ls-add sw0 +check ovn-nbctl ls-add sw1 +check ovn-nbctl ls-add public + +check ovn-nbctl lrp-add R1 rp-sw0 00:00:01:01:02:03 192.168.1.1/24 +check ovn-nbctl lrp-add R1 rp-sw1 00:00:03:01:02:03 192.168.2.1/24 +check ovn-nbctl lrp-add R1 rp-public 00:00:02:01:02:03 172.16.1.1/24 \ + -- lrp-set-gateway-chassis rp-public hv1 + +check ovn-nbctl lsp-add sw0 sw0-rp -- set Logical_Switch_Port sw0-rp \ + type=router options:router-port=rp-sw0 \ + -- lsp-set-addresses sw0-rp router +check ovn-nbctl lsp-add sw1 sw1-rp -- set Logical_Switch_Port sw1-rp \ + type=router options:router-port=rp-sw1 \ + -- lsp-set-addresses sw1-rp router + +check ovn-nbctl lsp-add public public-rp -- set Logical_Switch_Port public-rp \ + type=router options:router-port=rp-public \ + -- lsp-set-addresses public-rp router + +ADD_NAMESPACES(sw01) +ADD_VETH(sw01, sw01, br-int, "192.168.1.2/24", "f0:00:00:01:02:03", \ + "192.168.1.1") +check ovn-nbctl lsp-add sw0 sw01 \ + -- lsp-set-addresses sw01 "f0:00:00:01:02:03 192.168.1.2" + +ADD_NAMESPACES(sw11) +ADD_VETH(sw11, sw11, br-int, "192.168.2.2/24", "f0:00:00:02:02:03", \ + "192.168.2.1") +check ovn-nbctl lsp-add sw1 sw11 \ + -- lsp-set-addresses sw11 "f0:00:00:02:02:03 192.168.2.2" + +ADD_NAMESPACES(server) +NS_CHECK_EXEC([server], [ip link set dev lo up]) +ADD_VETH(s1, server, br-ext, "172.16.1.50/24", "f0:00:00:01:02:05", \ + "172.16.1.1") + +AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=phynet:br-ext]) +check ovn-nbctl lsp-add public public1 \ + -- lsp-set-addresses public1 unknown \ + -- lsp-set-type public1 localnet \ + -- lsp-set-options public1 network_name=phynet + +NS_CHECK_EXEC([server], [bfdd-beacon --listen=172.16.1.50], [0]) +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 +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 +OVS_WAIT_UNTIL([ovn-sbctl dump-flows R1 | grep 'match=(ip4.dst == 100.0.0.0/8)' | grep -q 172.16.1.50]) + +NS_CHECK_EXEC([server], [bfdd-control stop], [0], [dnl +stopping +]) + +wait_column "down" nb:bfd status logical_port=rp-public +OVS_WAIT_UNTIL([test "$(ovn-sbctl dump-flows R1 | grep 'match=(ip4.dst == 100.0.0.0/8)' | grep 172.16.1.50)" = ""]) + +kill $(pidof ovn-controller) + +as ovn-sb +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) + +as ovn-nb +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) + +as northd +OVS_APP_EXIT_AND_WAIT([ovn-northd]) + +as +OVS_TRAFFIC_VSWITCHD_STOP(["/.*error receiving.*/d +/.*terminating with signal 15.*/d"]) +AT_CLEANUP -- 2.29.2 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
