ospf6d: add vty support for multiple vrfs

Co-authored-by: Kaushik Nath <kaushiknath.null@gmail.com>
Signed-off-by: harios_niral <hari@niralnetworks.com>
This commit is contained in:
harios_niral 2021-05-05 23:19:01 +03:00 committed by Igor Ryzhov
parent 4e8ccd9213
commit d48ef099db
8 changed files with 1273 additions and 705 deletions

View File

@ -851,34 +851,21 @@ DEFUN (no_area_export_list,
return CMD_SUCCESS;
}
DEFUN (show_ipv6_ospf6_spf_tree,
show_ipv6_ospf6_spf_tree_cmd,
"show ipv6 ospf6 spf tree [json]",
SHOW_STR
IP6_STR
OSPF6_STR
"Shortest Path First calculation\n"
"Show SPF tree\n"
JSON_STR)
static int ipv6_ospf6_spf_tree_common(struct vty *vty, struct ospf6 *ospf6,
bool uj)
{
struct listnode *node;
struct ospf6_area *oa;
struct prefix prefix;
struct ospf6_vertex *root;
struct ospf6_route *route;
struct prefix prefix;
struct ospf6 *ospf6;
json_object *json = NULL;
json_object *json_area = NULL;
json_object *json_head = NULL;
bool uj = use_json(argc, argv);
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
OSPF6_CMD_CHECK_RUNNING(ospf6);
if (uj)
json = json_object_new_object();
ospf6_linkstate_prefix(ospf6->router_id, htonl(0), &prefix);
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
if (uj) {
json_area = json_object_new_object();
@ -918,35 +905,47 @@ DEFUN (show_ipv6_ospf6_spf_tree,
return CMD_SUCCESS;
}
DEFUN (show_ipv6_ospf6_area_spf_tree,
show_ipv6_ospf6_area_spf_tree_cmd,
"show ipv6 ospf6 area A.B.C.D spf tree",
SHOW_STR
IP6_STR
OSPF6_STR
OSPF6_AREA_STR
OSPF6_AREA_ID_STR
"Shortest Path First calculation\n"
"Show SPF tree\n")
DEFUN(show_ipv6_ospf6_spf_tree, show_ipv6_ospf6_spf_tree_cmd,
"show ipv6 ospf6 [vrf <NAME|all>] spf tree [json]",
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"All VRFs\n"
"Shortest Path First calculation\n"
"Show SPF tree\n" JSON_STR)
{
int idx_ipv4 = 4;
uint32_t area_id;
struct listnode *node;
struct ospf6 *ospf6;
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
bool uj = use_json(argc, argv);
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
ipv6_ospf6_spf_tree_common(vty, ospf6, uj);
if (!all_vrf)
break;
}
}
return CMD_SUCCESS;
}
static int show_ospf6_area_spf_tree_common(struct vty *vty,
struct cmd_token **argv,
struct ospf6 *ospf6,
uint32_t area_id, int idx_ipv4)
{
struct ospf6_area *oa;
struct prefix prefix;
struct ospf6_vertex *root;
struct ospf6_route *route;
struct prefix prefix;
struct ospf6 *ospf6;
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
OSPF6_CMD_CHECK_RUNNING(ospf6);
ospf6_linkstate_prefix(ospf6->router_id, htonl(0), &prefix);
if (inet_pton(AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) {
vty_out(vty, "Malformed Area-ID: %s\n", argv[idx_ipv4]->arg);
return CMD_SUCCESS;
}
oa = ospf6_area_lookup(area_id, ospf6);
if (oa == NULL) {
vty_out(vty, "No such Area: %s\n", argv[idx_ipv4]->arg);
@ -965,41 +964,55 @@ DEFUN (show_ipv6_ospf6_area_spf_tree,
return CMD_SUCCESS;
}
DEFUN (show_ipv6_ospf6_simulate_spf_tree_root,
show_ipv6_ospf6_simulate_spf_tree_root_cmd,
"show ipv6 ospf6 simulate spf-tree A.B.C.D area A.B.C.D",
SHOW_STR
IP6_STR
OSPF6_STR
"Shortest Path First calculation\n"
"Show SPF tree\n"
"Specify root's router-id to calculate another router's SPF tree\n"
"OSPF6 area parameters\n"
OSPF6_AREA_ID_STR)
DEFUN(show_ipv6_ospf6_area_spf_tree, show_ipv6_ospf6_area_spf_tree_cmd,
"show ipv6 ospf6 [vrf <NAME|all>] area A.B.C.D spf tree",
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"All VRFs\n" OSPF6_AREA_STR OSPF6_AREA_ID_STR
"Shortest Path First calculation\n"
"Show SPF tree\n")
{
int idx_ipv4 = 5;
int idx_ipv4_2 = 7;
int idx_ipv4 = 4;
uint32_t area_id;
struct ospf6 *ospf6;
struct listnode *node;
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0)
idx_ipv4 += 2;
if (inet_pton(AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) {
vty_out(vty, "Malformed Area-ID: %s\n", argv[idx_ipv4]->arg);
return CMD_SUCCESS;
}
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
show_ospf6_area_spf_tree_common(vty, argv, ospf6,
area_id, idx_ipv4);
if (!all_vrf)
break;
}
}
return CMD_SUCCESS;
}
static int
show_ospf6_simulate_spf_tree_commen(struct vty *vty, struct cmd_token **argv,
struct ospf6 *ospf6, uint32_t router_id,
uint32_t area_id, struct prefix prefix,
int idx_ipv4, int idx_ipv4_2)
{
struct ospf6_area *oa;
struct ospf6_vertex *root;
struct ospf6_route *route;
struct prefix prefix;
uint32_t router_id;
struct ospf6_route_table *spf_table;
unsigned char tmp_debug_ospf6_spf = 0;
struct ospf6 *ospf6;
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
OSPF6_CMD_CHECK_RUNNING(ospf6);
inet_pton(AF_INET, argv[idx_ipv4]->arg, &router_id);
ospf6_linkstate_prefix(router_id, htonl(0), &prefix);
if (inet_pton(AF_INET, argv[idx_ipv4_2]->arg, &area_id) != 1) {
vty_out(vty, "Malformed Area-ID: %s\n", argv[idx_ipv4_2]->arg);
return CMD_SUCCESS;
}
oa = ospf6_area_lookup(area_id, ospf6);
if (oa == NULL) {
vty_out(vty, "No such Area: %s\n", argv[idx_ipv4_2]->arg);
@ -1029,6 +1042,54 @@ DEFUN (show_ipv6_ospf6_simulate_spf_tree_root,
return CMD_SUCCESS;
}
DEFUN(show_ipv6_ospf6_simulate_spf_tree_root,
show_ipv6_ospf6_simulate_spf_tree_root_cmd,
"show ipv6 ospf6 [vrf <NAME|all>] simulate spf-tree A.B.C.D area A.B.C.D",
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"All VRFs\n"
"Shortest Path First calculation\n"
"Show SPF tree\n"
"Specify root's router-id to calculate another router's SPF tree\n"
"OSPF6 area parameters\n" OSPF6_AREA_ID_STR)
{
int idx_ipv4 = 5;
int idx_ipv4_2 = 7;
uint32_t area_id;
struct prefix prefix;
uint32_t router_id;
struct ospf6 *ospf6;
struct listnode *node;
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0) {
idx_ipv4 += 2;
idx_ipv4_2 += 2;
}
inet_pton(AF_INET, argv[idx_ipv4]->arg, &router_id);
ospf6_linkstate_prefix(router_id, htonl(0), &prefix);
if (inet_pton(AF_INET, argv[idx_ipv4_2]->arg, &area_id) != 1) {
vty_out(vty, "Malformed Area-ID: %s\n", argv[idx_ipv4_2]->arg);
return CMD_SUCCESS;
}
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
show_ospf6_simulate_spf_tree_commen(
vty, argv, ospf6, router_id, area_id, prefix,
idx_ipv4, idx_ipv4_2);
if (!all_vrf)
break;
}
}
return CMD_SUCCESS;
}
DEFUN (ospf6_area_stub,
ospf6_area_stub_cmd,
"area <A.B.C.D|(0-4294967295)> stub",
@ -1158,8 +1219,9 @@ void ospf6_area_interface_delete(struct ospf6_interface *oi)
if (!om6->ospf6)
return;
for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6))
for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) {
for (ALL_LIST_ELEMENTS(ospf6->area_list, node, nnode, oa))
if (listnode_lookup(oa->if_list, oi))
listnode_delete(oa->if_list, oi);
}
}

