Open Ethernet Networking (OpEN) API Guide and Reference Manual  3.6.0.3
Border Gateway Protocol (BGP)

This document provides a brief description of the BGP OpEN APIs. The BGP OpEN APIs allow processes outside of the ICOS main process (switchdrvr) access to BGP and its routing management services.

Global Configuration

In addition to providing the ability to create and delete a BGP entry with its local Autonomous System Number (ASN), the global OpEN_API's available are;

Neighbor Configuration

In addition to providing the ability to create and delete internal or external BGP peers with its associated ASN, the following OpEN API's for managing BGP peers are available;

All 'Set' operations would affect the Switch behavior and configuration.

Example C Application bgp_example

Initialization

In the main function, the sample application initializes the OpEN API RPC service by calling openapiClientRegister() and waits for the RPC service in switchdrvr to start. A Client Handle is returned by openapiClientRegister() which is used while invoking the OpEN APIs. The application then exercises the associated OpEN APIs and logs informational and/or error messages on the console. The example application runs to its completion and exits.

bgp_example

bgp_example.c is a sample application that demonstrates the use of the BGP OpEN API. bgp_example is started from the command line. The example first establishes a BGP entry with an ASN of 1 using an IPv4 address (1.1.1.1) as its identifier. The example continues to test the ability to set and get the available global attributes. The following is a list and sequence of these tests;

The second part of the bgp_example creates two (2) local peers, the first is a IPv4 peer (2.2.2.2) and the second, a IPv6 peer (2222::). The bgp_example continues to exercise the remaining BGP OpEN APIs one by one for each peer with appropriate arguments to demonstrate its capabilities using the ICOS main process (switchdrvr). The following is a list and sequence of these peer tests;

And lastly, this sample application retrieves the first available routing interface and demonstrates the following OpEN_API tests.

Sample Output (LiNe/LinuxHost platform)

Please note that a display containing Feature not supported is shown in the output if appropriate.

# ./bgp_example

Begin Sanity tests...
Establish BGP and global parameters...
Sanity Success - testLocalAS
Sanity Success - testLocalId
Sanity Success - testLocalPref
Sanity Success - testDistance
Sanity Success - testDistance
Sanity Success - testDistance
Sanity Success - testGlobalHoldTime
Sanity Success - testGlobalKeepAlive
Sanity Success - testLogNeighbor
Sanity Success - testMaxPaths
Sanity Success - testMaxPaths
Sanity Success - testNetwork
Sanity Success - testRedistribution
Create a ipv4 test peer...
Sanity Success - testPeerRemoteAS
Sanity Success - testPeerAdminStatus
Sanity Success - testPeerKeepAlive
Sanity Success - testPeerHoldTime
Sanity Success - testPeerActivate
Sanity Success - testPeerAdvertisement
Sanity Success - testPeerNextHopSelf
Sanity Success - testPeerPfxLimit
Create a ipv6 test peer...
Sanity Success - testPeerRemoteAS
Sanity Success - testPeerAdminStatus
Sanity Success - testPeerKeepAlive
Sanity Success - testPeerHoldTime
Sanity Success - testPeerActivate
Sanity Success - testPeerAdvertisement
Sanity Success - testPeerNextHopSelf
Sanity Success - testPeerPfxLimit
Sanity Success - testPeerRemoteAS
Sanity Success - testPeerUpdateSource
Complete.

Example Python Application bgp_example

In addition to bgp_example.c, a python implementation has also been provided for demonstration purposes. This python bgp_example.py script essentially duplicates the bgp_example.c implementation.

Example Ruby Application bgp_example

In addition to bgp_example.c, a ruby implementation has also been provided for demonstration purposes. This ruby bgp_example.rb application essentially duplicates the bgp_example.c implementation.

Example Ruby Applications to monitor BGP status

The below ruby implementations have also been provided to monitor BGP status and statistics for demonstration purposes.

bgp_flapCount

bgp_flapCount.rb is a sample application that demonstrates the use of the BGP OpEN API to view the flap count of a neighbor.

Sample Output

# ./bgp_flapCount.rb –ipv4

ICOS Version 3.9.23.21
OpEN version = 1.0.0.0

Remote Address ........................ 1.1.1.1
Remote AS ............................. 100
Flap Count ............................ 1

Remote Address ........................ 2.2.2.2
Remote AS ............................. 100
Flap Count ............................ 0

bgp_flapCountClearOnRead

bgp_flapCountClearOnRead.rb is a sample application that demonstrates the use of the BGP OpEN API to clear the flap count of a neighbor.

Sample Output

# ./bgp_flapCountClearOnRead.rb –ipv4

ICOS Version 3.9.23.21
OpEN version = 1.0.0.0

