X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=isisd%2Fisis_redist.c;h=dc23e8ea499d18bad1f5efdfd6a784a73c3cc32c;hb=f94ed830df98218447f00b97f856de811bfcc4a2;hp=ab7584ed3e04c5dc9a71ee50de70476593bf8c3c;hpb=5297438f5976b9a4460b07866413dfb990957af2;p=mirror_frr.git diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c index ab7584ed3..dc23e8ea4 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -32,7 +32,6 @@ #include "vty.h" #include "srcdest_table.h" -#include "isisd/dict.h" #include "isisd/isis_constants.h" #include "isisd/isis_common.h" #include "isisd/isis_flags.h" @@ -171,8 +170,7 @@ static void isis_redist_update_ext_reach(struct isis_area *area, int level, if (redist->map_name) { map_ret = - route_map_apply(redist->map, (struct prefix *)p, - RMAP_ISIS, &area_info); + route_map_apply(redist->map, p, RMAP_ISIS, &area_info); if (map_ret == RMAP_DENYMATCH) area_info.distance = 255; } @@ -339,12 +337,14 @@ static void isis_redist_routemap_set(struct isis_redist *redist, { if (redist->map_name) { XFREE(MTYPE_ISIS, redist->map_name); + route_map_counter_decrement(redist->map); redist->map = NULL; } if (routemap && strlen(routemap)) { redist->map_name = XSTRDUP(MTYPE_ISIS, routemap); redist->map = route_map_lookup_by_name(routemap); + route_map_counter_increment(redist->map); } } @@ -389,9 +389,8 @@ static void isis_redist_update_zebra_subscriptions(struct isis *isis) } } -static void isis_redist_set(struct isis_area *area, int level, int family, - int type, uint32_t metric, const char *routemap, - int originate_type) +void isis_redist_set(struct isis_area *area, int level, int family, int type, + uint32_t metric, const char *routemap, int originate_type) { int protocol = redist_protocol(family); struct isis_redist *redist = @@ -441,12 +440,12 @@ static void isis_redist_set(struct isis_area *area, int level, int family, } isis_redist_update_ext_reach(area, level, redist, p, - (struct prefix_ipv6 *)src_p, info); + (const struct prefix_ipv6 *)src_p, + info); } } -static void isis_redist_unset(struct isis_area *area, int level, int family, - int type) +void isis_redist_unset(struct isis_area *area, int level, int family, int type) { struct isis_redist *redist = get_redist_settings(area, family, type, level); @@ -504,8 +503,7 @@ void isis_redist_area_finish(struct isis_area *area) redist = &area->redist_settings[protocol][type] [level]; redist->redist = 0; - if (redist->map_name) - XFREE(MTYPE_ISIS, redist->map_name); + XFREE(MTYPE_ISIS, redist->map_name); } route_table_finish(area->ext_reach[protocol][level]); } @@ -513,21 +511,15 @@ void isis_redist_area_finish(struct isis_area *area) isis_redist_update_zebra_subscriptions(area->isis); } +#ifdef FABRICD DEFUN (isis_redistribute, isis_redistribute_cmd, "redistribute " PROTO_REDIST_STR -#ifndef FABRICD - " " -#endif - " []", + " [{metric (0-16777215)|route-map WORD}]", REDIST_STR "Redistribute IPv4 routes\n" "Redistribute IPv6 routes\n" PROTO_REDIST_HELP -#ifndef FABRICD - "Redistribute into level-1\n" - "Redistribute into level-2\n" -#endif "Metric for redistributed routes\n" "ISIS default metric\n" "Route map reference\n" @@ -535,8 +527,7 @@ DEFUN (isis_redistribute, { int idx_afi = 1; int idx_protocol = 2; - int idx_level = 3; - int idx_metric_rmap = fabricd ? 3 : 4; + int idx_metric_rmap = 1; VTY_DECLVAR_CONTEXT(isis_area, area); int family; int afi; @@ -557,34 +548,20 @@ DEFUN (isis_redistribute, if (type < 0) return CMD_WARNING_CONFIG_FAILED; - if (fabricd) - level = 2; - else if (!strcmp("level-1", argv[idx_level]->arg)) - level = 1; - else if (!strcmp("level-2", argv[idx_level]->arg)) - level = 2; - else - return CMD_WARNING_CONFIG_FAILED; + level = 2; if ((area->is_type & level) != level) { vty_out(vty, "Node is not a level-%d IS\n", level); return CMD_WARNING_CONFIG_FAILED; } - if (argc > idx_metric_rmap + 1) { - if (argv[idx_metric_rmap + 1]->arg[0] == '\0') - return CMD_WARNING_CONFIG_FAILED; - - if (strmatch(argv[idx_metric_rmap]->text, "metric")) { - char *endp; - metric = strtoul(argv[idx_metric_rmap + 1]->arg, &endp, - 10); + if (argv_find(argv, argc, "metric", &idx_metric_rmap)) { + metric = strtoul(argv[idx_metric_rmap + 1]->arg, NULL, 10); + } - if (*endp != '\0') - return CMD_WARNING_CONFIG_FAILED; - } else { - routemap = argv[idx_metric_rmap + 1]->arg; - } + idx_metric_rmap = 1; + if (argv_find(argv, argc, "route-map", &idx_metric_rmap)) { + routemap = argv[idx_metric_rmap + 1]->arg; } isis_redist_set(area, level, family, type, metric, routemap, 0); @@ -593,24 +570,15 @@ DEFUN (isis_redistribute, DEFUN (no_isis_redistribute, no_isis_redistribute_cmd, - "no redistribute " PROTO_REDIST_STR -#ifndef FABRICD - " " -#endif - , NO_STR + "no redistribute " PROTO_REDIST_STR, + NO_STR REDIST_STR "Redistribute IPv4 routes\n" "Redistribute IPv6 routes\n" - PROTO_REDIST_HELP -#ifndef FABRICD - "Redistribute into level-1\n" - "Redistribute into level-2\n" -#endif - ) + PROTO_REDIST_HELP) { int idx_afi = 2; int idx_protocol = 3; - int idx_level = 4; VTY_DECLVAR_CONTEXT(isis_area, area); int type; int level; @@ -629,10 +597,7 @@ DEFUN (no_isis_redistribute, if (type < 0) return CMD_WARNING_CONFIG_FAILED; - if (fabricd) - level = 2; - else - level = strmatch("level-1", argv[idx_level]->text) ? 1 : 2; + level = 2; isis_redist_unset(area, level, family, type); return 0; @@ -641,18 +606,11 @@ DEFUN (no_isis_redistribute, DEFUN (isis_default_originate, isis_default_originate_cmd, "default-information originate " -#ifndef FABRICD - " " -#endif - " [always] []", + " [always] [{metric (0-16777215)|route-map WORD}]", "Control distribution of default information\n" "Distribute a default route\n" "Distribute default route for IPv4\n" "Distribute default route for IPv6\n" -#ifndef FABRICD - "Distribute default route into level-1\n" - "Distribute default route into level-2\n" -#endif "Always advertise default route\n" "Metric for default route\n" "ISIS default metric\n" @@ -660,9 +618,8 @@ DEFUN (isis_default_originate, "Pointer to route-map entries\n") { int idx_afi = 2; - int idx_level = 3; int idx_always = fabricd ? 3 : 4; - int idx_metric_rmap = fabricd ? 3 : 4; + int idx_metric_rmap = 1; VTY_DECLVAR_CONTEXT(isis_area, area); int family; int originate_type = DEFAULT_ORIGINATE; @@ -674,10 +631,7 @@ DEFUN (isis_default_originate, if (family < 0) return CMD_WARNING_CONFIG_FAILED; - if (fabricd) - level = 2; - else - level = strmatch("level-1", argv[idx_level]->text) ? 1 : 2; + level = 2; if ((area->is_type & level) != level) { vty_out(vty, "Node is not a level-%d IS\n", level); @@ -689,12 +643,13 @@ DEFUN (isis_default_originate, idx_metric_rmap++; } - if (argc > idx_metric_rmap) { - if (strmatch(argv[idx_metric_rmap]->text, "metric")) - metric = strtoul(argv[idx_metric_rmap + 1]->arg, NULL, - 10); - else - routemap = argv[idx_metric_rmap + 1]->arg; + if (argv_find(argv, argc, "metric", &idx_metric_rmap)) { + metric = strtoul(argv[idx_metric_rmap + 1]->arg, NULL, 10); + } + + idx_metric_rmap = 1; + if (argv_find(argv, argc, "route-map", &idx_metric_rmap)) { + routemap = argv[idx_metric_rmap + 1]->arg; } if (family == AF_INET6 && originate_type != DEFAULT_ORIGINATE_ALWAYS) { @@ -711,23 +666,14 @@ DEFUN (isis_default_originate, DEFUN (no_isis_default_originate, no_isis_default_originate_cmd, - "no default-information originate " -#ifndef FABRICD - " " -#endif - , NO_STR + "no default-information originate ", + NO_STR "Control distribution of default information\n" "Distribute a default route\n" "Distribute default route for IPv4\n" - "Distribute default route for IPv6\n" -#ifndef FABRICD - "Distribute default route into level-1\n" - "Distribute default route into level-2\n" -#endif - ) + "Distribute default route for IPv6\n") { int idx_afi = 3; - int idx_level = 4; VTY_DECLVAR_CONTEXT(isis_area, area); int family; int level; @@ -736,18 +682,12 @@ DEFUN (no_isis_default_originate, if (family < 0) return CMD_WARNING_CONFIG_FAILED; - if (fabricd) - level = 2; - else if (strmatch("level-1", argv[idx_level]->text)) - level = 1; - else if (strmatch("level-2", argv[idx_level]->text)) - level = 2; - else - return CMD_WARNING_CONFIG_FAILED; + level = 2; isis_redist_unset(area, level, family, DEFAULT_ROUTE); return 0; } +#endif /* ifdef FABRICD */ int isis_redist_config_write(struct vty *vty, struct isis_area *area, int family) @@ -810,8 +750,11 @@ int isis_redist_config_write(struct vty *vty, struct isis_area *area, void isis_redist_init(void) { +#ifdef FABRICD install_element(ROUTER_NODE, &isis_redistribute_cmd); install_element(ROUTER_NODE, &no_isis_redistribute_cmd); + install_element(ROUTER_NODE, &isis_default_originate_cmd); install_element(ROUTER_NODE, &no_isis_default_originate_cmd); +#endif /* ifdef FABRICD */ }