X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ospfd%2Fospf_vty.c;h=c2b08cab772ea9a1d4fa1b8fd3b3effeb5ad0c20;hb=62b346eefa1b9e09c9372f5b6376e1bca4162015;hp=4c97615ed14858c31050082f55210df0b028f428;hpb=d79368d3a54fe4fabffee626858e4aa9e9a5abe2;p=mirror_frr.git diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 4c97615ed..c2b08cab7 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -53,6 +53,11 @@ #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"}; @@ -88,7 +93,7 @@ static int str2metric(const char *str, int *metric) 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; } @@ -138,6 +143,7 @@ static struct ospf *ospf_cmd_lookup_ospf(struct vty *vty, 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)) @@ -149,18 +155,23 @@ static struct ospf *ospf_cmd_lookup_ospf(struct vty *vty, 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; } @@ -608,8 +619,7 @@ DEFUN (ospf_network_area, 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; } @@ -3540,7 +3550,7 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf, } /* 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"); @@ -4154,7 +4164,7 @@ DEFUN (show_ip_ospf_interface_traffic, static void show_ip_ospf_neighbour_header(struct vty *vty) { - vty_out(vty, "\n%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s\n", + vty_out(vty, "\n%-15s %3s %-15s %9s %-15s %-32s %5s %5s %5s\n", "Neighbor ID", "Pri", "State", "Dead Time", "Address", "Interface", "RXmtL", "RqstL", "DBsmL"); } @@ -4188,7 +4198,7 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty, } 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 @@ -4247,7 +4257,7 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty, 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 @@ -4260,7 +4270,7 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty, timebuf, sizeof(timebuf))); vty_out(vty, "%-15s ", inet_ntoa(nbr->src)); - vty_out(vty, "%-20s %5ld %5ld %5d\n", + vty_out(vty, "%-32s %5ld %5ld %5d\n", IF_NAME(oi), ospf_ls_retransmit_count(nbr), ospf_ls_request_count(nbr), @@ -4524,7 +4534,7 @@ static int show_ip_ospf_neighbor_all_common(struct vty *vty, struct ospf *ospf, "-", nbr_nbma->priority, "Down", "-"); vty_out(vty, - "%-15s %-20s %5d %5d %5d\n", + "%-32s %-20s %5d %5d %5d\n", inet_ntoa(nbr_nbma->addr), IF_NAME(oi), 0, 0, 0); } @@ -4897,7 +4907,8 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty, 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), @@ -4915,7 +4926,8 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty, } 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,", @@ -9668,7 +9680,7 @@ DEFUN (show_ip_ospf_vrfs, 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; @@ -10358,9 +10370,9 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf) 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"); } @@ -10544,7 +10556,11 @@ void ospf_vty_show_init(void) /* 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) @@ -10656,7 +10672,11 @@ static void ospf_vty_zebra_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) {