summaryrefslogtreecommitdiff
path: root/zebra/rt_netlink.c
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2019-08-01 14:53:06 -0400
committerStephen Worley <sworley@cumulusnetworks.com>2019-10-25 11:13:41 -0400
commit815059466cdfb022ff5beec55f7ffee649db7600 (patch)
treea86f3963dd589eaa3d0de24f54c15952a803837a /zebra/rt_netlink.c
parent9a1588c4ce9ef163c9f4eeeed1a92e11133ed6c8 (diff)
zebra: Move the supports_nh bool to a better place
Move the supports_nh bool indicating whether the kernel we are using supports nexthop objects into the netlink kernel interface itself. Since only linux and netlink support nexthop object APIs for now this is fine. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'zebra/rt_netlink.c')
-rw-r--r--zebra/rt_netlink.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 6e791b1336..840354a8bc 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -74,6 +74,8 @@
static vlanid_t filter_vlan = 0;
+static bool supports_nh = false;
+
struct gw_family_t {
uint16_t filler;
uint16_t family;
@@ -1644,7 +1646,7 @@ static int netlink_route_multipath(int cmd, struct zebra_dplane_ctx *ctx)
RTA_PAYLOAD(rta));
}
- if (dplane_ctx_get_nhe_id(ctx)) {
+ if (supports_nh) {
/* Kernel supports nexthop objects */
addattr32(&req.n, sizeof(req), RTA_NH_ID,
dplane_ctx_get_nhe_id(ctx));
@@ -1938,6 +1940,10 @@ static int netlink_nexthop(int cmd, struct zebra_dplane_ctx *ctx)
char buf[NL_PKT_BUF_SIZE];
} req;
+ /* Nothing to do if the kernel doesn't support nexthop objects */
+ if (!supports_nh)
+ return 0;
+
memset(&req, 0, sizeof(req));
req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct nhmsg));
@@ -2424,6 +2430,15 @@ int netlink_nexthop_read(struct zebra_ns *zns)
return ret;
ret = netlink_parse_info(netlink_nexthop_change, &zns->netlink_cmd,
&dp_info, 0, 1);
+
+ if (!ret)
+ /* If we succesfully read in nexthop objects,
+ * this kernel must support them.
+ */
+ supports_nh = true;
+ else if (IS_ZEBRA_DEBUG_KERNEL)
+ zlog_debug("Nexthop objects not supported on this kernel");
+
return ret;
}