#include "ospfd/ospf_dump.h"
#include "ospfd/ospf_bfd.h"
+FRR_CFG_DEFAULT_BOOL(OSPF_LOG_ADJACENCY_CHANGES,
+ { .val_bool = true, .match_profile = "datacenter", },
+ { .val_bool = false },
+)
+
static const char *const ospf_network_type_str[] = {
"Null", "POINTOPOINT", "BROADCAST", "NBMA", "POINTOMULTIPOINT",
"VIRTUALLINK", "LOOPBACK"};
return 0;
*metric = strtol(str, NULL, 10);
- if (*metric < 0 && *metric > 16777214) {
+ if (*metric < 0 || *metric > 16777214) {
/* vty_out (vty, "OSPF metric value is invalid\n"); */
return 0;
}
struct ospf *ospf = NULL;
int idx_vrf = 0, idx_inst = 0;
const char *vrf_name = NULL;
+ bool created = false;
*instance = 0;
if (argv_find(argv, argc, "(1-65535)", &idx_inst))
vrf_name = NULL;
if (enable) {
/* Allocate VRF aware instance */
- ospf = ospf_get(*instance, vrf_name);
+ ospf = ospf_get(*instance, vrf_name, &created);
} else {
ospf = ospf_lookup_by_inst_name(*instance, vrf_name);
}
} else {
if (enable) {
- ospf = ospf_get(*instance, NULL);
+ ospf = ospf_get(*instance, NULL, &created);
} else {
ospf = ospf_lookup_instance(*instance);
}
}
+ if (created) {
+ if (DFLT_OSPF_LOG_ADJACENCY_CHANGES)
+ SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
+ }
+
return ospf;
}
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
"%s ospf vrf %s num of %u ip osp area x config",
- __PRETTY_FUNCTION__,
- ospf->name ? ospf->name : "NIL",
+ __func__, ospf->name ? ospf->name : "NIL",
ospf->if_ospf_cli_count);
return CMD_WARNING_CONFIG_FAILED;
}
}
/* Show DR information. */
- if (DR(oi).s_addr == 0) {
+ if (DR(oi).s_addr == INADDR_ANY) {
if (!use_json)
vty_out(vty,
" No backup designated router on this network\n");
}
if (nbr->state == NSM_Attempt
- && nbr->router_id.s_addr == 0)
+ && nbr->router_id.s_addr == INADDR_ANY)
strlcpy(neigh_str, "neighbor",
sizeof(neigh_str));
else
ospf_nbr_state_message(nbr, msgbuf, 16);
if (nbr->state == NSM_Attempt
- && nbr->router_id.s_addr == 0)
+ && nbr->router_id.s_addr == INADDR_ANY)
vty_out(vty, "%-15s %3d %-15s ", "-",
nbr->priority, msgbuf);
else
json_neigh_array = NULL;
}
- if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
+ if (nbr->state == NSM_Attempt
+ && nbr->router_id.s_addr == INADDR_ANY)
strlcpy(neigh_str, "noNbrId", sizeof(neigh_str));
else
strlcpy(neigh_str, inet_ntoa(nbr->router_id),
} else {
/* Show neighbor ID. */
- if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
+ if (nbr->state == NSM_Attempt
+ && nbr->router_id.s_addr == INADDR_ANY)
vty_out(vty, " Neighbor %s,", "-");
else
vty_out(vty, " Neighbor %s,",
if (uj)
json_vrf = json_object_new_object();
- if (ospf->vrf_id == 0)
+ if (ospf->vrf_id == VRF_DEFAULT)
name = VRF_DEFAULT_NAME;
else
name = ospf->name;
if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) {
if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
vty_out(vty, " log-adjacency-changes detail\n");
- else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES)
+ else if (!SAVE_OSPF_LOG_ADJACENCY_CHANGES)
vty_out(vty, " log-adjacency-changes\n");
- } else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES) {
+ } else if (SAVE_OSPF_LOG_ADJACENCY_CHANGES) {
vty_out(vty, " no log-adjacency-changes\n");
}
/* ospfd's interface node. */
-static struct cmd_node interface_node = {INTERFACE_NODE, "%s(config-if)# ", 1};
+static struct cmd_node interface_node = {
+ .node = INTERFACE_NODE,
+ .prompt = "%s(config-if)# ",
+ .vtysh = 1,
+};
/* Initialization of OSPF interface. */
static void ospf_vty_if_init(void)
#endif /* 0 */
}
-static struct cmd_node ospf_node = {OSPF_NODE, "%s(config-router)# ", 1};
+static struct cmd_node ospf_node = {
+ .node = OSPF_NODE,
+ .prompt = "%s(config-router)# ",
+ .vtysh = 1,
+};
static void ospf_interface_clear(struct interface *ifp)
{