bgpd: bgpd-peer-outq.patch

BGP: Show more meaningful outq value in 'show ip bgp summary' output.

'outq' field in 'show ip bgp sum' displays the number of formatted packets
to a peer. Since the route announcement follows an input-buffered pattern
(i.e. adj-rib-out is a separate queue of routes per peer and packets are
formatted from the routes at the time of TCP write), the outq field doesn't
show any interesting data worth watching.

The patch is to display the adj-rib-out queue depth instead.

signed-off-by: pmohapat@cumulusnetworks.com
reviewed-by: dwalton@cumulusnetworks.com
This commit is contained in:
Donald Sharp 2015-05-19 17:40:36 -07:00
parent 01a2af4562
commit cdabb8b691
3 changed files with 34 additions and 9 deletions

View File

@ -185,10 +185,12 @@ bgp_advertise_clean (struct peer *peer, struct bgp_adj_out *adj,
struct bgp_advertise *adv; struct bgp_advertise *adv;
struct bgp_advertise_attr *baa; struct bgp_advertise_attr *baa;
struct bgp_advertise *next; struct bgp_advertise *next;
struct bgp_advertise_fifo *fhead;
adv = adj->adv; adv = adj->adv;
baa = adv->baa; baa = adv->baa;
next = NULL; next = NULL;
fhead = &peer->sync[afi][safi]->withdraw;
if (baa) if (baa)
{ {
@ -200,10 +202,12 @@ bgp_advertise_clean (struct peer *peer, struct bgp_adj_out *adj,
/* Unintern BGP advertise attribute. */ /* Unintern BGP advertise attribute. */
bgp_advertise_unintern (peer->hash[afi][safi], baa); bgp_advertise_unintern (peer->hash[afi][safi], baa);
fhead = &peer->sync[afi][safi]->update;
} }
/* Unlink myself from advertisement FIFO. */ /* Unlink myself from advertisement FIFO. */
FIFO_DEL (adv); BGP_ADV_FIFO_DEL (fhead, adv);
/* Free memory. */ /* Free memory. */
bgp_advertise_free (adj->adv); bgp_advertise_free (adj->adv);
@ -263,7 +267,7 @@ bgp_adj_out_set (struct bgp_node *rn, struct peer *peer, struct prefix *p,
/* Add new advertisement to advertisement attribute list. */ /* Add new advertisement to advertisement attribute list. */
bgp_advertise_add (adv->baa, adv); bgp_advertise_add (adv->baa, adv);
FIFO_ADD (&peer->sync[afi][safi]->update, &adv->fifo); BGP_ADV_FIFO_ADD (&peer->sync[afi][safi]->update, &adv->fifo);
} }
void void
@ -297,7 +301,7 @@ bgp_adj_out_unset (struct bgp_node *rn, struct peer *peer, struct prefix *p,
adv->adj = adj; adv->adj = adj;
/* Add to synchronization entry for withdraw announcement. */ /* Add to synchronization entry for withdraw announcement. */
FIFO_ADD (&peer->sync[afi][safi]->withdraw, &adv->fifo); BGP_ADV_FIFO_ADD (&peer->sync[afi][safi]->withdraw, &adv->fifo);
/* Schedule packet write. */ /* Schedule packet write. */
BGP_WRITE_ON (peer->t_write, bgp_write, peer->fd); BGP_WRITE_ON (peer->t_write, bgp_write, peer->fd);
@ -389,9 +393,9 @@ bgp_sync_init (struct peer *peer)
{ {
sync = XCALLOC (MTYPE_BGP_SYNCHRONISE, sync = XCALLOC (MTYPE_BGP_SYNCHRONISE,
sizeof (struct bgp_synchronize)); sizeof (struct bgp_synchronize));
FIFO_INIT (&sync->update); BGP_ADV_FIFO_INIT (&sync->update);
FIFO_INIT (&sync->withdraw); BGP_ADV_FIFO_INIT (&sync->withdraw);
FIFO_INIT (&sync->withdraw_low); BGP_ADV_FIFO_INIT (&sync->withdraw_low);
peer->sync[afi][safi] = sync; peer->sync[afi][safi] = sync;
peer->hash[afi][safi] = hash_create (baa_hash_key, baa_hash_cmp); peer->hash[afi][safi] = hash_create (baa_hash_key, baa_hash_cmp);
} }

View File

@ -26,6 +26,7 @@ struct bgp_advertise_fifo
{ {
struct bgp_advertise *next; struct bgp_advertise *next;
struct bgp_advertise *prev; struct bgp_advertise *prev;
u_int32_t count;
}; };
/* BGP advertise attribute. */ /* BGP advertise attribute. */
@ -127,6 +128,24 @@ struct bgp_synchronize
#define BGP_ADJ_OUT_ADD(N,A) BGP_INFO_ADD(N,A,adj_out) #define BGP_ADJ_OUT_ADD(N,A) BGP_INFO_ADD(N,A,adj_out)
#define BGP_ADJ_OUT_DEL(N,A) BGP_INFO_DEL(N,A,adj_out) #define BGP_ADJ_OUT_DEL(N,A) BGP_INFO_DEL(N,A,adj_out)
#define BGP_ADV_FIFO_ADD(F, N) \
do { \
FIFO_ADD((F), (N)); \
(F)->count++; \
} while (0)
#define BGP_ADV_FIFO_DEL(F, N) \
do { \
FIFO_DEL((N)); \
(F)->count--; \
} while (0)
#define BGP_ADV_FIFO_INIT(F) \
do { \
FIFO_INIT((F)); \
(F)->count = 0; \
} while (0)
/* Prototypes. */ /* Prototypes. */
extern void bgp_adj_out_set (struct bgp_node *, struct peer *, struct prefix *, extern void bgp_adj_out_set (struct bgp_node *, struct peer *, struct prefix *,
struct attr *, afi_t, safi_t, struct bgp_info *); struct attr *, afi_t, safi_t, struct bgp_info *);

View File

@ -7174,7 +7174,7 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, char *del
vty_out(vty, "%c", *delimit); vty_out(vty, "%c", *delimit);
if (!delimit) if (!delimit)
vty_out (vty, "%5u %7d %7d %8d %4d %4lu", vty_out (vty, "%5u %7d %7d %8d %4d %4lu ",
peer->as, peer->as,
peer->open_in + peer->update_in + peer->keepalive_in peer->open_in + peer->update_in + peer->keepalive_in
+ peer->notify_in + peer->refresh_in + peer->notify_in + peer->refresh_in
@ -7184,7 +7184,8 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, char *del
+ peer->dynamic_cap_out, + peer->dynamic_cap_out,
0, 0,
0, 0,
(unsigned long) peer->obuf->count); peer->sync[afi][safi]->update.count +
peer->sync[afi][safi]->withdraw.count);
else else
vty_out (vty, "%5u %c %7d %c %7d %c %8d %c %4d %c %4lu %c", vty_out (vty, "%5u %c %7d %c %7d %c %8d %c %4d %c %4lu %c",
peer->as, *delimit, peer->as, *delimit,
@ -7196,7 +7197,8 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, char *del
+ peer->dynamic_cap_out, *delimit, + peer->dynamic_cap_out, *delimit,
0, *delimit, 0, *delimit,
0, *delimit, 0, *delimit,
(unsigned long) peer->obuf->count, *delimit); peer->sync[afi][safi]->update.count +
peer->sync[afi][safi]->withdraw.count, *delimit);
vty_out (vty, "%8s", vty_out (vty, "%8s",
peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN)); peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN));