Skip to content
LinkState
Go back

Normalizing BGP summaries without flattening peer state

Introduction to BGP Summary and Per-Neighbor CLI

Overview of BGP Protocol

The Border Gateway Protocol (BGP) is a standardized exterior gateway protocol designed to exchange routing and reachability information among autonomous systems (AS) on the Internet. BGP is a crucial component of the Internet’s infrastructure, enabling networks to communicate with each other and facilitating the exchange of traffic. The protocol operates over TCP, using port 179, and is widely used for both IPv4 and IPv6 routing.

Importance of AFI, SAFI, and Neighbor Status

Address Family Identifier (AFI) and Subsequent Address Family Identifier (SAFI) are essential components of BGP, as they define the type of network layer reachability information being exchanged. AFI specifies the address family (e.g., IPv4 or IPv6), while SAFI specifies the sub-address family (e.g., unicast or multicast). Understanding the AFI and SAFI is crucial for configuring and troubleshooting BGP sessions. Neighbor status is also vital, as it indicates the state of the BGP session between two peers.

Understanding Current CLI Limitations

Single Status String Issues

The current show bgp summary and show bgp neighbor CLI commands provide a single status string, which can be ambiguous and does not offer sufficient information about the BGP session. This limitation can lead to difficulties in identifying the root cause of issues, as the status string may not accurately reflect the underlying problem.

Loss of Context in Current Implementation

The current implementation loses context when displaying the BGP neighbor status, making it challenging to understand the specific issue affecting the session. For example, the status string may indicate that a neighbor is in an “idle” state, but it does not provide information about the reason for this state or any error messages that may be relevant.

Need for Detailed Error Context

To improve the effectiveness of BGP troubleshooting and configuration, it is essential to have a detailed error context that provides information about the specific issues affecting the BGP session. This includes error messages, AFI and SAFI information, admin shutdown status, and graceful restart capabilities.

Designing a New Schema

Preserving AFI and SAFI Information

The new schema should preserve AFI and SAFI information to ensure that the BGP session details are accurately represented. This includes displaying the AFI and SAFI values for each neighbor, as well as any relevant error messages or status information.

Incorporating Admin Shutdown and Graceful Restart

The new schema should incorporate admin shutdown and graceful restart information to provide a more comprehensive view of the BGP session. This includes indicating whether the neighbor is administratively shut down or if graceful restart is enabled.

Adding Per-Peer Error Context

The new schema should include per-peer error context to provide detailed information about any issues affecting the BGP session. This includes error messages, error codes, and any relevant debugging information.

CLI Syntax and Examples

Show BGP Summary with Detailed Status

The show bgp summary command should be modified to display detailed status information, including AFI and SAFI values, admin shutdown status, and graceful restart capabilities.

Router# show bgp summary
BGP router identifier 10.1.1.1, local AS number 100
BGP table version is 12, main routing table version 12
12 network entries using 1248 bytes of memory
12 path entries using 936 bytes of memory
2/2 BGP path/bestpath attribute entries using 248 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 2576 total bytes of memory
BGP activity 12/10 prefixes, 20/18 paths, scan interval 60 secs
Neighbor        V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.1.1.2        4 200 12     11     12     0    0    00:10:12 Established 
                 AFI: IPv4, SAFI: Unicast
                 Admin Shutdown: No, Graceful Restart: Yes
                 Error Context: None

Show BGP Neighbor with Error Context

The show bgp neighbor command should be modified to display detailed error context information, including error messages and error codes.

Router# show bgp neighbor 10.1.1.2
BGP neighbor is 10.1.1.2, remote AS 200, external link
BGP version 4, remote router ID 10.1.1.2
BGP state = Established, up for 00:10:12
Last read 00:00:12, last write 00:00:12
Hold time is 180, keepalive interval is 60 seconds
Configured hold time is 180, configured keepalive interval is 60 seconds
Neighbor sessions: 1 active, is not multisession capable
Message statistics:
  InQ depth is 0
  OutQ depth is 0
AFI: IPv4, SAFI: Unicast
Admin Shutdown: No, Graceful Restart: Yes
Error Context:
  Error Code: 5, Error Message: "Neighbor reset due to BGP notification"
  Error Code: 3, Error Message: "BGP notification sent due to malformed attribute"

Code Examples for Common Use Cases

The following code example demonstrates how to use the show bgp summary and show bgp neighbor commands to troubleshoot a BGP session issue:

import netmiko

