]> git.proxmox.com Git - mirror_frr.git/blobdiff - staticd/static_zebra.c
staticd: reject route config with too many nexthops
[mirror_frr.git] / staticd / static_zebra.c
index 538fae28aa4ece56336bb44817c881a5e4423de6..b75e1a1cdf6779fa46ece03e9c385e81000ac241 100644 (file)
@@ -84,12 +84,6 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)
 
 static int static_ifp_up(struct interface *ifp)
 {
-       if (if_is_vrf(ifp)) {
-               struct static_vrf *svrf = static_vrf_lookup_by_id(ifp->vrf_id);
-
-               static_fixup_vrf_ids(svrf);
-       }
-
        /* Install any static reliant on this interface coming up */
        static_install_intf_nh(ifp);
        static_ifindex_update(ifp, true);
@@ -162,14 +156,10 @@ static bool
 static_nexthop_is_local(vrf_id_t vrfid, struct prefix *addr, int family)
 {
        if (family == AF_INET) {
-               if (if_lookup_exact_address(&addr->u.prefix4,
-                                       AF_INET,
-                                       vrfid))
+               if (if_address_is_local(&addr->u.prefix4, AF_INET, vrfid))
                        return true;
        } else if (family == AF_INET6) {
-               if (if_lookup_exact_address(&addr->u.prefix6,
-                                       AF_INET6,
-                                       vrfid))
+               if (if_address_is_local(&addr->u.prefix6, AF_INET6, vrfid))
                        return true;
        }
        return false;
@@ -215,6 +205,7 @@ static int static_zebra_nexthop_update(ZAPI_CALLBACK_ARGS)
 static void static_zebra_capabilities(struct zclient_capabilities *cap)
 {
        mpls_enabled = cap->mpls_enabled;
+       zebra_ecmp_count = cap->ecmp;
 }
 
 static unsigned int static_nht_hash_key(const void *data)
@@ -423,6 +414,10 @@ extern void static_zebra_route_add(struct static_path *pn, bool install)
                api.tableid = pn->table_id;
        }
        frr_each(static_nexthop_list, &pn->nexthop_list, nh) {
+               /* Don't overrun the nexthop array */
+               if (nh_num == zebra_ecmp_count)
+                       break;
+
                api_nh = &api.nexthops[nh_num];
                if (nh->nh_vrf_id == VRF_UNKNOWN)
                        continue;