Skip to content

[backport] Fix BGP CLI bug for dynamic neighbors (#4409)#312

Merged
prabhataravind merged 1 commit into
Azure:202506from
NavdhaJindal:cherry/msft-202506/4409
Apr 23, 2026
Merged

[backport] Fix BGP CLI bug for dynamic neighbors (#4409)#312
prabhataravind merged 1 commit into
Azure:202506from
NavdhaJindal:cherry/msft-202506/4409

Conversation

@NavdhaJindal

Copy link
Copy Markdown

Backport request for PR: sonic-net/sonic-utilities#4409

What I did

  1. Certain bgp CLI commands like show ip bgp sum,show ip bgp neighbors <neighbor-ip> and show ip bgp neighbors <neighbor-ip> routes do not work for dynamic neighbors. Fixed the CLI by parsing dynamic BGP neighbors correctly.
  2. These fixes also result in the neighborName being displayed correctly for dynamic neighbors in the bgp summary.
  3. In addition, fixed a bug for static neighbors where the vrf name was not being checked (when specified). A neighbor IP match would return true even if the neighbor was configured in a different vrf.
  4. Fixed vrf all show commands, eg show ip bgp vrf all sum. Earlier it would combine the summaries for different vrfs into one table. Separated them out for clarity and to match VTYSH output.

How I did it

  1. Removed dependency on src_address from dynamic neighbor parsing for bgp summary, which is an optional field.
  2. Added dynamic neighbor parsing for show ip bgp neighbors <neighbor-ip>. Earlier dynamic neighbors were not being checked at all.
  3. enhanced existing static neighbor parsing to also compare the vrf name instead of partial check on IP

How to verify it

Run show ip bgp sum,show ip bgp neighbors <neighbor-ip>,show ip bgp neighbors <neighbor-ip> routes on a DUT with dynamic neighbors, verify CLI output

Previous command output (if the output of a command-line utility has changed)

show ip bgp neighbors <neighbor-ip> for dynamic neighbors

(bash)$ show ip bgp neighbors 100.112.28.131 routes
Usage: show ip bgp neighbors [OPTIONS] [IPADDRESS] [[routes|advertised-routes|received-routes]]

Try "show ip bgp neighbors -h" for help.

Error: Bgp neighbor 100.112.28.131 not configured

show ip bgp sum for dynamic neighbors

(bash)$ show ip bgp vrf Vnet_7244744 sum
Usage: show ip bgp vrf sum [OPTIONS]
Try "show ip bgp vrf sum -h" for help.

Error: v4 missing in the bgp summary

show ip bgp vrf all sum

show ip bgp vrf all sum

IPv4 Unicast Summary:
BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0
BGP table version 12
BGP router identifier 0.0.0.0, local AS number 65100 vrf-id -1
BGP table version 0
RIB entries 12807, using 1639428 bytes of memory
Peers 4, using 96288 KiB of memory
Peer groups 5, using 320 bytes of memory


Neighbhor      V     AS    MsgRcvd    MsgSent    TblVer    InQ    OutQ  Up/Down    State/PfxRcd    NeighborName
-----------  ---  -----  ---------  ---------  --------  -----  ------  ---------  --------------  --------------
10.0.0.57      4  64600          0          0         0      0       0  never      Idle            ARISTA01T1
10.0.0.59      4  64600      10882       6552        12      0       0  05:27:14   2               ARISTA02T1
10.0.0.61      4  64600      10891       6549        12      0       0  05:27:15   2               ARISTA03T1
10.0.0.63      4  64600      10901       6549        12      0       0  05:27:15   2               ARISTA04T1

Total number of neighbors 4

New command output (if the output of a command-line utility has changed)

show ip bgp neighbors <neighbor-ip> for dynamic neighbors

(bash)$ show ip bgp neighbors 100.112.28.132 routes
BGP table version is 85343, local router ID is 25.65.143.15, vrf id 0
Default local pref 100, local AS 64625
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

   Network          Next Hop        Metric LocPrf Weight Path
*  10.140.197.221/32
                   100.112.28.185       0             64959 64959 64959 64959 64959 64959 64959 64959 64959 64959
64959 64959 64959 64959 64959 64959 64959 64959 i
*> 10.140.220.40/32 100.112.28.185       0             64959 i

Displayed 2 routes and 17165 total paths

show ip bgp sum for dynamic neighbors

(bash)$ show ip bgp vrf Vnet_7127926 sum

IPv4 Unicast Summary:
BGP router identifier 10.5.0.10, local AS number 64639 vrf-id 25
BGP table version 2
RIB entries 1, using 128 bytes of memory
Peers 2, using 48144 KiB of memory
Peer groups 1, using 64 bytes of memory

Neighbor        V    AS           MsgRcvd  MsgSent  TblVer  InQ  OutQ  Up/Down   State/PfxRcd  NeighborName
-----------------------------------------------------------------------------------------------------
10.5.0.9        4  4210000062        1346     1147       2    0     0  19:03:43   1   WLPARTNER_PASSIVE_V4
10.5.0.11       4  4210000062        1349     1147       2    0     0  19:03:43   1   WLPARTNER_PASSIVE_V4

Total number of neighbors 2

show ip bgp vrf all sum

IPv4 Unicast Summary:
BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0
BGP table version 12
RIB entries 12808, using 1639100 bytes of memory
Peers 3, using 71288 KiB of memory
Peer groups 4, using 64 bytes of memory


Neighbhor      V     AS    MsgRcvd    MsgSent    TblVer    InQ    OutQ  Up/Down    State/PfxRcd    NeighborName
-----------  ---  -----  ---------  ---------  --------  -----  ------  ---------  --------------  --------------
10.0.0.59      4  64600      10882       6552        12      0       0  05:27:14   2               ARISTA02T1
10.0.0.61      4  64600      10891       6549        12      0       0  05:27:15   2               ARISTA03T1
10.0.0.63      4  64600      10901       6549        12      0       0  05:27:15   2               ARISTA04T1

Total number of neighbors 3

IPv4 Unicast Summary:
BGP router identifier 0.0.0.0, local AS number 65100 vrf-id -1
BGP table version 0
RIB entries 12808, using 128 bytes of memory
Peers 1, using 25000 KiB of memory
Peer groups 5, using 320 bytes of memory


Neighbhor      V     AS    MsgRcvd    MsgSent    TblVer    InQ    OutQ  Up/Down    State/PfxRcd    NeighborName
-----------  ---  -----  ---------  ---------  --------  -----  ------  ---------  --------------  --------------
10.0.0.57      4  64600          0          0         0      0       0  never      Idle            ARISTA01T1

Total number of neighbors 1

What I did
Certain bgp CLI commands like show ip bgp sum,show ip bgp neighbors <neighbor-ip> and show ip bgp neighbors <neighbor-ip> routes do not work for dynamic neighbors. Fixed the CLI by parsing dynamic BGP neighbors correctly.
These fixes also result in the neighborName being displayed correctly for dynamic neighbors in the bgp summary.
In addition, fixed a bug for static neighbors where the vrf name was not being checked (when specified). A neighbor IP match would return true even if the neighbor was configured in a different vrf.
Fixed vrf all show commands, eg show ip bgp vrf all sum. Earlier it would combine the summaries for different vrfs into one table. Separated them out for clarity and to match VTYSH output.
How I did it
Removed dependency on src_address from dynamic neighbor parsing for bgp summary, which is an optional field.
Added dynamic neighbor parsing for show ip bgp neighbors <neighbor-ip>. Earlier dynamic neighbors were not being checked at all.
enhanced existing static neighbor parsing to also compare the vrf name instead of partial check on IP
How to verify it
Run show ip bgp sum,show ip bgp neighbors <neighbor-ip>,show ip bgp neighbors <neighbor-ip> routes on a DUT with dynamic neighbors, verify CLI output
@prabhataravind prabhataravind merged commit 0116bea into Azure:202506 Apr 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants