summaryrefslogtreecommitdiffstats
path: root/ospfd
diff options
context:
space:
mode:
authorChirag Shah <chirag@cumulusnetworks.com>2017-10-07 22:26:13 +0200
committerChirag Shah <chirag@cumulusnetworks.com>2017-10-16 19:02:05 +0200
commit7ef56a7321d475055e7405ed0c61f66676c42b46 (patch)
treee8d052c6da0a00c5dfc26ffe15fb5fbc00892f70 /ospfd
parentMerge pull request #1313 from LabNConsulting/working/master/patch-set/block-n... (diff)
downloadfrr-7ef56a7321d475055e7405ed0c61f66676c42b46.tar.xz
frr-7ef56a7321d475055e7405ed0c61f66676c42b46.zip
ospfd: fix ospf nssa command
-Fix ordering of nssa command with translate options and no-summary option. Just like ospf stub no-summary keep the order order of nssa no-summary. - Fix NSSA options. - Avoid displaying translate-candiate (default) option in running-config. cumulus(config-router)# area 2.2.2.2 nssa <cr> no-summary Do not inject inter-area routes into nssa translate-always Configure NSSA-ABR to always translate translate-candidate Configure NSSA-ABR for translate election (default) translate-never Configure NSSA-ABR to never translate Running-config output: router ospf area 2.2.2.2 nssa translate-always area 2.2.2.2 nssa no-summary Ticket:CM-8312 Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ospf_vty.c113
-rw-r--r--ospfd/ospfd.c44
-rw-r--r--ospfd/ospfd.h4
3 files changed, 111 insertions, 50 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index f53efa435..70e0da115 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -1470,7 +1470,8 @@ DEFUN (no_ospf_area_stub_no_summary,
}
static int ospf_area_nssa_cmd_handler(struct vty *vty, int argc,
- struct cmd_token **argv, int nosum)
+ struct cmd_token **argv, int cfg_nosum,
+ int nosum)
{
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
struct in_addr area_id;
@@ -1502,30 +1503,18 @@ static int ospf_area_nssa_cmd_handler(struct vty *vty, int argc,
OSPF_NSSA_ROLE_CANDIDATE);
}
- if (nosum)
- ospf_area_no_summary_set(ospf, area_id);
- else
- ospf_area_no_summary_unset(ospf, area_id);
+ if (cfg_nosum) {
+ if (nosum)
+ ospf_area_no_summary_set(ospf, area_id);
+ else
+ ospf_area_no_summary_unset(ospf, area_id);
+ }
ospf_schedule_abr_task(ospf);
return CMD_SUCCESS;
}
-DEFUN (ospf_area_nssa_translate_no_summary,
- ospf_area_nssa_translate_no_summary_cmd,
- "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
- "OSPF area parameters\n"
- "OSPF area ID in IP address format\n"
- "OSPF area ID as a decimal value\n"
- "Configure OSPF area as nssa\n"
- "Configure NSSA-ABR for translate election (default)\n"
- "Configure NSSA-ABR to never translate\n"
- "Configure NSSA-ABR to always translate\n"
- "Do not inject inter-area routes into nssa\n")
-{
- return ospf_area_nssa_cmd_handler(vty, argc, argv, 1);
-}
DEFUN (ospf_area_nssa_translate,
ospf_area_nssa_translate_cmd,
@@ -1538,7 +1527,7 @@ DEFUN (ospf_area_nssa_translate,
"Configure NSSA-ABR to never translate\n"
"Configure NSSA-ABR to always translate\n")
{
- return ospf_area_nssa_cmd_handler(vty, argc, argv, 0);
+ return ospf_area_nssa_cmd_handler(vty, argc, argv, 0, 0);
}
DEFUN (ospf_area_nssa,
@@ -1549,7 +1538,7 @@ DEFUN (ospf_area_nssa,
"OSPF area ID as a decimal value\n"
"Configure OSPF area as nssa\n")
{
- return ospf_area_nssa_cmd_handler(vty, argc, argv, 0);
+ return ospf_area_nssa_cmd_handler(vty, argc, argv, 1, 0);
}
DEFUN (ospf_area_nssa_no_summary,
@@ -1561,12 +1550,54 @@ DEFUN (ospf_area_nssa_no_summary,
"Configure OSPF area as nssa\n"
"Do not inject inter-area routes into nssa\n")
{
- return ospf_area_nssa_cmd_handler(vty, argc, argv, 1);
+ int idx_ipv4_number = 1;
+ struct in_addr area_id;
+ int format;
+
+ VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
+ VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id, format,
+ argv[idx_ipv4_number]->arg);
+
+ ospf_area_display_format_set(ospf, ospf_area_get(ospf, area_id),
+ format);
+ ospf_area_nssa_no_summary_set(ospf, area_id);
+
+ ospf_schedule_abr_task(ospf);
+
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_ospf_area_nssa_no_summary,
+ no_ospf_area_nssa_no_summary_cmd,
+ "no area <A.B.C.D|(0-4294967295)> nssa no-summary",
+ NO_STR
+ "OSPF area parameters\n"
+ "OSPF area ID in IP address format\n"
+ "OSPF area ID as a decimal value\n"
+ "Configure OSPF area as nssa\n"
+ "Do not inject inter-area routes into nssa\n")
+{
+ int idx_ipv4_number = 2;
+ struct in_addr area_id;
+ int format;
+
+ VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
+
+ VTY_GET_OSPF_AREA_ID_NO_BB("nssa", area_id, format,
+ argv[idx_ipv4_number]->arg);
+
+ ospf_area_display_format_set(ospf, ospf_area_get(ospf, area_id),
+ format);
+ ospf_area_no_summary_unset(ospf, area_id);
+
+ ospf_schedule_abr_task(ospf);
+
+ return CMD_SUCCESS;
}
DEFUN (no_ospf_area_nssa,
no_ospf_area_nssa_cmd,
- "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
+ "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always>]",
NO_STR
"OSPF area parameters\n"
"OSPF area ID in IP address format\n"
@@ -1574,8 +1605,7 @@ DEFUN (no_ospf_area_nssa,
"Configure OSPF area as nssa\n"
"Configure NSSA-ABR for translate election (default)\n"
"Configure NSSA-ABR to never translate\n"
- "Configure NSSA-ABR to always translate\n"
- "Do not inject inter-area routes into nssa\n")
+ "Configure NSSA-ABR to always translate\n")
{
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
@@ -1585,8 +1615,7 @@ DEFUN (no_ospf_area_nssa,
VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id, format,
argv[idx_ipv4_number]->arg);
- ospf_area_nssa_unset(ospf, area_id);
- ospf_area_no_summary_unset(ospf, area_id);
+ ospf_area_nssa_unset(ospf, area_id, argc);
ospf_schedule_abr_task(ospf);
@@ -8985,28 +9014,30 @@ static int config_write_ospf_area(struct vty *vty, struct ospf *ospf)
if ((area->external_routing == OSPF_AREA_STUB)
|| (area->external_routing == OSPF_AREA_NSSA)) {
- if (area->external_routing == OSPF_AREA_STUB)
+ if (area->external_routing == OSPF_AREA_STUB) {
vty_out(vty, " area %s stub", buf);
- else if (area->external_routing == OSPF_AREA_NSSA) {
- vty_out(vty, " area %s nssa", buf);
+ if (area->no_summary)
+ vty_out(vty, " no-summary\n");
+ vty_out(vty, "\n");
+ } else if (area->external_routing == OSPF_AREA_NSSA) {
switch (area->NSSATranslatorRole) {
case OSPF_NSSA_ROLE_NEVER:
- vty_out(vty, " translate-never");
+ vty_out(vty,
+ " area %s nssa translate-never\n",
+ buf);
break;
case OSPF_NSSA_ROLE_ALWAYS:
- vty_out(vty, " translate-always");
+ vty_out(vty,
+ " area %s nssa translate-always\n",
+ buf);
break;
- case OSPF_NSSA_ROLE_CANDIDATE:
- default:
- vty_out(vty, " translate-candidate");
}
+ if (area->no_summary)
+ vty_out(vty,
+ " area %s nssa no-summary\n",
+ buf);
}
- if (area->no_summary)
- vty_out(vty, " no-summary");
-
- vty_out(vty, "\n");
-
if (area->default_cost != 1)
vty_out(vty, " area %s default-cost %d\n", buf,
area->default_cost);
@@ -9721,9 +9752,9 @@ void ospf_vty_init(void)
/* "area nssa" commands. */
install_element(OSPF_NODE, &ospf_area_nssa_cmd);
- install_element(OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
install_element(OSPF_NODE, &ospf_area_nssa_translate_cmd);
install_element(OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
+ install_element(OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
install_element(OSPF_NODE, &no_ospf_area_nssa_cmd);
install_element(OSPF_NODE, &ospf_area_default_cost_cmd);
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index 9e1cf8116..8ee32289c 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -1493,7 +1493,7 @@ int ospf_area_no_summary_unset(struct ospf *ospf, struct in_addr area_id)
return 1;
}
-int ospf_area_nssa_set(struct ospf *ospf, struct in_addr area_id)
+int ospf_area_nssa_no_summary_set(struct ospf *ospf, struct in_addr area_id)
{
struct ospf_area *area;
@@ -1504,18 +1504,37 @@ int ospf_area_nssa_set(struct ospf *ospf, struct in_addr area_id)
if (area->external_routing != OSPF_AREA_NSSA) {
ospf_area_type_set(area, OSPF_AREA_NSSA);
ospf->anyNSSA++;
+ area->NSSATranslatorRole = OSPF_NSSA_ROLE_CANDIDATE;
}
- /* set NSSA area defaults */
- area->no_summary = 0;
- area->NSSATranslatorRole = OSPF_NSSA_ROLE_CANDIDATE;
- area->NSSATranslatorState = OSPF_NSSA_TRANSLATE_DISABLED;
- area->NSSATranslatorStabilityInterval = OSPF_NSSA_TRANS_STABLE_DEFAULT;
+ ospf_area_no_summary_set(ospf, area_id);
return 1;
}
-int ospf_area_nssa_unset(struct ospf *ospf, struct in_addr area_id)
+int ospf_area_nssa_set(struct ospf *ospf, struct in_addr area_id)
+{
+ struct ospf_area *area;
+
+ area = ospf_area_get(ospf, area_id);
+ if (ospf_area_vlink_count(ospf, area))
+ return 0;
+
+ if (area->external_routing != OSPF_AREA_NSSA) {
+ ospf_area_type_set(area, OSPF_AREA_NSSA);
+ ospf->anyNSSA++;
+
+ /* set NSSA area defaults */
+ area->no_summary = 0;
+ area->NSSATranslatorRole = OSPF_NSSA_ROLE_CANDIDATE;
+ area->NSSATranslatorState = OSPF_NSSA_TRANSLATE_DISABLED;
+ area->NSSATranslatorStabilityInterval =
+ OSPF_NSSA_TRANS_STABLE_DEFAULT;
+ }
+ return 1;
+}
+
+int ospf_area_nssa_unset(struct ospf *ospf, struct in_addr area_id, int argc)
{
struct ospf_area *area;
@@ -1523,9 +1542,18 @@ int ospf_area_nssa_unset(struct ospf *ospf, struct in_addr area_id)
if (area == NULL)
return 0;
- if (area->external_routing == OSPF_AREA_NSSA) {
+ /* argc < 5 -> 'no area x nssa' */
+ if (argc < 5 && area->external_routing == OSPF_AREA_NSSA) {
ospf->anyNSSA--;
+ /* set NSSA area defaults */
+ area->no_summary = 0;
+ area->NSSATranslatorRole = OSPF_NSSA_ROLE_CANDIDATE;
+ area->NSSATranslatorState = OSPF_NSSA_TRANSLATE_DISABLED;
+ area->NSSATranslatorStabilityInterval =
+ OSPF_NSSA_TRANS_STABLE_DEFAULT;
ospf_area_type_set(area, OSPF_AREA_DEFAULT);
+ } else {
+ area->NSSATranslatorRole = OSPF_NSSA_ROLE_CANDIDATE;
}
ospf_area_check_free(ospf, area_id);
diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h
index 01147c200..4b0ebc8eb 100644
--- a/ospfd/ospfd.h
+++ b/ospfd/ospfd.h
@@ -524,7 +524,7 @@ extern int ospf_area_stub_unset(struct ospf *, struct in_addr);
extern int ospf_area_no_summary_set(struct ospf *, struct in_addr);
extern int ospf_area_no_summary_unset(struct ospf *, struct in_addr);
extern int ospf_area_nssa_set(struct ospf *, struct in_addr);
-extern int ospf_area_nssa_unset(struct ospf *, struct in_addr);
+extern int ospf_area_nssa_unset(struct ospf *, struct in_addr, int);
extern int ospf_area_nssa_translator_role_set(struct ospf *, struct in_addr,
int);
extern int ospf_area_export_list_set(struct ospf *, struct ospf_area *,
@@ -574,4 +574,6 @@ extern void ospf_vrf_terminate(void);
extern void ospf_vrf_link(struct ospf *ospf, struct vrf *vrf);
extern void ospf_vrf_unlink(struct ospf *ospf, struct vrf *vrf);
const char *ospf_vrf_id_to_name(vrf_id_t vrf_id);
+int ospf_area_nssa_no_summary_set(struct ospf *, struct in_addr);
+
#endif /* _ZEBRA_OSPFD_H */