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>
This commit is contained in:
rgirada 2021-10-08 00:15:48 -07:00
parent eb4ed6e8c7
commit 059fd3a48a
4 changed files with 33 additions and 7 deletions

View File

@ -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),

View File

@ -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 *);

View File

@ -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);

View File

@ -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)