From 7096e93875b2deceb6e16cf3120c0adb59611279 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 Jun 2018 20:44:15 -0400 Subject: [PATCH 1/5] bgpd, lib, pimd: Remove unused variable. route_map_mark_updated has a `int del_later` variable that is passed in but never used. Just remove it. Signed-off-by: Donald Sharp --- bgpd/bgp_routemap.c | 6 +++--- lib/routemap.c | 2 +- lib/routemap.h | 2 +- pimd/pim_routemap.c | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index cbacd6b4f2..14c1c33a31 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -3172,7 +3172,7 @@ static void bgp_route_map_mark_update(const char *rmap_name) static void bgp_route_map_add(const char *rmap_name) { - if (route_map_mark_updated(rmap_name, 0) == 0) + if (route_map_mark_updated(rmap_name) == 0) bgp_route_map_mark_update(rmap_name); route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED); @@ -3180,7 +3180,7 @@ static void bgp_route_map_add(const char *rmap_name) static void bgp_route_map_delete(const char *rmap_name) { - if (route_map_mark_updated(rmap_name, 1) == 0) + if (route_map_mark_updated(rmap_name) == 0) bgp_route_map_mark_update(rmap_name); route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_DELETED); @@ -3188,7 +3188,7 @@ static void bgp_route_map_delete(const char *rmap_name) static void bgp_route_map_event(route_map_event_t event, const char *rmap_name) { - if (route_map_mark_updated(rmap_name, 0) == 0) + if (route_map_mark_updated(rmap_name) == 0) bgp_route_map_mark_update(rmap_name); route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED); diff --git a/lib/routemap.c b/lib/routemap.c index 892b19dac5..4601da759d 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -751,7 +751,7 @@ struct route_map *route_map_lookup_by_name(const char *name) return map; } -int route_map_mark_updated(const char *name, int del_later) +int route_map_mark_updated(const char *name) { struct route_map *map; int ret = -1; diff --git a/lib/routemap.h b/lib/routemap.h index 990c7fa72f..4ec4ce1a0a 100644 --- a/lib/routemap.h +++ b/lib/routemap.h @@ -215,7 +215,7 @@ extern route_map_result_t route_map_apply(struct route_map *map, extern void route_map_add_hook(void (*func)(const char *)); extern void route_map_delete_hook(void (*func)(const char *)); extern void route_map_event_hook(void (*func)(route_map_event_t, const char *)); -extern int route_map_mark_updated(const char *name, int deleted); +extern int route_map_mark_updated(const char *name); extern int route_map_clear_updated(struct route_map *rmap); extern void route_map_walk_update_list(int (*update_fn)(char *name)); extern void route_map_upd8_dependency(route_map_event_t type, const char *arg, diff --git a/pimd/pim_routemap.c b/pimd/pim_routemap.c index 6d06229b98..8f6309340d 100644 --- a/pimd/pim_routemap.c +++ b/pimd/pim_routemap.c @@ -35,7 +35,7 @@ static void pim_route_map_mark_update(const char *rmap_name) static void pim_route_map_add(const char *rmap_name) { - if (route_map_mark_updated(rmap_name, 0) == 0) + if (route_map_mark_updated(rmap_name) == 0) pim_route_map_mark_update(rmap_name); route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED); @@ -43,7 +43,7 @@ static void pim_route_map_add(const char *rmap_name) static void pim_route_map_delete(const char *rmap_name) { - if (route_map_mark_updated(rmap_name, 1) == 0) + if (route_map_mark_updated(rmap_name) == 0) pim_route_map_mark_update(rmap_name); route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_DELETED); @@ -51,7 +51,7 @@ static void pim_route_map_delete(const char *rmap_name) static void pim_route_map_event(route_map_event_t event, const char *rmap_name) { - if (route_map_mark_updated(rmap_name, 0) == 0) + if (route_map_mark_updated(rmap_name) == 0) pim_route_map_mark_update(rmap_name); route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED); From c573cddd2a4fed3c3b40e50605255537b229ef9d Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 Jun 2018 20:46:07 -0400 Subject: [PATCH 2/5] pimd: Remove unused code pim does not even use route-maps, remove the unneded code. Signed-off-by: Donald Sharp --- pimd/pim_routemap.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/pimd/pim_routemap.c b/pimd/pim_routemap.c index 8f6309340d..b41124376f 100644 --- a/pimd/pim_routemap.c +++ b/pimd/pim_routemap.c @@ -26,34 +26,18 @@ #include "pimd.h" - -static void pim_route_map_mark_update(const char *rmap_name) -{ - // placeholder - return; -} - static void pim_route_map_add(const char *rmap_name) { - if (route_map_mark_updated(rmap_name) == 0) - pim_route_map_mark_update(rmap_name); - route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED); } static void pim_route_map_delete(const char *rmap_name) { - if (route_map_mark_updated(rmap_name) == 0) - pim_route_map_mark_update(rmap_name); - route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_DELETED); } static void pim_route_map_event(route_map_event_t event, const char *rmap_name) { - if (route_map_mark_updated(rmap_name) == 0) - pim_route_map_mark_update(rmap_name); - route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED); } From 75a2b29dd6b25725274bb8d8bd145e198a37d5f5 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 Jun 2018 21:00:39 -0400 Subject: [PATCH 3/5] zebra: Add initial framework to keep track of changed route-maps Add some basic code for zebra to start to keep track of route-maps that have changed. At this point we are not doing anything. As we fix code to handle route-maps better, code will be shifted around. Signed-off-by: Donald Sharp --- zebra/zebra_routemap.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index 10ba88880a..8e368c257e 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -1282,6 +1282,15 @@ static struct route_map_rule_cmd route_set_src_cmd = { "src", route_set_src, route_set_src_compile, route_set_src_free, }; +static int zebra_route_map_process_update_cb(char *rmap_name) +{ + if (IS_ZEBRA_DEBUG_EVENT) + zlog_debug("Event handler for route-map: %s", + rmap_name); + + return 0; +} + static int zebra_route_map_update_timer(struct thread *thread) { zebra_t_rmap_update = NULL; @@ -1294,6 +1303,13 @@ static int zebra_route_map_update_timer(struct thread *thread) "%u: Routemap update-timer fired, scheduling RIB processing", VRF_DEFAULT); + route_map_walk_update_list(zebra_route_map_process_update_cb); + + /* + * This code needs to be updated to be: + * 1) VRF Aware + * 2) Route-map aware + */ zebra_import_table_rm_update(); rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE); zebra_evaluate_rnh(0, AF_INET, 1, RNH_NEXTHOP_TYPE, NULL); @@ -1433,20 +1449,26 @@ static void zebra_route_map_mark_update(const char *rmap_name) static void zebra_route_map_add(const char *rmap_name) { - zebra_route_map_mark_update(rmap_name); + if (route_map_mark_updated(rmap_name) == 0) + zebra_route_map_mark_update(rmap_name); + route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED); } static void zebra_route_map_delete(const char *rmap_name) { - zebra_route_map_mark_update(rmap_name); + if (route_map_mark_updated(rmap_name) == 0) + zebra_route_map_mark_update(rmap_name); + route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_DELETED); } static void zebra_route_map_event(route_map_event_t event, const char *rmap_name) { - zebra_route_map_mark_update(rmap_name); + if (route_map_mark_updated(rmap_name) == 0) + zebra_route_map_mark_update(rmap_name); + route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED); } From 69f02720836c75a53f05e6acd4a5bad459db7258 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 Jun 2018 21:12:11 -0400 Subject: [PATCH 4/5] lib: Don't expose a function that is never used route_map_clear_updated is only used by routemap.c, don't expose it too be used by the outside world. Signed-off-by: Donald Sharp --- lib/routemap.c | 2 +- lib/routemap.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/routemap.c b/lib/routemap.c index 4601da759d..b2c1929507 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -781,7 +781,7 @@ int route_map_mark_updated(const char *name) return (ret); } -int route_map_clear_updated(struct route_map *map) +static int route_map_clear_updated(struct route_map *map) { int ret = -1; diff --git a/lib/routemap.h b/lib/routemap.h index 4ec4ce1a0a..e653a8a788 100644 --- a/lib/routemap.h +++ b/lib/routemap.h @@ -216,7 +216,6 @@ extern void route_map_add_hook(void (*func)(const char *)); extern void route_map_delete_hook(void (*func)(const char *)); extern void route_map_event_hook(void (*func)(route_map_event_t, const char *)); extern int route_map_mark_updated(const char *name); -extern int route_map_clear_updated(struct route_map *rmap); extern void route_map_walk_update_list(int (*update_fn)(char *name)); extern void route_map_upd8_dependency(route_map_event_t type, const char *arg, const char *rmap_name); From 46a69f10c01676e5f5dd0d12f542b58f8747decd Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 Jun 2018 21:18:33 -0400 Subject: [PATCH 5/5] bgpd, lib, zebra: Remove unnecessary return The route_map_walk_update_list callback function never uses the return code, so just remove it. Signed-off-by: Donald Sharp --- bgpd/bgp_routemap.c | 4 +--- lib/routemap.c | 2 +- lib/routemap.h | 2 +- zebra/zebra_routemap.c | 4 +--- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 14c1c33a31..9f3bec81d3 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -3112,7 +3112,7 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name, } } -static int bgp_route_map_process_update_cb(char *rmap_name) +static void bgp_route_map_process_update_cb(char *rmap_name) { struct listnode *node, *nnode; struct bgp *bgp; @@ -3127,8 +3127,6 @@ static int bgp_route_map_process_update_cb(char *rmap_name) } vpn_policy_routemap_event(rmap_name); - - return 0; } int bgp_route_map_update_timer(struct thread *thread) diff --git a/lib/routemap.c b/lib/routemap.c index b2c1929507..056c793454 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -807,7 +807,7 @@ static struct route_map *route_map_get(const char *name) return map; } -void route_map_walk_update_list(int (*route_map_update_fn)(char *name)) +void route_map_walk_update_list(void (*route_map_update_fn)(char *name)) { struct route_map *node; struct route_map *nnode = NULL; diff --git a/lib/routemap.h b/lib/routemap.h index e653a8a788..0aeba7e1f6 100644 --- a/lib/routemap.h +++ b/lib/routemap.h @@ -216,7 +216,7 @@ extern void route_map_add_hook(void (*func)(const char *)); extern void route_map_delete_hook(void (*func)(const char *)); extern void route_map_event_hook(void (*func)(route_map_event_t, const char *)); extern int route_map_mark_updated(const char *name); -extern void route_map_walk_update_list(int (*update_fn)(char *name)); +extern void route_map_walk_update_list(void (*update_fn)(char *name)); extern void route_map_upd8_dependency(route_map_event_t type, const char *arg, const char *rmap_name); extern void route_map_notify_dependencies(const char *affected_name, diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index 8e368c257e..6d3c2b2265 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -1282,13 +1282,11 @@ static struct route_map_rule_cmd route_set_src_cmd = { "src", route_set_src, route_set_src_compile, route_set_src_free, }; -static int zebra_route_map_process_update_cb(char *rmap_name) +static void zebra_route_map_process_update_cb(char *rmap_name) { if (IS_ZEBRA_DEBUG_EVENT) zlog_debug("Event handler for route-map: %s", rmap_name); - - return 0; } static int zebra_route_map_update_timer(struct thread *thread)