Skip to content

Commit

Permalink
bgpd, lib, ospf6d, ospfd, pimd, zebra: Rework routemap event callback
Browse files Browse the repository at this point in the history
The route_map_event_hook callback was passing the `route_map_event_t`
to each individual interested party.  No-one is ever using this data
so let's cut to the chase a bit and remove the pass through of data.
This is considered ok in that the routemap.c code came this way
originally and after 15+ years no-one is using this functionality.
Nor do I see any `easy` way to do anything useful with this data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
  • Loading branch information
donaldsharp committed May 10, 2019
1 parent ba1707c commit 097b597
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 51 deletions.
2 changes: 1 addition & 1 deletion bgpd/bgp_routemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -3447,7 +3447,7 @@ static void bgp_route_map_delete(const char *rmap_name)
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_DELETED);
}

static void bgp_route_map_event(route_map_event_t event, const char *rmap_name)
static void bgp_route_map_event(const char *rmap_name)
{
if (route_map_mark_updated(rmap_name) == 0)
bgp_route_map_mark_update(rmap_name);
Expand Down
22 changes: 0 additions & 22 deletions bgpd/rfapi/bgp_rfapi_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2208,24 +2208,6 @@ void vnc_routemap_update(struct bgp *bgp, const char *unused)
vnc_zlog_debug_verbose("%s done", __func__);
}

#if 0 /* superseded */
static void vnc_routemap_event(route_map_event_t type, /* ignored */
const char *rmap_name) /* ignored */
{
struct listnode *mnode, *mnnode;
struct bgp *bgp;

vnc_zlog_debug_verbose("%s(event type=%d)", __func__, type);
if (bm->bgp == NULL) /* may be called during cleanup */
return;

for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp))
vnc_routemap_update(bgp, rmap_name);

vnc_zlog_debug_verbose("%s: done", __func__);
}
#endif

