]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospf_route.c
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / ospfd / ospf_route.c
index 9c4dca2e2fbea2ed79e2c4dbc2000c9d920b6546..7ee91b5b6c9655427fea257512e7fc6f53018c43 100644 (file)
@@ -54,7 +54,7 @@ struct ospf_route *ospf_route_new()
 void ospf_route_free(struct ospf_route * or)
 {
        if (or->paths)
-               list_delete(or->paths);
+               list_delete(or->paths);
 
        XFREE(MTYPE_OSPF_ROUTE, or);
 }
@@ -83,7 +83,7 @@ void ospf_path_free(struct ospf_path *op)
        XFREE(MTYPE_OSPF_PATH, op);
 }
 
-void ospf_route_delete(struct route_table *rt)
+void ospf_route_delete(struct ospf *ospf, struct route_table *rt)
 {
        struct route_node *rn;
        struct ospf_route * or ;
@@ -91,11 +91,11 @@ void ospf_route_delete(struct route_table *rt)
        for (rn = route_top(rt); rn; rn = route_next(rn))
                if ((or = rn->info) != NULL) {
                        if (or->type == OSPF_DESTINATION_NETWORK)
-                               ospf_zebra_delete((struct prefix_ipv4 *)&rn->p,
-                                                 or);
+                               ospf_zebra_delete(
+                                       ospf, (struct prefix_ipv4 *)&rn->p, or);
                        else if (or->type == OSPF_DESTINATION_DISCARD)
                                ospf_zebra_delete_discard(
-                                       (struct prefix_ipv4 *)&rn->p);
+                                       ospf, (struct prefix_ipv4 *)&rn->p);
                }
 }
 
@@ -170,8 +170,8 @@ int ospf_route_match_same(struct route_table *rt, struct prefix_ipv4 *prefix,
                        /* Check each path. */
                        for (n1 = listhead(or->paths),
                            n2 = listhead(newor->paths);
-                            n1 && n2;
-                            n1 = listnextnode(n1), n2 = listnextnode(n2)) {
+                            n1 && n2; n1 = listnextnode_unchecked(n1),
+                           n2 = listnextnode_unchecked(n2)) {
                                op = listgetdata(n1);
                                newop = listgetdata(n2);
 
@@ -191,7 +191,8 @@ int ospf_route_match_same(struct route_table *rt, struct prefix_ipv4 *prefix,
 /* delete routes generated from AS-External routes if there is a inter/intra
  * area route
  */
-static void ospf_route_delete_same_ext(struct route_table *external_routes,
+static void ospf_route_delete_same_ext(struct ospf *ospf,
+                                      struct route_table *external_routes,
                                       struct route_table *routes)
 {
        struct route_node *rn, *ext_rn;
@@ -206,7 +207,8 @@ static void ospf_route_delete_same_ext(struct route_table *external_routes,
                        if ((ext_rn = route_node_lookup(external_routes,
                                                        (struct prefix *)p))) {
                                if (ext_rn->info) {
-                                       ospf_zebra_delete(p, ext_rn->info);
+                                       ospf_zebra_delete(ospf, p,
+                                                         ext_rn->info);
                                        ospf_route_free(ext_rn->info);
                                        ext_rn->info = NULL;
                                }
@@ -217,7 +219,7 @@ static void ospf_route_delete_same_ext(struct route_table *external_routes,
 }
 
 /* rt: Old, cmprt: New */
-static void ospf_route_delete_uniq(struct route_table *rt,
+static void ospf_route_delete_uniq(struct ospf *ospf, struct route_table *rt,
                                   struct route_table *cmprt)
 {
        struct route_node *rn;
@@ -233,6 +235,7 @@ static void ospf_route_delete_uniq(struct route_table *rt,
                                                    (struct prefix_ipv4 *)&rn
                                                            ->p))
                                                ospf_zebra_delete(
+                                                       ospf,
                                                        (struct prefix_ipv4
                                                                 *)&rn->p,
                                                        or);
@@ -242,6 +245,7 @@ static void ospf_route_delete_uniq(struct route_table *rt,
                                                    (struct prefix_ipv4 *)&rn
                                                            ->p))
                                                ospf_zebra_delete_discard(
+                                                       ospf,
                                                        (struct prefix_ipv4
                                                                 *)&rn->p);
                        }
@@ -263,9 +267,9 @@ void ospf_route_install(struct ospf *ospf, struct route_table *rt)
 
        /* Delete old routes. */
        if (ospf->old_table)
-               ospf_route_delete_uniq(ospf->old_table, rt);
+               ospf_route_delete_uniq(ospf, ospf->old_table, rt);
        if (ospf->old_external_route)
-               ospf_route_delete_same_ext(ospf->old_external_route, rt);
+               ospf_route_delete_same_ext(ospf, ospf->old_external_route, rt);
 
        /* Install new routes. */
        for (rn = route_top(rt); rn; rn = route_next(rn))
@@ -275,6 +279,7 @@ void ospf_route_install(struct ospf *ospf, struct route_table *rt)
                                            ospf->old_table,
                                            (struct prefix_ipv4 *)&rn->p, or))
                                        ospf_zebra_add(
+                                               ospf,
                                                (struct prefix_ipv4 *)&rn->p,
                                                or);
                        } else if (or->type == OSPF_DESTINATION_DISCARD)
@@ -282,6 +287,7 @@ void ospf_route_install(struct ospf *ospf, struct route_table *rt)
                                            ospf->old_table,
                                            (struct prefix_ipv4 *)&rn->p, or))
                                        ospf_zebra_add_discard(
+                                               ospf,
                                                (struct prefix_ipv4 *)&rn->p);
                }
 }
