Skip to content

Conversation

@JoshYangEC
Copy link

In alias mode, the output of "show ip/ipv6 bgp summary" and "show ip/ipv6 bgp neigh" return errors. This PR is used to fix these errors.

What I did

After setting alias mode, the output of "show ip/ipv6 bgp summary" and "show ip/ipv6 bgp neighbors" return errors. This PR fixes the issue to support alias mode for these bgp commands.

How I did it

enhance the function run_bgp_show_command in bgp_util.py to support alias mode for the following commands:

  • show ip|ipv6 bgp summary
  • show ip|ipv6 bgp neighbors

In the original function run_bgp_show_command, it only handles the command show ip|ipv6 route. Here, we define a new dict structure to map the vtysh commands, as these commands require specific functions to handle the output of the vtysh command. Additionally, the function needs to convert interface names to alias names in the output of the vtysh command.

How to verify it

  1. execute "show ip bgp summary" to verify
admin@sonic:~$ SONIC_CLI_IFACE_MODE=alias show ip bgp summary

IPv4 Unicast Summary:
BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0
BGP table version 1
RIB entries 1, using 192 bytes of memory
Peers 2, using 1483952 KiB of memory
Peer groups 2, using 128 bytes of memory


Neighbhor      V     AS    MsgRcvd    MsgSent    TblVer    InQ    OutQ  Up/Down    State/PfxRcd    NeighborName
-----------  ---  -----  ---------  ---------  --------  -----  ------  ---------  --------------  --------------
10.0.0.1       4  65200          0          0         0      0       0  never      Active          ARISTA01T2
10.0.0.3       4  65200          0          0         0      0       0  never      Active          ARISTA02T2

Total number of neighbors 2
  1. execute "show ipv6 bgp summary" to verify
admin@sonic:~$ SONIC_CLI_IFACE_MODE=alias show ipv6 bgp summary

IPv6 Unicast Summary:
BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0
BGP table version 1
RIB entries 1, using 192 bytes of memory
Peers 2, using 1483952 KiB of memory
Peer groups 2, using 128 bytes of memory


Neighbhor      V     AS    MsgRcvd    MsgSent    TblVer    InQ    OutQ  Up/Down    State/PfxRcd    NeighborName
-----------  ---  -----  ---------  ---------  --------  -----  ------  ---------  --------------  --------------
fc00::2        4  65200          0          0         0      0       0  never      Active          ARISTA01T2
fc00::4a       4  64003          0          0         0      0       0  never      Active          ARISTA03T0

Total number of neighbors 2
  1. execute "show ip bgp neighbors" to verify
admin@sonic:~$ SONIC_CLI_IFACE_MODE=alias show ip bgp neighbors
BGP neighbor is 10.0.0.1, remote AS 65200, local AS 65100, external link
  Local Role: undefined
  Remote Role: undefined
 Description: ARISTA01T2
 Member of peer-group PEER_V4 for session parameters
  BGP version 4, remote router ID 0.0.0.0, local router ID 10.1.0.32
  BGP state = Active
  Last read 00:18:03, Last write never
  Hold time is 10 seconds, keepalive interval is 3 seconds
  Configured hold time is 10 seconds, keepalive interval is 3 seconds
  Configured conditional advertisements interval is 60 seconds
  Graceful restart information:
    Local GR Mode: Helper*

    Remote GR Mode: NotApplicable

    R bit: False
    N bit: False
    Timers:
      Configured Restart Time(sec): 120
      Received Restart Time(sec): 0
  Message statistics:
    Inq depth is 0
    Outq depth is 0
                         Sent       Rcvd
    Opens:                  0          0
    Notifications:          0          0
    Updates:                0          0
    .......
    
    Keepalives:             0          0
    Route Refresh:          0          0
    Capability:             0          0
    Total:                  0          0
  Minimum time between advertisement runs is 0 seconds

 For address family: IPv6 Unicast
  PEER_V6 peer-group member
  Not part of any update group
  Inbound soft reconfiguration allowed
  Community attribute sent to this neighbor(all)
  Inbound path policy configured
  Outbound path policy configured
  Route map for incoming advertisements is *FROM_BGP_PEER_V6
  Route map for outgoing advertisements is *TO_BGP_PEER_V6
  0 accepted prefixes

  Connections established 0; dropped 0
  Last reset 00:18:03,  Waiting for peer OPEN
  External BGP neighbor may be up to 1 hops away.
