From d3ada366686926b3bd25df6b10b47ce4f3c6ae8e Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sun, 3 May 2020 21:49:46 +0300 Subject: [PATCH 1/2] bgpd: Show "(Policy)" under PfxRcd/PfxSnt when eBGP policy is in use It could be hard to notice when eBGP policy is missing in `show bgp summary`. This adds more sugar to the output: Normal: ``` MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt 10 0 0 0 00:02:07 6 8 ``` When rfc8212 is enabled (default since 7.4) - OUTBOUND: ``` MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt 13 0 0 0 00:04:56 6 (Policy) ``` INBOUND: ``` MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt 19 0 0 0 00:06:27 (Policy) 2 ``` Signed-off-by: Donatas Abraitis --- bgpd/bgp_vty.c | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 4f36073e9a..0f09369860 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -8766,6 +8766,7 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, json_object *json_peer = NULL; json_object *json_peers = NULL; struct peer_af *paf; + struct bgp_filter *filter; /* labeled-unicast routes are installed in the unicast table so in order * to @@ -9066,6 +9067,7 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, } paf = peer_af_find(peer, afi, pfx_rcd_safi); + filter = &peer->filter[afi][safi]; count++; /* Works for both failed & successful cases */ @@ -9208,18 +9210,39 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, BGP_UPTIME_LEN, 0, NULL)); if (peer->status == Established) { - if (peer->afc_recv[afi][safi]) - vty_out(vty, " %12" PRIu32, - peer->pcount - [afi] - [pfx_rcd_safi]); - else + if (peer->afc_recv[afi][safi]) { + if (CHECK_FLAG( + bgp->flags, + BGP_FLAG_EBGP_REQUIRES_POLICY) + && !bgp_inbound_policy_exists( + peer, filter)) + vty_out(vty, " %12s", + "(Policy)"); + else + vty_out(vty, + " %12" PRIu32, + peer->pcount + [afi] + [pfx_rcd_safi]); + } else { vty_out(vty, " NoNeg"); + } - if (paf && PAF_SUBGRP(paf)) - vty_out(vty, " %8" PRIu32, - (PAF_SUBGRP(paf)) - ->scount); + if (paf && PAF_SUBGRP(paf)) { + if (CHECK_FLAG( + bgp->flags, + BGP_FLAG_EBGP_REQUIRES_POLICY) + && !bgp_outbound_policy_exists( + peer, filter)) + vty_out(vty, " %8s", + "(Policy)"); + else + vty_out(vty, + " %8" PRIu32, + (PAF_SUBGRP( + paf)) + ->scount); + } } else { if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) vty_out(vty, " Idle (Admin)"); From 62c42b0efe6956a907765e9be1e95bf92a19c3e7 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Mon, 4 May 2020 14:49:13 +0300 Subject: [PATCH 2/2] doc: Add an example about what "(Policy)" means under `show bgp summary` Signed-off-by: Donatas Abraitis --- doc/user/bgp.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst index 2b3cc9e535..cb343e8dad 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -420,6 +420,23 @@ Require policy on EBGP This is enabled by default. + When the incoming or outgoing filter is missing you will see + "(Policy)" sign under ``show bgp summary``: + + .. code-block:: frr + + exit1# show bgp summary + + IPv4 Unicast Summary: + BGP router identifier 10.10.10.1, local AS number 65001 vrf-id 0 + BGP table version 4 + RIB entries 7, using 1344 bytes of memory + Peers 2, using 43 KiB of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt + 192.168.0.2 4 65002 8 10 0 0 0 00:03:09 5 (Policy) + fe80:1::2222 4 65002 9 11 0 0 0 00:03:09 (Policy) (Policy) + Reject routes with AS_SET or AS_CONFED_SET types ------------------------------------------------