Fix evpn neighbors advertisement when dynamic-routing-redistribute option is set to "fdb,ip"
Reported-at: https://issues.redhat.com/browse/FDP-2221 Fixes: 499ddafbf160 ("controller: Advertise local EVPN type2 routes in ovn-controller.") Fixes: 3b500540552f ("northd: Collect vif and router port IPs/MAC bindings in the SB Advertised_Mac_Binding table.") Signed-off-by: Lorenzo Bianconi <[email protected]> --- Changes since v1: - Rely on nrm_mode_*_is_set() utilities --- controller/neighbor.c | 8 ++++---- controller/ovn-controller.c | 9 +++------ lib/ovn-util.c | 25 +++++++++++++++++++++++++ lib/ovn-util.h | 30 ++++++++++++++++++++++++++++++ northd/en-advertised-route-sync.c | 6 +++--- tests/system-ovn.at | 9 ++++++++- 6 files changed, 73 insertions(+), 14 deletions(-) diff --git a/controller/neighbor.c b/controller/neighbor.c index 0bad7e019..545f01a87 100644 --- a/controller/neighbor.c +++ b/controller/neighbor.c @@ -117,15 +117,15 @@ neighbor_run(struct neighbor_ctx_in *n_ctx_in, NEIGH_IFACE_BRIDGE, vni); vector_push(n_ctx_out->monitored_interfaces, &br_v6); - const char *redistribute = smap_get(&ld->datapath->external_ids, - "dynamic-routing-redistribute"); - if (redistribute && !strcmp(redistribute, "fdb")) { + enum neigh_redistribute_mode mode = + parse_neigh_dynamic_redistribute(&ld->datapath->external_ids); + if (nrm_mode_FDB_is_set(mode)) { neighbor_collect_mac_to_advertise(n_ctx_in, &lo->announced_neighbors, n_ctx_out->advertised_pbs, ld->datapath); } - if (redistribute && !strcmp(redistribute, "ip")) { + if (nrm_mode_IP_is_set(mode)) { neighbor_collect_ip_mac_to_advertise(n_ctx_in, &br_v4->announced_neighbors, &br_v6->announced_neighbors, diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index c2dab41c1..3aaa86ff6 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -5983,12 +5983,9 @@ neighbor_runtime_data_handler(struct engine_node *node, void *data) return EN_UNHANDLED; } - const char *redistribute = smap_get(&ld->datapath->external_ids, - "dynamic-routing-redistribute"); - if (!redistribute) { - continue; - } - if (strcmp(redistribute, "fdb") && strcmp(redistribute, "ip")) { + enum neigh_redistribute_mode mode = + parse_neigh_dynamic_redistribute(&ld->datapath->external_ids); + if (mode == NRM_NONE) { continue; } diff --git a/lib/ovn-util.c b/lib/ovn-util.c index d27983d1e..502ca7718 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -1648,3 +1648,28 @@ normalize_addr_str(const char *orig_addr) return ret; } + +enum neigh_redistribute_mode +parse_neigh_dynamic_redistribute(const struct smap *options) +{ + const char *redistribute = smap_get(options, + "dynamic-routing-redistribute"); + if (!redistribute) { + return NRM_NONE; + } + + enum neigh_redistribute_mode mode = NRM_NONE; + char *save_ptr = NULL, *tokstr = xstrdup(redistribute); + for (char *token = strtok_r(tokstr, ",", &save_ptr); + token; token = strtok_r(NULL, ",", &save_ptr)) { + if (!strcmp(token, "fdb")) { + mode |= NRM_FDB; + } + if (!strcmp(token, "ip")) { + mode |= NRM_IP; + } + } + free(tokstr); + + return mode; +} diff --git a/lib/ovn-util.h b/lib/ovn-util.h index 7a5bb9559..5e1eb1652 100644 --- a/lib/ovn-util.h +++ b/lib/ovn-util.h @@ -686,4 +686,34 @@ char *normalize_ipv6_addr_str(const char *orig_addr); char *normalize_addr_str(const char *orig_addr); +#define NEIGH_REDISTRIBUTE_MODES \ + NEIGH_REDISTRIBUTE_MODE(FDB, 0) \ + NEIGH_REDISTRIBUTE_MODE(IP, 1) + +enum neigh_redistribute_mode_bits { +#define NEIGH_REDISTRIBUTE_MODE(PROTOCOL, BIT) NRM_##PROTOCOL##_BIT = BIT, + NEIGH_REDISTRIBUTE_MODES +#undef NEIGH_REDISTRIBUTE_MODE +}; + +enum neigh_redistribute_mode { + NRM_NONE = 0, +#define NEIGH_REDISTRIBUTE_MODE(PROTOCOL, BIT) \ + NRM_##PROTOCOL = (1 << NRM_##PROTOCOL##_BIT), + NEIGH_REDISTRIBUTE_MODES +#undef NEIGH_REDISTRIBUTE_MODE +}; + +#define NEIGH_REDISTRIBUTE_MODE(PROTOCOL, BIT) \ + static inline bool nrm_mode_##PROTOCOL##_is_set( \ + enum neigh_redistribute_mode value) \ + { \ + return !!(value & NRM_##PROTOCOL); \ + } +NEIGH_REDISTRIBUTE_MODES +#undef NEIGH_REDISTRIBUTE_MODE + +enum neigh_redistribute_mode +parse_neigh_dynamic_redistribute(const struct smap *options); + #endif /* OVN_UTIL_H */ diff --git a/northd/en-advertised-route-sync.c b/northd/en-advertised-route-sync.c index ef830188f..be771391d 100644 --- a/northd/en-advertised-route-sync.c +++ b/northd/en-advertised-route-sync.c @@ -887,9 +887,9 @@ evpn_ip_redistribution_enabled(const struct ovn_datapath *od) return false; } - const char *redistribute = smap_get(&od->nbs->other_config, - "dynamic-routing-redistribute"); - return redistribute && !strcmp(redistribute, "ip"); + enum neigh_redistribute_mode mode = + parse_neigh_dynamic_redistribute(&od->nbs->other_config); + return nrm_mode_IP_is_set(mode); } static uint32_t diff --git a/tests/system-ovn.at b/tests/system-ovn.at index cc672d43a..c7c6b6c09 100644 --- a/tests/system-ovn.at +++ b/tests/system-ovn.at @@ -18649,13 +18649,20 @@ check ovn-nbctl --wait=hv \ -- lrp-add lr lr-ls-evpn f0:00:0f:16:01:01 172.16.1.1/24 ls_evpn_uuid=$(fetch_column Datapath_Binding _uuid external_ids:name=ls-evpn) -check ovn-nbctl --wait=hv set logical_switch ls-evpn other_config:dynamic-routing-redistribute=ip +check ovn-nbctl --wait=hv set logical_switch ls-evpn other_config:dynamic-routing-redistribute=fdb,ip check_row_count Advertised_MAC_Binding 1 ip=172.16.1.10 mac='f0\:00\:0f\:16\:01\:10' datapath=$ls_evpn_uuid check_row_count Advertised_MAC_Binding 1 ip=172.16.1.1 mac='f0\:00\:0f\:16\:01\:01' datapath=$ls_evpn_uuid AT_CHECK([ip neigh show dev br-10 nud noarp | grep -q '172.16.1.10 lladdr f0:00:0f:16:01:10 NOARP']) AT_CHECK([ip neigh show dev br-10 nud noarp | grep -q '172.16.1.1 lladdr f0:00:0f:16:01:01 NOARP']) +OVS_WAIT_FOR_OUTPUT([bridge fdb show | grep "lo-10" | grep "f0:00:0f:16:01" | sort], [0], [dnl +f0:00:0f:16:01:01 dev lo-10 master br-10 static +f0:00:0f:16:01:01 dev lo-10 vlan 1 master br-10 static +f0:00:0f:16:01:10 dev lo-10 master br-10 static +f0:00:0f:16:01:10 dev lo-10 vlan 1 master br-10 static +]) + check ovn-nbctl --wait=hv lsp-add ls-evpn workload2 \ -- lsp-set-addresses workload2 "f0:00:0f:16:01:20 172.16.1.20" -- 2.51.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
