Merge "Update yangtools release notes for Oxygen"
[docs.git] / docs / user-guide / bgpcep-guide / bgp / bgp-user-guide-bgp-application-peer.rst
1 .. _bgp-user-guide-bgp-application-peer:
2
3 BGP Application Peer and programmable RIB
4 =========================================
5 The OpenDaylight BGP implementation also supports routes injection via *Application Peer*.
6 Such peer has its own programmable RIB, which can be modified by user.
7 This concept allows user to originate new routes and advertise them to all connected peers.
8
9 Application Peer configuration
10 ''''''''''''''''''''''''''''''
11 Following configuration sample show a way to configure the *Application Peer*:
12
13 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/neighbors``
14
15 **Method:** ``POST``
16
17 **Content-Type:** ``application/xml``
18
19 **Request Body:**
20
21 .. code-block:: xml
22    :linenos:
23    :emphasize-lines: 2,4
24
25    <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
26        <neighbor-address>10.25.1.9</neighbor-address>
27        <config>
28            <peer-group>application-peers</peer-group>
29        </config>
30    </neighbor>
31
32 @line 2: IP address is uniquely identifying *Application Peer* and its programmable RIB. Address is also used in local BGP speaker decision process.
33
34 @line 4: Indicates that peer is associated with *application-peers* group. It serves to distinguish *Application Peer's* from regular neighbors.
35
36 -----
37
38 The *Application Peer* presence can be verified via REST:
39
40 **URL:** ``/restconf/operational/bgp-rib:bgp-rib/rib/bgp-example/peer/bgp:%2F%2F10.25.1.9``
41
42 **Method:** ``GET``
43
44 **Response Body:**
45
46 .. code-block:: xml
47    :linenos:
48    :emphasize-lines: 3,8
49
50    <peer xmlns="urn:opendaylight:params:xml:ns:yang:bgp-rib">
51        <peer-id>bgp://10.25.1.9</peer-id>
52        <peer-role>internal</peer-role>
53        <adj-rib-in>
54            <tables>
55                <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
56                <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
57                <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet"></ipv4-routes>
58                <attributes>
59                    <uptodate>false</uptodate>
60                </attributes>
61            </tables>
62        </adj-rib-in>
63        <effective-rib-in>
64            <tables>
65                <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
66                <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
67                <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet"></ipv4-routes>
68                <attributes></attributes>
69            </tables>
70        </effective-rib-in>
71    </peer>
72
73 @line 3: Peer role for *Application Peer* is *internal*.
74
75 @line 8: Adj-RIB-In is empty, as no routes were originated yet.
76
77 .. note:: There is no Adj-RIB-Out for *Application Peer*.
78
79 Programmable RIB
80 ''''''''''''''''
81 Next example shows how to inject a route into the programmable RIB.
82
83 **URL:** ``/restconf/config/bgp-rib:application-rib/10.25.1.9/tables/bgp-types:ipv4-address-family/bgp-types:unicast-subsequent-address-family/bgp-inet:ipv4-routes``
84
85 **Method:** ``POST``
86
87 **Content-Type:** ``application/xml``
88
89 **Request Body:**
90
91 .. code-block:: xml
92
93    <ipv4-route xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
94        <path-id>0</path-id>
95        <prefix>10.0.0.11/32</prefix>
96        <attributes>
97            <as-path></as-path>
98            <origin>
99                <value>igp</value>
100            </origin>
101            <local-pref>
102                <pref>100</pref>
103            </local-pref>
104            <ipv4-next-hop>
105                <global>10.11.1.1</global>
106            </ipv4-next-hop>
107        </attributes>
108    </ipv4-route>
109
110 -----
111
112 Now the injected route appears in *Application Peer's* RIBs and in local speaker's Loc-RIB:
113
114 **URL:** ``/restconf/operational/bgp-rib:bgp-rib/rib/bgp-example/peer/bgp:%2F%2F10.25.1.9``
115
116 **Method:** ``GET``
117
118 **Response Body:**
119
120 .. code-block:: xml
121    :linenos:
122    :emphasize-lines: 9
123
124    <peer xmlns="urn:opendaylight:params:xml:ns:yang:bgp-rib">
125        <peer-id>bgp://10.25.1.9</peer-id>
126        <peer-role>internal</peer-role>
127        <adj-rib-in>
128            <tables>
129                <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
130                <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
131                <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
132                    <ipv4-route>
133                        <path-id>0</path-id>
134                        <prefix>10.0.0.11/32</prefix>
135                        <attributes>
136                            <as-path></as-path>
137                            <origin>
138                                <value>igp</value>
139                            </origin>
140                            <local-pref>
141                                <pref>100</pref>
142                            </local-pref>
143                            <ipv4-next-hop>
144                                <global>10.11.1.1</global>
145                            </ipv4-next-hop>
146                        </attributes>
147                    </ipv4-route>
148                </ipv4-routes>
149                <attributes>
150                    <uptodate>false</uptodate>
151                </attributes>
152            </tables>
153        </adj-rib-in>
154        <effective-rib-in>
155            <tables>
156                <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
157                <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
158                <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
159                    <ipv4-route>
160                        <path-id>0</path-id>
161                        <prefix>10.0.0.11/32</prefix>
162                        <attributes>
163                            <as-path></as-path>
164                            <origin>
165                                <value>igp</value>
166                            </origin>
167                            <local-pref>
168                                <pref>100</pref>
169                            </local-pref>
170                            <ipv4-next-hop>
171                                <global>10.11.1.1</global>
172                            </ipv4-next-hop>
173                        </attributes>
174                    </ipv4-route>
175                </ipv4-routes>
176                <attributes></attributes>
177            </tables>
178        </effective-rib-in>
179    </peer>
180
181 @line 9: Injected route is present in *Application Peer's* Adj-RIB-In and Effective-RIB-In.
182
183 -----
184
185 **URL:** ``/restconf/operational/bgp-rib:bgp-rib/rib/bgp-example/loc-rib/tables/bgp-types:ipv4-address-family/bgp-types:unicast-subsequent-address-family/ipv4-routes``
186
187 **Method:** ``GET``
188
189 **Response Body:**
190
191 .. code-block:: xml
192    :linenos:
193    :emphasize-lines: 2
194
195    <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
196        <ipv4-route>
197            <path-id>0</path-id>
198            <prefix>10.0.0.10/32</prefix>
199            <attributes>
200                <as-path></as-path>
201                <origin>
202                    <value>igp</value>
203                </origin>
204                <local-pref>
205                    <pref>100</pref>
206                </local-pref>
207                <ipv4-next-hop>
208                    <global>10.11.1.1</global>
209                </ipv4-next-hop>
210            </attributes>
211        </ipv4-route>
212        <ipv4-route>
213            <path-id>0</path-id>
214            <prefix>10.0.0.10/32</prefix>
215            <attributes>
216                <as-path></as-path>
217                <origin>
218                    <value>igp</value>
219                </origin>
220                <local-pref>
221                    <pref>100</pref>
222                </local-pref>
223                <ipv4-next-hop>
224                    <global>10.10.1.1</global>
225                </ipv4-next-hop>
226            </attributes>
227        </ipv4-route>
228    </ipv4-routes>
229
230 @line 2: The injected route is now present in Loc-RIB along with a route (destination *10.0.0.10/32*) advertised by remote peer.
231
232 -----
233
234 This route is also advertised to the remote peer (*192.0.2.1*), hence route appears in its Adj-RIB-Out:
235
236 **URL:** ``/restconf/operational/bgp-rib:bgp-rib/rib/bgp-example/peer/bgp:%2F%2F192.0.2.1/adj-rib-out/tables/bgp-types:ipv4-address-family/bgp-types:unicast-subsequent-address-family/bgp-inet:ipv4-routes``
237
238 **Method:** ``GET``
239
240 **Response Body:**
241
242 .. code-block:: xml
243
244    <ipv4-route xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
245        <path-id>0</path-id>
246        <prefix>10.0.0.11/32</prefix>
247        <attributes>
248            <as-path></as-path>
249            <origin>
250                <value>igp</value>
251            </origin>
252            <local-pref>
253                <pref>100</pref>
254            </local-pref>
255            <ipv4-next-hop>
256                <global>10.11.1.1</global>
257            </ipv4-next-hop>
258        </attributes>
259    </ipv4-route>
260
261 -----
262
263 The injected route can be modified (i.e. different path attribute):
264
265 **URL:** ``/restconf/config/bgp-rib:application-rib/10.25.1.9/tables/bgp-types:ipv4-address-family/bgp-types:unicast-subsequent-address-family/bgp-inet:ipv4-routes/ipv4-route/10.0.0.11%2F32/0``
266
267 **Method:** ``PUT``
268
269 **Content-Type:** ``application/xml``
270
271 **Request Body:**
272
273 .. code-block:: xml
274
275    <ipv4-route xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
276        <path-id>0</path-id>
277        <prefix>10.0.0.11/32</prefix>
278        <attributes>
279            <as-path></as-path>
280            <origin>
281                <value>igp</value>
282            </origin>
283            <local-pref>
284                <pref>50</pref>
285            </local-pref>
286            <ipv4-next-hop>
287                <global>10.11.1.2</global>
288            </ipv4-next-hop>
289        </attributes>
290    </ipv4-route>
291
292 -----
293
294 The route can be removed from programmable RIB in a following way:
295
296 **URL:** ``/restconf/config/bgp-rib:application-rib/10.25.1.9/tables/bgp-types:ipv4-address-family/bgp-types:unicast-subsequent-address-family/bgp-inet:ipv4-routes/ipv4-route/10.0.0.11%2F32/0``
297
298 **Method:** ``DELETE``
299
300 -----
301
302 Also it is possible to remove all routes from a particular table at once:
303
304 **URL:** ``/restconf/config/bgp-rib:application-rib/10.25.1.9/tables/bgp-types:ipv4-address-family/bgp-types:unicast-subsequent-address-family/bgp-inet:ipv4-routes/``
305
306 **Method:** ``DELETE``
307
308 -----
309
310 Consequently, route disappears from programmable RIB, *Application Peer's* RIBs, Loc-RIB and peer's Adj-RIB-Out (UPDATE message with prefix withdrawal is send).
311
312 .. note:: Routes stored in programmable RIB are persisted on OpendDaylight shutdown and restored after the re-start.