diff options
author | rgirada <rgirada@vmware.com> | 2021-10-08 09:15:48 +0200 |
---|---|---|
committer | rgirada <rgirada@vmware.com> | 2021-10-26 14:36:20 +0200 |
commit | 059fd3a48a8fca175125c4e1467c4471873b6659 (patch) | |
tree | 391993c50668d170b73578b394d766622e0b4dd3 | |
parent | ospfd: Few modifications in "show ip ospf neighbor" o/p. (diff) | |
download | frr-059fd3a48a8fca175125c4e1467c4471873b6659.tar.xz frr-059fd3a48a8fca175125c4e1467c4471873b6659.zip |
ospfd: Adding apropriate ism state in ptop neighbors.
Description:
In PointToPoint networks, There wont be DR and BDR.
But by default, All neighbours ism state is shown as
DR_OTHER.
Changed the nbr state format to <nbrsate>/- (ex : FULL/-)
to P2pnetworks.
Signed-off-by: Rajesh Girada <rgirada@vmware.com>
-rw-r--r-- | ospfd/ospf_dump.c | 29 | ||||
-rw-r--r-- | ospfd/ospf_dump.h | 5 | ||||
-rw-r--r-- | ospfd/ospf_snmp.c | 2 | ||||
-rw-r--r-- | ospfd/ospf_vty.c | 4 |
4 files changed, 33 insertions, 7 deletions
diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index b1aeefcd4..fab5b7d3c 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -127,7 +127,9 @@ const char *ospf_area_desc_string(struct ospf_area *area) return buf; } -#define OSPF_IF_STRING_MAXLEN 40 +#define OSPF_IF_STRING_MAXLEN 40 + +/* Display both nbr and ism state of the ospf neighbor.*/ const char *ospf_if_name_string(struct ospf_interface *oi) { static char buf[OSPF_IF_STRING_MAXLEN] = ""; @@ -146,6 +148,13 @@ const char *ospf_if_name_string(struct ospf_interface *oi) return buf; } +/* Display only the nbr state.*/ +void ospf_nbr_state_message(struct ospf_neighbor *nbr, char *buf, size_t size) +{ + snprintf(buf, size, "%s", + lookup_msg(ospf_nsm_state_msg, nbr->state, NULL)); +} + int ospf_nbr_ism_state(struct ospf_neighbor *nbr) { int state; @@ -161,9 +170,23 @@ int ospf_nbr_ism_state(struct ospf_neighbor *nbr) return state; } -void ospf_nbr_state_message(struct ospf_neighbor *nbr, char *buf, size_t size) +void ospf_nbr_ism_state_message(struct ospf_neighbor *nbr, char *buf, + size_t size) { - int state = ospf_nbr_ism_state(nbr); + int state; + struct ospf_interface *oi = nbr->oi; + + if (!oi) + return; + + /* network type is point-to-point */ + if (oi->type == OSPF_IFTYPE_POINTOPOINT) { + snprintf(buf, size, "%s/-", + lookup_msg(ospf_nsm_state_msg, nbr->state, NULL)); + return; + } + + state = ospf_nbr_ism_state(nbr); snprintf(buf, size, "%s/%s", lookup_msg(ospf_nsm_state_msg, nbr->state, NULL), diff --git a/ospfd/ospf_dump.h b/ospfd/ospf_dump.h index 031ec2f42..58227d038 100644 --- a/ospfd/ospf_dump.h +++ b/ospfd/ospf_dump.h @@ -151,7 +151,10 @@ extern const char *ospf_area_name_string(struct ospf_area *); extern const char *ospf_area_desc_string(struct ospf_area *); extern const char *ospf_if_name_string(struct ospf_interface *); extern int ospf_nbr_ism_state(struct ospf_neighbor *nbr); -extern void ospf_nbr_state_message(struct ospf_neighbor *, char *, size_t); +extern void ospf_nbr_state_message(struct ospf_neighbor *nbr, char *buf, + size_t size); +extern void ospf_nbr_ism_state_message(struct ospf_neighbor *nbr, char *buf, + size_t size); extern const char *ospf_timer_dump(struct thread *, char *, size_t); extern const char *ospf_timeval_dump(struct timeval *, char *, size_t); extern void ospf_packet_dump(struct stream *); diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index 432f95f9d..a1ea4e45d 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -2432,7 +2432,7 @@ static void ospfTrapNbrStateChange(struct ospf_neighbor *on) oid index[sizeof(oid) * (IN_ADDR_SIZE + 1)]; char msgbuf[16]; - ospf_nbr_state_message(on, msgbuf, sizeof(msgbuf)); + ospf_nbr_ism_state_message(on, msgbuf, sizeof(msgbuf)); if (IS_DEBUG_OSPF_EVENT) zlog_info("%s: trap sent: %pI4 now %s", __func__, &on->address.u.prefix4, msgbuf); diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 96c28be1b..a3fb291bf 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -4400,7 +4400,7 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty, json_neighbor = json_object_new_object(); - ospf_nbr_state_message(nbr, msgbuf, 16); + ospf_nbr_ism_state_message(nbr, msgbuf, 16); json_object_int_add(json_neighbor, "priority", nbr->priority); @@ -4467,7 +4467,7 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty, json_object_array_add(json_neigh_array, json_neighbor); } else { - ospf_nbr_state_message(nbr, msgbuf, 16); + ospf_nbr_ism_state_message(nbr, msgbuf, 16); if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == INADDR_ANY) |