summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_area.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-05-26 01:49:30 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2021-06-08 21:38:09 +0300
commit42cabc552d50b3dbc658b88a27b75fd6a2f7bec5 (patch)
tree80f2fe12c51a8075e481376adc13eb37b90d7c54 /ospf6d/ospf6_area.c
parent6869bb921e7b79aeb2b145ce0b98bec8af8cbc84 (diff)
ospf6d: fix interface area configuration
Currently the interface area is configured from the router node using "interface IFNAME area ID" command. There are multiple problems with this command: - it is not in line with all other interface-related commands - other parameters are configured from the interface node using "ipv6 ospf6" prefix - it is not in line with OSPFv2 - area is configured from the interface node using "ip ospf area" command - most importantly, it doesn't work correctly when the interface is in a different VRF - instead of configuring the interface, it creates a new fake interface and configuring it instead To fix all the problems, this commit adds a new command to the interface configuration node - "ipv6 ospf6 area ID". The purpose of the command is completely the same, but it works correctly in a multi-VRF environment. The old command is preserved for the backward compatibility, but the warning is added that it is deprecated because it doesn't work correctly with VRFs. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'ospf6d/ospf6_area.c')
-rw-r--r--ospf6d/ospf6_area.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c
index 92934d3764..27ba030aed 100644
--- a/ospf6d/ospf6_area.c
+++ b/ospf6d/ospf6_area.c
@@ -50,20 +50,28 @@
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_AREA, "OSPF6 area");
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_PLISTNAME, "Prefix list name");
-/* Utility functions. */
-int str2area_id(const char *str, struct in_addr *area_id, int *area_id_fmt)
+int str2area_id(const char *str, uint32_t *area_id, int *area_id_fmt)
{
char *ep;
- area_id->s_addr = htonl(strtoul(str, &ep, 10));
- if (*ep && !inet_aton(str, area_id))
+ *area_id = htonl(strtoul(str, &ep, 10));
+ if (*ep && inet_pton(AF_INET, str, area_id) != 1)
return -1;
- *area_id_fmt = *ep ? OSPF6_AREA_FMT_DECIMAL : OSPF6_AREA_FMT_DOTTEDQUAD;
+ *area_id_fmt =
+ !*ep ? OSPF6_AREA_FMT_DECIMAL : OSPF6_AREA_FMT_DOTTEDQUAD;
return 0;
}
+void area_id2str(char *buf, int len, uint32_t area_id, int area_id_fmt)
+{
+ if (area_id_fmt == OSPF6_AREA_FMT_DECIMAL)
+ snprintf(buf, len, "%u", ntohl(area_id));
+ else
+ inet_ntop(AF_INET, &area_id, buf, len);
+}
+
int ospf6_area_cmp(void *va, void *vb)
{
struct ospf6_area *oa = (struct ospf6_area *)va;