Wailok Shum | bb7408b | 2021-09-30 22:41:32 +0800 | [diff] [blame] | 1 | External Connectivity |
| 2 | ===================== |
| 3 | |
| 4 | vRouter |
| 5 | ------- |
| 6 | |
| 7 | Physical Connectivity |
| 8 | ^^^^^^^^^^^^^^^^^^^^^ |
| 9 | |
| 10 | External routers must be physically connected to one of the fabric leaf |
| 11 | switches. |
| 12 | |
| 13 | Currently there is a limitation that the **external/upstream router and the |
| 14 | Quagga instance must be connected to the same fabric leaf switch**. |
| 15 | |
| 16 | Therefore it is necessary to use an additional front panel port on the |
| 17 | leaf-switch (or at least an additional VLAN) to connect to the compute node |
| 18 | hosting Quagga. |
| 19 | |
| 20 | .. image:: ../../images/config-vr-physical.png |
| 21 | |
| 22 | Configure vRouter |
| 23 | ^^^^^^^^^^^^^^^^^ |
| 24 | |
| 25 | The operator will need to configure a subnet between the Leaf-switch, the |
| 26 | external/upstream router and the Quagga instance. There are 3 IP addresses we |
| 27 | need to allocate - 1 on the switch port, 1 in Quagga, and 1 on the upstream |
| 28 | router. This means the peering subnet **cannot be smaller than a /29**. |
| 29 | |
| 30 | BGP peering happens between the IP addresses configured on the interfaces in |
| 31 | Quagga and the external router. |
| 32 | |
| 33 | Routes are advertised by Quagga to the upstream with the next-hop set to the |
| 34 | switch port IP address. This means that when traffic comes to the fabric leaf |
| 35 | switch from outside, the switch is able to distinguish peering traffic from |
| 36 | data traffic and treat each appropriately. |
| 37 | |
| 38 | The following shows an ONOS interface configuration example: |
| 39 | |
| 40 | .. code-block:: json |
| 41 | |
| 42 | { |
| 43 | "ports" : { |
| 44 | "of:0000000000000001/1" : { |
| 45 | "interfaces" : [ |
| 46 | { |
| 47 | "name" : "upstream1", |
| 48 | "ips" : [ "10.0.1.2/24" ], |
| 49 | "vlan-untagged" : 4000 |
| 50 | } |
| 51 | ] |
| 52 | }, |
| 53 | "of:0000000000000001/2" : { |
| 54 | "interfaces" : [ |
| 55 | { |
| 56 | "name" : "quagga", |
| 57 | "ips" : [ "10.0.1.2/24" ], |
| 58 | "vlan-untagged" : 4000 |
| 59 | } |
| 60 | ] |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | - ``name``: An arbitrary name string for the interface. Optional. |
| 66 | |
| 67 | - ``ips``: Configure the peering subnet (10.0.1.0/24) and the switch port IP |
| 68 | (10.0.1.2). Note that we use the same IP address on both the Quagga and |
| 69 | upstream interfaces. |
| 70 | |
| 71 | - ``vlan-untagged``: Configure the same VLAN ID on both interfaces. It doesn't |
| 72 | matter exactly what the VLAN ID is, but it must be the same on both the |
| 73 | Quagga-facing and upstream-facing interfaces. |
| 74 | |
| 75 | In this case the peering subnet is ``10.0.1.0/24``. |
| 76 | The upstream router is using the ``10.0.1.1`` address. |
| 77 | Quagga is assigned ``10.0.1.3``, which is the address used for peering. |
| 78 | |
| 79 | The upstream router needs to be configured with ``10.0.1.3`` as its BGP |
| 80 | neighbor, and the BGP peering will be established between ``10.0.1.1`` and |
| 81 | ``10.0.1.3``. The ``10.0.1.2`` address is used by the fabric switch and for the |
| 82 | next-hop for routes advertised by Quagga. |
| 83 | |
| 84 | Of course you are not obliged to use ``10.0.1.0/24``, you should use a subnet |
| 85 | that makes sense for your peering environment. |
| 86 | |
| 87 | .. note:: |
| 88 | This configuration will set up an L2 link between the two fabric switch |
| 89 | ports, over which the Quagga and external router can communicate. |
| 90 | |
| 91 | Both Quagga and the upstream router will receive untagged packets (i.e they |
| 92 | will never see packets with VLAN id 4000, which is used inside the leaf |
| 93 | switch to establish a bridging domain). |
| 94 | |
| 95 | If you need a VLAN tag in the compute node to distinguish the traffic going |
| 96 | to Quagga, you can change the VLAN assignment on the switch port |
| 97 | "of:0000000000000001/2" to be ``vlan-tagged`` instead of ``vlan-untagged``. |
| 98 | |
| 99 | Deploy the Quagga Docker Image |
| 100 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 101 | |
| 102 | SD-Fabric uses a slightly modified version of Quagga, so the easiest way to |
| 103 | deploy this is to use the provided docker image. |
| 104 | |
| 105 | .. code-block:: console |
| 106 | |
| 107 | $ docker pull opencord/quagga |
| 108 | |
| 109 | We also need to download the **pipework** tool which will be used to connect |
| 110 | the docker image to the physical interface that we set aside earlier. |
| 111 | |
| 112 | .. code-block:: console |
| 113 | |
| 114 | $ wget https://raw.githubusercontent.com/jpetazzo/pipework/master/pipework |
| 115 | $ chmod +x pipework |
| 116 | |
| 117 | Create a directory for your Quagga configuration files, and create a ``bgpd.conf`` |
| 118 | and ``zebra.conf`` in there. This folder is going to be mounted into the Quagga |
| 119 | container. More on configuring Quagga later. |
| 120 | |
| 121 | .. code-block:: console |
| 122 | |
| 123 | $ mkdir configs |
| 124 | $ touch zebra.conf bgpd.conf |
| 125 | |
| 126 | Now run the docker image (make sure the path the config directory matches what |
| 127 | is on your system): |
| 128 | |
| 129 | .. code-block:: console |
| 130 | |
| 131 | $ sudo docker run --privileged -d -v configs:/etc/quagga -n quagga opencord/quagga |
| 132 | |
| 133 | Finally, we can use the pipework tool to add the physical interface into the |
| 134 | container so that Quagga can talk out over the fabric: |
| 135 | |
| 136 | .. code-block:: console |
| 137 | |
| 138 | $ sudo ./pipework mlx1 -i eth1 quagga 10.0.1.3/24 |
| 139 | |
| 140 | This will add host interface ``mlx1`` to the container with name ``quagga`` |
| 141 | with interface name ``eth1`` inside the container. The newly added interface |
| 142 | will have the IP ``10.0.1.3``. This IP address should be the peering subnet |
| 143 | address that you want to assign to Quagga. |
| 144 | |
| 145 | If you need to change anything about the container (for example if you change |
| 146 | the Quagga configuration) you can remove the original container and run a new |
| 147 | one: |
| 148 | |
| 149 | .. code-block:: console |
| 150 | |
| 151 | $ sudo docker rm -f quagga |
| 152 | $ sudo docker run --privileged -d -v configs:/etc/quagga -n quagga opencord/quagga |
| 153 | |
| 154 | Configure Quagga |
| 155 | ^^^^^^^^^^^^^^^^ |
| 156 | |
| 157 | At this point Quagga should have IP connectivity to the external routers, and |
| 158 | it should be able to ping them on the peering subnet. |
| 159 | |
| 160 | Now Quagga and the upstream routers can be configured to peer with one another. |
| 161 | This configuration of Quagga is going to be highly dependent on the |
| 162 | configuration of the upstream network, so it won't be possible to give |
| 163 | comprehensive configuration examples here. |
| 164 | |
| 165 | It is recommended to consult the Quagga documentation for exhaustive |
| 166 | information on Quagga's capabilities and configuration. Here I will attempt to |
| 167 | provide a few basic examples of Quagga configuration to get you started. |
| 168 | You'll have to enhance these with the features and functions that are needed in |
| 169 | your network. |
| 170 | |
| 171 | Zebra configuration |
| 172 | """"""""""""""""""" |
| 173 | |
| 174 | Regardless of which routing protocols you are using in your network, it is |
| 175 | important to configure Zebra's FPM connection to send routes to the FPM app |
| 176 | running on ONOS. This feature was enabled by the patch that was applied |
| 177 | earlier when we installed Quagga. |
| 178 | |
| 179 | A minimal Zebra configuration might look like this: |
| 180 | |
| 181 | .. code-block:: text |
| 182 | |
| 183 | ! |
| 184 | hostname cord-zebra |
| 185 | password cord |
| 186 | ! |
| 187 | fpm connection ip 10.6.0.1 port 2620 |
| 188 | ! |
| 189 | |
| 190 | The FPM connection IP address is the IP address of **one of the onos cluster |
| 191 | instances** - does not matter which one. If you have other configuration that |
| 192 | needs to go in ``zebra.conf`` you should add that here as well. |
| 193 | |
| 194 | BGP configuration |
| 195 | """"""""""""""""" |
| 196 | |
| 197 | An example simple BGP configuration for peering with one BGP peer might look |
| 198 | like this: |
| 199 | |
| 200 | .. code-block:: text |
| 201 | |
| 202 | hostname bgp |
| 203 | password cord |
| 204 | ! |
| 205 | ip prefix-list 1 seq 10 permit 192.168.0.0/16 |
| 206 | ! |
| 207 | route-map NEXTHOP permit 10 |
| 208 | match ip address prefix-list 1 |
| 209 | set ip next-hop 10.0.1.2 |
| 210 | ! |
| 211 | router bgp 65535 |
| 212 | bgp router-id 10.0.1.3 |
| 213 | ! |
| 214 | network 192.168.0.0/16 |
| 215 | ! |
| 216 | neighbor 10.0.1.1 remote-as 65540 |
| 217 | neighbor 10.0.1.1 description upstream1 |
| 218 | neighbor 10.0.1.1 route-map NEXTHOP out |
| 219 | ! |
| 220 | |
| 221 | This configuration peers with one upstream router ``10.0.1.1`` and advertises |
| 222 | one route ``192.168.0.0/16``. Note that Quagga (and as a result SD-Fabric) is in |
| 223 | a different AS ``65535`` from the upstream router AS ``65540``, as we are using |
| 224 | E-BGP for this connectivity. |
| 225 | |
| 226 | .. note:: |
| 227 | Pay attention to the configuration to rewrite the next hop of routes that |
| 228 | are advertised to the upstream router. |
| 229 | |
| 230 | A ``route-map`` is used to set the next hop of advertised routes to |
| 231 | ``10.0.1.2``, which is **different from the address that Quagga is using to |
| 232 | peer with the external router**. |
| 233 | |
| 234 | As mentioned above, it is important that this rewriting is done correctly |
| 235 | so that the fabric switch is able to **distinguish data plane and control |
| 236 | plane** traffic. |
| 237 | |
| 238 | Route service and static route |
| 239 | ------------------------------ |
| 240 | |
| 241 | Access route service via CLI |
| 242 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 243 | |
| 244 | View routes |
| 245 | """"""""""" |
| 246 | |
| 247 | This will show routes from all sources, including static and dynamic routes. |
| 248 | |
| 249 | The example below shows routes learned from the upstream router (Source: FPM) |
| 250 | and routes configured manually (Source: STATIC) |
| 251 | |
| 252 | .. code-block:: text |
| 253 | |
| 254 | onos> routes |
| 255 | |
| 256 | B: Best route, R: Resolved route |
| 257 | |
| 258 | Table: ipv4 |
| 259 | B R Network Next Hop Source (Node) |
| 260 | 0.0.0.0/0 172.16.0.1 FPM (127.0.0.1) |
| 261 | > * 1.1.0.0/18 10.0.1.20 STATIC |
| 262 | > * 10.0.99.0/24 10.0.1.1 FPM (127.0.0.1) |
| 263 | * 10.0.99.0/24 10.0.6.1 FPM (127.0.0.1) |
| 264 | Total: 2 |
| 265 | |
| 266 | Table: ipv6 |
| 267 | B R Network Next Hop Source (Node) |
| 268 | > * 2000::7700/120 fe80::288:ff:fe00:1 FPM (127.0.0.1) |
| 269 | > * 2000::8800/120 fe80::288:ff:fe00:2 FPM (127.0.0.1) |
| 270 | > * 2000::9900/120 fe80::288:ff:fe00:1 FPM (127.0.0.1) |
| 271 | * 2000::9900/120 fe80::288:ff:fe00:2 FPM (127.0.0.1) |
| 272 | Total: 3 |
| 273 | |
| 274 | |
| 275 | Add a static route |
| 276 | """""""""""""""""" |
| 277 | |
| 278 | .. code-block:: console |
| 279 | |
| 280 | onos> route-add <prefix> <nexthop> |
| 281 | onos> route-add 1.1.0.0/18 10.0.1.20 |
| 282 | onos> route-add 2020::101/120 2000::1 |
| 283 | |
| 284 | |
| 285 | Remove a static route |
| 286 | """"""""""""""""""""" |
| 287 | |
| 288 | .. code-block:: console |
| 289 | |
| 290 | onos> route-remove <prefix> <nexthop> |
| 291 | onos> route-remove 1.1.0.0/18 10.0.1.20 |
| 292 | |
| 293 | |
| 294 | Access route service via REST |
| 295 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 296 | |
| 297 | Single route |
| 298 | """""""""""" |
| 299 | |
| 300 | .. code-block:: console |
| 301 | |
| 302 | $ curl --user onos:rocks -X POST -H 'Content-Type:application/json' http://<controller-ip>:8181/onos/routeservice/routes -d@routes.json |
| 303 | $ curl --user onos:rocks -X GET -H 'Accept:application/json' http://<controller-ip>:8181/onos/routeservice/routes | python -mjson.tool |
| 304 | $ curl --user onos:rocks -X DELETE -H 'Content-Type:application/json' http://<controller-ip>:8181/onos/routeservice/routes -d@routes.json |
| 305 | |
| 306 | with identical json format for both POST and DELETE: |
| 307 | |
| 308 | .. code-block:: json |
| 309 | |
| 310 | { |
| 311 | "prefix": "20.0.0.1/24", |
| 312 | "nextHop": "10.0.1.10" |
| 313 | } |
| 314 | |
| 315 | |
| 316 | Bulk routes |
| 317 | """"""""""" |
| 318 | |
| 319 | .. code-block:: console |
| 320 | |
| 321 | $ curl --user onos:rocks -X POST -H 'Content-Type:application/json' http://<controller-ip>:8181/onos/routeservice/routes/bulk -d@routes.json |
| 322 | $ curl --user onos:rocks -X DELETE -H 'Content-Type:application/json' http://<controller-ip>:8181/onos/routeservice/routes/bulk -d@routes.json |
| 323 | |
| 324 | with identical json format for both POST and DELETE: |
| 325 | |
| 326 | .. code-block:: json |
| 327 | |
| 328 | { |
| 329 | "routes": [ |
| 330 | { |
| 331 | "prefix": "20.0.0.1/24", |
| 332 | "nextHop": "10.0.1.10" |
| 333 | }, |
| 334 | { |
| 335 | "prefix": "30.0.0.1/24", |
| 336 | "nextHop": "10.0.2.15" |
| 337 | } |
| 338 | ] |
| 339 | } |
| 340 | |
| 341 | |
| 342 | Verify routes |
| 343 | ^^^^^^^^^^^^^ |
| 344 | Check the leaf switches that the route (e.g. 1.1.0.0/18) has been programmed in |
| 345 | the routing table (table 30). |
| 346 | |
| 347 | .. code-block:: console |
| 348 | |
| 349 | onos> flows any of:0000000000000205 30 |
| 350 | <snip> |
| 351 | id=670000d1f6782c, state=ADDED, bytes=0, packets=0, duration=39, liveType=UNKNOWN, priority=36010, tableId=30, appId=org.onosproject.segmentrouting, payLoad=null, selector=[ETH_TYPE:ipv4, IPV4_DST:1.1.0.0/18], |
| 352 | treatment=DefaultTrafficTreatment{immediate=[], deferred=[GROUP:0x70000014], transition=TABLE:60, meter=None, cleared=false, metadata=null} |
| 353 | <snip> |
| 354 | |
| 355 | Notes about next hops |
| 356 | ^^^^^^^^^^^^^^^^^^^^^ |
| 357 | The next hop of a route should be resolvable to a MAC address that is known to |
| 358 | ONOS. Typically the next hop is a server interface that is known to ONOS as a |
| 359 | host learned via ARP or DHCP. If you are not sure, check the ``hosts`` command |
| 360 | on the ONOS CLI. |
| 361 | |
| 362 | .. code-block:: console |
| 363 | |
| 364 | onos> hosts |
| 365 | <snip> |
| 366 | id=A2:9B:32:9D:7F:B3/None, mac=A2:9B:32:9D:7F:B3, location=of:0000000000000205/48, vlan=None, ip(s)=[192.168.101.2], configured=false |
| 367 | id=B2:A4:E2:72:D1:91/None, mac=B2:A4:E2:72:D1:91, location=of:0000000000000204/16, vlan=None, ip(s)=[10.0.1.20], configured=false |
| 368 | id=EE:22:F7:BE:86:50/None, mac=EE:22:F7:BE:86:50, location=of:0000000000000205/16, vlan=None, ip(s)=[10.0.2.15], configured=false |
| 369 | |
| 370 | If the next hop has not been resolved for any reason, it would be necessary to |
| 371 | configure the next hop as a host (/32 prefix) together with MAC address and |
| 372 | location. |
| 373 | |
| 374 | Learn more about how to configure a host using `Network Config Host Provider |
| 375 | <https://wiki.onosproject.org/display/ONOS/Network+Config+Host+Provider>`_ |
| 376 | |
| 377 | Finally note that if you are configuring routes manually/statically and they |
| 378 | are publicly routable IPs that should be reachable from “outside”, you would |
| 379 | need to configure Quagga to advertise them upstream. |
| 380 | |
| 381 | |
| 382 | Route blackhole |
| 383 | --------------- |
| 384 | The blackhole consists of a rule on table 30 on every edge device on the |
| 385 | fabric. The Table 30 rule matches on a given IP address and mask and has |
| 386 | nothing but a ``clearDeferred`` action, practically dropping the packet. Every IP |
| 387 | we want to blackhole will have it's own rule in every edge switch. |
| 388 | |
| 389 | An example of such rule is: |
| 390 | |
| 391 | .. code-block:: text |
| 392 | |
| 393 | ADDED, bytes=0, packets=0, table=30, priority=48010, selector=[ETH_TYPE:ipv4, IPV4_DST:50.0.0.0/24], treatment=[transition=TABLE:60] |
| 394 | |
| 395 | Route blackholing can be done via network configuration. |
| 396 | |
| 397 | .. code-block:: json |
| 398 | |
| 399 | { |
| 400 | "apps" : { |
| 401 | "org.onosproject.segmentrouting" : { |
| 402 | "segmentrouting": { |
| 403 | "blackholeIps": [ |
| 404 | "50.0.0.0/24" |
| 405 | ] |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | Ignore certain FPM peer |
| 412 | ----------------------- |
| 413 | The ``FpmConnectionInfo`` consists a new flag ``acceptRoutes``, indicating |
| 414 | whether we want to accept or discard the routes advertised by certain FPM peer. |
| 415 | Per current requirement, we always have the ``acceptRoutes`` flag set to |
| 416 | ``true`` by default, meaning that we will accept routes from all peers. |
| 417 | |
| 418 | We can updated the flag using REST API and CLI command as below |
| 419 | |
| 420 | REST API |
| 421 | ^^^^^^^^ |
| 422 | - ``POST /acceptRoutes`` to enable or disable ``acceptRoutes`` flag |
| 423 | - ``GET /acceptRoutes`` to fetch the current status of the FPM connection |
| 424 | |
| 425 | .. image:: ../../images/config-fpm-rest.png |
| 426 | :width: 900px |
| 427 | |
| 428 | CLI |
| 429 | ^^^ |
| 430 | |
| 431 | - ``fpm-set-accept-routes`` to enable or disable ``acceptRoutes`` flag |
| 432 | |
| 433 | .. code-block:: console |
| 434 | |
| 435 | onos> fpm-set-accept-routes 10.250.16.40 52560 false |
| 436 | |
| 437 | - ``fpm-get-accept-route`` to fetch the current status of the FPM connection |
| 438 | |
| 439 | .. code-block:: console |
| 440 | |
| 441 | onos> fpm-get-accept-route |
| 442 | <snip> |
| 443 | peer 10.250.16.40 port 52560 acceptRoutes false |
| 444 | peer 10.250.16.41 port 52594 acceptRoutes true |
| 445 | <snip> |