summaryrefslogtreecommitdiff
path: root/packages/frr/patches/0002-ospf6d-decimal-area-format-in-interface-command.patch
blob: 570ebd57817d2ad1171082d9fb41eb1258961fa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
From de842255f9a1930d7f927e94e7ea800bcfd1434c Mon Sep 17 00:00:00 2001
From: Patrick Ruddy <pruddy@vyatta.att-mail.com>
Date: Wed, 3 Oct 2018 18:22:34 +0100
Subject: [PATCH] ospf6d: decimal area format in interface command

The ospf6 "interface <blah> area <x>" command only allows the area to
be specified in the ipv4 address format, whereas the show run command
always shows it in the format in which the area was created. This causes
the frr-reload script to be unable to remove ospfv3 interfaces when the
area was created in decimal format. The solution is to allow both formats
to be configured as they can be for other area commands.

Signed-off-by: Duncan Eastoe <duncan.eastoe@att.com>
---
 ospf6d/ospf6_area.c | 16 ----------------
 ospf6d/ospf6_area.h | 15 +++++++++++++++
 ospf6d/ospf6_top.c  | 23 +++++++----------------
 3 files changed, 22 insertions(+), 32 deletions(-)

diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c
index 9fe077b54..713ce26ec 100644
--- a/ospf6d/ospf6_area.c
+++ b/ospf6d/ospf6_area.c
@@ -379,22 +379,6 @@ void ospf6_area_show(struct vty *vty, struct ospf6_area *oa)
 		vty_out(vty, "SPF has not been run\n");
 }
 
-
-#define OSPF6_CMD_AREA_GET(str, oa)                                            \
-	{                                                                      \
-		char *ep;                                                      \
-		uint32_t area_id = htonl(strtoul(str, &ep, 10));               \
-		if (*ep && inet_pton(AF_INET, str, &area_id) != 1) {           \
-			vty_out(vty, "Malformed Area-ID: %s\n", str);          \
-			return CMD_SUCCESS;                                    \
-		}                                                              \
-		int format = !*ep ? OSPF6_AREA_FMT_DECIMAL                     \
-				  : OSPF6_AREA_FMT_DOTTEDQUAD;                 \
-		oa = ospf6_area_lookup(area_id, ospf6);                        \
-		if (oa == NULL)                                                \
-			oa = ospf6_area_create(area_id, ospf6, format);        \
-	}
-
 DEFUN (area_range,
        area_range_cmd,
        "area <A.B.C.D|(0-4294967295)> range X:X::X:X/M [<advertise|not-advertise|cost (0-16777215)>]",
diff --git a/ospf6d/ospf6_area.h b/ospf6d/ospf6_area.h
index 5648b1dfe..7ce6717fc 100644
--- a/ospf6d/ospf6_area.h
+++ b/ospf6d/ospf6_area.h
@@ -117,6 +117,21 @@ struct ospf6_area {
 #define IS_AREA_TRANSIT(oa) (CHECK_FLAG ((oa)->flag, OSPF6_AREA_TRANSIT))
 #define IS_AREA_STUB(oa) (CHECK_FLAG ((oa)->flag, OSPF6_AREA_STUB))
 
+#define OSPF6_CMD_AREA_GET(str, oa)                                            \
+	{                                                                      \
+		char *ep;                                                      \
+		uint32_t area_id = htonl(strtoul(str, &ep, 10));               \
+		if (*ep && inet_pton(AF_INET, str, &area_id) != 1) {           \
+			vty_out(vty, "Malformed Area-ID: %s\n", str);          \
+			return CMD_SUCCESS;                                    \
+		}                                                              \
+		int format = !*ep ? OSPF6_AREA_FMT_DECIMAL                     \
+				  : OSPF6_AREA_FMT_DOTTEDQUAD;                 \
+		oa = ospf6_area_lookup(area_id, ospf6);                        \
+		if (oa == NULL)                                                \
+			oa = ospf6_area_create(area_id, ospf6, format);        \
+	}
+
 /* prototypes */
 extern int ospf6_area_cmp(void *va, void *vb);
 
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c
index dd672dd1c..f49ea9add 100644
--- a/ospf6d/ospf6_top.c
+++ b/ospf6d/ospf6_top.c
@@ -644,11 +644,12 @@ DEFUN (no_ospf6_distance_source,
 
 DEFUN (ospf6_interface_area,
        ospf6_interface_area_cmd,
-       "interface IFNAME area A.B.C.D",
+       "interface IFNAME area <A.B.C.D|(0-4294967295)>",
        "Enable routing on an IPv6 interface\n"
        IFNAME_STR
        "Specify the OSPF6 area ID\n"
        "OSPF6 area ID in IPv4 address notation\n"
+       "OSPF6 area ID in decimal notation\n"
       )
 {
 	VTY_DECLVAR_CONTEXT(ospf6, o);
@@ -657,7 +658,6 @@ DEFUN (ospf6_interface_area,
 	struct ospf6_area *oa;
 	struct ospf6_interface *oi;
 	struct interface *ifp;
-	uint32_t area_id;
 
 	/* find/create ospf6 interface */
 	ifp = if_get_by_name(argv[idx_ifname]->arg, VRF_DEFAULT);
@@ -671,15 +671,7 @@ DEFUN (ospf6_interface_area,
 	}
 
 	/* parse Area-ID */
-	if (inet_pton(AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) {
-		vty_out(vty, "Invalid Area-ID: %s\n", argv[idx_ipv4]->arg);
-		return CMD_SUCCESS;
-	}
-
-	/* find/create ospf6 area */
-	oa = ospf6_area_lookup(area_id, o);
-	if (oa == NULL)
-		oa = ospf6_area_create(area_id, o, OSPF6_AREA_FMT_DOTTEDQUAD);
+	OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, oa);
 
 	/* attach interface to area */
 	listnode_add(oa->if_list, oi); /* sort ?? */
@@ -703,12 +695,13 @@ DEFUN (ospf6_interface_area,
 
 DEFUN (no_ospf6_interface_area,
        no_ospf6_interface_area_cmd,
-       "no interface IFNAME area A.B.C.D",
+       "no interface IFNAME area <A.B.C.D|(0-4294967295)>",
        NO_STR
        "Disable routing on an IPv6 interface\n"
        IFNAME_STR
        "Specify the OSPF6 area ID\n"
        "OSPF6 area ID in IPv4 address notation\n"
+       "OSPF6 area ID in decimal notation\n"
        )
 {
 	int idx_ifname = 2;
@@ -731,10 +724,8 @@ DEFUN (no_ospf6_interface_area,
 	}
 
 	/* parse Area-ID */
-	if (inet_pton(AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) {
-		vty_out(vty, "Invalid Area-ID: %s\n", argv[idx_ipv4]->arg);
-		return CMD_SUCCESS;
-	}
+	if (inet_pton(AF_INET, argv[idx_ipv4]->arg, &area_id) != 1)
+		area_id = htonl(strtoul(argv[idx_ipv4]->arg, NULL, 10));
 
 	/* Verify Area */
 	if (oi->area == NULL) {
-- 
2.20.1