diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2021-05-26 01:49:30 +0300 |
|---|---|---|
| committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-06-08 21:38:09 +0300 |
| commit | 42cabc552d50b3dbc658b88a27b75fd6a2f7bec5 (patch) | |
| tree | 80f2fe12c51a8075e481376adc13eb37b90d7c54 /ospf6d/ospf6_top.c | |
| parent | 6869bb921e7b79aeb2b145ce0b98bec8af8cbc84 (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_top.c')
| -rw-r--r-- | ospf6d/ospf6_top.c | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 33b5dd1960..97b3bc096b 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -410,6 +410,8 @@ static struct ospf6 *ospf6_create(const char *name) struct ospf6 *ospf6_instance_create(const char *name) { struct ospf6 *ospf6; + struct vrf *vrf; + struct interface *ifp; ospf6 = ospf6_create(name); if (DFLT_OSPF6_LOG_ADJACENCY_CHANGES) @@ -417,6 +419,13 @@ struct ospf6 *ospf6_instance_create(const char *name) if (ospf6->router_id == 0) ospf6_router_id_update(ospf6); ospf6_add(ospf6); + if (ospf6->vrf_id != VRF_UNKNOWN) { + vrf = vrf_lookup_by_id(ospf6->vrf_id); + FOR_ALL_INTERFACES (vrf, ifp) { + if (ifp->info) + ospf6_interface_start(ifp->info); + } + } if (ospf6->fd < 0) return ospf6; @@ -867,7 +876,7 @@ DEFUN (no_ospf6_distance_ospf6, return CMD_SUCCESS; } -DEFUN (ospf6_interface_area, +DEFUN_HIDDEN (ospf6_interface_area, ospf6_interface_area_cmd, "interface IFNAME area <A.B.C.D|(0-4294967295)>", "Enable routing on an IPv6 interface\n" @@ -885,6 +894,13 @@ DEFUN (ospf6_interface_area, struct interface *ifp; vrf_id_t vrf_id = VRF_DEFAULT; int ipv6_count = 0; + uint32_t area_id; + int format; + + vty_out(vty, + "This command is deprecated, because it is not VRF-aware.\n"); + vty_out(vty, + "Please, use \"ipv6 ospf6 area\" on an interface instead.\n"); if (ospf6->vrf_id != VRF_UNKNOWN) vrf_id = ospf6->vrf_id; @@ -917,8 +933,17 @@ DEFUN (ospf6_interface_area, return CMD_WARNING_CONFIG_FAILED; } - /* parse Area-ID */ - OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, oa, ospf6); + if (str2area_id(argv[idx_ipv4]->arg, &area_id, &format)) { + vty_out(vty, "Malformed Area-ID: %s\n", argv[idx_ipv4]->arg); + return CMD_WARNING_CONFIG_FAILED; + } + + oi->area_id = area_id; + oi->area_id_format = format; + + oa = ospf6_area_lookup(area_id, ospf6); + if (oa == NULL) + oa = ospf6_area_create(area_id, ospf6, format); /* attach interface to area */ listnode_add(oa->if_list, oi); /* sort ?? */ @@ -942,7 +967,7 @@ DEFUN (ospf6_interface_area, return CMD_SUCCESS; } -DEFUN (no_ospf6_interface_area, +DEFUN_HIDDEN (no_ospf6_interface_area, no_ospf6_interface_area_cmd, "no interface IFNAME area <A.B.C.D|(0-4294967295)>", NO_STR @@ -962,6 +987,11 @@ DEFUN (no_ospf6_interface_area, uint32_t area_id; vrf_id_t vrf_id = VRF_DEFAULT; + vty_out(vty, + "This command is deprecated, because it is not VRF-aware.\n"); + vty_out(vty, + "Please, use \"no ipv6 ospf6 area\" on an interface instead.\n"); + if (ospf6->vrf_id != VRF_UNKNOWN) vrf_id = ospf6->vrf_id; @@ -1008,6 +1038,9 @@ DEFUN (no_ospf6_interface_area, ospf6_abr_disable_area(oa); } + oi->area_id = 0; + oi->area_id_format = OSPF6_AREA_FMT_UNSET; + return CMD_SUCCESS; } @@ -1585,9 +1618,6 @@ static int ospf6_distance_config_write(struct vty *vty, struct ospf6 *ospf6) /* OSPF configuration write function. */ static int config_write_ospf6(struct vty *vty) { - struct listnode *j, *k; - struct ospf6_area *oa; - struct ospf6_interface *oi; struct ospf6 *ospf6; struct listnode *node, *nnode; @@ -1638,11 +1668,6 @@ static int config_write_ospf6(struct vty *vty) ospf6_distance_config_write(vty, ospf6); ospf6_distribute_config_write(vty, ospf6); - for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, j, oa)) { - for (ALL_LIST_ELEMENTS_RO(oa->if_list, k, oi)) - vty_out(vty, " interface %s area %s\n", - oi->interface->name, oa->name); - } vty_out(vty, "!\n"); } return 0; |
