Background

Routes advertised by the upstream router are automatically programmed by the vrouter functionality in all fabric leaf switches. In this release, we add static routing capabilities for v4 and v6 prefixes.

CLI

Static route management can be done through ONOS CLI


- Add route:

 

onos> route-add <prefix> <nexthop>
onos> route-add 1.1.0.0/18 10.0.1.20

 

- Remove route:

 

onos> route-remove <prefix> <nexthop>
onos> route-remove 1.1.0.0/18 10.0.1.20

 

- Show routes:  This will show routes from all sources, including static and dynamic routes. The example below shows routes learned from the upstream router (Source: FPM) and routes configured manually (Source: STATIC)

 

onos> routes
Table: ipv4
   Network            Next Hop        Source
   0.0.0.0/0          192.168.101.1   FPM       
   1.1.0.0/18         10.0.1.20       STATIC    
   33.33.33.0/24      192.168.101.1   FPM       
   66.66.66.0/24      192.168.101.1   FPM       
   Total: 4
 
Table: ipv6
   Network            Next Hop        Source
   Total: 0

 

It is also possible to add IPv6 routes statically.

 

onos> route-add 2020::101/120 2000::1
onos> routes
Table: ipv4
   Network            Next Hop        Source
   0.0.0.0/0          192.168.101.1   FPM       
   66.66.66.0/24      192.168.101.1   FPM       
   33.33.33.0/24      192.168.101.1   FPM       
   Total: 3
 
Table: ipv6
   Network            Next Hop        Source
   2020::100/120      2000::1         STATIC    
   ::/0               fe80::290:bff:fe1f:9d12 FPM       
   2000::c000:6400/120 fe80::290:bff:fe1f:9d12 FPM       
   Total: 3

 

Notes:

The route-add command must provide a next-hop that is known to ONOS. In other words, the next-hop should be resolvable to a MAC address that is known to ONOS. Typically the next-hop is a server interface that is known to ONOS as a ‘host’ learned via ARP or DHCP. If you are not sure, check the ‘hosts’ or the ‘next-hops’ command on the ONOS cli.

 

onos> hosts
<snip>
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
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
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
 

onos> next-hops 
ip=10.0.1.20, mac=B2:A4:E2:72:D1:91, loc=of:0000000000000205/1, numRoutes=3
 
If the next-hop has not been resolved for any reason, it would be necessary to configure the next-hop as a host (/32 prefix) together with MAC address and location. Configuring hosts requires the netcfghostprovider app.
onos> app activate org.onosproject.netcfghostprovider


Use the REST API to send host config

$ curl --user onos:rocks -X POST -H 'Content-Type:application/json' http://<controller-ip>:8181/onos/v1/network/configuration/hosts -d@hostconfig.json

where the file hostconfig.json content looks like:

{
    "00:02:c9:1e:b1:21/None": {
 	"basic": {
     		"ips": [10.0.1.20],
     		"location": "of:0000000000000001/13"
 	}
    }
}

 

Finally note that if you are configuring routes manually/statically and they are publicly routable IPs that should be reachable from “outside”, you would need to configure Quagga to advertise them upstream.

REST API

You can also use the REST api to configure routes. There are two different REST-APIs that can be used.

Typically at runtime, you can add, remove or get routes using the following API

 

In ONOS 1.10.4:

 

  POST http://<onos_ip>:8181/onos/v1/routes 

 

  DELETE http://<onos_ip>:8181/onos/v1/routes 

 

in both cases, the data (in say a file 'routes.json') is JSON formatted like this: { "prefix" : "12.0.0.0/8", "nextHop" : "10.0.1.10" }

 

The curl commands are shown below

$ curl --user onos:rocks -X POST -H 'Content-Type:application/json' http://<controller-ip>:8181/onos/v1/routes -d@routes.json
$ curl --user onos:rocks -X GET -H 'Accept:application/json' http://<controller-ip>:8181/onos/v1/routes | python -mjson.tool
$ curl --user onos:rocks -X DELETE -H 'Content-Type:application/json' http://<controller-ip>:8181/onos/v1/routes -d@routes.json

 

 

In ONOS 1.11 or higher:

 

  POST http://<onos_ip>:8181/onos/routeservice/routes
  DELETE http://<onos_ip>:8181/onos/routeservice/routes

In ONOS 1.12.1 or higher (including master branch)

Single route:
  POST http://<onos_ip>:8181/onos/routeservice/routes
  DELETE http://<onos_ip>:8181/onos/routeservice/routes

with identical json format for both POST and DELETE:

 

{
 "prefix": "20.0.0.1/24",
 "nextHop": "10.0.1.10"
}

 


Bulk group of routes:
  POST http://<onos_ip>:8181/onos/routeservice/routes/bulk
  DELETE http://<onos_ip>:8181/onos/routeservice/routes/bulk

 

$ curl --user onos:rocks -X POST -H 'Content-Type:application/json' http://<controller-ip>:8181/onos/v1/routes/bulk -d@routes.json
$ curl --user onos:rocks -X DELETE -H 'Content-Type:application/json' http://<controller-ip>:8181/onos/v1/routes/bulk -d@routes.json

 


with identical json format for both POST and DELETE:

 

{
  "routes": [    
      {
        "prefix": "20.0.0.1/24",
        "nextHop": "10.0.1.10"
      },    
      {
        "prefix": "30.0.0.1/24",
        "nextHop": "10.0.2.15"
      }
  ]
}

 

 

The JSON data has the same format as above. Note that the route-system functionality is in the routeservice app in ONOS 1.11, which is why the URL is different.


Another way to configure routes is through the Network Configuration sub-system in ONOS, and its corresponding REST-API.

Note that this method should only be used when configuring a set of routes at system start up. It is not meant to be used for dynamically at run-time. Please use the APIs shown above for runtime changes.

 

$ curl --user onos:rocks -X POST -H 'Content-Type:application/json' http://<controller-ip>:8181/onos/v1/network/configuration/apps/org.onosproject.routing/routes -d@routes.json

 

where the file routes.json content looks like:

[
    {
        "prefix": "20.0.0.1/24",
        "nextHop": "10.0.1.10"
    },
    {
        "prefix": "30.0.0.1/24",
        "nextHop": "10.0.2.15"
    }
]


Verification

Check the leaf switches that the route (eg. 1.1.0.0/18) has been programmed in the routing table (table#30).

 

onos> flows any of:0000000000000205 30
<snip>
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],
 treatment=DefaultTrafficTreatment{immediate=[], deferred=[GROUP:0x70000014], transition=TABLE:60, meter=None, cleared=false, metadata=null}
<snip>