]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Add function to find/create single nexthop
authorStephen Worley <sworley@cumulusnetworks.com>
Fri, 29 Mar 2019 14:51:07 +0000 (10:51 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:38 +0000 (11:13 -0400)
Add a function that allows us to take a single
nexthop struct and look that up or create a group and
nexthop hash entry with it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
zebra/zebra_nhg.c
zebra/zebra_nhg.h

index 54f31a6c623c3fe3fbf392252a0cdddf2bb6c648..18f5cf3b8dbf2693d7de54988357c3fc694741e9 100644 (file)
@@ -372,6 +372,29 @@ struct nhg_hash_entry *zebra_nhg_find(struct nexthop_group *nhg,
        return nhe;
 }
 
+/**
+ * zebra_nhg_find_nexthop() - Create a group with a single nexthop, find it in
+ *                           our table, or create it
+ *
+ * @nh:                Nexthop to lookup
+ * @afi:       Address Family type
+ *
+ * Return:     Hash entry found or created
+ */
+struct nhg_hash_entry *zebra_nhg_find_nexthop(struct nexthop *nh, afi_t afi)
+{
+       struct nhg_hash_entry *nhe = NULL;
+
+       struct nexthop_group *nhg = nexthop_group_new();
+
+       nexthop_group_add_sorted(nhg, nh);
+       nhe = zebra_nhg_find(nhg, nh->vrf_id, afi, 0, NULL, false);
+
+       nexthop_group_delete(&nhg);
+
+       return nhe;
+}
+
 /**
  * zebra_nhg_free_group_depends() - Helper function for freeing nexthop_group
  *                                 struct and depends
index 4efb1b08e5c7c7d9374d893af68b77a423ee2c36..8daa2a1ccf520b9043ea8315f5046e3dde486411 100644 (file)
@@ -105,6 +105,9 @@ extern struct nhg_hash_entry *
 zebra_nhg_find(struct nexthop_group *nhg, vrf_id_t vrf_id, afi_t afi,
               uint32_t id, struct list *nhg_depends, bool is_kernel_nh);
 
+extern struct nhg_hash_entry *zebra_nhg_find_nexthop(struct nexthop *nh,
+                                                    afi_t afi);
+
 void zebra_nhg_free_group_depends(struct nexthop_group *nhg,
                                  struct list *nhg_depends);
 void zebra_nhg_free_members(struct nhg_hash_entry *nhe);