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; return CMD_SUCCESS;
} }
DEFUN (show_ipv6_ospf6_spf_tree, static int ipv6_ospf6_spf_tree_common(struct vty *vty, struct ospf6 *ospf6,
show_ipv6_ospf6_spf_tree_cmd, bool uj)
"show ipv6 ospf6 spf tree [json]",
SHOW_STR
IP6_STR
OSPF6_STR
"Shortest Path First calculation\n"
"Show SPF tree\n"
JSON_STR)
{ {
struct listnode *node; struct listnode *node;
struct ospf6_area *oa; struct ospf6_area *oa;
struct prefix prefix;
struct ospf6_vertex *root; struct ospf6_vertex *root;
struct ospf6_route *route; struct ospf6_route *route;
struct prefix prefix;
struct ospf6 *ospf6;
json_object *json = NULL; json_object *json = NULL;
json_object *json_area = NULL; json_object *json_area = NULL;
json_object *json_head = 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) if (uj)
json = json_object_new_object(); json = json_object_new_object();
ospf6_linkstate_prefix(ospf6->router_id, htonl(0), &prefix); ospf6_linkstate_prefix(ospf6->router_id, htonl(0), &prefix);
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) { for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
if (uj) { if (uj) {
json_area = json_object_new_object(); json_area = json_object_new_object();
@ -918,35 +905,47 @@ DEFUN (show_ipv6_ospf6_spf_tree,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
DEFUN (show_ipv6_ospf6_area_spf_tree, DEFUN(show_ipv6_ospf6_spf_tree, show_ipv6_ospf6_spf_tree_cmd,
show_ipv6_ospf6_area_spf_tree_cmd, "show ipv6 ospf6 [vrf <NAME|all>] spf tree [json]",
"show ipv6 ospf6 area A.B.C.D spf tree", SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
SHOW_STR "All VRFs\n"
IP6_STR
OSPF6_STR
OSPF6_AREA_STR
OSPF6_AREA_ID_STR
"Shortest Path First calculation\n" "Shortest Path First calculation\n"
"Show SPF tree\n") "Show SPF tree\n" JSON_STR)
{ {
int idx_ipv4 = 4; struct listnode *node;
uint32_t area_id; 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 ospf6_area *oa;
struct prefix prefix;
struct ospf6_vertex *root; struct ospf6_vertex *root;
struct ospf6_route *route; 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); 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); oa = ospf6_area_lookup(area_id, ospf6);
if (oa == NULL) { if (oa == NULL) {
vty_out(vty, "No such Area: %s\n", argv[idx_ipv4]->arg); 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; return CMD_SUCCESS;
} }
DEFUN (show_ipv6_ospf6_simulate_spf_tree_root, DEFUN(show_ipv6_ospf6_area_spf_tree, show_ipv6_ospf6_area_spf_tree_cmd,
show_ipv6_ospf6_simulate_spf_tree_root_cmd, "show ipv6 ospf6 [vrf <NAME|all>] area A.B.C.D spf tree",
"show ipv6 ospf6 simulate spf-tree A.B.C.D area A.B.C.D", SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
SHOW_STR "All VRFs\n" OSPF6_AREA_STR OSPF6_AREA_ID_STR
IP6_STR
OSPF6_STR
"Shortest Path First calculation\n" "Shortest Path First calculation\n"
"Show SPF tree\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 = 4;
int idx_ipv4_2 = 7;
uint32_t area_id; 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_area *oa;
struct ospf6_vertex *root; struct ospf6_vertex *root;
struct ospf6_route *route; struct ospf6_route *route;
struct prefix prefix;
uint32_t router_id;
struct ospf6_route_table *spf_table; struct ospf6_route_table *spf_table;
unsigned char tmp_debug_ospf6_spf = 0; 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); oa = ospf6_area_lookup(area_id, ospf6);
if (oa == NULL) { if (oa == NULL) {
vty_out(vty, "No such Area: %s\n", argv[idx_ipv4_2]->arg); 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; 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, DEFUN (ospf6_area_stub,
ospf6_area_stub_cmd, ospf6_area_stub_cmd,
"area <A.B.C.D|(0-4294967295)> stub", "area <A.B.C.D|(0-4294967295)> stub",
@ -1158,8 +1219,9 @@ void ospf6_area_interface_delete(struct ospf6_interface *oi)
if (!om6->ospf6) if (!om6->ospf6)
return; 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)) for (ALL_LIST_ELEMENTS(ospf6->area_list, node, nnode, oa))
if (listnode_lookup(oa->if_list, oi)) if (listnode_lookup(oa->if_list, oi))
listnode_delete(oa->if_list, oi); listnode_delete(oa->if_list, oi);
} }
}

View File

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

View File

@ -1175,19 +1175,13 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp,
return 0; return 0;
} }
/* show interface */ static int show_ospf6_interface_common(struct vty *vty, vrf_id_t vrf_id,
DEFUN(show_ipv6_ospf6_interface, int argc, struct cmd_token **argv,
show_ipv6_ospf6_interface_ifname_cmd, int idx_ifname, int intf_idx,
"show ipv6 ospf6 interface [IFNAME] [json]", int json_idx)
SHOW_STR
IP6_STR
OSPF6_STR
INTERFACE_STR
IFNAME_STR
JSON_STR)
{ {
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; struct interface *ifp;
json_object *json; json_object *json;
json_object *json_int; json_object *json_int;
@ -1195,9 +1189,8 @@ DEFUN(show_ipv6_ospf6_interface,
if (uj) { if (uj) {
json = json_object_new_object(); json = json_object_new_object();
if (argc == 6) { if (argc == json_idx) {
ifp = if_lookup_by_name(argv[idx_ifname]->arg, ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
VRF_DEFAULT);
json_int = json_object_new_object(); json_int = json_object_new_object();
if (ifp == NULL) { if (ifp == NULL) {
json_object_string_add(json, "noSuchInterface", json_object_string_add(json, "noSuchInterface",
@ -1224,9 +1217,8 @@ DEFUN(show_ipv6_ospf6_interface,
json, JSON_C_TO_STRING_PRETTY)); json, JSON_C_TO_STRING_PRETTY));
json_object_free(json); json_object_free(json);
} else { } else {
if (argc == 5) { if (argc == intf_idx) {
ifp = if_lookup_by_name(argv[idx_ifname]->arg, ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
VRF_DEFAULT);
if (ifp == NULL) { if (ifp == NULL) {
vty_out(vty, "No such Interface: %s\n", vty_out(vty, "No such Interface: %s\n",
argv[idx_ifname]->arg); argv[idx_ifname]->arg);
@ -1238,6 +1230,42 @@ DEFUN(show_ipv6_ospf6_interface,
ospf6_interface_show(vty, ifp, NULL, uj); 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; return CMD_SUCCESS;
} }
@ -1245,7 +1273,7 @@ DEFUN(show_ipv6_ospf6_interface,
static int ospf6_interface_show_traffic(struct vty *vty, static int ospf6_interface_show_traffic(struct vty *vty,
struct interface *intf_ifp, struct interface *intf_ifp,
int display_once, json_object *json, int display_once, json_object *json,
bool use_json) bool use_json, vrf_id_t vrf_id)
{ {
struct interface *ifp; struct interface *ifp;
struct vrf *vrf = NULL; struct vrf *vrf = NULL;
@ -1255,7 +1283,7 @@ static int ospf6_interface_show_traffic(struct vty *vty,
if (intf_ifp) if (intf_ifp)
vrf = vrf_lookup_by_id(intf_ifp->vrf_id); vrf = vrf_lookup_by_id(intf_ifp->vrf_id);
else else
vrf = vrf_lookup_by_id(VRF_DEFAULT); vrf = vrf_lookup_by_id(vrf_id);
if (!display_once && !use_json) { if (!display_once && !use_json) {
vty_out(vty, "\n"); vty_out(vty, "\n");
@ -1356,17 +1384,9 @@ static int ospf6_interface_show_traffic(struct vty *vty,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
/* show interface */ static int ospf6_interface_show_traffic_common(struct vty *vty, int argc,
DEFUN(show_ipv6_ospf6_interface_traffic, struct cmd_token **argv,
show_ipv6_ospf6_interface_traffic_cmd, vrf_id_t vrf_id)
"show ipv6 ospf6 interface traffic [IFNAME] [json]",
SHOW_STR
IP6_STR
OSPF6_STR
INTERFACE_STR
"Protocol Packet counters\n"
IFNAME_STR
JSON_STR)
{ {
int idx_ifname = 0; int idx_ifname = 0;
int display_once = 0; int display_once = 0;
@ -1380,7 +1400,7 @@ DEFUN(show_ipv6_ospf6_interface_traffic,
if (argv_find(argv, argc, "IFNAME", &idx_ifname)) { if (argv_find(argv, argc, "IFNAME", &idx_ifname)) {
intf_name = argv[idx_ifname]->arg; 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 (uj) {
if (ifp == NULL) { if (ifp == NULL) {
json_object_string_add(json, "status", 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) { if (uj) {
vty_out(vty, "%s\n", vty_out(vty, "%s\n",
@ -1429,6 +1449,34 @@ DEFUN(show_ipv6_ospf6_interface_traffic,
json_object_free(json); 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; return CMD_SUCCESS;
} }
@ -1436,88 +1484,114 @@ DEFUN(show_ipv6_ospf6_interface_traffic,
DEFUN(show_ipv6_ospf6_interface_ifname_prefix, DEFUN(show_ipv6_ospf6_interface_ifname_prefix,
show_ipv6_ospf6_interface_ifname_prefix_cmd, show_ipv6_ospf6_interface_ifname_prefix_cmd,
"show ipv6 ospf6 interface IFNAME prefix\ "show ipv6 ospf6 [vrf <NAME|all>] interface IFNAME prefix\
[<\ [<\
detail\ detail\
|<X:X::X:X|X:X::X:X/M> [<match|detail>]\ |<X:X::X:X|X:X::X:X/M> [<match|detail>]\
>] [json]", >] [json]",
SHOW_STR SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
IP6_STR "All VRFs\n" INTERFACE_STR IFNAME_STR
OSPF6_STR
INTERFACE_STR
IFNAME_STR
"Display connected prefixes to advertise\n" "Display connected prefixes to advertise\n"
"Display details of the prefixes\n" "Display details of the prefixes\n" OSPF6_ROUTE_ADDRESS_STR
OSPF6_ROUTE_ADDRESS_STR OSPF6_ROUTE_PREFIX_STR OSPF6_ROUTE_MATCH_STR
OSPF6_ROUTE_PREFIX_STR "Display details of the prefixes\n" JSON_STR)
OSPF6_ROUTE_MATCH_STR
"Display details of the prefixes\n"
JSON_STR)
{ {
int idx_ifname = 4; int idx_ifname = 4;
int idx_prefix = 6; int idx_prefix = 6;
struct interface *ifp;
struct ospf6_interface *oi; struct ospf6_interface *oi;
bool uj = use_json(argc, argv); bool uj = use_json(argc, argv);
ifp = if_lookup_by_name(argv[idx_ifname]->arg, VRF_DEFAULT); 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;
}
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) { if (ifp == NULL) {
vty_out(vty, "No such Interface: %s\n", argv[idx_ifname]->arg); vty_out(vty, "No such Interface: %s\n",
argv[idx_ifname]->arg);
return CMD_WARNING; return CMD_WARNING;
} }
oi = ifp->info; oi = ifp->info;
if (oi == NULL) { if (oi == NULL
vty_out(vty, "OSPFv3 is not enabled on %s\n", || CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE)) {
vty_out(vty,
"Interface %s not attached to area\n",
argv[idx_ifname]->arg); argv[idx_ifname]->arg);
return CMD_WARNING; return CMD_WARNING;
} }
if (CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE)) { ospf6_route_table_show(vty, idx_prefix, argc, argv,
vty_out(vty, "Interface %s not attached to area\n", oi->route_connected, uj);
argv[idx_ifname]->arg);
return CMD_WARNING;
}
ospf6_route_table_show(vty, idx_prefix, argc, argv, oi->route_connected, if (!all_vrf)
uj); break;
}
}
return CMD_SUCCESS; return CMD_SUCCESS;
} }
DEFUN (show_ipv6_ospf6_interface_prefix, DEFUN(show_ipv6_ospf6_interface_prefix, show_ipv6_ospf6_interface_prefix_cmd,
show_ipv6_ospf6_interface_prefix_cmd, "show ipv6 ospf6 [vrf <NAME|all>] interface prefix\
"show ipv6 ospf6 interface prefix\
[<\ [<\
detail\ detail\
|<X:X::X:X|X:X::X:X/M> [<match|detail>]\ |<X:X::X:X|X:X::X:X/M> [<match|detail>]\
>] [json]", >] [json]",
SHOW_STR SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
IP6_STR "All VRFs\n" INTERFACE_STR
OSPF6_STR
INTERFACE_STR
"Display connected prefixes to advertise\n" "Display connected prefixes to advertise\n"
"Display details of the prefixes\n" "Display details of the prefixes\n" OSPF6_ROUTE_ADDRESS_STR
OSPF6_ROUTE_ADDRESS_STR OSPF6_ROUTE_PREFIX_STR OSPF6_ROUTE_MATCH_STR
OSPF6_ROUTE_PREFIX_STR "Display details of the prefixes\n" JSON_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; int idx_prefix = 5;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct interface *ifp; struct interface *ifp;
bool uj = use_json(argc, argv); 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;
OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0)
idx_prefix += 2;
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) { FOR_ALL_INTERFACES (vrf, ifp) {
oi = (struct ospf6_interface *)ifp->info; oi = (struct ospf6_interface *)ifp->info;
if (oi == NULL || CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE)) if (oi == NULL
|| CHECK_FLAG(oi->flag,
OSPF6_INTERFACE_DISABLE))
continue; continue;
ospf6_route_table_show(vty, idx_prefix, argc, argv, ospf6_route_table_show(vty, idx_prefix, argc,
argv,
oi->route_connected, uj); oi->route_connected, uj);
} }
if (!all_vrf)
break;
}
}
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -2211,9 +2285,8 @@ DEFUN (no_ipv6_ospf6_network,
return CMD_SUCCESS; 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 ospf6_interface *oi;
struct interface *ifp; struct interface *ifp;
@ -2222,7 +2295,11 @@ static int config_write_ospf6_interface(struct vty *vty)
if (oi == NULL) if (oi == NULL)
continue; continue;
if (vrf->vrf_id == VRF_DEFAULT)
vty_frame(vty, "interface %s\n", oi->interface->name); 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) if (ifp->desc)
vty_out(vty, " description %s\n", 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; 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 = { static struct cmd_node interface_node = {
.name = "interface", .name = "interface",
.node = INTERFACE_NODE, .node = INTERFACE_NODE,
.parent_node = CONFIG_NODE, .parent_node = CONFIG_NODE,
.prompt = "%s(config-if)# ", .prompt = "%s(config-if)# ",
.config_write = config_write_ospf6_interface, .config_write = config_write_interface,
}; };
static int ospf6_ifp_create(struct interface *ifp) 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, static void ospf6_neighbor_show_detail_common(struct vty *vty, int argc,
show_ipv6_ospf6_neighbor_cmd, struct cmd_token **argv,
"show ipv6 ospf6 neighbor [<detail|drchoice>] [json]", struct ospf6 *ospf6, int idx_type,
SHOW_STR int detail_idx, int json_idx)
IP6_STR
OSPF6_STR
"Neighbor list\n"
"Display details\n"
"Display DR choices\n"
JSON_STR)
{ {
int idx_type = 4;
struct ospf6_neighbor *on; struct ospf6_neighbor *on;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct ospf6_area *oa; struct ospf6_area *oa;
struct listnode *i, *j, *k; struct listnode *i, *j, *k;
struct ospf6 *ospf6;
json_object *json = NULL; json_object *json = NULL;
json_object *json_array = NULL; json_object *json_array = NULL;
bool uj = use_json(argc, argv); bool uj = use_json(argc, argv);
void (*showfunc)(struct vty *, struct ospf6_neighbor *, void (*showfunc)(struct vty *, struct ospf6_neighbor *,
json_object *json, bool use_json); json_object *json, bool use_json);
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
OSPF6_CMD_CHECK_RUNNING(ospf6);
showfunc = ospf6_neighbor_show; 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)) if (!strncmp(argv[idx_type]->arg, "de", 2))
showfunc = ospf6_neighbor_show_detail; showfunc = ospf6_neighbor_show_detail;
else if (!strncmp(argv[idx_type]->arg, "dr", 2)) 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, JSON_C_TO_STRING_PRETTY));
json_object_free(json); 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; return CMD_SUCCESS;
} }
static int ospf6_neighbor_show_common(struct vty *vty, int argc,
DEFUN (show_ipv6_ospf6_neighbor_one, struct cmd_token **argv,
show_ipv6_ospf6_neighbor_one_cmd, struct ospf6 *ospf6, int idx_ipv4)
"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)
{ {
int idx_ipv4 = 4;
struct ospf6_neighbor *on; struct ospf6_neighbor *on;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct ospf6_area *oa; struct ospf6_area *oa;
@ -1059,12 +1077,9 @@ DEFUN (show_ipv6_ospf6_neighbor_one,
void (*showfunc)(struct vty *, struct ospf6_neighbor *, void (*showfunc)(struct vty *, struct ospf6_neighbor *,
json_object *json, bool use_json); json_object *json, bool use_json);
uint32_t router_id; uint32_t router_id;
struct ospf6 *ospf6;
json_object *json = NULL; json_object *json = NULL;
bool uj = use_json(argc, argv); 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; showfunc = ospf6_neighbor_show_detail;
if (uj) if (uj)
json = json_object_new_object(); json = json_object_new_object();
@ -1088,6 +1103,39 @@ DEFUN (show_ipv6_ospf6_neighbor_one,
json, JSON_C_TO_STRING_PRETTY)); json, JSON_C_TO_STRING_PRETTY));
json_object_free(json); 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; return CMD_SUCCESS;
} }

View File

@ -539,17 +539,20 @@ void ospf6_router_id_update(struct ospf6 *ospf6)
} }
/* start ospf6 */ /* start ospf6 */
DEFUN_NOSH (router_ospf6, DEFUN_NOSH(router_ospf6, router_ospf6_cmd, "router ospf6 [vrf NAME]",
router_ospf6_cmd, ROUTER_STR OSPF6_STR VRF_CMD_HELP_STR)
"router ospf6",
ROUTER_STR
OSPF6_STR)
{ {
struct ospf6 *ospf6; 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) if (ospf6 == NULL)
ospf6 = ospf6_instance_create(VRF_DEFAULT_NAME); ospf6 = ospf6_instance_create(vrf_name);
/* set current ospf point. */ /* set current ospf point. */
VTY_PUSH_CONTEXT(OSPF6_NODE, ospf6); VTY_PUSH_CONTEXT(OSPF6_NODE, ospf6);
@ -558,16 +561,18 @@ DEFUN_NOSH (router_ospf6,
} }
/* stop ospf6 */ /* stop ospf6 */
DEFUN (no_router_ospf6, DEFUN(no_router_ospf6, no_router_ospf6_cmd, "no router ospf6 [vrf NAME]",
no_router_ospf6_cmd, NO_STR ROUTER_STR OSPF6_STR VRF_CMD_HELP_STR)
"no router ospf6",
NO_STR
ROUTER_STR
OSPF6_STR)
{ {
struct ospf6 *ospf6; 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) if (ospf6 == NULL)
vty_out(vty, "OSPFv3 is not configured\n"); vty_out(vty, "OSPFv3 is not configured\n");
else { else {
@ -838,16 +843,19 @@ DEFUN (ospf6_interface_area,
"OSPF6 area ID in decimal notation\n" "OSPF6 area ID in decimal notation\n"
) )
{ {
VTY_DECLVAR_CONTEXT(ospf6, ospf6);
int idx_ifname = 1; int idx_ifname = 1;
int idx_ipv4 = 3; int idx_ipv4 = 3;
struct ospf6_area *oa; struct ospf6_area *oa;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct interface *ifp; 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 */ /* 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; oi = (struct ospf6_interface *)ifp->info;
if (oi == NULL) if (oi == NULL)
oi = ospf6_interface_create(ifp); oi = ospf6_interface_create(ifp);
@ -891,14 +899,21 @@ DEFUN (no_ospf6_interface_area,
"OSPF6 area ID in decimal notation\n" "OSPF6 area ID in decimal notation\n"
) )
{ {
VTY_DECLVAR_CONTEXT(ospf6, ospf6);
int idx_ifname = 2; int idx_ifname = 2;
int idx_ipv4 = 4; int idx_ipv4 = 4;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct ospf6_area *oa; struct ospf6_area *oa;
struct interface *ifp; struct interface *ifp;
uint32_t area_id; 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) { if (ifp == NULL) {
vty_out(vty, "No such interface %s\n", argv[idx_ifname]->arg); vty_out(vty, "No such interface %s\n", argv[idx_ifname]->arg);
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1297,38 +1312,43 @@ DEFUN(show_ipv6_ospf6_vrfs, show_ipv6_ospf6_vrfs_cmd,
} }
/* show top level structures */ /* show top level structures */
DEFUN(show_ipv6_ospf6, DEFUN(show_ipv6_ospf6, show_ipv6_ospf6_cmd,
show_ipv6_ospf6_cmd, "show ipv6 ospf6 [vrf <NAME|all>] [json]",
"show ipv6 ospf6 [json]", SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR "All VRFs\n" JSON_STR)
SHOW_STR
IP6_STR
OSPF6_STR
JSON_STR)
{ {
struct ospf6 *ospf6; 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); bool uj = use_json(argc, argv);
json_object *json = NULL; json_object *json = NULL;
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME); OSPF6_CMD_CHECK_RUNNING();
OSPF6_CMD_CHECK_RUNNING(ospf6); 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) {
if (uj) if (uj)
json = json_object_new_object(); json = json_object_new_object();
ospf6_show(vty, ospf6, json, uj); ospf6_show(vty, ospf6, json, uj);
if (!all_vrf)
break;
}
}
if (uj) if (uj)
json_object_free(json); json_object_free(json);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
DEFUN (show_ipv6_ospf6_route, DEFUN(show_ipv6_ospf6_route, show_ipv6_ospf6_route_cmd,
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 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 VRF_CMD_HELP_STR
SHOW_STR "All VRFs\n" ROUTE_STR
IP6_STR
OSPF6_STR
ROUTE_STR
"Display Intra-Area routes\n" "Display Intra-Area routes\n"
"Display Inter-Area routes\n" "Display Inter-Area routes\n"
"Display Type-1 External routes\n" "Display Type-1 External routes\n"
@ -1336,85 +1356,136 @@ DEFUN (show_ipv6_ospf6_route,
"Specify IPv6 address\n" "Specify IPv6 address\n"
"Specify IPv6 prefix\n" "Specify IPv6 prefix\n"
"Detailed information\n" "Detailed information\n"
"Summary of route table\n" "Summary of route table\n" JSON_STR)
JSON_STR)
{ {
struct ospf6 *ospf6; 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); bool uj = use_json(argc, argv);
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME); OSPF6_CMD_CHECK_RUNNING();
OSPF6_CMD_CHECK_RUNNING(ospf6); 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; return CMD_SUCCESS;
} }
DEFUN (show_ipv6_ospf6_route_match, DEFUN(show_ipv6_ospf6_route_match, show_ipv6_ospf6_route_match_cmd,
show_ipv6_ospf6_route_match_cmd, "show ipv6 ospf6 [vrf <NAME|all>] route X:X::X:X/M <match|longer> [json]",
"show ipv6 ospf6 route X:X::X:X/M <match|longer> [json]", SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
SHOW_STR "All VRFs\n" ROUTE_STR
IP6_STR
OSPF6_STR
ROUTE_STR
"Specify IPv6 prefix\n" "Specify IPv6 prefix\n"
"Display routes which match the specified route\n" "Display routes which match the specified route\n"
"Display routes longer than the specified route\n" "Display routes longer than the specified route\n" JSON_STR)
JSON_STR)
{ {
struct ospf6 *ospf6; 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); bool uj = use_json(argc, argv);
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME); OSPF6_CMD_CHECK_RUNNING();
OSPF6_CMD_CHECK_RUNNING(ospf6); 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; return CMD_SUCCESS;
} }
DEFUN(show_ipv6_ospf6_route_match_detail, DEFUN(show_ipv6_ospf6_route_match_detail,
show_ipv6_ospf6_route_match_detail_cmd, show_ipv6_ospf6_route_match_detail_cmd,
"show ipv6 ospf6 route X:X::X:X/M match detail [json]", "show ipv6 ospf6 [vrf <NAME|all>] route X:X::X:X/M match detail [json]",
SHOW_STR SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
IP6_STR "All VRFs\n" ROUTE_STR
OSPF6_STR
ROUTE_STR
"Specify IPv6 prefix\n" "Specify IPv6 prefix\n"
"Display routes which match the specified route\n" "Display routes which match the specified route\n"
"Detailed information\n" "Detailed information\n" JSON_STR)
JSON_STR)
{ {
struct ospf6 *ospf6; 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); bool uj = use_json(argc, argv);
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME); OSPF6_CMD_CHECK_RUNNING();
OSPF6_CMD_CHECK_RUNNING(ospf6); 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; return CMD_SUCCESS;
} }
DEFUN(show_ipv6_ospf6_route_type_detail, show_ipv6_ospf6_route_type_detail_cmd,
DEFUN (show_ipv6_ospf6_route_type_detail, "show ipv6 ospf6 [vrf <NAME|all>] route <intra-area|inter-area|external-1|external-2> detail [json]",
show_ipv6_ospf6_route_type_detail_cmd, SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"show ipv6 ospf6 route <intra-area|inter-area|external-1|external-2> detail [json]", "All VRFs\n" ROUTE_STR
SHOW_STR
IP6_STR
OSPF6_STR
ROUTE_STR
"Display Intra-Area routes\n" "Display Intra-Area routes\n"
"Display Inter-Area routes\n" "Display Inter-Area routes\n"
"Display Type-1 External routes\n" "Display Type-1 External routes\n"
"Display Type-2 External routes\n" "Display Type-2 External routes\n"
"Detailed information\n" "Detailed information\n" JSON_STR)
JSON_STR)
{ {
struct ospf6 *ospf6; 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); bool uj = use_json(argc, argv);
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME); OSPF6_CMD_CHECK_RUNNING();
OSPF6_CMD_CHECK_RUNNING(ospf6); 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; return CMD_SUCCESS;
} }
@ -1471,7 +1542,11 @@ static int config_write_ospf6(struct vty *vty)
return CMD_SUCCESS; return CMD_SUCCESS;
for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) { for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) {
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"); vty_out(vty, "router ospf6\n");
if (ospf6->router_id_static != 0) if (ospf6->router_id_static != 0)
vty_out(vty, " ospf6 router-id %pI4\n", vty_out(vty, " ospf6 router-id %pI4\n",
&ospf6->router_id_static); &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_ROUTER_ID_STR "Specify Router-ID\n"
#define OSPF6_LS_ID_STR "Specify Link State ID\n" #define OSPF6_LS_ID_STR "Specify Link State ID\n"
#define OSPF6_CMD_CHECK_RUNNING(ospf6) \ #define OSPF6_CMD_CHECK_RUNNING() \
if (ospf6 == NULL) { \ if (om6->ospf6 == NULL) { \
vty_out(vty, "OSPFv3 is not running\n"); \ vty_out(vty, "OSPFv3 is not running\n"); \
return CMD_SUCCESS; \ return CMD_SUCCESS; \
} }
#define IS_OSPF6_ASBR(O) ((O)->flag & OSPF6_FLAG_ASBR) #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; extern struct zebra_privs_t ospf6d_privs;
/* Function Prototypes */ /* Function Prototypes */

View File

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