diff options
author | Stephen Worley <sworley@cumulusnetworks.com> | 2020-06-11 19:49:25 +0200 |
---|---|---|
committer | Stephen Worley <sworley@cumulusnetworks.com> | 2020-09-28 18:41:00 +0200 |
commit | 2053061baeff77c8ce39baf59d6abefa1ee821eb (patch) | |
tree | c81ebe855c589c8573f0a6f0f75ba03b98fe338b /sharpd/sharp_nht.c | |
parent | zebra: reply fail on NHG add if not ifindex/onlink (diff) | |
download | frr-2053061baeff77c8ce39baf59d6abefa1ee821eb.tar.xz frr-2053061baeff77c8ce39baf59d6abefa1ee821eb.zip |
sharpd: implement NHG notification handling
Implement handling of NHG notifications in sharpd so that
the routes don't attempt to use an NHG ID that did not
successfully get created. If it does not get installed, we
fall back to traditional zapi messaging.
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'sharpd/sharp_nht.c')
-rw-r--r-- | sharpd/sharp_nht.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/sharpd/sharp_nht.c b/sharpd/sharp_nht.c index 731d58e56..4c32dc279 100644 --- a/sharpd/sharp_nht.c +++ b/sharpd/sharp_nht.c @@ -78,6 +78,8 @@ struct sharp_nhg { uint32_t id; char name[256]; + + bool installed; }; static uint32_t nhg_id; @@ -99,6 +101,22 @@ static int sharp_nhg_compare_func(const struct sharp_nhg *a, DECLARE_RBTREE_UNIQ(sharp_nhg_rb, struct sharp_nhg, mylistitem, sharp_nhg_compare_func); +static struct sharp_nhg *sharp_nhgroup_find_id(uint32_t id) +{ + struct sharp_nhg *lookup; + + /* Yea its just a for loop, I don't want add complexity + * to sharpd with another RB tree for just IDs + */ + + frr_each(sharp_nhg_rb, &nhg_head, lookup) { + if (lookup->id == id) + return lookup; + } + + return NULL; +} + static void sharp_nhgroup_add_cb(const char *name) { struct sharp_nhg *snhg; @@ -166,6 +184,32 @@ uint32_t sharp_nhgroup_get_id(const char *name) return snhg->id; } +void sharp_nhgroup_id_set_installed(uint32_t id, bool installed) +{ + struct sharp_nhg *snhg; + + snhg = sharp_nhgroup_find_id(id); + if (!snhg) { + zlog_debug("%s: nhg %u not found", __func__, id); + return; + } + + snhg->installed = installed; +} + +bool sharp_nhgroup_id_is_installed(uint32_t id) +{ + struct sharp_nhg *snhg; + + snhg = sharp_nhgroup_find_id(id); + if (!snhg) { + zlog_debug("%s: nhg %u not found", __func__, id); + return false; + } + + return snhg->installed; +} + void sharp_nhgroup_init(void) { sharp_nhg_rb_init(&nhg_head); |