]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_nhg.h
zebra: multiple vlan aware bridge data structure and related changes
[mirror_frr.git] / zebra / zebra_nhg.h
index 38015bf557d3fede57ae50bf70c20de94d8ebabf..9b925bf10fd7dc8dede4733864a3c96a3086609a 100644 (file)
@@ -51,6 +51,9 @@ struct nhg_hash_entry {
        afi_t afi;
        vrf_id_t vrf_id;
 
+       /* Time since last update */
+       time_t uptime;
+
        /* Source protocol - zebra or another daemon */
        int type;
 
@@ -76,16 +79,34 @@ struct nhg_hash_entry {
 
        uint32_t flags;
 
-       /* Dependency tree for other entries.
+       /* Dependency trees for other entries.
         * For instance a group with two
         * nexthops will have two dependencies
         * pointing to those nhg_hash_entries.
         *
         * Using a rb tree here to make lookups
         * faster with ID's.
+        *
+        * nhg_depends the RB tree of entries that this
+        * group contains.
+        *
+        * nhg_dependents the RB tree of entries that
+        * this group is being used by
+        *
+        * NHG id 3 with nexthops id 1/2
+        * nhg(3)->nhg_depends has 1 and 2 in the tree
+        * nhg(3)->nhg_dependents is empty
+        *
+        * nhg(1)->nhg_depends is empty
+        * nhg(1)->nhg_dependents is 3 in the tree
+        *
+        * nhg(2)->nhg_depends is empty
+        * nhg(3)->nhg_dependents is 3 in the tree
         */
        struct nhg_connected_tree_head nhg_depends, nhg_dependents;
 
+       struct thread *timer;
+
 /*
  * Is this nexthop group valid, ie all nexthops are fully resolved.
  * What is fully resolved?  It's a nexthop that is either self contained
@@ -126,6 +147,15 @@ struct nhg_hash_entry {
  */
 #define NEXTHOP_GROUP_PROTO_RELEASED (1 << 5)
 
+/*
+ * When deleting a NHG notice that it is still installed
+ * and if it is, slightly delay the actual removal to
+ * the future.  So that upper level protocols might
+ * be able to take advantage of some NHG's that
+ * are there
+ */
+#define NEXTHOP_GROUP_KEEP_AROUND (1 << 6)
+
 /*
  * Track FPM installation status..
  */
@@ -147,6 +177,8 @@ enum nhg_type {
 /* Is this an NHE owned by zebra and not an upper level protocol? */
 #define ZEBRA_OWNED(NHE) (NHE->type == ZEBRA_ROUTE_NHG)
 
+#define PROTO_OWNED(NHE) (NHE->id >= ZEBRA_NHG_PROTO_LOWER)
+
 /*
  * Backup nexthops: this is a group object itself, so
  * that the backup nexthops can use the same code as a normal object.
@@ -196,6 +228,7 @@ struct nhg_ctx {
                struct nh_grp grp[MULTIPATH_NUM];
        } u;
 
+       struct nhg_resilience resilience;
        enum nhg_ctx_op_e op;
        enum nhg_ctx_status status;
 };
@@ -224,6 +257,7 @@ struct nhg_hash_entry *zebra_nhg_alloc(void);
 void zebra_nhg_free(struct nhg_hash_entry *nhe);
 /* In order to clear a generic hash, we need a generic api, sigh. */
 void zebra_nhg_hash_free(void *p);
+void zebra_nhg_hash_free_zero_id(struct hash_bucket *b, void *arg);
 
 /* Init an nhe, for use in a hash lookup for example. There's some fuzziness
  * if the nhe represents only a single nexthop, so we try to capture that
@@ -269,12 +303,14 @@ extern bool zebra_nhg_hash_id_equal(const void *arg1, const void *arg2);
  * the rib meta queue.
  */
 extern int nhg_ctx_process(struct nhg_ctx *ctx);
+void nhg_ctx_free(struct nhg_ctx **ctx);
 
 /* Find via kernel nh creation */
 extern int zebra_nhg_kernel_find(uint32_t id, struct nexthop *nh,
                                 struct nh_grp *grp, uint8_t count,
                                 vrf_id_t vrf_id, afi_t afi, int type,
-                                int startup);
+                                int startup,
+                                struct nhg_resilience *resilience);
 /* Del via kernel */
 extern int zebra_nhg_kernel_del(uint32_t id, vrf_id_t vrf_id);
 
@@ -358,6 +394,10 @@ extern void zebra_nhg_mark_keep(void);
 struct route_entry; /* Forward ref to avoid circular includes */
 extern int nexthop_active_update(struct route_node *rn, struct route_entry *re);
 
+#ifdef _FRR_ATTRIBUTE_PRINTFRR
+#pragma FRR printfrr_ext "%pNG" (const struct nhg_hash_entry *)
+#endif
+
 #ifdef __cplusplus
 }
 #endif