]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_rib.c
lib: enforce vrf_name_to_id by returning default_vrf when name is null
[mirror_frr.git] / zebra / zebra_rib.c
index 0c8c777ea56695e01d636af9945b15d1f2d54494..5d6eac75330d0590ddf93e294882800bb0527a9a 100644 (file)
@@ -808,84 +808,6 @@ struct route_entry *rib_lookup_ipv4(struct prefix_ipv4 *p, vrf_id_t vrf_id)
        return NULL;
 }
 
-/*
- * This clone function, unlike its original rib_lookup_ipv4(), checks
- * if specified IPv4 route record (prefix/mask -> gate) exists in
- * the whole RIB and has ROUTE_ENTRY_SELECTED_FIB set.
- *
- * Return values:
- * -1: error
- * 0: exact match found
- * 1: a match was found with a different gate
- * 2: connected route found
- * 3: no matches found
- */
-int rib_lookup_ipv4_route(struct prefix_ipv4 *p, union sockunion *qgate,
-                         vrf_id_t vrf_id)
-{
-       struct route_table *table;
-       struct route_node *rn;
-       struct route_entry *match = NULL;
-       struct nexthop *nexthop;
-       int nexthops_active;
-       rib_dest_t *dest;
-
-       /* Lookup table.  */
-       table = zebra_vrf_table(AFI_IP, SAFI_UNICAST, vrf_id);
-       if (!table)
-               return ZEBRA_RIB_LOOKUP_ERROR;
-
-       /* Scan the RIB table for exactly matching RIB entry. */
-       rn = route_node_lookup(table, (struct prefix *)p);
-
-       /* No route for this prefix. */
-       if (!rn)
-               return ZEBRA_RIB_NOTFOUND;
-
-       /* Unlock node. */
-       route_unlock_node(rn);
-       dest = rib_dest_from_rnode(rn);
-
-       /* Find out if a "selected" RR for the discovered RIB entry exists ever.
-        */
-       if (dest && dest->selected_fib
-           && !CHECK_FLAG(dest->selected_fib->status, ROUTE_ENTRY_REMOVED))
-               match = dest->selected_fib;
-
-       /* None such found :( */
-       if (!match)
-               return ZEBRA_RIB_NOTFOUND;
-
-       if (match->type == ZEBRA_ROUTE_CONNECT)
-               return ZEBRA_RIB_FOUND_CONNECTED;
-
-       /* Ok, we have a cood candidate, let's check it's nexthop list... */
-       nexthops_active = 0;
-       for (ALL_NEXTHOPS(match->ng, nexthop))
-               if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)) {
-                       nexthops_active = 1;
-                       if (nexthop->gate.ipv4.s_addr == sockunion2ip(qgate))
-                               return ZEBRA_RIB_FOUND_EXACT;
-                       if (IS_ZEBRA_DEBUG_RIB) {
-                               char gate_buf[INET_ADDRSTRLEN],
-                                       qgate_buf[INET_ADDRSTRLEN];
-                               inet_ntop(AF_INET, &nexthop->gate.ipv4.s_addr,
-                                         gate_buf, INET_ADDRSTRLEN);
-                               inet_ntop(AF_INET, &sockunion2ip(qgate),
-                                         qgate_buf, INET_ADDRSTRLEN);
-                               zlog_debug("%s: qgate == %s, %s == %s",
-                                          __func__, qgate_buf,
-                                          nexthop->rparent ? "rgate" : "gate",
-                                          gate_buf);
-                       }
-               }
-
-       if (nexthops_active)
-               return ZEBRA_RIB_FOUND_NOGATE;
-
-       return ZEBRA_RIB_NOTFOUND;
-}
-
 #define RIB_SYSTEM_ROUTE(R)                                                    \
        ((R)->type == ZEBRA_ROUTE_KERNEL || (R)->type == ZEBRA_ROUTE_CONNECT)
 
@@ -1049,7 +971,18 @@ static int nexthop_active_update(struct route_node *rn, struct route_entry *re,
                prev_src = nexthop->rmap_src;
                prev_active = CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
                prev_index = nexthop->ifindex;
-               if ((new_active = nexthop_active_check(rn, re, nexthop, set)))
+               /*
+                * We need to respect the multipath_num here
+                * as that what we should be able to install from
+                * a multipath perpsective should not be a data plane
+                * decision point.
+                */
+               new_active = nexthop_active_check(rn, re, nexthop, set);
+               if (new_active && re->nexthop_active_num >= multipath_num) {
+                       UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
+                       new_active = 0;
+               }
+               if (new_active)
                        re->nexthop_active_num++;
                /* Don't allow src setting on IPv6 addr for now */
                if (prev_active != new_active || prev_index != nexthop->ifindex
@@ -1950,7 +1883,7 @@ static void rib_process_after(struct zebra_dplane_ctx *ctx)
                                zvrf->removals++;
                } else {
                        zsend_route_notify_owner_ctx(ctx,
-                                                    ZAPI_ROUTE_FAIL_INSTALL);
+                                                    ZAPI_ROUTE_REMOVE_FAIL);
 
                        zlog_warn("%u:%s: Route Deletion failure",
                                  dplane_ctx_get_vrf(ctx),
@@ -2362,6 +2295,7 @@ static void rib_queue_init(struct zebra_t *zebra)
        /* XXX: TODO: These should be runtime configurable via vty */
        zebra->ribq->spec.max_retries = 3;
        zebra->ribq->spec.hold = ZEBRA_RIB_PROCESS_HOLD_TIME;
+       zebra->ribq->spec.retry = ZEBRA_RIB_PROCESS_RETRY_TIME;
 
        if (!(zebra->mq = meta_queue_new())) {
                flog_err(EC_ZEBRA_WQ_NONEXISTENT,