]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/rt_netlink.c
Merge pull request #5737 from mjstapp/zebra_disable_kern_nhs
[mirror_frr.git] / zebra / rt_netlink.c
index 29a341abbd9b4e3d3ce00b1697c78d585e2d35ab..b1c679e06607738aaa8b77e82f190a817544ae78 100644 (file)
 
 static vlanid_t filter_vlan = 0;
 
+/* We capture whether the current kernel supports nexthop ids; by
+ * default, we'll use them if possible. There's also a configuration
+ * available to _disable_ use of kernel nexthops.
+ */
 static bool supports_nh;
 
 struct gw_family_t {
@@ -86,6 +90,12 @@ struct gw_family_t {
 static const char ipv4_ll_buf[16] = "169.254.0.1";
 static struct in_addr ipv4_ll;
 
+/* Helper to control use of kernel-level nexthop ids */
+static bool kernel_nexthops_supported(void)
+{
+       return (supports_nh && zebra_nhg_kernel_nexthops_enabled());
+}
+
 /*
  * The ipv4_ll data structure is used for all 5549
  * additions to the kernel.  Let's figure out the
@@ -1628,7 +1638,7 @@ static int netlink_route_multipath(int cmd, struct zebra_dplane_ctx *ctx)
                          RTA_PAYLOAD(rta));
        }
 
-       if (supports_nh) {
+       if (kernel_nexthops_supported()) {
                /* Kernel supports nexthop objects */
                addattr32(&req.n, sizeof(req), RTA_NH_ID,
                          dplane_ctx_get_nhe_id(ctx));
@@ -1943,7 +1953,7 @@ static int netlink_nexthop(int cmd, struct zebra_dplane_ctx *ctx)
        size_t req_size = sizeof(req);
 
        /* Nothing to do if the kernel doesn't support nexthop objects */
-       if (!supports_nh)
+       if (!kernel_nexthops_supported())
                return 0;
 
        label_buf[0] = '\0';
@@ -2353,7 +2363,7 @@ int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
        unsigned char family;
        int type;
        afi_t afi = AFI_UNSPEC;
-       vrf_id_t vrf_id = 0;
+       vrf_id_t vrf_id = VRF_DEFAULT;
        struct interface *ifp = NULL;
        struct nhmsg *nhm = NULL;
        struct nexthop nh = {};
@@ -2364,6 +2374,9 @@ int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
 
        nhm = NLMSG_DATA(h);
 
+       if (ns_id)
+               vrf_id = ns_id;
+
        if (startup && h->nlmsg_type != RTM_NEWNEXTHOP)
                return 0;
 
@@ -2443,7 +2456,7 @@ int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
                        return -1;
 
        } else if (h->nlmsg_type == RTM_DELNEXTHOP)
-               zebra_nhg_kernel_del(id);
+               zebra_nhg_kernel_del(id, vrf_id);
 
        return 0;
 }
@@ -2501,8 +2514,10 @@ int netlink_nexthop_read(struct zebra_ns *zns)
                 * this kernel must support them.
                 */
                supports_nh = true;
-       else if (IS_ZEBRA_DEBUG_KERNEL)
-               zlog_debug("Nexthop objects not supported on this kernel");
+
+       if (IS_ZEBRA_DEBUG_KERNEL || IS_ZEBRA_DEBUG_NHG)
+               zlog_debug("Nexthop objects %ssupported on this kernel",
+                          supports_nh ? "" : "not ");
 
        return ret;
 }