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