Merge "Migrate OpenFlow Protocol dev docs to rst"
[docs.git] / manuals / user-guide / src / main / asciidoc / bgpcep / odl-bgpcep-bgp-all-user.adoc
1 == BGP User Guide ==
2
3 === Configuring BGP ===
4
5 The OpenDaylight Karaf distribution comes pre-configured with a baseline BGP
6 configuration. You can find it in the `etc/opendaylight/karaf` directory and it
7 consists of two files:
8
9 `31-bgp.xml`:: defines the basic parser and RIB support
10 `41-bgp-example.xml`:: contains a sample configuration which needs to be
11   customized to your deployment)
12
13 The next sections will describe how to configure BGP manually or using RESTCONF.
14
15 ==== RIB ====
16
17 The configuration of the Routing Information Base (RIB) is specified using a block in the `41-bgp-example.xml` file.
18
19 [source,xml]
20 ----
21 <module>
22     <type>prefix:rib-impl</type>
23     <name>example-bgp-rib</name>
24     <rib-id>example-bgp-rib</rib-id>
25     <local-as>64496</local-as>
26     <bgp-id>192.0.2.2</bgp-id>
27     <cluster-id>192.0.2.3</cluster-id>
28     ...
29 </module>
30 ----
31
32 - *type* - should always be set to `prefix:rib-impl`
33 - *name* and *rib-id* - BGP RIB Identifier, you can specify multiple BGP RIBs by
34 having multiple the above `module` blocks. Each such RIB must have a unique rib-id and name.
35 - *local-as* - the local AS number (where OpenDaylight is deployed), we use this in best path selection
36 - *bgp-id* - the local BGP identifier (the IP of the VM where OpenDaylight is deployed),
37 we use this in best path selection.
38 - *cluster-id* - cluster identifier, optional, if not specified, BGP Identifier will be used
39
40 Depending on your BGP router, you might need to switch from
41 linkstate attribute type 99 to 29. Check with your router vendor. Change the
42 field iana-linkstate-attribute-type to true if your router supports type 29.
43 This snippet is located in `31-bgp.xml` file.
44
45 [source,xml]
46 ----
47 <module>
48  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:linkstate">prefix:bgp-linkstate</type>
49  <name>bgp-linkstate</name>
50  <iana-linkstate-attribute-type>true</iana-linkstate-attribute-type>
51 </module>
52 ----
53
54 - *iana-linkstate-attribute-type* - IANA has issued an early allocation for the
55 BGP linkstate path attribute (=29). To preserve he old value (=99) set this to
56 to false; to use IANA assigned type set the value to true or remove it as it's true by default.
57
58 ==== BGP Peer ====
59
60 The initial configuration is written so that it will be ignored to prevent the
61 client from starting with default configuration. Therefore the first step is to
62 uncomment the module containing bgp-peer.
63
64 [source,xml]
65 ----
66 <module>
67  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-peer</type>
68  <name>example-bgp-peer</name>
69  <host>192.0.2.1</host>
70  <holdtimer>180</holdtimer>
71  <peer-role>ibgp</peer-role>
72  <rib>
73   <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:rib-instance</type>
74   <name>example-bgp-rib</name>
75  </rib>
76  ...
77 </module>
78 ----
79
80 - *name* - BGP Peer name, in this configuration file you specify multiple BGP Peers by replicating the above `module` block. Each peers must have a unique name.
81 - *host* - IP address or hostname of BGP speaker where OpenDaylight should connect to the peer
82 - *holdtimer* - hold time in seconds
83 - *peer-role* - If peer role is not present, default value "ibgp" will be used (other allowed values are "ebgp" and "rr-client"). This field is case-sensitive.
84 - *rib* - BGP RIB identifier
85
86 ==== Configure Connection Attributes (Optional) ====
87
88 [source,xml]
89 ----
90 <module>
91    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:reconnectstrategy">prefix:timed-reconnect-strategy</type>
92    <name>example-reconnect-strategy</name>
93    <min-sleep>1000</min-sleep>
94    <max-sleep>180000</max-sleep>
95    <sleep-factor>2.00</sleep-factor>
96    <connect-time>5000</connect-time>
97    <executor>
98        <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-event-executor</type>
99        <name>global-event-executor</name>
100    </executor>
101 </module>
102 ----
103
104 - *min-sleep* - minimum sleep time (miliseconds) in between reconnect tries
105 - *max-sleep* - maximum sleep time (miliseconds) in between reconnect tries
106 - *sleep-factor* - power factor of the sleep time between reconnect tries, i.e., the previous sleep time will be multiplied by this number to determine the next sleep time, but never exceed *max-sleep*
107 - *connect-time* - how long BGP should wait (miliseconds) for the TCP connect
108 attempt, overrides default connection timeout dictated by TCP.
109
110
111 ==== BGP Speaker Configuration ====
112
113 The previous entries described configuration of a BGP connections initiated by
114 OpenDaylight. OpenDaylight can also accept incoming BGP connections.
115
116 The configuration of BGP speaker is located in: `41-bgp-example.xml`:
117
118 [source,xml]
119 ----
120 <module>
121     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-peer-acceptor</type>
122     <name>bgp-peer-server</name>
123
124     <!--Default parameters-->
125     <!--<binding-address>0.0.0.0</binding-address>-->
126     <!--<binding-port>1790</binding-port>-->
127
128     ...
129     <!--Drops or accepts incoming BGP connection, every BGP Peer that should be accepted needs to be added to this registry-->
130     <peer-registry>
131         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-peer-registry</type>
132         <name>global-bgp-peer-registry</name>
133     </peer-registry>
134 </module>
135 ----
136
137 - 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_.
138 - Changing binding port: Uncomment tag binding-port and change the port to e.g.
139   _1790_. The default binding port is _179_ as specified in link:http://tools.ietf.org/html/rfc4271[RFC 4271].
140
141 ==== Incomming BGP Connections ====
142
143 *The BGP speaker drops all BGP connections from unknown BGP peers.* The decision is
144 made in component bgp-peer-registry that is injected into the speaker (The
145 registry is configured in `31-bgp.xml`).
146
147 To add a BGP Peer configuration into the registry, it is necessary to configure
148 regular BGP peer just like in example in `41-bgp-example.xml`. Notice that the
149 BGP peer depends on the same bgp-peer-registry as bgp-speaker:
150
151 [source,xml]
152 ----
153 <module>
154     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-peer</type>
155     <name>example-bgp-peer</name>
156     <host>192.0.2.1</host>
157     ...
158     <peer-registry>
159         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-peer-registry</type>
160         <name>global-bgp-peer-registry</name>
161     </peer-registry>
162     ...
163 </module>
164 ----
165
166 The BGP peer registers itself into the registry, which allows incoming BGP
167 connections handled by the bgp-speaker. (Config attribute peer-registry is
168 optional for now to preserve backwards compatibility). With this configuration,
169 the connection to 192.0.2.1 is initiated by OpenDaylight but will also be accepted from
170 192.0.2.1. In case both connections are being established, only one of them
171 will be preserved and the other will be dropped. The connection initiated from
172 device with lower BGP id will be dropped by the registry.  Each BGP peer must
173 be configured in its own `module` block. Note, that the name of the module needs to be
174 unique, so if you are configuring more peers, when changing the *host*, also change
175 the *name*.
176
177 To configure a peer that only listens for incoming connections and instruct
178 OpenDaylight not to initiate the connection, add the initiate-connection attribute
179 to peer's configuration and set it to false:
180
181 [source,xml]
182 ----
183 <module>
184     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-peer</type>
185     <name>example-bgp-peer</name>
186     <host>192.0.2.1</host>                         // IP address or hostname of the speaker
187     <holdtimer>180</holdtimer>
188     <initiate-connection>false</initiate-connection>  // Connection will not be initiated by ODL
189     ...
190 </module>
191 ----
192
193 - *initiate-connection* - if set to false OpenDaylight will not initiate connection to this peer. Default value is true.
194
195 ==== BGP Application Peer  ====
196
197 A BGP speaker needs to register all peers that can be connected to it (meaning if
198 a BGP peer is not configured, the connection with OpenDaylight won't be
199 successful). As a first step, configure RIB. Then, instead of configuring
200 regular peer, configure this application peer, with its own application RIB.
201 Change the bgp-peer-id, which is your local BGP ID that will be
202 used in BGP best path selection algorithm.
203
204 [source,xml]
205 ----
206 <module>
207  <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">x:bgp-application-peer</type>
208  <name>example-bgp-peer-app</name>
209  <bgp-peer-id>10.25.1.9</bgp-peer-id>
210  <target-rib>
211   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">x:rib-instance</type>
212   <name>example-bgp-rib</name>
213  </target-rib>
214  <application-rib-id>example-app-rib</application-rib-id>
215  ...
216 </module>
217 ----
218
219 - *bgp-peer-id* - the local BGP identifier (the IP of the VM where OpenDaylight is deployed), we use this in best path selection
220 - *target-rib* - RIB ID of existing RIB where the data should be transferred
221 - *application-rib-id* - RIB ID of local application RIB (all the routes that you put to OpenDaylight will be displayed here)
222
223 //TODO: internal link to Populate RIB
224 //To populate RIB use 
225
226 //TODO: internal jump to section?
227 //In order to get routes advertised to other peers, you have to also configure the peers, as described in section BGP Peer 
228
229 === Configuration through RESTCONF ===
230
231 Another method to configure BGP is dynamically through RESTCONF. Instead of
232 restarting Karaf, install another feature, that provides you the access to
233 'restconf/config/' URLs.
234
235   feature:install odl-netconf-connector-all
236
237 To check what modules you have currently configured, check following link:
238 http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules/
239
240 This URL is also used to POST new configuration. If you want to change any
241 other configuration that is listed here, make sure you include the correct
242 namespaces. RESTCONF will tell you if some namespace is wrong.
243
244 To update  an existing configuration use *PUT* and give the full path to the element you  wish to update.
245
246 It is vital that you respect the order of steps described in user guide.
247
248 ==== RIB ====
249
250 First, configure the RIB. This module is already present in the configuration,
251 therefore we change only the parameters we need. In this case, it's
252 *bgp-rib-id* and *local-as*.
253
254 *URL:*
255 _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_
256
257 *PUT:*
258 [source,xml]
259 ----
260 <module xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
261  <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">x:rib-impl</type>
262  <name>example-bgp-rib</name>
263  <session-reconnect-strategy xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
264   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:protocol:framework">x:reconnect-strategy-factory</type>
265   <name>example-reconnect-strategy-factory</name>
266  </session-reconnect-strategy>
267  <rib-id xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">example-bgp-rib</rib-id>
268  <extensions xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
269   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:spi">x:extensions</type>
270   <name>global-rib-extensions</name>
271  </extensions>
272  <codec-tree-factory xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
273   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">x:binding-codec-tree-factory</type>
274   <name>runtime-mapping-singleton</name>
275  </codec-tree-factory>
276  <tcp-reconnect-strategy xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
277   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:protocol:framework">x:reconnect-strategy-factory</type>
278   <name>example-reconnect-strategy-factory</name>
279  </tcp-reconnect-strategy>
280  <data-provider xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
281   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">x:binding-async-data-broker</type>
282   <name>pingpong-binding-data-broker</name>
283  </data-provider>
284  <local-as xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">64496</local-as>
285  <bgp-dispatcher xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
286   <type>bgp-dispatcher</type>
287   <name>global-bgp-dispatcher</name>
288  </bgp-dispatcher>
289  <dom-data-provider xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
290   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">x:dom-async-data-broker</type>
291   <name>pingpong-broker</name>
292  </dom-data-provider>
293  <local-table xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
294   <type>bgp-table-type</type>
295   <name>ipv4-unicast</name>
296  </local-table>
297  <local-table xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
298   <type>bgp-table-type</type>
299   <name>ipv6-unicast</name>
300  </local-table>
301  <local-table xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
302   <type>bgp-table-type</type>
303   <name>linkstate</name>
304  </local-table>
305  <local-table xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
306   <type>bgp-table-type</type>
307   <name>ipv4-flowspec</name>
308  </local-table>
309  <local-table xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
310   <type>bgp-table-type</type>
311   <name>ipv6-flowspec</name>
312  </local-table>
313  <local-table xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
314   <type>bgp-table-type</type>
315   <name>labeled-unicast</name>
316  </local-table>
317  <bgp-rib-id xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">192.0.2.2</bgp-rib-id>
318  <openconfig-provider xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
319   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp-openconfig-spi">x:bgp-openconfig-provider</type>
320   <name>openconfig-bgp</name>
321  </openconfig-provider>
322 </module>
323 ----
324
325 Depending on your BGP router, you might need to switch from
326 linkstate attribute type 99 to 29. Check with your router vendor. Change the
327 field iana-linkstate-attribute-type to true if your router supports type 29.
328 You can do that with the following RESTCONF operation:
329
330 *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_
331
332 *PUT:*
333 [source,xml]
334 ----
335 <module xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
336  <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:linkstate">x:bgp-linkstate</type>
337  <name>bgp-linkstate</name>
338  <iana-linkstate-attribute-type xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:linkstate">true</iana-linkstate-attribute-type>
339 </module>
340 ----
341
342 ==== BGP Peer ====
343
344 We also need to add a new module to configuration (bgp-peer). In this case, the
345 whole module needs to be configured. Please change values *host*, *holdtimer*
346 and *peer-role* (if necessary).
347
348 *URL:*  _http://127.0.0.1:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules_
349
350 *POST:*
351
352 [source,xml]
353 ----
354 <module xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
355  <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">x:bgp-peer</type>
356  <name>example-bgp-peer</name>
357  <host xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">192.0.2.1</host>
358  <holdtimer xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">180</holdtimer>
359  <peer-role xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">ibgp</peer-role>
360  <rib xmlns"urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
361   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">x:rib-instance</type>
362   <name>example-bgp-rib</name>
363  </rib>
364  <peer-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
365   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">x:bgp-peer-registry</type>
366   <name>global-bgp-peer-registry</name>
367  </peer-registry>
368  <advertized-table xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
369   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">x:bgp-table-type</type>
370   <name>ipv4-unicast</name>
371  </advertized-table>
372  <advertized-table xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
373   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">x:bgp-table-type</type>
374   <name>ipv6-unicast</name>
375  </advertized-table>
376  <advertized-table xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
377   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">x:bgp-table-type</type>
378   <name>linkstate</name>
379  </advertized-table>
380  <advertized-table xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
381   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">x:bgp-table-type</type>
382   <name>ipv4-flowspec</name>
383  </advertized-table>
384  <advertized-table xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
385   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">x:bgp-table-type</type>
386   <name>ipv6-flowspec</name>
387  </advertized-table>
388  <advertized-table xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
389   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">x:bgp-table-type</type>
390   <name>labeled-unicast</name>
391  </advertized-table>
392 </module>
393 ----
394
395 This is all necessary information that you need to get ODL connect to your speaker.
396
397 ==== BGP Application Peer ====
398
399 Change the value *bgp-peer-id* which is your local BGP ID that will be used in
400 BGP Best Path Selection algorithm.
401
402 *URL:* _http://127.0.0.1:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules_
403
404 *POST:*
405 [source,xml]
406 ----
407 <module xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
408  <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">x:bgp-application-peer</type>
409  <name>example-bgp-peer-app</name>
410  <bgp-peer-id xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">10.25.1.9</bgp-peer-id> <!-- Your local BGP-ID that will be used in BGP Best Path Selection algorithm -->
411  <target-rib xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
412   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">x:rib-instance</type>
413   <name>example-bgp-rib</name>
414   </target-rib>
415  <application-rib-id xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">example-app-rib</application-rib-id>
416  <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">
417   <type xmlns:x="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">x:dom-async-data-broker</type>
418   <name>pingpong-broker</name>
419  </data-broker>
420 </module>
421 ----
422
423 === Tutorials ===
424
425 ==== Viewing BGP Topology ====
426
427 This section summarizes how data from BGP can be viewed through RESTCONF. Currently it is the only way to view the data.
428
429 ===== Network Topology View =====
430
431 The URL for network topology is: http://localhost:8181/restconf/operational/network-topology:network-topology/
432
433 If BGP is configured properly, it should display output similar to:
434
435 [source,xml]
436 ----
437 <network-topology>
438  <topology>
439   <topology-id>pcep-topology</topology-id>
440   <topology-types>
441    <topology-pcep/>
442   </topology-types>
443  </topology>
444  <topology>
445   <server-provided>true</server-provided>
446   <topology-id>example-ipv4-topology</topology-id>
447   <topology-types/>
448  </topology>
449  <topology>
450   <server-provided>true</server-provided>
451   <topology-id>example-linkstate-topology</topology-id>
452   <topology-types/>
453  </topology>
454 </network-topology>
455 ----
456
457 BGP topology information as learned from BGP peers are is in three topologies (if all three are configured):
458
459 * *example-linkstate-topology* - displays links and nodes advertised through linkstate update messages
460
461 ** http://localhost:8181/restconf/operational/network-topology:network-topology/topology/example-linkstate-topology
462
463 * *example-ipv4-topology* - display IPv4 addresses of nodes in the topology
464
465 ** http://localhost:8181/restconf/operational/network-topology:network-topology/topology/example-ipv4-topology
466
467 * *example-ipv6-topology* - display IPv6 addresses of nodes in the topology
468
469 ** http://localhost:8181/restconf/operational/network-topology:network-topology/topology/example-ipv6-topology
470
471 ===== Route Information Base (RIB) View =====
472
473 Another view of BGP data is through *BGP RIBs*, located here: http://localhost:8181/restconf/operational/bgp-rib:bgp-rib/
474
475 There are multiple RIBs configured:
476
477 - AdjRibsIn (per Peer) : Adjacency RIBs In, BGP routes as they come from BGP Peer
478 - EffectiveRib (per Peer) : BGP routes after applying Import policies
479 - LocRib (per RIB) : Local RIB, BGP routes from all peers
480 - AdjRibsOut (per Peer) : BGP routes that will be advertizes, after applying Export policies
481
482 This is how the empty output looks like, when address families for IPv4 Unicast, IPv6 Unicast, IPv4 Flowspec, IPv6 Flowspec, IPv4 Labeled Unicast and Linkstate were configured: 
483
484 [source,xml]
485 ----
486 <loc-rib xmlns="urn:opendaylight:params:xml:ns:yang:bgp-rib">
487   <tables>
488     <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv6-address-family</afi>
489     <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
490     <attributes>
491       <uptodate>false</uptodate>
492     </attributes>
493     <ipv6-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
494     </ipv6-routes>
495   </tables>
496   <tables>
497     <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
498     <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
499     <attributes>
500       <uptodate>false</uptodate>
501     </attributes>
502     <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
503     </ipv4-routes>
504   </tables>
505   <tables>
506     <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
507     <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-flowspec">x:flowspec-subsequent-address-family</safi>
508     <attributes>
509       <uptodate>false</uptodate>
510     </attributes>
511     <flowspec-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-flowspec">
512     </flowspec-routes>
513   </tables>
514   <tables>
515     <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv6-address-family</afi>
516     <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-flowspec">x:flowspec-subsequent-address-family</safi>
517     <attributes>
518       <uptodate>false</uptodate>
519     </attributes>
520     <flowspec-ipv6-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-flowspec">
521     </flowspec-ipv6-routes>
522   </tables>
523   <tables>
524     <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
525     <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-labeled-unicast">x:labeled-unicast-subsequent-address-family</safi>
526     <attributes>
527       <uptodate>false</uptodate>
528     </attributes>
529     <labeled-unicast-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-labeled-unicast">
530     </labeled-unicast-routes>
531   </tables>
532   <tables>
533     <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-linkstate">x:linkstate-address-family</afi>
534     <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-linkstate">x:linkstate-subsequent-address-family</safi>
535     <attributes>
536       <uptodate>false</uptodate>
537     </attributes>
538     <linkstate-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-linkstate">
539     </linkstate-routes>
540   </tables>
541 </loc-rib>
542 ----
543
544 You can see details for each AFI by expanding the RESTCONF link:
545
546 * *IPv4 Unicast* : 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
547
548 * *IPv6 Unicast* : http://localhost:8181/restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/loc-rib/tables/bgp-types:ipv6-address-family/bgp-types:unicast-subsequent-address-family/ipv6-routes
549
550 * *IPv4 Labeled Unicast* : http://localhost:8181/restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/loc-rib/tables/bgp-types:ipv4-address-family/bgp-labeled-unicast:labeled-unicast-subsequent-address-family/bgp-labeled-unicast:labeled-unicast-routes
551
552 * *IPv4 Flowspec* : http://localhost:8181/restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/loc-rib/tables/bgp-types:ipv4-address-family/bgp-flowspec:flowspec-subsequent-address-family/bgp-flowspec:flowspec-routes
553
554 * *IPv6 Flowspec* : http://localhost:8181/restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/loc-rib/tables/bgp-types:ipv6-address-family/bgp-flowspec:flowspec-subsequent-address-family/bgp-flowspec:flowspec-ipv6-routes
555
556 * *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
557
558 ==== Populate RIB ====
559
560 If an application peer is configured, you can populate its RIB by making POST calls to RESTCONF like the following.
561
562 ===== IPv4 Unicast =====
563
564 *Add route:*
565
566 *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/bgp-inet:ipv4-routes/
567
568 - 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.
569
570 *Method:* POST
571
572 *Content-Type:* application/xml
573
574 [source,xml]
575 ----
576  <?xml version="1.0" encoding="UTF-8" standalone="no"?>
577   <ipv4-route xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
578    <prefix>1.1.1.1/32</prefix>
579    <attributes>
580     <ipv4-next-hop>
581      <global>199.20.160.41</global>
582     </ipv4-next-hop><as-path/>
583     <multi-exit-disc>
584      <med>0</med>
585     </multi-exit-disc>
586     <local-pref>
587      <pref>100</pref>
588     </local-pref>
589     <originator-id>
590      <originator>41.41.41.41</originator>
591     </originator-id>
592     <origin>
593      <value>igp</value>
594     </origin>
595     <cluster-id>
596      <cluster>40.40.40.40</cluster>
597     </cluster-id>
598    </attributes>
599   </ipv4-route>
600 ----
601
602 The request results in *204 No content*. This is expected.
603
604 *Delete route:*
605
606 *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/bgp-inet:ipv4-routes/bgp-inet:ipv4-route/<route-id>
607
608 *Method:* DELETE
609
610 ===== IPv6 Unicast =====
611
612 *Add route:*
613
614 *URL:* http://localhost:8181/restconf/config/bgp-rib:application-rib/example-app-rib/tables/bgp-types:ipv6-address-family/bgp-types:unicast-subsequent-address-family/bgp-inet:ipv6-routes/
615
616 *Method:* POST
617
618 *Content-Type:* application/xml
619
620 [source,xml]
621 ----
622   <ipv6-route xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
623    <prefix>2001:db8:30::3/128</prefix>
624    <attributes>
625     <ipv6-next-hop>
626      <global>2001:db8:1::6</global>
627     </ipv6-next-hop>
628     <as-path/>
629     <origin>
630      <value>egp</value>
631     </origin>
632    </attributes>
633   </ipv6-route>
634 ----
635
636 The request results in *204 No content*. This is expected.
637
638 *Delete route:*
639
640 *URL:*  http://localhost:8181/restconf/config/bgp-rib:application-rib/example-app-rib/tables/bgp-types:ipv6-address-family/bgp-types:unicast-subsequent-address-family/bgp-inet:ipv6-routes/bgp-inet:ipv6-route/<route-id>
641
642 *Method:* DELETE
643
644 ===== IPv4 Labeled Unicast =====
645
646 *Add route:*
647
648 *URL:* http://localhost:8181/restconf/config/bgp-rib:application-rib/example-app-rib/tables/bgp-types:ipv4-address-family/bgp-labeled-unicast:labeled-unicast-subsequent-address-family/bgp-labeled-unicast:labeled-unicast-routes
649
650 *Method:* POST
651
652 *Content-Type:* application/xml
653
654 [source,xml]
655 ----
656   <labeled-unicast-route xmlns="urn:opendaylight:params:xml:ns:yang:bgp-labeled-unicast">
657    <route-key>label1</route-key>
658    <prefix>1.1.1.1/32</prefix>
659    <label-stack>
660     <label-value>123</label-value>
661    </label-stack>
662    <label-stack>
663     <label-value>456</label-value>
664    </label-stack>
665    <label-stack>
666     <label-value>342</label-value>
667    </label-stack>
668    <attributes>
669     <ipv4-next-hop>
670      <global>199.20.160.41</global>
671     </ipv4-next-hop>
672     <origin>
673      <value>igp</value>
674     </origin>
675     <as-path/>
676     <local-pref>
677      <pref>100</pref>
678     </local-pref>
679    </attributes>
680   </labeled-unicast-route>
681 ----
682
683 The request results in *204 No content*. This is expected.
684
685 *Delete route:*
686
687 *URL:*  http://localhost:8181/restconf/config/bgp-rib:application-rib/example-app-rib/tables/bgp-types:ipv4-address-family/bgp-labeled-unicast:labeled-unicast-subsequent-address-family/bgp-labeled-unicast:labeled-unicast-routes/bgp-labeled-unicast:labeled-unicast-route/<route-id>
688
689 *Method:* DELETE
690
691 ===== IPv4 Flowspec =====
692
693 *Add route:*
694
695 *URL:* http://localhost:8181/restconf/config/bgp-rib:application-rib/example-app-rib/tables/bgp-types:ipv4-address-family/bgp-flowspec:flowspec-subsequent-address-family/bgp-flowspec:flowspec-routes
696
697 *Method:* POST
698
699 *Content-Type:* application/xml
700
701 [source,xml]
702 ----
703 <flowspec-route xmlns="urn:opendaylight:params:xml:ns:yang:bgp-flowspec">
704   <route-key>flow1</route-key>
705   <flowspec>
706     <destination-prefix>192.168.0.1/32</destination-prefix>
707   </flowspec>
708   <flowspec>
709     <source-prefix>10.0.0.1/32</source-prefix>
710   </flowspec>
711   <flowspec>
712     <protocol-ips>
713       <op>equals end-of-list</op>
714       <value>6</value>
715     </protocol-ips>
716   </flowspec>
717   <flowspec>
718     <ports>
719       <op>equals end-of-list</op>
720       <value>80</value>
721     </ports>
722   </flowspec>
723   <flowspec>
724     <destination-ports>
725       <op>greater-than</op>
726       <value>8080</value>
727     </destination-ports>
728     <destination-ports>
729       <op>and-bit less-than end-of-list</op>
730       <value>8088</value>
731     </destination-ports>
732   </flowspec>
733   <flowspec>
734     <source-ports>
735       <op>greater-than end-of-list</op>
736       <value>1024</value>
737     </source-ports>
738   </flowspec>
739   <flowspec>
740     <types>
741       <op>equals end-of-list</op>
742       <value>0</value>
743     </types>
744   </flowspec>
745   <flowspec>
746     <codes>
747       <op>equals end-of-list</op>
748       <value>0</value>
749     </codes>
750   </flowspec>
751   <flowspec>
752     <tcp-flags>
753       <op>match end-of-list</op>
754       <value>32</value>
755     </tcp-flags>
756   </flowspec>
757   <flowspec>
758     <packet-lengths>
759       <op>greater-than</op>
760       <value>400</value>
761     </packet-lengths>
762     <packet-lengths>
763       <op>and-bit less-than end-of-list</op>
764        <value>500</value>
765     </packet-lengths>
766   </flowspec>
767   <flowspec>
768     <dscps>
769       <op>equals end-of-list</op>
770       <value>20</value>
771     </dscps>
772   </flowspec>
773   <flowspec>
774     <fragments>
775       <op>match end-of-list</op>
776       <value>first</value>
777     </fragments>
778   </flowspec>
779   <attributes>
780     <origin>
781       <value>igp</value>
782     </origin>
783     <as-path/>
784     <local-pref>
785       <pref>100</pref>
786     </local-pref>
787     <extended-communities>
788     ....
789     </extended-communities>
790   </attributes>
791 </flowspec-route>
792 ----
793
794 *Flowspec Extended Communities (Actions):*
795
796 [source,xml]
797 ----
798   <extended-communities>
799     <transitive>true</transitive>
800     <traffic-rate-extended-community>
801       <informative-as>123</informative-as>
802       <local-administrator>AAAAAA==</local-administrator>
803     </traffic-rate-extended-community>
804   </extended-communities>
805
806   <extended-communities>
807     <transitive>true</transitive>
808     <traffic-action-extended-community>
809       <sample>true</sample>
810       <terminal-action>false</terminal-action>
811     </traffic-action-extended-community>
812   </extended-communities>
813
814   <extended-communities>
815     <transitive>true</transitive>
816     <redirect-extended-community>
817       <global-administrator>123</global-administrator>
818       <local-administrator>AAAAew==</local-administrator>
819     </redirect-extended-community>
820   </extended-communities>
821
822   <extended-communities>
823     <transitive>true</transitive>
824     <redirect-ipv4>
825       <global-administrator>192.168.0.1</global-administrator>
826       <local-administrator>12345</local-administrator>
827     </redirect-ipv4>
828   </extended-communities>
829
830   <extended-communities>
831     <transitive>true</transitive>
832     <redirect-as4>
833       <global-administrator>64495</global-administrator>
834       <local-administrator>12345</local-administrator>
835     </redirect-as4>
836   </extended-communities>
837
838   <extended-communities>
839     <transitive>true</transitive>
840     <redirect-ip-nh-extended-community>
841       <copy>false</false>
842     </redirect-ip-nh-extended-community>
843   </extended-communities>
844
845   <extended-communities>
846     <transitive>true</transitive>
847     <traffic-marking-extended-community>
848       <global-administrator>20</global-administrator>
849     </traffic-marking-extended-community>
850   </extended-communities>
851 ----
852
853 The request results in *204 No content*. This is expected.
854
855 *Delete route:*
856
857 *URL:* http://localhost:8181/restconf/config/bgp-rib:application-rib/example-app-rib/tables/bgp-types:ipv4-address-family/bgp-flowspec:flowspec-subsequent-address-family/bgp-flowspec:flowspec-routes/bgp-flowspec:flowspec-route/<route-id>
858
859 *Method:* DELETE
860
861 ===== IPv6 Flowspec =====
862
863 *Add route:*
864
865 *URL:* http://localhost:8181/restconf/config/bgp-rib:application-rib/example-app-rib/tables/bgp-types:ipv6-address-family/bgp-flowspec:flowspec-subsequent-address-family/bgp-flowspec:flowspec-ipv6-routes
866
867 *Method:* POST
868
869 *Content-Type:* application/xml
870
871 [source,xml]
872 ----
873 <flowspec-route xmlns="urn:opendaylight:params:xml:ns:yang:bgp-flowspec">
874   <route-key>flow-v6</route-key>
875   <flowspec>
876     <destination-prefix>2001:db8:30::3/128</destination-prefix>
877   </flowspec>
878   <flowspec>
879     <source-prefix>2001:db8:31::3/128</source-prefix>
880   </flowspec>
881   <flowspec>
882     <flow-label>
883       <op>equals end-of-list</op>
884       <value>1</value>
885     </flow-label>
886   </flowspec>
887   <attributes>
888     <extended-communities>
889       <redirect-ipv6>
890         <global-administrator>2001:db8:1::6</global-administrator>
891         <local-administrator>12345</local-administrator>
892       </redirect-ipv6>
893     </extended-communities>
894     <origin>
895       <value>igp</value>
896     </origin>
897     <as-path/>
898     <local-pref>
899       <pref>100</pref>
900     </local-pref>
901   </attributes>
902 </flowspec-route>
903 ----
904
905 The request results in *204 No content*. This is expected.
906
907 *Delete route:*
908
909 *URL:* http://localhost:8181/restconf/config/bgp-rib:application-rib/example-app-rib/tables/bgp-types:ipv6-address-family/bgp-flowspec:flowspec-subsequent-address-family/bgp-flowspec:flowspec-ipv6-routes/bgp-flowspec:flowspec-route/<route-id>
910
911 *Method:* DELETE