Remote Address ........................ 1.1.1.1
Remote AS ............................. 100
Flap Count ............................ 1

Remote Address ........................ 2.2.2.2
Remote AS ............................. 100
Flap Count ............................ 0

bgp_neighbors

bgp_neighbors.rb is a sample application that demonstrates the use of the BGP OpEN API to display neighbors.

Sample Output

# ./bgp_neighbors.rb –ipv4

ICOS Version 3.9.23.21
OpEN version = 1.0.0.0

Remote Address .................................... 1.1.1.1
Remote AS ......................................... 100
Peer ID ........................................... 1.1.1.1
Peer Admin Status ................................. START
Peer State ........................................ ACTIVE
Local Interface Address ........................... 1.1.1.2
Local Port ........................................ 53145
Remote Port ....................................... 179
Connection Retry Interval ......................... 2 sec
Neighbor Capabilities ............................. MP RF
IPv4 Unicast Support .............................. Both
IPv6 Unicast Support .............................. None
Template Name ..................................... None
Update Source ..................................... None
Configured Hold Time .............................. None
Configured Keep Alive Time ........................ None
MD5 Password ...................................... None
Last Error ........................................ Cease (Received)
Last SubError ..................................... None
Time Since Last Error ............................. 0 days 00 hrs 08 mins 51 secs
Established Transitions ........................... 1
Flap Count ........................................ 1
Established Time .................................. 0 days 00 hrs 08 mins 51 secs
Time Since Last Update ............................ 0 days 06 hrs 01 mins 54 secs
IPv4 Outbound Update Group ........................ None
IPv6 Outbound Update Group ........................ None<br>

         Open    Update    Keepalive    Notification    Refresh    Total<br>

Msgs Sent 1 2 816 1 0 820
Msgs Rcvd 1 2 819 0 0 822

Received UPDATE Queue Size: 0 bytes. High: 34 Limit: 392192 Drops: 0

IPv4 Prefix Statistics:
Inbound Outbound
Prefixes Advertised 3 6
Prefixes Withdrawn 0 0
Prefixes Current 0 0
Prefixes Accepted 0 N/A
Prefixes Rejected 0 N/A
Max NLRI per Update 3 3
Min NLRI per Update 0 3

bgp_statistics

bgp_statistics.rb is a sample application that demonstrates the use of the BGP OpEN API to display BGP process statistics.

Sample Output

# ./bgp_statistics.rb –ipv4<br>

ICOS Version 3.9.23.21
OpEN version = 1.0.0.0

Delta T Phase Upd Grp GenId Reason Peer Duration Adds Mods Dels
06:06:03 3 0 0 New update grp 0 0 0 0
06:06:02 1 0 Adj-RIB-In+ 1 6 0 0
06:06:02 2 1 Phase 1 done 1 3 0 0
06:06:02 3 0 1 Phase 2 done 0 3 0 0
06:05:58 2 2 Local route add 0 1 2 0
06:05:31 3 0 2 Phase 2 done 0 1 2 0
00:12:28 2 3 Accept-RIB-In- 0 0 1 0
00:12:28 3 0 3 Phase 2 done 0 0 1 0
00:12:27 2 4 Local route del 0 0 0 1
00:11:58 3 0 4 Phase 2 done 0 0 0 1

bgp_summary

bgp_summary.rb is a sample application that demonstrates the use of the BGP OpEN API to display BGP summary.

Sample Output

# ./bgp_summary.rb –ipv4<br>

ICOS Version 3.9.23.21
OpEN version = 1.0.0.0

IPv4 Routing .................................. Enabled
BGP Admin Mode ................................ Enabled
BGP Router ID ................................. 1.1.1.2
Local AS Number ............................... 200
Number of Network Entries ..................... 3
Number of AS Paths ............................ 1

Neighbor ASN MsgRcvd MsgSent State Up/Down Time Pfx Rcvd
-------------— --— -----— -----— ----------— -----------— ------—
1.1.1.1 100 822 820 ACTIVE 0:00:14:36 0
2.2.2.2 100 857 852 ESTABLISHED 0:06:08:11 2

BGP CLI/API Cross Reference

