]> git.puffer.fish Git - matthieu/frr.git/commitdiff
*: Add ability for daemons to notice resilience changes
authorDonald Sharp <sharpd@nvidia.com>
Mon, 24 Oct 2022 13:25:54 +0000 (09:25 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 4 Nov 2022 17:34:27 +0000 (13:34 -0400)
This patch just introduces the callback mechanism for the
resilient nexthop changes so that upper level daemons
can take advantage of the change.  This does nothing
at this point but just call some code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_nht.c
lib/nexthop_group.c
lib/nexthop_group.h
pbrd/pbr_main.c
pbrd/pbr_nht.c
pbrd/pbr_nht.h
sharpd/sharp_nht.c

index 7eeab373a01773cd6a43fe2ecef719fc3ed54e99..fd1aa6ab47c079715eda396247a8fe02ab28a925 100644 (file)
@@ -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);
 }
 
 
index f1417021b04aa60015e939628c8de8d76dd5144f..41fe64606bfd217d93dabc3ebf4394d855e3bdea 100644 (file)
@@ -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)
index 7d1b57a2f96c0e7e6cddff782c10d0e34b1791a3..0ea0b7c18526b2acbf7802cccf357900ba2faea1 100644 (file)
@@ -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,
index 59aa3676bfe6c2ffa5dbab147b5fb5acfd9d9c9a..28a7b62d10638f5186f92e44b1b3b011078fe54f 100644 (file)
@@ -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
index cbff4832a4ead2cf55b9ff1b2e2ad0b96c79c95c..298c9615198791dfc66ded835c919751db50dca7 100644 (file)
@@ -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)
 {
index ecc92cc051f4fafdc619ad4ba43c102b8f9c2529..900b7627f257d7737f914bf8b3be903b9133be5c 100644 (file)
@@ -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,
index a90387186e8295991494c53dece4ed01d26954b1..da14899768f703eab02c50f3a61bd4de36394581 100644 (file)
@@ -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);
 }