# Establish a connection to the router
router = netmiko.ConnectHandler(device_type='cisco_ios', ip='10.1.1.1', username='admin', password='password')

# Execute the show bgp summary command
summary_output = router.send_command('show bgp summary')

# Parse the output to extract the neighbor information
neighbor_info = []
for line in summary_output.splitlines():
    if 'Neighbor' in line:
        neighbor_info.append(line.split()[0])

# Execute the show bgp neighbor command for each neighbor
for neighbor in neighbor_info:
    neighbor_output = router.send_command(f'show bgp neighbor {neighbor}')
    print(neighbor_output)

# Close the connection to the router
router.disconnect()

Troubleshooting with the New Schema

Identifying Neighbor-Specific Issues

The new schema provides detailed information about each BGP neighbor, including AFI and SAFI values, admin shutdown status, and graceful restart capabilities. This information can be used to identify neighbor-specific issues, such as misconfigured AFI or SAFI values or admin shutdown errors.

Debugging AFI and SAFI Configuration Errors

The new schema provides detailed error context information, including error messages and error codes. This information can be used to debug AFI and SAFI configuration errors, such as mismatched AFI or SAFI values between neighbors.

Using Error Context for Root Cause Analysis

The new schema provides detailed error context information, including error messages and error codes. This information can be used to perform root cause analysis of BGP session issues, such as identifying the cause of a neighbor reset or a BGP notification.

Scaling Limitations and Considerations

Large-Scale BGP Deployments

The new schema may have scaling limitations in large-scale BGP deployments, where the number of neighbors and AFI/SAFI combinations is very large. In such cases, the schema may need to be optimized to reduce the amount of data being collected and processed.

Performance Impact of Detailed Status

The new schema may have a performance impact on the router, as it requires more processing power and memory to collect and display the detailed status information. This impact can be mitigated by optimizing the schema and using filtering and aggregation techniques to reduce the amount of data being collected.

Mitigating Scaling Limitations with Filtering and Aggregation

To mitigate the scaling limitations of the new schema, filtering and aggregation techniques can be used to reduce the amount of data being collected and processed. For example, the schema can be configured to only collect data for specific AFI/SAFI combinations or to aggregate data for multiple neighbors.

Implementation and Migration

Updating Existing CLI Tools

The existing CLI tools will need to be updated to support the new schema. This includes modifying the show bgp summary and show bgp neighbor commands to display the detailed status information.

Backward Compatibility and Migration Strategies

To ensure backward compatibility, the new schema should be designed to be compatible with existing BGP configurations and protocols. A migration strategy should be developed to transition from the old schema to the new schema, including updating existing CLI tools and configuring the new schema.

Example Migration Scripts and Code Snippets

The following code example demonstrates how to migrate from the old schema to the new schema:

import netmiko

# Establish a connection to the router
router = netmiko.ConnectHandler(device_type='cisco_ios', ip='10.1.1.1', username='admin', password='password')

# Configure the new schema
router.send_config_set(['bgp log-neighbor-changes', 'bgp graceful-restart'])

# Update the existing CLI tools
router.send_config_set(['ip bgp-community new-format'])

# Verify the new schema is configured correctly
summary_output = router.send_command('show bgp summary')
print(summary_output)

# Close the connection to the router
router.disconnect()

Security Considerations and Best Practices

Securing BGP Sessions and Neighbor Connections

BGP sessions and neighbor connections should be secured using authentication and encryption mechanisms, such as MD5 or IPsec.

Protecting Against Common BGP Attacks

BGP sessions and neighbor connections should be protected against common BGP attacks, such as prefix hijacking and route leaks.

Implementing Secure BGP Configuration and Monitoring

A secure BGP configuration and monitoring strategy should be implemented, including configuring BGP authentication and encryption, monitoring BGP sessions and neighbor connections, and detecting and responding to BGP security incidents.

Conclusion and Future Development

Future Enhancements to the BGP Schema

The BGP schema can be further enhanced to include additional features and functionality, such as support for new AFI/SAFI combinations and improved error context information.

Integrating with Other Networking Protocols

The BGP schema can be integrated with other networking protocols, such as OSPF and IS-IS, to provide a more comprehensive view of the network.

Ongoing Maintenance and Support

The BGP schema should be regularly maintained and updated to ensure it remains compatible with evolving BGP standards and protocols. Ongoing support should be provided to address any issues or concerns that may arise.


Share this post on:

Previous Post
Telemetry lag or real stability after a phase
Next Post
Semantic diffs beat line diffs for review