CLI Command OpEN API Reference
(Config)#
[no] router bgp <asn>
openapiBgpLocalASGet()
openapiBgpLocalASSet()
(Config-router)#
[no] bgp router-id <ip-address>
openapiBgpLocalIdGet()
openapiBgpLocalIdSet()
(Config-router)#
[no] bgp default local-preference <pref>
openapiBgpLocalPrefGet()
openapiBgpLocalPrefSet()
(Config-router)#
[no] distance bgp <external> <internal> <local>
openapiIpRouterPreferenceGet()
openapiIpRouterPreferenceSet()
(Config-router)#
[no] timers bgp <keep-alive-time> <hold-time>
openapiBgpGlobalHoldTimeConfiguredGet()
openapiBgpGlobalHoldTimeConfiguredSet()
openapiBgpGlobalKeepAliveConfiguredGet()
openapiBgpGlobalKeepAliveConfiguredSet()
(Config-router)#
[no] bgp log-neighbor-changes
openapiBgpLogNeighborChangesGet()
openapiBgpLogNeighborChangesSet()
(Config-router)#
[no] maximum-paths ibgp <paths>
openapiBgpMaxPathsGet()
openapiBgpMaxPathsSet()
(Config-router)#
[no] network <ip-address> mask <ip-mask> route-map <route-name>
openapiBgpNetworkAddDelete()
(Config-router)#
[no] redistribute <connected|ospf|rip|static> <match|metric|route-map>
openapiBgpRedistributionSet()
(Config-router)#
[no] neighbor <ipv4|ipv6> remote-as <asn>
openapiBgpPeerRemoteASGet()
openapiBgpPeerRemoteASSet()
(Config-router)#
[no] neighbor <ipv4|ipv6> shutdown
openapiBgpPeerAdminStatusGet()
openapiBgpPeerAdminStatusSet()
(Config-router)#
[no] neighbor timers <keep-alive-time> <hold-time>
openapiBgpPeerKeepAliveConfiguredGet()
openapiBgpPeerKeepAliveConfiguredSet()
openapiBgpPeerHoldTimeConfiguredGet()
openapiBgpPeerHoldTimeConfiguredSet()
(Config-router)#
[no] neighbor bgp advertisement-interval
openapiBgpPeerAdvertisementIntervalGet()
openapiBgpPeerAdvertisementIntervalSet()
(Config-router)#
[no] neighbor next-hop-self
openapiBgpPeerNextHopSelfModeGet()
openapiBgpPeerNextHopSelfModeSet()
(Config-router)#
[no] neighbor maximum-prefix
openapiBgpPeerPfxLimitGet()
openapiBgpPeerPfxLimitSet()
(Config-router)#
[no] neighbor update-source
openapiBgpPeerUpdateSourceGet()
openapiBgpPeerUpdateSourceSet()
(Config-router-af)#
[no] neighbor <ipv4|ipv6> activate
openapiBgpPeerActivateGet()
openapiBgpPeerActivateSet()
(Priv-User Mode)#
show ip bgp summary
show bgp ipv6 summary
openapiBgpAdminModeGet()
openapiBgpLocalASGet()
openapiBgpLocalIdGet()
openapiBgpMapGlobalStatusInfoGet()
openapiBgpPeerActivateGet()
openapiBgpPeerRemoteASGet()
openapiRtrAdminModeGet()
openapiBgpMapPeerRemoteAddrGetNext()
openapiBgpMapPeerStatusGet()
(Priv-User Mode)#
show ip bgp neighbors
show bgp ipv6 neighbors
openapiBgpAdminModeGet()
openapiBgpLocalIdGet()
openapiBgpMapPeerPasswordGet()
openapiBgpMapPeerPasswordMaxLengthGet()
openapiBgpPeerActivateGet()
openapiBgpPeerAdminStatusGet()
openapiBgpPeerDescriptionGet()
openapiBgpPeerDescriptionNameMaxLengthGet()
openapiBgpPeerHoldTimeConfiguredGet()
openapiBgpPeerInheritGet()
openapiBgpPeerKeepAliveConfiguredGet()
openapiBgpPeerRemoteASGet()
openapiBgpPeerUpdateSourceGet()
openapiBgpTemplateNameMaxLengthGet()
openapiIntfNameSizeGet()
openapiRtrAdminModeGet()
openapiRtrIntfNameGet()
openapiBgpMapPeerConnRetryIntervalGet()
openapiBgpMapPeerRemoteAddrGetNext()
openapiBgpMapPeerStatusGet()
(Priv-User Mode)#
show ip bgp statistics
show bgp ipv6 statistics
openapiBgpAdminModeGet()
openapiBgpLocalIdGet()
openapiBgpMapDecProcHistoryCountGet()
openapiBgpMapDecProcHistoryByIndexGet()
openapiIsInetAddrZero()
openapiRtrAdminModeGet()
(Priv-User Mode)#
show ip bgp neighbors | include Flap
and to clear flap counters
openapiBgpAdminModeGet()
openapiBgpLocalIdGet()
openapiBgpMapPeerFlapCountGet()
openapiRtrAdminModeGet()
openapiBgpMapPeerRemoteAddrGetNext()
openapiBgpMapPeerStatusGet()