diff options
| author | Stephen Worley <sworley@cumulusnetworks.com> | 2020-05-13 12:50:14 -0700 |
|---|---|---|
| committer | Stephen Worley <sworley@cumulusnetworks.com> | 2020-09-28 12:40:59 -0400 |
| commit | 6c67f41f9e39bca29416c38eecc74ec729d1d60f (patch) | |
| tree | 3ec3d87697438c4ffc35d5f685d113eb5a109a4b /zebra/rt_netlink.c | |
| parent | 0885b1e3d90b1fa4d84c7e7a5fb775ba397c4103 (diff) | |
zebra,lib: command to only install proto-based nexthops
Add a command/functionality to only install proto-based nexthops.
That is nexthops owned/created by upper level protocols, not ones
implicitly created by zebra.
There are some scenarios where you would not want zebra to be
arbitrarily installing nexthop groups and but you still want
to use ones you have control over via lib/nexthop_group config
and an upper level protocol.
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'zebra/rt_netlink.c')
| -rw-r--r-- | zebra/rt_netlink.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 146650f602..07135b7fc8 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -126,6 +126,31 @@ static bool kernel_nexthops_supported(void) } /* + * Some people may only want to use NHGs created by protos and not + * implicitly created by Zebra. This check accounts for that. + */ +static bool proto_nexthops_only(void) +{ + return zebra_nhg_proto_nexthops_only(); +} + +/* Is this a proto created NHG? */ +static bool is_proto_nhg(uint32_t id, int type) +{ + /* If type is available, use it as the source of truth */ + if (type) { + if (type != ZEBRA_ROUTE_NHG) + return true; + return false; + } + + if (id >= zclient_get_nhg_lower_bound()) + return true; + + return false; +} + +/* * The ipv4_ll data structure is used for all 5549 * additions to the kernel. Let's figure out the * correct value one time instead for every @@ -1748,7 +1773,10 @@ ssize_t netlink_route_multipath_msg_encode(int cmd, nl_attr_nest_end(&req->n, nest); } - if ((!fpm && kernel_nexthops_supported()) || (fpm && force_nhg)) { + if ((!fpm && kernel_nexthops_supported() + && (!proto_nexthops_only() + || is_proto_nhg(dplane_ctx_get_nhe_id(ctx), 0))) + || (fpm && force_nhg)) { /* Kernel supports nexthop objects */ if (IS_ZEBRA_DEBUG_KERNEL) zlog_debug("%s: %pFX nhg_id is %u", __func__, p, @@ -2073,6 +2101,16 @@ ssize_t netlink_nexthop_msg_encode(uint16_t cmd, char label_buf[256]; int num_labels = 0; + /* + * Nothing to do if the kernel doesn't support nexthop objects or + * we dont want to install this type of NHG + */ + if (!kernel_nexthops_supported() + || (proto_nexthops_only() + && !is_proto_nhg(dplane_ctx_get_nhe_id(ctx), + dplane_ctx_get_nhe_type(ctx)))) + return 0; + label_buf[0] = '\0'; if (buflen < sizeof(*req)) |
