diff options
author | Stephen Worley <sworley@cumulusnetworks.com> | 2020-05-27 23:39:41 +0200 |
---|---|---|
committer | Stephen Worley <sworley@cumulusnetworks.com> | 2020-09-28 18:40:59 +0200 |
commit | 0de1db8f3bd8d25be9dbebc3a090f85d60b41b14 (patch) | |
tree | 28e12799ca0198a29582c6f005206d5f5b42c792 /sharpd | |
parent | zebra: return the proto nhe on del even with refs (diff) | |
download | frr-0de1db8f3bd8d25be9dbebc3a090f85d60b41b14.tar.xz frr-0de1db8f3bd8d25be9dbebc3a090f85d60b41b14.zip |
lib,sharpd,pbrd: `set installable` nhg command
Add a command `set installable` that allows configured nexthop
groups to be treated as separate/installable objects in the RIB.
A callback needs to be implemented per daemon to handle installing
the NHG into the rib via zapi when this command is set. This
patch includes the implementation for sharpd.
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'sharpd')
-rw-r--r-- | sharpd/sharp_nht.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/sharpd/sharp_nht.c b/sharpd/sharp_nht.c index 731d58e56..e76b1016a 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 installable; }; static uint32_t nhg_id; @@ -120,7 +122,9 @@ static void sharp_nhgroup_add_nexthop_cb(const struct nexthop_group_cmd *nhgc, strncpy(lookup.name, nhgc->name, sizeof(lookup.name)); snhg = sharp_nhg_rb_find(&nhg_head, &lookup); - nhg_add(snhg->id, &nhgc->nhg); + if (snhg->installable) + nhg_add(snhg->id, &nhgc->nhg); + return; } @@ -133,7 +137,9 @@ static void sharp_nhgroup_del_nexthop_cb(const struct nexthop_group_cmd *nhgc, strncpy(lookup.name, nhgc->name, sizeof(lookup.name)); snhg = sharp_nhg_rb_find(&nhg_head, &lookup); - nhg_add(snhg->id, &nhgc->nhg); + if (snhg->installable) + nhg_add(snhg->id, &nhgc->nhg); + return; } @@ -147,12 +153,34 @@ static void sharp_nhgroup_delete_cb(const char *name) if (!snhg) return; - nhg_del(snhg->id); + if (snhg->installable) + nhg_del(snhg->id); + sharp_nhg_rb_del(&nhg_head, snhg); XFREE(MTYPE_NHG, snhg); return; } +static void sharp_nhgroup_installable_cb(const struct nexthop_group_cmd *nhgc) +{ + struct sharp_nhg lookup; + struct sharp_nhg *snhg; + + strncpy(lookup.name, nhgc->name, sizeof(lookup.name)); + snhg = sharp_nhg_rb_find(&nhg_head, &lookup); + if (!snhg) + return; + + snhg->installable = nhgc->installable; + + if (snhg->installable) + nhg_add(snhg->id, &nhgc->nhg); + else + nhg_del(snhg->id); + + return; +} + uint32_t sharp_nhgroup_get_id(const char *name) { struct sharp_nhg lookup; @@ -163,6 +191,9 @@ uint32_t sharp_nhgroup_get_id(const char *name) if (!snhg) return 0; + if (!snhg->installable) + return 0; + return snhg->id; } @@ -173,5 +204,6 @@ void sharp_nhgroup_init(void) nexthop_group_init(sharp_nhgroup_add_cb, sharp_nhgroup_add_nexthop_cb, sharp_nhgroup_del_nexthop_cb, - sharp_nhgroup_delete_cb); + sharp_nhgroup_delete_cb, + sharp_nhgroup_installable_cb); } |