/*-------------------------------------------------------------------------
* nve-group
*-----------------------------------------------------------------------*/
Expand Down Expand Up @@ -3699,10 +3681,6 @@ bgp_rfapi_get_ecommunity_by_lni_label(struct bgp *bgp, uint32_t is_import,

void bgp_rfapi_cfg_init(void)
{
/* main bgpd code does not use this hook, but vnc does */
/* superseded by bgp_route_map_process_update_cb() */
/* bgp_route_map_event_hook_add(vnc_routemap_event); */

install_node(&bgp_vnc_defaults_node, NULL);
install_node(&bgp_vnc_nve_group_node, NULL);
install_node(&bgp_vrf_policy_node, NULL);
Expand Down
31 changes: 9 additions & 22 deletions lib/routemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ struct route_map_list {

void (*add_hook)(const char *);
void (*delete_hook)(const char *);
void (*event_hook)(route_map_event_t, const char *);
void (*event_hook)(const char *);
};

/* Master list of route map. */
Expand Down Expand Up @@ -1077,8 +1077,7 @@ static void route_map_index_delete(struct route_map_index *index, int notify)

/* Execute event hook. */
if (route_map_master.event_hook && notify) {
(*route_map_master.event_hook)(RMAP_EVENT_INDEX_DELETED,
index->map->name);
(*route_map_master.event_hook)(index->map->name);
route_map_notify_dependencies(index->map->name,
RMAP_EVENT_CALL_ADDED);
}
Expand Down Expand Up @@ -1137,8 +1136,7 @@ route_map_index_add(struct route_map *map, enum route_map_type type, int pref)

/* Execute event hook. */
if (route_map_master.event_hook) {
(*route_map_master.event_hook)(RMAP_EVENT_INDEX_ADDED,
map->name);
(*route_map_master.event_hook)(map->name);
route_map_notify_dependencies(map->name, RMAP_EVENT_CALL_ADDED);
}
return index;
Expand Down Expand Up @@ -1337,10 +1335,7 @@ int route_map_add_match(struct route_map_index *index, const char *match_name,

/* Execute event hook. */
if (route_map_master.event_hook) {
(*route_map_master.event_hook)(
replaced ? RMAP_EVENT_MATCH_REPLACED
: RMAP_EVENT_MATCH_ADDED,
index->map->name);
(*route_map_master.event_hook)(index->map->name);
route_map_notify_dependencies(index->map->name,
RMAP_EVENT_CALL_ADDED);
}
Expand All @@ -1365,9 +1360,7 @@ int route_map_delete_match(struct route_map_index *index,
route_map_rule_delete(&index->match_list, rule);
/* Execute event hook. */
if (route_map_master.event_hook) {
(*route_map_master.event_hook)(
RMAP_EVENT_MATCH_DELETED,
index->map->name);
(*route_map_master.event_hook)(index->map->name);
route_map_notify_dependencies(
index->map->name,
RMAP_EVENT_CALL_ADDED);
Expand Down Expand Up @@ -1425,10 +1418,7 @@ int route_map_add_set(struct route_map_index *index, const char *set_name,

/* Execute event hook. */
if (route_map_master.event_hook) {
(*route_map_master.event_hook)(replaced
? RMAP_EVENT_SET_REPLACED
: RMAP_EVENT_SET_ADDED,
index->map->name);
(*route_map_master.event_hook)(index->map->name);
route_map_notify_dependencies(index->map->name,
RMAP_EVENT_CALL_ADDED);
}
Expand All @@ -1452,9 +1442,7 @@ int route_map_delete_set(struct route_map_index *index, const char *set_name,
route_map_rule_delete(&index->set_list, rule);
/* Execute event hook. */
if (route_map_master.event_hook) {
(*route_map_master.event_hook)(
RMAP_EVENT_SET_DELETED,
index->map->name);
(*route_map_master.event_hook)(index->map->name);
route_map_notify_dependencies(
index->map->name,
RMAP_EVENT_CALL_ADDED);
Expand Down Expand Up @@ -1651,7 +1639,7 @@ void route_map_delete_hook(void (*func)(const char *))
route_map_master.delete_hook = func;
}

void route_map_event_hook(void (*func)(route_map_event_t, const char *))
void route_map_event_hook(void (*func)(const char *name))
{
route_map_master.event_hook = func;
}
Expand Down Expand Up @@ -1874,13 +1862,12 @@ static struct hash *route_map_get_dep_hash(route_map_event_t event)
static void route_map_process_dependency(struct hash_bucket *bucket, void *data)
{
char *rmap_name = (char *)bucket->data;
route_map_event_t type = (route_map_event_t)(ptrdiff_t)data;

if (rmap_debug)
zlog_debug("%s: Notifying %s of dependency",
__FUNCTION__, rmap_name);
if (route_map_master.event_hook)
(*route_map_master.event_hook)(type, rmap_name);
(*route_map_master.event_hook)(rmap_name);
}

void route_map_upd8_dependency(route_map_event_t type, const char *arg,
Expand Down
10 changes: 9 additions & 1 deletion lib/routemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,15 @@ 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 *));

/*
* This is the callback for when something has changed about a
* route-map. The interested parties can register to receive
* this data.
*
* name - Is the name of the changed route-map
*/
extern void route_map_event_hook(void (*func)(const char *name));
extern int route_map_mark_updated(const 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,
Expand Down
2 changes: 1 addition & 1 deletion ospf6d/ospf6_asbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ static void ospf6_asbr_routemap_update(const char *mapname)
}
}

static void ospf6_asbr_routemap_event(route_map_event_t event, const char *name)
static void ospf6_asbr_routemap_event(const char *name)
{
int type;

Expand Down
2 changes: 1 addition & 1 deletion ospfd/ospf_routemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static void ospf_route_map_update(const char *name)
}
}

static void ospf_route_map_event(route_map_event_t event, const char *name)
static void ospf_route_map_event(const char *name)
{
struct ospf *ospf;
int type;
Expand Down
2 changes: 1 addition & 1 deletion pimd/pim_routemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static void pim_route_map_delete(const char *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)
static void pim_route_map_event(const char *rmap_name)
{
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED);
}
Expand Down
3 changes: 1 addition & 2 deletions zebra/zebra_routemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1798,8 +1798,7 @@ static void zebra_route_map_delete(const char *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)
static void zebra_route_map_event(const char *rmap_name)
{
if (route_map_mark_updated(rmap_name) == 0)
zebra_route_map_mark_update(rmap_name);
Expand Down

0 comments on commit 097b597

Please sign in to comment.