View File

@ -41,6 +41,7 @@
#include "ospf6_spf.h"
#include "ospf6_top.h"
#include "ospf6d.h"
#include "ospf6_area.h"
#include "ospf6_interface.h"
#include "ospf6_neighbor.h"
@ -1397,7 +1398,7 @@ DEFUN (ospf6_redistribute,
struct ospf6_redist *red;
VTY_DECLVAR_CONTEXT(ospf6, ospf6);
OSPF6_CMD_CHECK_RUNNING(ospf6);
char *proto = argv[argc - 1]->text;
type = proto_redistnum(AFI_IP6, proto);
if (type < 0)
@ -1427,7 +1428,6 @@ DEFUN (ospf6_redistribute_routemap,
struct ospf6_redist *red;
VTY_DECLVAR_CONTEXT(ospf6, ospf6);
OSPF6_CMD_CHECK_RUNNING(ospf6);
char *proto = argv[idx_protocol]->text;
type = proto_redistnum(AFI_IP6, proto);
@ -1460,8 +1460,6 @@ DEFUN (no_ospf6_redistribute,
VTY_DECLVAR_CONTEXT(ospf6, ospf6);
OSPF6_CMD_CHECK_RUNNING(ospf6);
char *proto = argv[idx_protocol]->text;
type = proto_redistnum(AFI_IP6, proto);
if (type < 0)
@ -1639,8 +1637,6 @@ DEFPY (ospf6_default_route_originate,
int cur_originate = ospf6->default_originate;
OSPF6_CMD_CHECK_RUNNING(ospf6);
red = ospf6_redist_add(ospf6, DEFAULT_ROUTE, 0);
if (always != NULL)
@ -1696,8 +1692,6 @@ DEFPY (no_ospf6_default_information_originate,
VTY_DECLVAR_CONTEXT(ospf6, ospf6);
OSPF6_CMD_CHECK_RUNNING(ospf6);
red = ospf6_redist_lookup(ospf6, DEFAULT_ROUTE, 0);
if (!red)
return CMD_SUCCESS;
@ -2215,46 +2209,61 @@ static void ospf6_asbr_external_route_show(struct vty *vty,
forwarding);
}
DEFUN (show_ipv6_ospf6_redistribute,
show_ipv6_ospf6_redistribute_cmd,
"show ipv6 ospf6 redistribute [json]",
SHOW_STR
IP6_STR
OSPF6_STR
"redistributing External information\n"
JSON_STR)
DEFUN(show_ipv6_ospf6_redistribute, show_ipv6_ospf6_redistribute_cmd,
"show ipv6 ospf6 [vrf <NAME|all>] redistribute [json]",
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"All VRFs\n"
"redistributing External information\n" JSON_STR)
{
struct ospf6_route *route;
struct ospf6 *ospf6 = NULL;
json_object *json = NULL;
bool uj = use_json(argc, argv);
struct listnode *node;
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
json_object *json_array_routes = NULL;
json_object *json_array_redistribute = NULL;
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
OSPF6_CMD_CHECK_RUNNING(ospf6);
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (uj) {
json = json_object_new_object();
json_array_routes = json_object_new_array();
json_array_redistribute = json_object_new_array();
}
ospf6_redistribute_show_config(vty, ospf6, json_array_redistribute,
json, uj);
for (route = ospf6_route_head(ospf6->external_table); route;
route = ospf6_route_next(route)) {
ospf6_asbr_external_route_show(vty, route, json_array_routes,
uj);
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf
|| ((ospf6->name == NULL && vrf_name == NULL)
|| (ospf6->name && vrf_name
&& strcmp(ospf6->name, vrf_name) == 0))) {
ospf6_redistribute_show_config(
vty, ospf6, json_array_redistribute, json, uj);
for (route = ospf6_route_head(ospf6->external_table);
route; route = ospf6_route_next(route)) {
ospf6_asbr_external_route_show(
vty, route, json_array_routes, uj);
}
if (uj) {
json_object_object_add(json, "routes",
json_array_routes);
vty_out(vty, "%s\n",
json_object_to_json_string_ext(
json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
if (!all_vrf)
break;
}
}
if (uj) {
json_object_object_add(json, "routes", json_array_routes);
vty_out(vty, "%s\n",
json_object_to_json_string_ext(
json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
return CMD_SUCCESS;
}

View File

@ -1175,19 +1175,13 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp,
return 0;
}
/* show interface */
DEFUN(show_ipv6_ospf6_interface,
show_ipv6_ospf6_interface_ifname_cmd,
"show ipv6 ospf6 interface [IFNAME] [json]",
SHOW_STR
IP6_STR
OSPF6_STR
INTERFACE_STR
IFNAME_STR
JSON_STR)
static int show_ospf6_interface_common(struct vty *vty, vrf_id_t vrf_id,
int argc, struct cmd_token **argv,
int idx_ifname, int intf_idx,
int json_idx)
{
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
int idx_ifname = 4;
struct vrf *vrf = vrf_lookup_by_id(vrf_id);
struct interface *ifp;
json_object *json;
json_object *json_int;
@ -1195,9 +1189,8 @@ DEFUN(show_ipv6_ospf6_interface,
if (uj) {
json = json_object_new_object();
if (argc == 6) {
ifp = if_lookup_by_name(argv[idx_ifname]->arg,
VRF_DEFAULT);
if (argc == json_idx) {
ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
json_int = json_object_new_object();
if (ifp == NULL) {
json_object_string_add(json, "noSuchInterface",
@ -1224,9 +1217,8 @@ DEFUN(show_ipv6_ospf6_interface,
json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else {
if (argc == 5) {
ifp = if_lookup_by_name(argv[idx_ifname]->arg,
VRF_DEFAULT);
if (argc == intf_idx) {
ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
if (ifp == NULL) {
vty_out(vty, "No such Interface: %s\n",
argv[idx_ifname]->arg);
@ -1238,6 +1230,42 @@ DEFUN(show_ipv6_ospf6_interface,
ospf6_interface_show(vty, ifp, NULL, uj);
}
}
return CMD_SUCCESS;
}
/* show interface */
DEFUN(show_ipv6_ospf6_interface, show_ipv6_ospf6_interface_ifname_cmd,
"show ipv6 ospf6 [vrf <NAME|all>] interface [IFNAME] [json]",
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"All VRFs\n" INTERFACE_STR IFNAME_STR JSON_STR)
{
int idx_ifname = 4;
int intf_idx = 5;
int json_idx = 6;
struct listnode *node;
struct ospf6 *ospf6;
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0) {
idx_ifname += 2;
intf_idx += 2;
json_idx += 2;
}
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
show_ospf6_interface_common(vty, ospf6->vrf_id, argc,
argv, idx_ifname, intf_idx,
json_idx);
if (!all_vrf)
break;
}
}
return CMD_SUCCESS;
}
@ -1245,7 +1273,7 @@ DEFUN(show_ipv6_ospf6_interface,
static int ospf6_interface_show_traffic(struct vty *vty,
struct interface *intf_ifp,
int display_once, json_object *json,
bool use_json)
bool use_json, vrf_id_t vrf_id)
{
struct interface *ifp;
struct vrf *vrf = NULL;
@ -1255,7 +1283,7 @@ static int ospf6_interface_show_traffic(struct vty *vty,
if (intf_ifp)
vrf = vrf_lookup_by_id(intf_ifp->vrf_id);
else
vrf = vrf_lookup_by_id(VRF_DEFAULT);
vrf = vrf_lookup_by_id(vrf_id);
if (!display_once && !use_json) {
vty_out(vty, "\n");
@ -1356,17 +1384,9 @@ static int ospf6_interface_show_traffic(struct vty *vty,
return CMD_SUCCESS;
}
/* show interface */
DEFUN(show_ipv6_ospf6_interface_traffic,
show_ipv6_ospf6_interface_traffic_cmd,
"show ipv6 ospf6 interface traffic [IFNAME] [json]",
SHOW_STR
IP6_STR
OSPF6_STR
INTERFACE_STR
"Protocol Packet counters\n"
IFNAME_STR
JSON_STR)
static int ospf6_interface_show_traffic_common(struct vty *vty, int argc,
struct cmd_token **argv,
vrf_id_t vrf_id)
{
int idx_ifname = 0;
int display_once = 0;
@ -1380,7 +1400,7 @@ DEFUN(show_ipv6_ospf6_interface_traffic,
if (argv_find(argv, argc, "IFNAME", &idx_ifname)) {
intf_name = argv[idx_ifname]->arg;
ifp = if_lookup_by_name(intf_name, VRF_DEFAULT);
ifp = if_lookup_by_name(intf_name, vrf_id);
if (uj) {
if (ifp == NULL) {
json_object_string_add(json, "status",
@ -1420,7 +1440,7 @@ DEFUN(show_ipv6_ospf6_interface_traffic,
}
}
ospf6_interface_show_traffic(vty, ifp, display_once, json, uj);
ospf6_interface_show_traffic(vty, ifp, display_once, json, uj, vrf_id);
if (uj) {
vty_out(vty, "%s\n",
@ -1429,94 +1449,148 @@ DEFUN(show_ipv6_ospf6_interface_traffic,
json_object_free(json);
}
return CMD_SUCCESS;
}
/* show interface */
DEFUN(show_ipv6_ospf6_interface_traffic, show_ipv6_ospf6_interface_traffic_cmd,
"show ipv6 ospf6 [vrf <NAME|all>] interface traffic [IFNAME] [json]",
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"All VRFs\n" INTERFACE_STR
"Protocol Packet counters\n" IFNAME_STR JSON_STR)
{
struct ospf6 *ospf6;
struct listnode *node;
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
ospf6_interface_show_traffic_common(vty, argc, argv,
ospf6->vrf_id);
if (!all_vrf)
break;
}
}
return CMD_SUCCESS;
}
DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
show_ipv6_ospf6_interface_ifname_prefix_cmd,
"show ipv6 ospf6 interface IFNAME prefix\
DEFUN(show_ipv6_ospf6_interface_ifname_prefix,
show_ipv6_ospf6_interface_ifname_prefix_cmd,
"show ipv6 ospf6 [vrf <NAME|all>] interface IFNAME prefix\
[<\
detail\
|<X:X::X:X|X:X::X:X/M> [<match|detail>]\
>] [json]",
SHOW_STR
IP6_STR
OSPF6_STR
INTERFACE_STR
IFNAME_STR
"Display connected prefixes to advertise\n"
"Display details of the prefixes\n"
OSPF6_ROUTE_ADDRESS_STR
OSPF6_ROUTE_PREFIX_STR
OSPF6_ROUTE_MATCH_STR
"Display details of the prefixes\n"
JSON_STR)
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"All VRFs\n" INTERFACE_STR IFNAME_STR
"Display connected prefixes to advertise\n"
"Display details of the prefixes\n" OSPF6_ROUTE_ADDRESS_STR
OSPF6_ROUTE_PREFIX_STR OSPF6_ROUTE_MATCH_STR
"Display details of the prefixes\n" JSON_STR)
{
int idx_ifname = 4;
int idx_prefix = 6;
struct interface *ifp;
struct ospf6_interface *oi;
bool uj = use_json(argc, argv);
ifp = if_lookup_by_name(argv[idx_ifname]->arg, VRF_DEFAULT);
if (ifp == NULL) {
vty_out(vty, "No such Interface: %s\n", argv[idx_ifname]->arg);
return CMD_WARNING;
struct ospf6 *ospf6;
struct listnode *node;
struct interface *ifp;
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0) {
idx_ifname += 2;
idx_prefix += 2;
}
oi = ifp->info;
if (oi == NULL) {
vty_out(vty, "OSPFv3 is not enabled on %s\n",
argv[idx_ifname]->arg);
return CMD_WARNING;
}
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
ifp = if_lookup_by_name(argv[idx_ifname]->arg,
ospf6->vrf_id);
if (ifp == NULL) {
vty_out(vty, "No such Interface: %s\n",
argv[idx_ifname]->arg);
return CMD_WARNING;
}
if (CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE)) {
vty_out(vty, "Interface %s not attached to area\n",
argv[idx_ifname]->arg);
return CMD_WARNING;
}
oi = ifp->info;
if (oi == NULL
|| CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE)) {
vty_out(vty,
"Interface %s not attached to area\n",
argv[idx_ifname]->arg);
return CMD_WARNING;
}
ospf6_route_table_show(vty, idx_prefix, argc, argv, oi->route_connected,
uj);
ospf6_route_table_show(vty, idx_prefix, argc, argv,
oi->route_connected, uj);
if (!all_vrf)
break;
}
}
return CMD_SUCCESS;
}
DEFUN (show_ipv6_ospf6_interface_prefix,
show_ipv6_ospf6_interface_prefix_cmd,
"show ipv6 ospf6 interface prefix\
DEFUN(show_ipv6_ospf6_interface_prefix, show_ipv6_ospf6_interface_prefix_cmd,
"show ipv6 ospf6 [vrf <NAME|all>] interface prefix\
[<\
detail\
|<X:X::X:X|X:X::X:X/M> [<match|detail>]\
>] [json]",
SHOW_STR
IP6_STR
OSPF6_STR
INTERFACE_STR
"Display connected prefixes to advertise\n"
"Display details of the prefixes\n"
OSPF6_ROUTE_ADDRESS_STR
OSPF6_ROUTE_PREFIX_STR
OSPF6_ROUTE_MATCH_STR
"Display details of the prefixes\n"
JSON_STR)
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"All VRFs\n" INTERFACE_STR
"Display connected prefixes to advertise\n"
"Display details of the prefixes\n" OSPF6_ROUTE_ADDRESS_STR
OSPF6_ROUTE_PREFIX_STR OSPF6_ROUTE_MATCH_STR
"Display details of the prefixes\n" JSON_STR)
{
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct vrf *vrf = NULL;
int idx_prefix = 5;
struct ospf6_interface *oi;
struct interface *ifp;
bool uj = use_json(argc, argv);
struct listnode *node;
struct ospf6 *ospf6;
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
FOR_ALL_INTERFACES (vrf, ifp) {
oi = (struct ospf6_interface *)ifp->info;
if (oi == NULL || CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE))
continue;
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0)
idx_prefix += 2;
ospf6_route_table_show(vty, idx_prefix, argc, argv,
oi->route_connected, uj);
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
vrf = vrf_lookup_by_id(ospf6->vrf_id);
FOR_ALL_INTERFACES (vrf, ifp) {
oi = (struct ospf6_interface *)ifp->info;
if (oi == NULL
|| CHECK_FLAG(oi->flag,
OSPF6_INTERFACE_DISABLE))
continue;
ospf6_route_table_show(vty, idx_prefix, argc,
argv,
oi->route_connected, uj);
}
if (!all_vrf)
break;
}
}
return CMD_SUCCESS;
@ -2211,9 +2285,8 @@ DEFUN (no_ipv6_ospf6_network,
return CMD_SUCCESS;
}
static int config_write_ospf6_interface(struct vty *vty)
static int config_write_ospf6_interface(struct vty *vty, struct vrf *vrf)
{
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct ospf6_interface *oi;
struct interface *ifp;
@ -2222,7 +2295,11 @@ static int config_write_ospf6_interface(struct vty *vty)
if (oi == NULL)
continue;
vty_frame(vty, "interface %s\n", oi->interface->name);
if (vrf->vrf_id == VRF_DEFAULT)
vty_frame(vty, "interface %s\n", oi->interface->name);
else
vty_frame(vty, "interface %s vrf %s\n",
oi->interface->name, vrf->name);
if (ifp->desc)
vty_out(vty, " description %s\n", ifp->desc);
@ -2277,13 +2354,27 @@ static int config_write_ospf6_interface(struct vty *vty)
return 0;
}
static int config_write_ospf6_interface(struct vty *vty);
/* Configuration write function for ospfd. */
static int config_write_interface(struct vty *vty)
{
int write = 0;
struct vrf *vrf = NULL;
/* Display all VRF aware OSPF interface configuration */
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
write += config_write_ospf6_interface(vty, vrf);
}
return write;
}
static int config_write_ospf6_interface(struct vty *vty, struct vrf *vrf);
static struct cmd_node interface_node = {
.name = "interface",
.node = INTERFACE_NODE,
.parent_node = CONFIG_NODE,
.prompt = "%s(config-if)# ",
.config_write = config_write_ospf6_interface,
.config_write = config_write_interface,
};
static int ospf6_ifp_create(struct interface *ifp)

View File

@ -969,35 +969,24 @@ static void ospf6_neighbor_show_detail(struct vty *vty,
}
}
DEFUN (show_ipv6_ospf6_neighbor,
show_ipv6_ospf6_neighbor_cmd,
"show ipv6 ospf6 neighbor [<detail|drchoice>] [json]",
SHOW_STR
IP6_STR
OSPF6_STR
"Neighbor list\n"
"Display details\n"
"Display DR choices\n"
JSON_STR)
static void ospf6_neighbor_show_detail_common(struct vty *vty, int argc,
struct cmd_token **argv,
struct ospf6 *ospf6, int idx_type,
int detail_idx, int json_idx)
{
int idx_type = 4;
struct ospf6_neighbor *on;
struct ospf6_interface *oi;
struct ospf6_area *oa;
struct listnode *i, *j, *k;
struct ospf6 *ospf6;
json_object *json = NULL;
json_object *json_array = NULL;
bool uj = use_json(argc, argv);
void (*showfunc)(struct vty *, struct ospf6_neighbor *,
json_object *json, bool use_json);
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
OSPF6_CMD_CHECK_RUNNING(ospf6);
showfunc = ospf6_neighbor_show;
if ((uj && argc == 6) || (!uj && argc == 5)) {
if ((uj && argc == detail_idx) || (!uj && argc == json_idx)) {
if (!strncmp(argv[idx_type]->arg, "de", 2))
showfunc = ospf6_neighbor_show_detail;
else if (!strncmp(argv[idx_type]->arg, "dr", 2))
@ -1037,21 +1026,50 @@ DEFUN (show_ipv6_ospf6_neighbor,
json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
DEFUN(show_ipv6_ospf6_neighbor, show_ipv6_ospf6_neighbor_cmd,
"show ipv6 ospf6 [vrf <NAME|all>] neighbor [<detail|drchoice>] [json]",
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"All VRFs\n"
"Neighbor list\n"
"Display details\n"
"Display DR choices\n" JSON_STR)
{
int idx_type = 4;
int detail_idx = 5;
int json_idx = 6;
struct ospf6 *ospf6;
struct listnode *node;
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0) {
idx_type += 2;
detail_idx += 2;
json_idx += 2;
}
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
ospf6_neighbor_show_detail_common(vty, argc, argv,
ospf6, idx_type,
detail_idx, json_idx);
if (!all_vrf)
break;
}
}
return CMD_SUCCESS;
}
DEFUN (show_ipv6_ospf6_neighbor_one,
show_ipv6_ospf6_neighbor_one_cmd,
"show ipv6 ospf6 neighbor A.B.C.D [json]",
SHOW_STR
IP6_STR
OSPF6_STR
"Neighbor list\n"
"Specify Router-ID as IPv4 address notation\n"
JSON_STR)
static int ospf6_neighbor_show_common(struct vty *vty, int argc,
struct cmd_token **argv,
struct ospf6 *ospf6, int idx_ipv4)
{
int idx_ipv4 = 4;
struct ospf6_neighbor *on;
struct ospf6_interface *oi;
struct ospf6_area *oa;
@ -1059,12 +1077,9 @@ DEFUN (show_ipv6_ospf6_neighbor_one,
void (*showfunc)(struct vty *, struct ospf6_neighbor *,
json_object *json, bool use_json);
uint32_t router_id;
struct ospf6 *ospf6;
json_object *json = NULL;
bool uj = use_json(argc, argv);
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
OSPF6_CMD_CHECK_RUNNING(ospf6);
showfunc = ospf6_neighbor_show_detail;
if (uj)
json = json_object_new_object();
@ -1088,6 +1103,39 @@ DEFUN (show_ipv6_ospf6_neighbor_one,
json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
return CMD_SUCCESS;
}
DEFUN(show_ipv6_ospf6_neighbor_one, show_ipv6_ospf6_neighbor_one_cmd,
"show ipv6 ospf6 [vrf <NAME|all>] neighbor A.B.C.D [json]",
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"All VRFs\n"
"Neighbor list\n"
"Specify Router-ID as IPv4 address notation\n" JSON_STR)
{
int idx_ipv4 = 4;
struct ospf6 *ospf6;
struct listnode *node;
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0)
idx_ipv4 += 2;
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
ospf6_neighbor_show_common(vty, argc, argv, ospf6,
idx_ipv4);
if (!all_vrf)
break;
}
}
return CMD_SUCCESS;
}

View File

@ -539,17 +539,20 @@ void ospf6_router_id_update(struct ospf6 *ospf6)
}
/* start ospf6 */
DEFUN_NOSH (router_ospf6,
router_ospf6_cmd,
"router ospf6",
ROUTER_STR
OSPF6_STR)
DEFUN_NOSH(router_ospf6, router_ospf6_cmd, "router ospf6 [vrf NAME]",
ROUTER_STR OSPF6_STR VRF_CMD_HELP_STR)
{
struct ospf6 *ospf6;
const char *vrf_name = VRF_DEFAULT_NAME;
int idx_vrf = 0;
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
if (argv_find(argv, argc, "vrf", &idx_vrf)) {
vrf_name = argv[idx_vrf + 1]->arg;
}
ospf6 = ospf6_lookup_by_vrf_name(vrf_name);
if (ospf6 == NULL)
ospf6 = ospf6_instance_create(VRF_DEFAULT_NAME);
ospf6 = ospf6_instance_create(vrf_name);
/* set current ospf point. */
VTY_PUSH_CONTEXT(OSPF6_NODE, ospf6);
@ -558,16 +561,18 @@ DEFUN_NOSH (router_ospf6,
}
/* stop ospf6 */
DEFUN (no_router_ospf6,
no_router_ospf6_cmd,
"no router ospf6",
NO_STR
ROUTER_STR
OSPF6_STR)
DEFUN(no_router_ospf6, no_router_ospf6_cmd, "no router ospf6 [vrf NAME]",
NO_STR ROUTER_STR OSPF6_STR VRF_CMD_HELP_STR)
{
struct ospf6 *ospf6;
const char *vrf_name = VRF_DEFAULT_NAME;
int idx_vrf = 0;
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
if (argv_find(argv, argc, "vrf", &idx_vrf)) {
vrf_name = argv[idx_vrf + 1]->arg;
}
ospf6 = ospf6_lookup_by_vrf_name(vrf_name);
if (ospf6 == NULL)
vty_out(vty, "OSPFv3 is not configured\n");
else {
@ -838,16 +843,19 @@ DEFUN (ospf6_interface_area,
"OSPF6 area ID in decimal notation\n"
)
{
VTY_DECLVAR_CONTEXT(ospf6, ospf6);
int idx_ifname = 1;
int idx_ipv4 = 3;
struct ospf6_area *oa;
struct ospf6_interface *oi;
struct interface *ifp;
vrf_id_t vrf_id = VRF_DEFAULT;
VTY_DECLVAR_CONTEXT(ospf6, ospf6);
if (ospf6->vrf_id != VRF_UNKNOWN)
vrf_id = ospf6->vrf_id;
/* find/create ospf6 interface */
ifp = if_get_by_name(argv[idx_ifname]->arg, VRF_DEFAULT);
ifp = if_get_by_name(argv[idx_ifname]->arg, vrf_id);
oi = (struct ospf6_interface *)ifp->info;
if (oi == NULL)
oi = ospf6_interface_create(ifp);
@ -891,14 +899,21 @@ DEFUN (no_ospf6_interface_area,
"OSPF6 area ID in decimal notation\n"
)
{
VTY_DECLVAR_CONTEXT(ospf6, ospf6);
int idx_ifname = 2;
int idx_ipv4 = 4;
struct ospf6_interface *oi;
struct ospf6_area *oa;
struct interface *ifp;
uint32_t area_id;
vrf_id_t vrf_id = VRF_DEFAULT;
if (ospf6->vrf_id != VRF_UNKNOWN)
vrf_id = ospf6->vrf_id;
/* find/create ospf6 interface */
ifp = if_get_by_name(argv[idx_ifname]->arg, vrf_id);
ifp = if_lookup_by_name(argv[idx_ifname]->arg, VRF_DEFAULT);
if (ifp == NULL) {
vty_out(vty, "No such interface %s\n", argv[idx_ifname]->arg);
return CMD_SUCCESS;
@ -1297,124 +1312,180 @@ DEFUN(show_ipv6_ospf6_vrfs, show_ipv6_ospf6_vrfs_cmd,
}
/* show top level structures */
DEFUN(show_ipv6_ospf6,
show_ipv6_ospf6_cmd,
"show ipv6 ospf6 [json]",
SHOW_STR
IP6_STR
OSPF6_STR
JSON_STR)
DEFUN(show_ipv6_ospf6, show_ipv6_ospf6_cmd,
"show ipv6 ospf6 [vrf <NAME|all>] [json]",
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR "All VRFs\n" JSON_STR)
{
struct ospf6 *ospf6;
struct listnode *node;
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
bool uj = use_json(argc, argv);
json_object *json = NULL;
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
OSPF6_CMD_CHECK_RUNNING(ospf6);
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (uj)
json = json_object_new_object();
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
if (uj)
json = json_object_new_object();
ospf6_show(vty, ospf6, json, uj);
ospf6_show(vty, ospf6, json, uj);
if (!all_vrf)
break;
}
}
if (uj)
json_object_free(json);
return CMD_SUCCESS;
}
DEFUN (show_ipv6_ospf6_route,
show_ipv6_ospf6_route_cmd,
"show ipv6 ospf6 route [<intra-area|inter-area|external-1|external-2|X:X::X:X|X:X::X:X/M|detail|summary>] [json]",
SHOW_STR
IP6_STR
OSPF6_STR
ROUTE_STR
"Display Intra-Area routes\n"
"Display Inter-Area routes\n"
"Display Type-1 External routes\n"
"Display Type-2 External routes\n"
"Specify IPv6 address\n"
"Specify IPv6 prefix\n"
"Detailed information\n"
"Summary of route table\n"
JSON_STR)
DEFUN(show_ipv6_ospf6_route, show_ipv6_ospf6_route_cmd,
"show ipv6 ospf6 [vrf <NAME|all>] route [<intra-area|inter-area|external-1|external-2|X:X::X:X|X:X::X:X/M|detail|summary>] [json]",
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"All VRFs\n" ROUTE_STR
"Display Intra-Area routes\n"
"Display Inter-Area routes\n"
"Display Type-1 External routes\n"
"Display Type-2 External routes\n"
"Specify IPv6 address\n"
"Specify IPv6 prefix\n"
"Detailed information\n"
"Summary of route table\n" JSON_STR)
{
struct ospf6 *ospf6;
struct listnode *node;
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
int idx_arg_start = 4;
bool uj = use_json(argc, argv);
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
OSPF6_CMD_CHECK_RUNNING(ospf6);
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0)
idx_arg_start += 2;
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
ospf6_route_table_show(vty, idx_arg_start, argc, argv,
ospf6->route_table, uj);
if (!all_vrf)
break;
}
}
ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table, uj);
return CMD_SUCCESS;
}
DEFUN (show_ipv6_ospf6_route_match,
show_ipv6_ospf6_route_match_cmd,
"show ipv6 ospf6 route X:X::X:X/M <match|longer> [json]",
SHOW_STR
IP6_STR
OSPF6_STR
ROUTE_STR
"Specify IPv6 prefix\n"
"Display routes which match the specified route\n"
"Display routes longer than the specified route\n"
JSON_STR)
DEFUN(show_ipv6_ospf6_route_match, show_ipv6_ospf6_route_match_cmd,
"show ipv6 ospf6 [vrf <NAME|all>] route X:X::X:X/M <match|longer> [json]",
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"All VRFs\n" ROUTE_STR
"Specify IPv6 prefix\n"
"Display routes which match the specified route\n"
"Display routes longer than the specified route\n" JSON_STR)
{
struct ospf6 *ospf6;
struct listnode *node;
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
int idx_start_arg = 4;
bool uj = use_json(argc, argv);
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
OSPF6_CMD_CHECK_RUNNING(ospf6);
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0)
idx_start_arg += 2;
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
ospf6_route_table_show(vty, idx_start_arg, argc, argv,
ospf6->route_table, uj);
if (!all_vrf)
break;
}
}
ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table, uj);
return CMD_SUCCESS;
}
DEFUN (show_ipv6_ospf6_route_match_detail,
show_ipv6_ospf6_route_match_detail_cmd,
"show ipv6 ospf6 route X:X::X:X/M match detail [json]",
SHOW_STR
IP6_STR
OSPF6_STR
ROUTE_STR
"Specify IPv6 prefix\n"
"Display routes which match the specified route\n"
"Detailed information\n"
JSON_STR)
DEFUN(show_ipv6_ospf6_route_match_detail,
show_ipv6_ospf6_route_match_detail_cmd,
"show ipv6 ospf6 [vrf <NAME|all>] route X:X::X:X/M match detail [json]",
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"All VRFs\n" ROUTE_STR
"Specify IPv6 prefix\n"
"Display routes which match the specified route\n"
"Detailed information\n" JSON_STR)
{
struct ospf6 *ospf6;
struct listnode *node;
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
int idx_start_arg = 4;
bool uj = use_json(argc, argv);
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
OSPF6_CMD_CHECK_RUNNING(ospf6);
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0)
idx_start_arg += 2;
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
ospf6_route_table_show(vty, idx_start_arg, argc, argv,
ospf6->route_table, uj);
if (!all_vrf)
break;
}
}
ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table, uj);
return CMD_SUCCESS;
}
DEFUN (show_ipv6_ospf6_route_type_detail,
show_ipv6_ospf6_route_type_detail_cmd,
"show ipv6 ospf6 route <intra-area|inter-area|external-1|external-2> detail [json]",
SHOW_STR
IP6_STR
OSPF6_STR
ROUTE_STR
"Display Intra-Area routes\n"
"Display Inter-Area routes\n"
"Display Type-1 External routes\n"
"Display Type-2 External routes\n"
"Detailed information\n"
JSON_STR)
DEFUN(show_ipv6_ospf6_route_type_detail, show_ipv6_ospf6_route_type_detail_cmd,
"show ipv6 ospf6 [vrf <NAME|all>] route <intra-area|inter-area|external-1|external-2> detail [json]",
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"All VRFs\n" ROUTE_STR
"Display Intra-Area routes\n"
"Display Inter-Area routes\n"
"Display Type-1 External routes\n"
"Display Type-2 External routes\n"
"Detailed information\n" JSON_STR)
{
struct ospf6 *ospf6;
struct listnode *node;
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
int idx_start_arg = 4;
bool uj = use_json(argc, argv);
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
OSPF6_CMD_CHECK_RUNNING(ospf6);
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0)
idx_start_arg += 2;
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
ospf6_route_table_show(vty, idx_start_arg, argc, argv,
ospf6->route_table, uj);
if (!all_vrf)
break;
}
}
ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table, uj);
return CMD_SUCCESS;
}
@ -1471,7 +1542,11 @@ static int config_write_ospf6(struct vty *vty)
return CMD_SUCCESS;
for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) {
vty_out(vty, "router ospf6\n");
if (ospf6->name && strcmp(ospf6->name, VRF_DEFAULT_NAME))
vty_out(vty, "router ospf6 vrf %s\n", ospf6->name);
else
vty_out(vty, "router ospf6\n");
if (ospf6->router_id_static != 0)
vty_out(vty, " ospf6 router-id %pI4\n",
&ospf6->router_id_static);

File diff suppressed because it is too large Load Diff

View File

@ -89,13 +89,21 @@ extern struct thread_master *master;
#define OSPF6_ROUTER_ID_STR "Specify Router-ID\n"
#define OSPF6_LS_ID_STR "Specify Link State ID\n"
#define OSPF6_CMD_CHECK_RUNNING(ospf6) \
if (ospf6 == NULL) { \
#define OSPF6_CMD_CHECK_RUNNING() \
if (om6->ospf6 == NULL) { \
vty_out(vty, "OSPFv3 is not running\n"); \
return CMD_SUCCESS; \
}
#define IS_OSPF6_ASBR(O) ((O)->flag & OSPF6_FLAG_ASBR)
#define OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf) \
if (argv_find(argv, argc, "vrf", &idx_vrf)) { \
vrf_name = argv[idx_vrf + 1]->arg; \
all_vrf = strmatch(vrf_name, "all"); \
} else { \
vrf_name = VRF_DEFAULT_NAME; \
}
extern struct zebra_privs_t ospf6d_privs;
/* Function Prototypes */

View File

@ -1976,8 +1976,8 @@ DEFUNSH(VTYSH_BABELD, router_babel, router_babel_cmd, "router babel",
#endif /* HAVE_BABELD */
#ifdef HAVE_OSPF6D
DEFUNSH(VTYSH_OSPF6D, router_ospf6, router_ospf6_cmd, "router ospf6",
ROUTER_STR OSPF6_STR)
DEFUNSH(VTYSH_OSPF6D, router_ospf6, router_ospf6_cmd, "router ospf6 [vrf NAME]",
ROUTER_STR OSPF6_STR VRF_CMD_HELP_STR)
{
vty->node = OSPF6_NODE;
return CMD_SUCCESS;