== BGP User Guide == === Overview === The OpenDaylight Karaf distribution comes pre-configured with baseline BGP configuration. You can find it in the etc/opendaylight/karaf directory and it consists of two files: - *31-bgp.xml* (defines the basic parser and RIB support) - *41-bgp-example.xml* (which contains a sample configuration which needs to be customized to your deployment) The next sections will describe how to configure BGP manually or using RESTCONF. === Configuring BGP === ==== RIB ==== [source,xml] ---- prefix:rib-impl example-bgp-rib example-bgp-rib 64496 192.0.2.2 192.0.2.3 ... ---- - *rib-id* - BGP RIB Identifier, in this configuration file you can specify more BGP RIBs by copy-pasting the above module. These RIBs must have a unique rib-id and name. - *local-as* - Our local AS number (where OpenDaylight is deployed), we use this in best path selection - *bgp-id* - Our local BGP identifier (the IP of the VM where OpenDaylight is deployed), we use this in best path selection. - *cluster-id* - Cluster Identifier, non-mandatory, if not specified, BGP Identifier will be used MIGHT NOT BE NEEDED: depending on your BGP router, you might need to switch from linkstate attribute type 99 to 29. Check with your router vendor. Change the field iana-linkstate-attribute-type to true if your router supports type 29. This snippet is located in 31-bgp.xml file. [source,xml] ---- prefix:bgp-linkstate bgp-linkstate true ---- - *iana-linkstate-attribute-type* - IANA has issued an early allocation for the BGP Linkstate path attribute (=29). To preserve (TYPE = 99) set value bellow to false; to use IANA assigned type set the value to true or remove it as it's true by default. ==== BGP Peer ==== The initial configuration is written so that it will be ignored to prevent the client from starting with default configuration. Therefore the first step is to uncomment the module containing bgp-peer. [source,xml] ---- prefix:bgp-peer example-bgp-peer 192.0.2.1 180 ibgp prefix:rib-instance example-bgp-rib ... ---- - *name* - BGP Peer name, in this configuration file you can specify more BGP Peers by copy-pasting the above module. These peers must have a *unique* name. - *host* - IP address or hostname of BGP speaker (IP where OpenDaylight should connect to gather topology) - *holdtimer* - unit: seconds - *peer-role* - If peer role is not present, default value "ibgp" will be used (allowed values are also "ebgp" and "rr-client"). This field is case-sensitive. - *rib* - BGP RIB identifier ==== Configure Connection Attributes - OPTIONAL ==== [source,xml] ---- prefix:timed-reconnect-strategy example-reconnect-strategy 1000 180000 2.00 5000 netty:netty-event-executor global-event-executor ---- - *min-sleep* - Minimum sleep time (miliseconds) in between reconnect tries - *max-sleep* - Maximum sleep time (miliseconds) in between reconnect tries - *sleep-factor* - Power factor of the sleep time between reconnect tries - *connect-time* - How long we should wait (miliseconds) for the TCP connect attempt, overrides default connection timeout dictated by TCP retransmits ==== BGP Speaker Configuration ==== Previous entries addressed the configuration of a BGP connection initiated by OpenDaylight. OpenDaylight also supports BGP Speaker functionality and accepts incoming BGP connections. *The configuration of BGP speaker is located in: 41-bgp-example.xml: [source,xml] ---- prefix:bgp-peer-acceptor bgp-peer-server ... prefix:bgp-peer-registry global-bgp-peer-registry ---- *Changing speaker configuration* - Changing binding address: Uncomment tag binding-address and change the address to e.g. _127.0.0.1_. The default binding address is _0.0.0.0_. - Changing binding port: Uncomment tag binding-port and change the port to e.g. _1790_. The default binding port is _179_ as specified in link:http://tools.ietf.org/html/rfc4271[BGP RFC]. -- ==== Incomming BGP Connections ==== *BGP speaker drops all BGP connections from unknown BGP peers.* The decision is made in component bgp-peer-registry that is injected into the speaker (The registry is configured in 31-bgp.xml). To add BGP Peer configuration into the registry, it is necessary to configure regular BGP peer just like in example in 41-bgp-example.xml. Notice that the BGP peer depends on the same bgp-peer-registry as bgp-speaker: [source,xml] ---- prefix:bgp-peer example-bgp-peer 192.0.2.1 ... prefix:bgp-peer-registry global-bgp-peer-registry ... ---- The BGP peer registers itself into the registry, which allows incoming BGP connections handled by the bgp-speaker. (Config attribute peer-registry is optional for now to preserve backwards compatibility). With this configuration, the connection to 192.0.2.1 is initiated by OpenDaylight but will also be accepted from 192.0.2.1. In case both connections are being established, only one of them will be preserved and the other will be dropped. The connection initiated from device with lower bgp id will be dropped by the registry. Each BGP peer must be configured in its own module. Note, that the name of the module needs to be unique, so if you are configuring more peers, when changing the *host*, change also the *name*. There is a way to configure the peer only for incoming connections (The connection will not be initiated by the OpenDaylight, OpenDaylight will only wait for incoming connection from the peer. The peer is identified by its IP address). To configure peer only for incoming connection add attribute initiate-connection to peer's configuration: [source,xml] ---- prefix:bgp-peer example-bgp-peer 192.0.2.1 // IP address or hostname of the speaker 180 false // Connection will not be initiated by ODL ... ---- - *initiate-connection* - if set to false OpenDaylight will not initiate connection to this peer. Default value is true for all peers. ==== BGP Application Peer ==== A BGP speaker needs to register all peers that can be connected to it (meaning if a BGP peer is not configured, the connection with OpenDaylight won't be successful). As a first step, configure RIB. Then, instead of configuring regular peer, configure this application peer, with its own application RIB. Change the value in bold bgp-peer-id which is your local BGP-ID that will be used in BGP Best Path Selection algorithm. [source,xml] ---- x:bgp-application-peer example-bgp-peer-app 10.25.1.9 x:rib-instance example-bgp-rib example-app-rib ... ---- - *bgp-peer-id* - Our local BGP identifier (the IP of the VM where OpenDaylight is deployed), we use this in best path selection - *target-rib* - RIB ID of existing RIB where the data should be transferred - *application-rib-id* - RIB ID of local application RIB (all the routes that you put to OpenDaylight will be displayed here) //TODO: internal link to Populate RIB //To populate RIB use //TODO: internal jump to section? //In order to get routes advertised to other peers, you have to also configure the peers, as described in section BGP Peer === Configuration through RESTCONF === Another method to configure BGP is dynamically through RESTCONF. Before you start, make sure, you've completed steps 1-5 in Installation Guide. Instead of restarting Karaf, install another feature, that provides you the access to 'restconf/config/' URLs. feature:install odl-netconf-connector-all To check what modules you have currently configured, check following link: http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules/ This URL is also used to POST new configuration. If you want to change any other configuration that is listed here, make sure you include the correct namespaces. RESTCONF will tell you if some namespace is wrong. To update an existing configuration use *PUT* and give the full path to the element you wish to update. It is vital that you respect the order of steps described in user guide. ==== RIB ==== First, configure RIB. This module is already present in the configuration, therefore we change only the parameters we need. In this case, it's *bgp-rib-id* and *local-as*. *URL:* _ _http://127.0.0.1:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules/module/odl-bgp-rib-impl-cfg:rib-impl/example-bgp-rib_ *PUT:* [source,xml] ---- x:rib-impl example-bgp-rib x:reconnect-strategy-factory example-reconnect-strategy-factory example-bgp-rib x:extensions global-rib-extensions x:binding-codec-tree-factory runtime-mapping-singleton x:reconnect-strategy-factory example-reconnect-strategy-factory x:binding-async-data-broker pingpong-binding-data-broker 64496 bgp-dispatcher global-bgp-dispatcher x:dom-async-data-broker pingpong-broker bgp-table-type ipv4-unicast bgp-table-type ipv6-unicast bgp-table-type linkstate bgp-table-type flowspec 192.0.2.2 ---- IMPORTANT: MIGHT NOT BE NEEDED depending on your BGP router, you might need a switch from linkstate attribute type 99 to 29. Check with your router vendor. Switch the field to true if your router supports type 29. *URL:* _http://127.0.0.1:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules/module/odl-bgp-linkstate-cfg:bgp-linkstate/bgp-linkstate_ *PUT:* [source,xml] ---- x:bgp-linkstate bgp-linkstate true ---- ==== BGP Peer ==== We also need to add new module to configuration (bgp-peer). In this case, the whole module needs to be configured. Please change values *host*, *holdtimer* and *peer-role* (if necessary). .*POST:* [source,xml] ---- x:bgp-peer example-bgp-peer 192.0.2.1 180 ibgp x:rib-instance example-bgp-rib x:bgp-peer-registry global-bgp-peer-registry x:bgp-table-type ipv4-unicast x:bgp-table-type ipv6-unicast x:bgp-table-type linkstate x:bgp-table-type flowspec ---- This is all necessary information that you need to get ODL connect to your speaker. ==== BGP Application Peer ==== Change the value *bgp-peer-id* which is your local BGP ID that will be used in BGP Best Path Selection algorithm. .*POST:* [source,xml] ---- x:bgp-application-peer example-bgp-peer-app 10.25.1.9 x:rib-instance example-bgp-rib example-app-rib x:dom-async-data-broker pingpong-broker ---- === Tutorials === ==== Viewing BGP Topology ==== This section summarizes how data from BGP can be viewed through RESTCONF. Currently it is the only way to view the data. IMPORTANT: From Helium release the port changed from 8080 to 8181. ===== Network Topology View ===== Basic URL for network topology is *http://localhost:8181/restconf/operational/network-topology:network-topology/* . If BGP is configured properly, it should display output similar to this one: [source,xml] ---- pcep-topology true example-ipv4-topology true example-linkstate-topology ---- BGP data as were sent from BGP speaker are listed in three topologies (if all three are configured): *example-linkstate-topology* - displays links and nodes advertised through linkstate Update messages http://localhost:8181/restconf/operational/network-topology:network-topology/topology/example-linkstate-topology *example-ipv4-topology* - display Ipv4 adresses of nodes in the topology http://localhost:8181/restconf/operational/network-topology:network-topology/topology/example-ipv4-topology *example-ipv6-topology* - display Ipv6 adresses of nodes in the topology http://localhost:8181/restconf/operational/network-topology:network-topology/topology/example-ipv6-topology ===== Route Information Base (RIB) View ===== Another view of BGP data is through *BGP RIBs*, located here: http://localhost:8181/restconf/operational/bgp-rib:bgp-rib/ There are multiple RIBs configured: - AdjRibsIn (per Peer) : Adjacency RIBs In, BGP routes as they come from BGP Peer - EffectiveRib (per Peer) : BGP routes after applying Import policies - LocRib (per RIB) : Local RIB, BGP routes from all peers - AdjRibsOut (per Peer) : BGP routes that will be advertizes, after applying Export policies This is how the output looks like, when address families for IPv4 and Linkstate were configured: [source,xml] ---- x:linkstate-subsequent-address-family x:linkstate-address-family x:unicast-subsequent-address-family x:ipv4-address-family ---- You can see details for each AFI by expanding the RESTCONF link: *IPv4* : http://localhost:8181/restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/loc-rib/tables/bgp-types:ipv4-address-family/bgp-types:unicast-subsequent-address-family/ipv4-routes *Linkstate* : http://localhost:8181/restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/loc-rib/tables/bgp-linkstate:linkstate-address-family/bgp-linkstate:linkstate-subsequent-address-family/linkstate-routes ==== Populate RIB ==== If your peer is configured, you can populate the RIB by making following POST call to RESTCONF: *URL:* http://localhost:8181/restconf/config/bgp-rib:application-rib/example-app-rib/tables/bgp-types:ipv4-address-family/bgp-types:unicast-subsequent-address-family/ - where example-app-rib is your application RIB id (that you specified in the configuration) and tables specifies AFI and SAFI of the data that you want to add. *POST:* *Content-Type:* application/xml [source,xml] ---- 200.20.160.1/32 199.20.160.41 0 100 41.41.41.41 igp 40.40.40.40 ---- The request results in *204 No content*. This is expected.