Skip to content

Commit

Permalink
ospf6d: cleanup useless checks
Browse files Browse the repository at this point in the history
om6->ospf6 is always initialized at the start of the execution.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
  • Loading branch information
idryzhov committed Sep 15, 2021
1 parent aae2cae commit 175c92e
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 57 deletions.
9 changes: 0 additions & 9 deletions ospf6d/ospf6_area.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,6 @@ void ospf6_area_plist_update(struct prefix_list *plist, int add)
const char *name = prefix_list_name(plist);
struct ospf6 *ospf6 = NULL;


if (!om6->ospf6)
return;

for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) {
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, n, oa)) {
if (PREFIX_NAME_IN(oa)
Expand Down Expand Up @@ -988,7 +984,6 @@ DEFUN(show_ipv6_ospf6_spf_tree, show_ipv6_ospf6_spf_tree_cmd,
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)) {
Expand Down Expand Up @@ -1048,7 +1043,6 @@ DEFUN(show_ipv6_ospf6_area_spf_tree, show_ipv6_ospf6_area_spf_tree_cmd,
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;
Expand Down Expand Up @@ -1132,7 +1126,6 @@ DEFUN(show_ipv6_ospf6_simulate_spf_tree_root,
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;
Expand Down Expand Up @@ -1340,8 +1333,6 @@ void ospf6_area_interface_delete(struct ospf6_interface *oi)
struct listnode *node, *nnode;
struct ospf6 *ospf6;

if (!om6->ospf6)
return;
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))
Expand Down
1 change: 0 additions & 1 deletion ospf6d/ospf6_asbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2522,7 +2522,6 @@ DEFUN(show_ipv6_ospf6_redistribute, show_ipv6_ospf6_redistribute_cmd,
json_object *json_array_routes = NULL;
json_object *json_array_redistribute = NULL;

OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);

if (uj) {
Expand Down
4 changes: 0 additions & 4 deletions ospf6d/ospf6_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,6 @@ DEFUN(show_ipv6_ospf6_interface, show_ipv6_ospf6_interface_ifname_cmd,
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;
Expand Down Expand Up @@ -1547,7 +1546,6 @@ DEFUN(show_ipv6_ospf6_interface_traffic, show_ipv6_ospf6_interface_traffic_cmd,
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)) {
Expand Down Expand Up @@ -1590,7 +1588,6 @@ DEFUN(show_ipv6_ospf6_interface_ifname_prefix,
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;
Expand Down Expand Up @@ -1651,7 +1648,6 @@ DEFUN(show_ipv6_ospf6_interface_prefix, show_ipv6_ospf6_interface_prefix_cmd,
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;
Expand Down
2 changes: 0 additions & 2 deletions ospf6d/ospf6_neighbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,6 @@ DEFUN(show_ipv6_ospf6_neighbor, show_ipv6_ospf6_neighbor_cmd,
bool detail = false;
bool drchoice = false;

OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);

if (argv_find(argv, argc, "detail", &idx_type))
Expand Down Expand Up @@ -1156,7 +1155,6 @@ DEFUN(show_ipv6_ospf6_neighbor_one, show_ipv6_ospf6_neighbor_one_cmd,
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;
Expand Down
10 changes: 0 additions & 10 deletions ospf6d/ospf6_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -1120,11 +1120,6 @@ void ospf6_route_show(struct vty *vty, struct ospf6_route *route,
json_object *json_array_next_hops = NULL;
json_object *json_next_hop;

if (om6->ospf6 == NULL) {
vty_out(vty, "OSPFv3 is not running\n");
return;
}

monotime(&now);
timersub(&now, &route->changed, &res);
timerstring(&res, duration, sizeof(duration));
Expand Down Expand Up @@ -1208,11 +1203,6 @@ void ospf6_route_show_detail(struct vty *vty, struct ospf6_route *route,
json_object *json_array_next_hops = NULL;
json_object *json_next_hop;

if (om6->ospf6 == NULL) {
vty_out(vty, "OSPFv3 is not running\n");
return;
}

monotime(&now);

/* destination */
Expand Down
6 changes: 0 additions & 6 deletions ospf6d/ospf6_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,6 @@ DEFUN(show_ipv6_ospf6, show_ipv6_ospf6_cmd,
bool uj = use_json(argc, argv);
json_object *json = NULL;

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)) {
Expand Down Expand Up @@ -1560,7 +1559,6 @@ DEFUN(show_ipv6_ospf6_route, show_ipv6_ospf6_route_cmd,
int idx_arg_start = 4;
bool uj = use_json(argc, argv);

OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0)
idx_arg_start += 2;
Expand Down Expand Up @@ -1594,7 +1592,6 @@ DEFUN(show_ipv6_ospf6_route_match, show_ipv6_ospf6_route_match_cmd,
int idx_start_arg = 4;
bool uj = use_json(argc, argv);

OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0)
idx_start_arg += 2;
Expand Down Expand Up @@ -1629,7 +1626,6 @@ DEFUN(show_ipv6_ospf6_route_match_detail,
int idx_start_arg = 4;
bool uj = use_json(argc, argv);

OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0)
idx_start_arg += 2;
Expand Down Expand Up @@ -1665,7 +1661,6 @@ DEFUN(show_ipv6_ospf6_route_type_detail, show_ipv6_ospf6_route_type_detail_cmd,
int idx_start_arg = 4;
bool uj = use_json(argc, argv);

OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0)
idx_start_arg += 2;
Expand Down Expand Up @@ -2078,7 +2073,6 @@ DEFPY (show_ipv6_ospf6_external_aggregator,
if (uj)
json = json_object_new_object();

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)) {
Expand Down
19 changes: 0 additions & 19 deletions ospf6d/ospf6d.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ DEFUN(show_ipv6_ospf6_database, show_ipv6_ospf6_database_cmd,
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);
if (idx_vrf > 0)
idx_level += 2;
Expand Down Expand Up @@ -460,7 +459,6 @@ DEFUN(show_ipv6_ospf6_database_type, show_ipv6_ospf6_database_type_cmd,
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_lsa += 2;
Expand Down Expand Up @@ -505,7 +503,6 @@ DEFUN(show_ipv6_ospf6_database_id, show_ipv6_ospf6_database_id_cmd,
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 (argv[idx_ipv4]->type == IPV4_TKN)
inet_pton(AF_INET, argv[idx_ipv4]->arg, &id);
Expand Down Expand Up @@ -548,7 +545,6 @@ DEFUN(show_ipv6_ospf6_database_router, show_ipv6_ospf6_database_router_cmd,
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);
if (idx_vrf > 0) {
idx_ipv4 += 2;
Expand Down Expand Up @@ -619,7 +615,6 @@ DEFUN_HIDDEN(
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;
Expand Down Expand Up @@ -672,7 +667,6 @@ DEFUN(show_ipv6_ospf6_database_type_id, show_ipv6_ospf6_database_type_id_cmd,
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_lsa += 2;
Expand Down Expand Up @@ -731,7 +725,6 @@ DEFUN(show_ipv6_ospf6_database_type_router,
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_lsa += 2;
Expand Down Expand Up @@ -782,7 +775,6 @@ DEFUN(show_ipv6_ospf6_database_id_router,
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_ls_id += 2;
Expand Down Expand Up @@ -833,7 +825,6 @@ DEFUN(show_ipv6_ospf6_database_adv_router_linkstate_id,
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_adv_rtr += 2;
Expand Down Expand Up @@ -891,7 +882,6 @@ DEFUN(show_ipv6_ospf6_database_type_id_router,
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_lsa += 2;
Expand Down Expand Up @@ -960,7 +950,6 @@ DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id,
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_lsa += 2;
Expand Down Expand Up @@ -1008,7 +997,6 @@ DEFUN(show_ipv6_ospf6_database_self_originated,
uint32_t adv_router = 0;
bool uj = use_json(argc, argv);

OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0)
idx_level += 2;
Expand Down Expand Up @@ -1063,7 +1051,6 @@ DEFUN(show_ipv6_ospf6_database_type_self_originated,
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_lsa += 2;
Expand Down Expand Up @@ -1123,7 +1110,6 @@ DEFUN(show_ipv6_ospf6_database_type_self_originated_linkstate_id,
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_lsa += 2;
Expand Down Expand Up @@ -1185,7 +1171,6 @@ DEFUN(show_ipv6_ospf6_database_type_id_self_originated,
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_lsa += 2;
Expand Down Expand Up @@ -1268,7 +1253,6 @@ DEFUN(show_ipv6_ospf6_border_routers, show_ipv6_ospf6_border_routers_cmd,
int idx_vrf = 0;
int idx_argc = 5;

OSPF6_CMD_CHECK_RUNNING();
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0) {
idx_argc += 2;
Expand Down Expand Up @@ -1308,7 +1292,6 @@ DEFUN(show_ipv6_ospf6_linkstate, show_ipv6_ospf6_linkstate_cmd,
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;
Expand Down Expand Up @@ -1348,8 +1331,6 @@ DEFUN(show_ipv6_ospf6_linkstate_detail, show_ipv6_ospf6_linkstate_detail_cmd,
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_detail += 2;
Expand Down
6 changes: 0 additions & 6 deletions ospf6d/ospf6d.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ 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() \
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)) { \
Expand Down

0 comments on commit 175c92e

Please sign in to comment.