]> git.puffer.fish Git - mirror/frr.git/commitdiff
isisd: Fix the issue where redistributed routes do not change when the route-map... 18369/head
authorhuachao01 <1945995178@qq.com>
Wed, 12 Mar 2025 13:19:02 +0000 (09:19 -0400)
committerhuachao01 <1945995178@qq.com>
Wed, 12 Mar 2025 13:19:19 +0000 (09:19 -0400)
Signed-off-by: huachao01 <1945995178@qq.com>
isisd/isis_redist.c
isisd/isis_redist.h
isisd/isis_routemap.c
isisd/isisd.h

index 2cb08db27bd70ae3b28c89816e308f95a9b31d1b..76189edcdc5f852e8ea49bbe35eb37474edcb96a 100644 (file)
@@ -44,6 +44,17 @@ static int redist_protocol(int family)
        return 0;
 }
 
+int afi_skt_for_redist_protocol(int protocol)
+{
+       if (protocol == 0)
+               return AF_INET;
+       if (protocol == 1)
+               return AF_INET6;
+
+       assert(!"Unknown redist protocol!");
+       return AF_INET;
+}
+
 afi_t afi_for_redist_protocol(int protocol)
 {
        if (protocol == 0)
@@ -430,6 +441,41 @@ void isis_redist_free(struct isis *isis)
        }
 }
 
+void isis_redist_update(struct isis_area *area, int level, int family, int type, uint16_t table)
+{
+       struct isis_redist *redist;
+       struct route_table *ei_table;
+       struct route_node *rn;
+       struct isis_ext_info *info;
+
+       redist = isis_redist_lookup(area, family, type, level, table);
+       if (!redist)
+               return;
+
+       ei_table = get_ext_info(area->isis, family);
+       for (rn = route_top(ei_table); rn; rn = srcdest_route_next(rn)) {
+               if (!rn->info)
+                       continue;
+               info = rn->info;
+
+               const struct prefix *p, *src_p;
+
+               srcdest_rnode_prefixes(rn, &p, &src_p);
+
+               if (type == DEFAULT_ROUTE) {
+                       if (!is_default_prefix(p) || (src_p && src_p->prefixlen)) {
+                               continue;
+                       }
+               } else {
+                       if (info->origin != type)
+                               continue;
+               }
+
+               isis_redist_update_ext_reach(area, level, redist, p,
+                                            (const struct prefix_ipv6 *)src_p, info);
+       }
+}
+
 void isis_redist_set(struct isis_area *area, int level, int family, int type,
                     uint32_t metric, const char *routemap, int originate_type,
                     uint16_t table)
index 688f27e62db8498c29bd8aeb906d9a23de315517..7ae3c0e52ab90046d25c2dbb2423bce3f4f73ca6 100644 (file)
@@ -43,6 +43,7 @@ struct prefix;
 struct prefix_ipv6;
 struct vty;
 
+int afi_skt_for_redist_protocol(int protocol);
 afi_t afi_for_redist_protocol(int protocol);
 
 struct route_table *get_ext_reach(struct isis_area *area, int family,
@@ -60,6 +61,7 @@ void isis_redist_area_finish(struct isis_area *area);
 void isis_redist_set(struct isis_area *area, int level, int family, int type,
                     uint32_t metric, const char *routemap, int originate_type,
                     uint16_t table);
+void isis_redist_update(struct isis_area *area, int level, int family, int type, uint16_t table);
 void isis_redist_unset(struct isis_area *area, int level, int family, int type,
                       uint16_t table);
 
index 9be133c7880d75b92d9507064b1d96c5eaa9770b..7aaba08c44e8eb52863903f043a7da002a59a554 100644 (file)
@@ -234,10 +234,51 @@ static const struct route_map_rule_cmd route_set_metric_cmd = {
        route_set_metric_free
 };
 
+static void isis_route_map_update(const char *name)
+{
+       struct isis *isis;
+       struct listnode *node, *lnode;
+       struct isis_area *area;
+       int type;
+       int level;
+       int protocol;
+       struct isis_redist *redist;
+
+       for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
+               for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area))
+                       for (protocol = 0; protocol < REDIST_PROTOCOL_COUNT; protocol++)
+                               for (type = 0; type < ZEBRA_ROUTE_MAX + 1; type++)
+                                       for (level = 0; level < ISIS_LEVELS; level++) {
+                                               if (area->redist_settings[protocol][type][level] ==
+                                                   NULL)
+                                                       continue;
+                                               for (ALL_LIST_ELEMENTS_RO(area->redist_settings
+                                                                                 [protocol][type]
+                                                                                 [level],
+                                                                         lnode, redist)) {
+                                                       if (redist->redist == 0)
+                                                               continue;
+
+                                                       if (redist->map_name &&
+                                                           strcmp(redist->map_name, name) == 0) {
+                                                               isis_redist_update(area, level + 1,
+                                                                                  afi_skt_for_redist_protocol(
+                                                                                          protocol),
+                                                                                  type,
+                                                                                  redist->table);
+                                                       }
+                                               }
+                                       }
+}
+
 void isis_route_map_init(void)
 {
        route_map_init();
 
+       route_map_add_hook(isis_route_map_update);
+       route_map_delete_hook(isis_route_map_update);
+       route_map_event_hook(isis_route_map_update);
+
        route_map_match_ip_address_hook(generic_match_add);
        route_map_no_match_ip_address_hook(generic_match_delete);
 
index ae39502023d404a62d3c1cea846690088ea2aac3..f9723c22e1c3ee2ab561809b14dba9df43e7e660 100644 (file)
@@ -56,6 +56,7 @@ static const bool fabricd = false;
 extern void isis_cli_init(void);
 #endif
 
+
 #define ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf)             \
        if (argv_find(argv, argc, "vrf", &idx_vrf)) {                          \
                vrf_name = argv[idx_vrf + 1]->arg;                             \