]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospf6d/ospf6_asbr.c
Merge pull request #5280 from qlyoung/doc-clean-topotest-json
[mirror_frr.git] / ospf6d / ospf6_asbr.c
index 7f575ee50638b8e5da6c56add7fa7f4cc802a34c..7914412e875bb43632fa0bbc3763f6cb3587963b 100644 (file)
@@ -497,7 +497,8 @@ void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa)
        route->type = OSPF6_DEST_TYPE_NETWORK;
        route->prefix.family = AF_INET6;
        route->prefix.prefixlen = external->prefix.prefix_length;
-       ospf6_prefix_in6_addr(&route->prefix.u.prefix6, &external->prefix);
+       ospf6_prefix_in6_addr(&route->prefix.u.prefix6, external,
+                             &external->prefix);
 
        route->path.area_id = asbr_entry->path.area_id;
        route->path.origin.type = lsa->header->type;
@@ -576,7 +577,7 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,
        route_to_del->type = OSPF6_DEST_TYPE_NETWORK;
        route_to_del->prefix.family = AF_INET6;
        route_to_del->prefix.prefixlen = external->prefix.prefix_length;
-       ospf6_prefix_in6_addr(&route_to_del->prefix.u.prefix6,
+       ospf6_prefix_in6_addr(&route_to_del->prefix.u.prefix6, external,
                              &external->prefix);
 
        route_to_del->path.origin.type = lsa->header->type;
@@ -603,7 +604,7 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,
        memset(&prefix, 0, sizeof(struct prefix));
        prefix.family = AF_INET6;
        prefix.prefixlen = external->prefix.prefix_length;
-       ospf6_prefix_in6_addr(&prefix.u.prefix6, &external->prefix);
+       ospf6_prefix_in6_addr(&prefix.u.prefix6, external, &external->prefix);
 
        route = ospf6_route_lookup(&prefix, ospf6->route_table);
        if (route == NULL) {
@@ -731,7 +732,8 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,
                                                        ? 1
                                                        : 2,
                                                buf, listcount(route->paths),
-                                               listcount(route->nh_list));
+                                               route->nh_list ?
+                                               listcount(route->nh_list) : 0);
                                }
 
                                if (listcount(route->paths)) {
@@ -854,16 +856,22 @@ void ospf6_asbr_lsentry_remove(struct ospf6_route *asbr_entry)
 
 static void ospf6_asbr_routemap_set(int type, const char *mapname)
 {
-       if (ospf6->rmap[type].name)
+       if (ospf6->rmap[type].name) {
+               route_map_counter_decrement(ospf6->rmap[type].map);
                free(ospf6->rmap[type].name);
+       }
        ospf6->rmap[type].name = strdup(mapname);
        ospf6->rmap[type].map = route_map_lookup_by_name(mapname);
+       route_map_counter_increment(ospf6->rmap[type].map);
 }
 
 static void ospf6_asbr_routemap_unset(int type)
 {
        if (ospf6->rmap[type].name)
                free(ospf6->rmap[type].name);
+
+       route_map_counter_decrement(ospf6->rmap[type].map);
+
        ospf6->rmap[type].name = NULL;
        ospf6->rmap[type].map = NULL;
 }
@@ -937,6 +945,10 @@ static void ospf6_asbr_routemap_update(const char *mapname)
                                                "%s: route-map %s update, reset redist %s",
                                                __PRETTY_FUNCTION__, mapname,
                                                ZROUTE_NAME(type));
+
+                               route_map_counter_increment(
+                                       ospf6->rmap[type].map);
+
                                ospf6_asbr_distribute_list_update(type);
                        }
                } else
@@ -944,7 +956,7 @@ static void ospf6_asbr_routemap_update(const char *mapname)
        }
 }
 
-static void ospf6_asbr_routemap_event(route_map_event_t event, const char *name)
+static void ospf6_asbr_routemap_event(const char *name)
 {
        int type;
 
@@ -994,7 +1006,7 @@ void ospf6_asbr_send_externals_to_area(struct ospf6_area *oa)
 
        for (ALL_LSDB(oa->ospf6->lsdb, lsa)) {
                if (ntohs(lsa->header->type) == OSPF6_LSTYPE_AS_EXTERNAL) {
-                       zlog_debug("%s: Flooding AS-External LSA %s\n",
+                       zlog_debug("%s: Flooding AS-External LSA %s",
                                   __func__, lsa->name);
                        ospf6_flood_area(NULL, lsa, oa);
                }
@@ -1006,7 +1018,7 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
                                 unsigned int nexthop_num,
                                 struct in6_addr *nexthop, route_tag_t tag)
 {
-       int ret;
+       route_map_result_t ret;
        struct ospf6_route troute;
        struct ospf6_external_info tinfo;
        struct ospf6_route *route, *match;
@@ -1343,8 +1355,9 @@ static void ospf6_redistribute_show_config(struct vty *vty)
 
 
 /* Routemap Functions */
-static route_map_result_t
-ospf6_routemap_rule_match_address_prefixlist(void *rule, struct prefix *prefix,
+static enum route_map_cmd_result_t
+ospf6_routemap_rule_match_address_prefixlist(void *rule,
+                                            const struct prefix *prefix,
                                             route_map_object_t type,
                                             void *object)
 {
@@ -1382,8 +1395,8 @@ struct route_map_rule_cmd ospf6_routemap_rule_match_address_prefixlist_cmd = {
 /* `match interface IFNAME' */
 /* Match function should return 1 if match is success else return
    zero. */
-static route_map_result_t
-ospf6_routemap_rule_match_interface(void *rule, struct prefix *prefix,
+static enum route_map_cmd_result_t
+ospf6_routemap_rule_match_interface(void *rule, const struct prefix *prefix,
                                    route_map_object_t type, void *object)
 {
        struct interface *ifp;
@@ -1420,10 +1433,9 @@ struct route_map_rule_cmd ospf6_routemap_rule_match_interface_cmd = {
        ospf6_routemap_rule_match_interface_free};
 
 /* Match function for matching route tags */
-static route_map_result_t ospf6_routemap_rule_match_tag(void *rule,
-                                                       struct prefix *prefix,
-                                                       route_map_object_t type,
-                                                       void *object)
+static enum route_map_cmd_result_t
+ospf6_routemap_rule_match_tag(void *rule, const struct prefix *p,
+                             route_map_object_t type, void *object)
 {
        route_tag_t *tag = rule;
        struct ospf6_route *route = object;
@@ -1440,8 +1452,8 @@ static struct route_map_rule_cmd ospf6_routemap_rule_match_tag_cmd = {
        route_map_rule_tag_free,
 };
 
-static route_map_result_t
-ospf6_routemap_rule_set_metric_type(void *rule, struct prefix *prefix,
+static enum route_map_cmd_result_t
+ospf6_routemap_rule_set_metric_type(void *rule, const struct prefix *prefix,
                                    route_map_object_t type, void *object)
 {
        char *metric_type = rule;
@@ -1476,8 +1488,8 @@ struct route_map_rule_cmd ospf6_routemap_rule_set_metric_type_cmd = {
        ospf6_routemap_rule_set_metric_type_free,
 };
 
-static route_map_result_t
-ospf6_routemap_rule_set_metric(void *rule, struct prefix *prefix,
+static enum route_map_cmd_result_t
+ospf6_routemap_rule_set_metric(void *rule, const struct prefix *prefix,
                               route_map_object_t type, void *object)
 {
        char *metric = rule;
@@ -1511,8 +1523,8 @@ struct route_map_rule_cmd ospf6_routemap_rule_set_metric_cmd = {
        ospf6_routemap_rule_set_metric_free,
 };
 
-static route_map_result_t
-ospf6_routemap_rule_set_forwarding(void *rule, struct prefix *prefix,
+static enum route_map_cmd_result_t
+ospf6_routemap_rule_set_forwarding(void *rule, const struct prefix *prefix,
                                   route_map_object_t type, void *object)
 {
        char *forwarding = rule;
@@ -1549,10 +1561,9 @@ struct route_map_rule_cmd ospf6_routemap_rule_set_forwarding_cmd = {
        ospf6_routemap_rule_set_forwarding_free,
 };
 
-static route_map_result_t ospf6_routemap_rule_set_tag(void *rule,
-                                                     struct prefix *prefix,
-                                                     route_map_object_t type,
-                                                     void *object)
+static enum route_map_cmd_result_t
+ospf6_routemap_rule_set_tag(void *rule, const struct prefix *p,
+                           route_map_object_t type, void *object)
 {
        route_tag_t *tag = rule;
        struct ospf6_route *route = object;
@@ -1570,7 +1581,7 @@ static struct route_map_rule_cmd ospf6_routemap_rule_set_tag_cmd = {
        route_map_rule_tag_free,
 };
 
-static int route_map_command_status(struct vty *vty, int ret)
+static int route_map_command_status(struct vty *vty, enum rmap_compile_rets ret)
 {
        switch (ret) {
        case RMAP_RULE_MISSING:
@@ -1599,8 +1610,10 @@ DEFUN (ospf6_routemap_set_metric_type,
 {
        VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
        int idx_external = 2;
-       int ret = route_map_add_set(route_map_index, "metric-type",
-                                   argv[idx_external]->arg);
+       enum rmap_compile_rets ret = route_map_add_set(route_map_index,
+                                                      "metric-type",
+                                                      argv[idx_external]->arg);
+
        return route_map_command_status(vty, ret);
 }
 
@@ -1616,7 +1629,9 @@ DEFUN (ospf6_routemap_no_set_metric_type,
 {
        VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
        char *ext = (argc == 4) ? argv[3]->text : NULL;
-       int ret = route_map_delete_set(route_map_index, "metric-type", ext);
+       enum rmap_compile_rets ret = route_map_delete_set(route_map_index,
+                                                         "metric-type", ext);
+
        return route_map_command_status(vty, ret);
 }
 
@@ -1630,8 +1645,10 @@ DEFUN (ospf6_routemap_set_forwarding,
 {
        VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
        int idx_ipv6 = 2;
-       int ret = route_map_add_set(route_map_index, "forwarding-address",
-                                   argv[idx_ipv6]->arg);
+       enum rmap_compile_rets ret = route_map_add_set(route_map_index,
+                                                      "forwarding-address",
+                                                      argv[idx_ipv6]->arg);
+
        return route_map_command_status(vty, ret);
 }
 
@@ -1646,8 +1663,10 @@ DEFUN (ospf6_routemap_no_set_forwarding,
 {
        VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
        int idx_ipv6 = 3;
-       int ret = route_map_delete_set(route_map_index, "forwarding-address",
-                                      argv[idx_ipv6]->arg);
+       enum rmap_compile_rets ret = route_map_delete_set(route_map_index,
+                                                         "forwarding-address",
+                                                         argv[idx_ipv6]->arg);
+
        return route_map_command_status(vty, ret);
 }
 
@@ -1705,7 +1724,8 @@ static char *ospf6_as_external_lsa_get_prefix_str(struct ospf6_lsa *lsa,
                        lsa->header);
 
                if (pos == 0) {
-                       ospf6_prefix_in6_addr(&in6, &external->prefix);
+                       ospf6_prefix_in6_addr(&in6, external,
+                                             &external->prefix);
                        prefix_length = external->prefix.prefix_length;
                } else {
                        in6 = *((struct in6_addr
@@ -1858,9 +1878,6 @@ void ospf6_asbr_redistribute_reset(void)
 void ospf6_asbr_terminate(void)
 {
        /* Cleanup route maps */
-       route_map_add_hook(NULL);
-       route_map_delete_hook(NULL);
-       route_map_event_hook(NULL);
        route_map_finish();
 }
 
@@ -1896,7 +1913,7 @@ int config_write_ospf6_debug_asbr(struct vty *vty)
        return 0;
 }
 
-void install_element_ospf6_debug_asbr()
+void install_element_ospf6_debug_asbr(void)
 {
        install_element(ENABLE_NODE, &debug_ospf6_asbr_cmd);
        install_element(ENABLE_NODE, &no_debug_ospf6_asbr_cmd);