In case we want to replace route with the same destination but just different nexthop we need to remove the stale ones first otherwise the first loop would return that the route already exists and it would be created the second loop. At the same time remove the unused err variable in the re_nl_cleanup_routes function.
Signed-off-by: Ales Musil <[email protected]> --- controller/route-exchange-netlink.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/controller/route-exchange-netlink.c b/controller/route-exchange-netlink.c index ed9224a1c..60bae4781 100644 --- a/controller/route-exchange-netlink.c +++ b/controller/route-exchange-netlink.c @@ -300,7 +300,6 @@ re_nl_sync_routes(uint32_t table_id, const struct hmap *routes, struct hmapx routes_to_advertise = HMAPX_INITIALIZER(&routes_to_advertise); struct vector stale_routes = VECTOR_EMPTY_INITIALIZER(struct route_data); struct advertise_route_entry *ar; - int ret = 0; HMAP_FOR_EACH (ar, node, routes) { hmapx_add(&routes_to_advertise, ar); @@ -319,6 +318,8 @@ re_nl_sync_routes(uint32_t table_id, const struct hmap *routes, }; route_table_dump_one_table(table_id, handle_route_msg, &data); + int ret = re_nl_delete_stale_routes(&stale_routes); + /* Add any remaining routes in the routes_to_advertise hmapx to the * system routing table. */ struct hmapx_node *hn; @@ -342,11 +343,6 @@ re_nl_sync_routes(uint32_t table_id, const struct hmap *routes, } } - int err = re_nl_delete_stale_routes(&stale_routes); - if (!ret) { - ret = err; - } - hmapx_destroy(&routes_to_advertise); vector_destroy(&stale_routes); @@ -356,7 +352,6 @@ re_nl_sync_routes(uint32_t table_id, const struct hmap *routes, int re_nl_cleanup_routes(uint32_t table_id) { - int ret = 0; struct vector stale_routes = VECTOR_EMPTY_INITIALIZER(struct route_data); /* Remove routes from the system that are not in the host_routes hmap and * remove entries from host_routes hmap that match routes already installed @@ -369,10 +364,7 @@ re_nl_cleanup_routes(uint32_t table_id) }; route_table_dump_one_table(table_id, handle_route_msg, &data); - int err = re_nl_delete_stale_routes(&stale_routes); - if (!ret) { - ret = err; - } + int ret = re_nl_delete_stale_routes(&stale_routes); vector_destroy(&stale_routes); return ret; -- 2.51.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