BGP Connect Retry Timer in Seconds: 10
Next connect timer due in 5 seconds
Read thread: off  Write thread: off  FD used: -1
  1. execute "show ipv6 bgp neighbors" to verify
admin@sonic:~$ SONIC_CLI_IFACE_MODE=alias show ipv6 bgp neighbors
BGP neighbor is 10.0.0.1, remote AS 65200, local AS 65100, external link
  Local Role: undefined
  Remote Role: undefined
 Description: ARISTA01T2
 Member of peer-group PEER_V4 for session parameters
  BGP version 4, remote router ID 0.0.0.0, local router ID 10.1.0.32
  BGP state = Active
  Last read 00:18:03, Last write never
  Hold time is 10 seconds, keepalive interval is 3 seconds
  Configured hold time is 10 seconds, keepalive interval is 3 seconds
  Configured conditional advertisements interval is 60 seconds
  Graceful restart information:
    Local GR Mode: Helper*

    Remote GR Mode: NotApplicable

    R bit: False
    N bit: False
    Timers:
      Configured Restart Time(sec): 120
      Received Restart Time(sec): 0
  Message statistics:
    Inq depth is 0
    Outq depth is 0
                         Sent       Rcvd
    Opens:                  0          0
    Notifications:          0          0
    Updates:                0          0
    .......
    
    Keepalives:             0          0
    Route Refresh:          0          0
    Capability:             0          0
    Total:                  0          0
  Minimum time between advertisement runs is 0 seconds

 For address family: IPv6 Unicast
  PEER_V6 peer-group member
  Not part of any update group
  Inbound soft reconfiguration allowed
  Community attribute sent to this neighbor(all)
  Inbound path policy configured
  Outbound path policy configured
  Route map for incoming advertisements is *FROM_BGP_PEER_V6
  Route map for outgoing advertisements is *TO_BGP_PEER_V6
  0 accepted prefixes

  Connections established 0; dropped 0
  Last reset 00:18:03,  Waiting for peer OPEN
  External BGP neighbor may be up to 1 hops away.
BGP Connect Retry Timer in Seconds: 10
Next connect timer due in 5 seconds
Read thread: off  Write thread: off  FD used: -1

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

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

In alias mode, the output of "show ip/ipv6 bgp summary" and "show ip/ipv6
bgp neigh" return errors. This PR is used to fix these errors.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 6 out of 9 changed files in this pull request and generated 1 comment.

Files not reviewed (3)
  • tests/mock_tables/ip_bgp_summary_alias_empty.json: Language not supported
  • tests/mock_tables/ipv4_bgp_summary_alias.json: Language not supported
  • tests/mock_tables/ipv6_bgp_summary_alias.json: Language not supported
Comments suppressed due to low confidence (1)

utilities_common/bgp_util.py:255

  • [nitpick] The command patterns for IPv4 and IPv6 BGP summaries are inconsistent ('show ip bgp summary' vs 'show bgp ipv6 summary'). Consider unifying the syntax patterns or including additional patterns to ensure comprehensive alias conversion.
vtysh_alias_dict = {

return converter


def get_alias_neighbor_converter(vtysh_output):
Copy link

Copilot AI Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex in the get_alias_neighbor_converter function (matching 'BGP neighbor on (Ethernet[0-9]*):') may not match neighbor output lines that do not use the 'Ethernet' prefix. Consider revising the pattern to accommodate other interface naming conventions.

Copilot uses AI. Check for mistakes.
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.

1 participant