@@ -356,6 +362,7 @@ void ospf_intra_add_router(struct route_table *rt, struct vertex *v,
        p.family = AF_INET;
        p.prefix = v->id;
        p.prefixlen = IPV4_MAX_BITLEN;
+       apply_mask_ipv4(&p);
 
        if (IS_DEBUG_OSPF_EVENT)
                zlog_debug("ospf_intra_add_router: talking about %s/%d",
@@ -442,7 +449,7 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link,
                         struct vertex *v, struct ospf_area *area,
                         int parent_is_root, int lsa_pos)
 {
-       u_int32_t cost;
+       uint32_t cost;
        struct route_node *rn;
        struct ospf_route * or ;
        struct prefix_ipv4 p;
@@ -669,7 +676,7 @@ void ospf_route_table_dump(struct route_table *rt)
 static int ospf_asbr_route_cmp(struct ospf *ospf, struct ospf_route *r1,
                               struct ospf_route *r2)
 {
-       u_char r1_type, r2_type;
+       uint8_t r1_type, r2_type;
 
        r1_type = r1->path_type;
        r2_type = r2->path_type;
@@ -898,15 +905,15 @@ void ospf_prune_unreachable_routers(struct route_table *rtrs)
                                zlog_debug("Pruning router node %s",
                                           inet_ntoa(rn->p.u.prefix4));
 
-                       list_delete(paths);
+                       list_delete(&paths);
                        rn->info = NULL;
                        route_unlock_node(rn);
                }
        }
 }
 
-int ospf_add_discard_route(struct route_table *rt, struct ospf_area *area,
-                          struct prefix_ipv4 *p)
+int ospf_add_discard_route(struct ospf *ospf, struct route_table *rt,
+                          struct ospf_area *area, struct prefix_ipv4 *p)
 {
        struct route_node *rn;
        struct ospf_route * or, *new_or;
@@ -960,12 +967,13 @@ int ospf_add_discard_route(struct route_table *rt, struct ospf_area *area,
        new_or->path_type = OSPF_PATH_INTER_AREA;
        rn->info = new_or;
 
-       ospf_zebra_add_discard(p);
+       ospf_zebra_add_discard(ospf, p);
 
        return 1;
 }
 
-void ospf_delete_discard_route(struct route_table *rt, struct prefix_ipv4 *p)
+void ospf_delete_discard_route(struct ospf *ospf, struct route_table *rt,
+                              struct prefix_ipv4 *p)
 {
        struct route_node *rn;
        struct ospf_route * or ;
@@ -1011,7 +1019,7 @@ void ospf_delete_discard_route(struct route_table *rt, struct prefix_ipv4 *p)
        route_unlock_node(rn);
 
        /* remove the discard entry from the rib */
-       ospf_zebra_delete_discard(p);
+       ospf_zebra_delete_discard(ospf, p);
 
        return;
 }