]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_rib.c
bgpd: Add missing enum's to case statement
[mirror_frr.git] / zebra / zebra_rib.c
index 9551f26d8009ce56c25daf01f0cd4dc792e5840f..2f71a10d3d249198e244ae2c126ec1737e391678 100644 (file)
@@ -72,7 +72,7 @@ DEFINE_MTYPE_STATIC(ZEBRA, WQ_WRAPPER, "WQ wrapper");
  */
 static pthread_mutex_t dplane_mutex;
 static struct thread *t_dplane;
-static struct dplane_ctx_q rib_dplane_q;
+static struct dplane_ctx_list_head rib_dplane_q;
 
 DEFINE_HOOK(rib_update, (struct route_node * rn, const char *reason),
            (rn, reason));
@@ -1306,6 +1306,7 @@ static void rib_process(struct route_node *rn)
                                                                        vrf),
                                                                vrf_id, rn);
                                                rib_unlink(rn, re);
+                                               continue;
                                        } else
                                                SET_FLAG(re->status,
                                                         ROUTE_ENTRY_REMOVED);
@@ -1787,9 +1788,12 @@ no_nexthops:
                        ctxnhg->nexthop != NULL ? "" : " (empty)");
 
        /* Set the flag about the dedicated fib list */
-       SET_FLAG(re->status, ROUTE_ENTRY_USE_FIB_NHG);
-       if (ctxnhg->nexthop)
-               copy_nexthops(&(re->fib_ng.nexthop), ctxnhg->nexthop, NULL);
+       if (zrouter.asic_notification_nexthop_control) {
+               SET_FLAG(re->status, ROUTE_ENTRY_USE_FIB_NHG);
+               if (ctxnhg->nexthop)
+                       copy_nexthops(&(re->fib_ng.nexthop), ctxnhg->nexthop,
+                                     NULL);
+       }
 
 check_backups:
 
@@ -2711,10 +2715,6 @@ static void process_subq_early_route_add(struct zebra_early_route *ere)
        if (ere->src_p_provided)
                apply_mask_ipv6(&ere->src_p);
 
-       /* Set default distance by route type. */
-       if (re->distance == 0)
-               re->distance = route_distance(re->type);
-
        /* Lookup route node.*/
        rn = srcdest_rnode_get(table, &ere->p,
                               ere->src_p_provided ? &ere->src_p : NULL);
@@ -2761,6 +2761,22 @@ static void process_subq_early_route_add(struct zebra_early_route *ere)
                }
        }
 
+       /* Set default distance by route type. */
+       if (re->distance == 0) {
+               if (same && !zebra_router_notify_on_ack())
+                       re->distance = same->distance;
+               else
+                       re->distance = route_distance(re->type);
+       }
+
+       if (re->metric == ROUTE_INSTALLATION_METRIC &&
+           CHECK_FLAG(re->flags, ZEBRA_FLAG_SELFROUTE)) {
+               if (same && !zebra_router_notify_on_ack())
+                       re->metric = same->metric;
+               else
+                       re->metric = 0;
+       }
+
        /* If this route is kernel/connected route, notify the dataplane. */
        if (RIB_SYSTEM_ROUTE(re)) {
                /* Notify dataplane */
@@ -4324,25 +4340,6 @@ void rib_update_table(struct route_table *table, enum rib_update_event event,
        }
 }
 
-static void rib_update_handle_vrf(vrf_id_t vrf_id, enum rib_update_event event,
-                                 int rtype)
-{
-       struct route_table *table;
-
-       if (IS_ZEBRA_DEBUG_EVENT)
-               zlog_debug("%s: Handling VRF %s event %s", __func__,
-                          vrf_id_to_name(vrf_id), rib_update_event2str(event));
-
-       /* Process routes of interested address-families. */
-       table = zebra_vrf_table(AFI_IP, SAFI_UNICAST, vrf_id);
-       if (table)
-               rib_update_table(table, event, rtype);
-
-       table = zebra_vrf_table(AFI_IP6, SAFI_UNICAST, vrf_id);
-       if (table)
-               rib_update_table(table, event, rtype);
-}
-
 static void rib_update_handle_vrf_all(enum rib_update_event event, int rtype)
 {
        struct zebra_router_table *zrt;
@@ -4358,7 +4355,6 @@ static void rib_update_handle_vrf_all(enum rib_update_event event, int rtype)
 
 struct rib_update_ctx {
        enum rib_update_event event;
-       bool vrf_all;
        vrf_id_t vrf_id;
 };
 
@@ -4386,10 +4382,7 @@ static void rib_update_handler(struct thread *thread)
 
        ctx = THREAD_ARG(thread);
 
-       if (ctx->vrf_all)
-               rib_update_handle_vrf_all(ctx->event, ZEBRA_ROUTE_ALL);
-       else
-               rib_update_handle_vrf(ctx->vrf_id, ctx->event, ZEBRA_ROUTE_ALL);
+       rib_update_handle_vrf_all(ctx->event, ZEBRA_ROUTE_ALL);
 
        rib_update_ctx_fini(&ctx);
 }
@@ -4409,7 +4402,6 @@ void rib_update(enum rib_update_event event)
                return;
 
        ctx = rib_update_ctx_init(0, event);
-       ctx->vrf_all = true;
 
        thread_add_event(zrouter.master, rib_update_handler, ctx, 0,
                         &t_rib_update_threads[event]);
@@ -4600,13 +4592,13 @@ static void handle_pw_result(struct zebra_dplane_ctx *ctx)
 static void rib_process_dplane_results(struct thread *thread)
 {
        struct zebra_dplane_ctx *ctx;
-       struct dplane_ctx_q ctxlist;
+       struct dplane_ctx_list_head ctxlist;
        bool shut_p = false;
 
        /* Dequeue a list of completed updates with one lock/unlock cycle */
 
        do {
-               TAILQ_INIT(&ctxlist);
+               dplane_ctx_q_init(&ctxlist);
 
                /* Take lock controlling queue of results */
                frr_with_mutex (&dplane_mutex) {
@@ -4775,7 +4767,7 @@ static void rib_process_dplane_results(struct thread *thread)
  * the dataplane pthread. We enqueue the results here for processing by
  * the main thread later.
  */
-static int rib_dplane_results(struct dplane_ctx_q *ctxlist)
+static int rib_dplane_results(struct dplane_ctx_list_head *ctxlist)
 {
        /* Take lock controlling queue of results */
        frr_with_mutex (&dplane_mutex) {
@@ -4820,7 +4812,7 @@ void rib_init(void)
 
        /* Init dataplane, and register for results */
        pthread_mutex_init(&dplane_mutex, NULL);
-       TAILQ_INIT(&rib_dplane_q);
+       dplane_ctx_q_init(&rib_dplane_q);
        zebra_dplane_init(rib_dplane_results);
 }