diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 7eeab373a0..fd1aa6ab47 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -1390,14 +1390,21 @@ static uint32_t bgp_l3nhg_start; static void bgp_l3nhg_add_cb(const char *name) { } + +static void bgp_l3nhg_modify_cb(const struct nexthop_group_cmd *nhgc) +{ +} + static void bgp_l3nhg_add_nexthop_cb(const struct nexthop_group_cmd *nhgc, const struct nexthop *nhop) { } + static void bgp_l3nhg_del_nexthop_cb(const struct nexthop_group_cmd *nhgc, const struct nexthop *nhop) { } + static void bgp_l3nhg_del_cb(const char *name) { } @@ -1410,8 +1417,9 @@ static void bgp_l3nhg_zebra_init(void) bgp_l3nhg_zebra_inited = true; bgp_l3nhg_start = zclient_get_nhg_start(ZEBRA_ROUTE_BGP); - nexthop_group_init(bgp_l3nhg_add_cb, bgp_l3nhg_add_nexthop_cb, - bgp_l3nhg_del_nexthop_cb, bgp_l3nhg_del_cb); + nexthop_group_init(bgp_l3nhg_add_cb, bgp_l3nhg_modify_cb, + bgp_l3nhg_add_nexthop_cb, bgp_l3nhg_del_nexthop_cb, + bgp_l3nhg_del_cb); } diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index f1417021b0..41fe64606b 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -47,6 +47,7 @@ struct nexthop_hold { struct nexthop_group_hooks { void (*new)(const char *name); + void (*modify)(const struct nexthop_group_cmd *nhgc); void (*add_nexthop)(const struct nexthop_group_cmd *nhg, const struct nexthop *nhop); void (*del_nexthop)(const struct nexthop_group_cmd *nhg, @@ -691,6 +692,9 @@ DEFPY(nexthop_group_resilience, nhgc->nhg.nhgr.idle_timer = idle_timer; nhgc->nhg.nhgr.unbalanced_timer = unbalanced_timer; + if (nhg_hooks.modify) + nhg_hooks.modify(nhgc); + return CMD_SUCCESS; } @@ -1347,6 +1351,7 @@ static const struct cmd_variable_handler nhg_name_handlers[] = { {.completions = NULL}}; void nexthop_group_init(void (*new)(const char *name), + void (*modify)(const struct nexthop_group_cmd *nhgc), void (*add_nexthop)(const struct nexthop_group_cmd *nhg, const struct nexthop *nhop), void (*del_nexthop)(const struct nexthop_group_cmd *nhg, @@ -1373,6 +1378,8 @@ void nexthop_group_init(void (*new)(const char *name), if (new) nhg_hooks.new = new; + if (modify) + nhg_hooks.modify = modify; if (add_nexthop) nhg_hooks.add_nexthop = add_nexthop; if (del_nexthop) diff --git a/lib/nexthop_group.h b/lib/nexthop_group.h index 7d1b57a2f9..0ea0b7c185 100644 --- a/lib/nexthop_group.h +++ b/lib/nexthop_group.h @@ -118,9 +118,17 @@ DECLARE_QOBJ_TYPE(nexthop_group_cmd); * a nexthop_group is added/deleted/modified, then set the * appropriate callback functions to handle it in your * code + * + * create - The creation of the nexthop group + * modify - Modification of the nexthop group when not changing a nexthop + * ( resilience as an example ) + * add_nexthop - A nexthop is added to the NHG + * del_nexthop - A nexthop is deleted from the NHG + * destroy - The NHG is deleted */ void nexthop_group_init( void (*create)(const char *name), + void (*modify)(const struct nexthop_group_cmd *nhgc), void (*add_nexthop)(const struct nexthop_group_cmd *nhgc, const struct nexthop *nhop), void (*del_nexthop)(const struct nexthop_group_cmd *nhgc, diff --git a/pbrd/pbr_main.c b/pbrd/pbr_main.c index 59aa3676bf..28a7b62d10 100644 --- a/pbrd/pbr_main.c +++ b/pbrd/pbr_main.c @@ -160,10 +160,9 @@ int main(int argc, char **argv, char **envp) pbr_debug_init(); - nexthop_group_init(pbr_nhgroup_add_cb, + nexthop_group_init(pbr_nhgroup_add_cb, pbr_nhgroup_modify_cb, pbr_nhgroup_add_nexthop_cb, - pbr_nhgroup_del_nexthop_cb, - pbr_nhgroup_delete_cb); + pbr_nhgroup_del_nexthop_cb, pbr_nhgroup_delete_cb); /* * So we safely ignore these commands since diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c index cbff4832a4..298c961519 100644 --- a/pbrd/pbr_nht.c +++ b/pbrd/pbr_nht.c @@ -229,6 +229,10 @@ void pbr_nhgroup_add_cb(const char *name) pbr_map_check_nh_group_change(name); } +void pbr_nhgroup_modify_cb(const struct nexthop_group_cmd *nhgc) +{ +} + void pbr_nhgroup_add_nexthop_cb(const struct nexthop_group_cmd *nhgc, const struct nexthop *nhop) { diff --git a/pbrd/pbr_nht.h b/pbrd/pbr_nht.h index ecc92cc051..900b7627f2 100644 --- a/pbrd/pbr_nht.h +++ b/pbrd/pbr_nht.h @@ -96,6 +96,7 @@ extern void pbr_nht_set_rule_range(uint32_t low, uint32_t high); extern uint32_t pbr_nht_get_next_rule(uint32_t seqno); extern void pbr_nhgroup_add_cb(const char *name); +extern void pbr_nhgroup_modify_cb(const struct nexthop_group_cmd *nhgc); extern void pbr_nhgroup_add_nexthop_cb(const struct nexthop_group_cmd *nhg, const struct nexthop *nhop); extern void pbr_nhgroup_del_nexthop_cb(const struct nexthop_group_cmd *nhg, diff --git a/sharpd/sharp_nht.c b/sharpd/sharp_nht.c index a90387186e..da14899768 100644 --- a/sharpd/sharp_nht.c +++ b/sharpd/sharp_nht.c @@ -124,6 +124,10 @@ static void sharp_nhgroup_add_cb(const char *name) sharp_nhg_rb_add(&nhg_head, snhg); } +static void sharp_nhgroup_modify_cb(const struct nexthop_group_cmd *nhgc) +{ +} + static void sharp_nhgroup_add_nexthop_cb(const struct nexthop_group_cmd *nhgc, const struct nexthop *nhop) { @@ -215,7 +219,8 @@ void sharp_nhgroup_init(void) sharp_nhg_rb_init(&nhg_head); nhg_id = zclient_get_nhg_start(ZEBRA_ROUTE_SHARP); - nexthop_group_init(sharp_nhgroup_add_cb, sharp_nhgroup_add_nexthop_cb, + nexthop_group_init(sharp_nhgroup_add_cb, sharp_nhgroup_modify_cb, + sharp_nhgroup_add_nexthop_cb, sharp_nhgroup_del_nexthop_cb, sharp_nhgroup_delete_cb); }