Merge pull request #4304 from donaldsharp/route_map_switch

Route map switch
This commit is contained in:
David Lamparter 2019-05-14 15:29:58 +02:00 committed by GitHub
commit 0396d40631
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 44 additions and 54 deletions

View File

@ -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);

View File

@ -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
*-----------------------------------------------------------------------*/
@ -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);

View File

@ -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. */
@ -902,7 +902,7 @@ static const char *route_map_type_str(enum route_map_type type)
case RMAP_DENY:
return "deny";
break;
default:
case RMAP_ANY:
return "";
break;
}
@ -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);
}
@ -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;
@ -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);
}
@ -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);
@ -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);
}
@ -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);
@ -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;
}
@ -1795,7 +1783,14 @@ static int route_map_dep_update(struct hash *dephash, const char *dep_name,
dep = NULL;
}
break;
default:
case RMAP_EVENT_SET_ADDED:
case RMAP_EVENT_SET_DELETED:
case RMAP_EVENT_SET_REPLACED:
case RMAP_EVENT_MATCH_ADDED:
case RMAP_EVENT_MATCH_DELETED:
case RMAP_EVENT_MATCH_REPLACED:
case RMAP_EVENT_INDEX_ADDED:
case RMAP_EVENT_INDEX_DELETED:
break;
}
@ -1846,7 +1841,18 @@ static struct hash *route_map_get_dep_hash(route_map_event_t event)
case RMAP_EVENT_FILTER_DELETED:
upd8_hash = route_map_dep_hash[ROUTE_MAP_DEP_FILTER];
break;
default:
/*
* Should we actually be ignoring these?
* I am not sure but at this point in time, let
* us get them into this switch and we can peel
* them into the appropriate place in the future
*/
case RMAP_EVENT_SET_ADDED:
case RMAP_EVENT_SET_DELETED:
case RMAP_EVENT_SET_REPLACED:
case RMAP_EVENT_MATCH_REPLACED:
case RMAP_EVENT_INDEX_ADDED:
case RMAP_EVENT_INDEX_DELETED:
upd8_hash = NULL;
break;
}
@ -1856,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,

View File

@ -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,

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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);