Skip to content

ONOS vRouter with OVS

Hyunsun Moon edited this page Jun 3, 2016 · 37 revisions

Prerequisites

This post describes how to make the gateway node in the previous to also act as a router with ONOS and vRouter. Here's an overall picture of the test.

Step 0

Remove the quagga container running in the gateway node, if there is.

Step 1

Create a new bridge br-router, which will be controlled by ONOS and vRouter application.

hyunsun@gateway$ sudo ovs-vsctl add-br br-router
hyunsun@gateway$ sudo ovs-vsctl set bridge br-router other-config:datapath-id=00000000000000b1
hyunsun@gateway$ sudo ovs-vsctl set-fail-mode br-router secure
hyunsun@gateway$ sudo ovs-vsctl set bridge br-router protocols=OpenFlow13

Step 2

Create a veth pair and link between br-ex and br-router.

hyunsun@gateway$ sudo ip link add veth0 type veth peer name veth1
hyunsun@gateway$ sudo ip link set veth0 up
hyunsun@gateway$ sudo ip link set veth1 up
hyunsun@gateway$ sudo ovs-vsctl add-port br-router veth0
hyunsun@gateway$ sudo ovs-vsctl add-port br-ex veth1

Step 3

Modify zebra.conf and add fpm connection with the IP address of your ONOS. Refer to the volumes/quagga/zebra.conf.sample for the configuration.

Step 4

Create a quagga container with the following command. It creates a container with two interfaces, one attached to the docker0 and the other attached to the br-router bridge, which is to be controlled by ONOS.

hyunsun@gateway$ ./run.sh gateway 172.18.0.101/24 00:00:00:00:01:01 br-router

Step 5

Create configuration file for vRouter. Refer to the ONOS wiki (https://wiki.onosproject.org/display/ONOS/vRouter) for the configuration details. Here's very simple example.

{
    "apps" : {
        "org.onosproject.router" : {
            "router" : {
                "controlPlaneConnectPoint" : "of:00000000000000b1/2",
                "ospfEnabled" : "false",
                "interfaces" : [ "b1-1" ]
            }
        }
    },
    "devices" : {
        "of:00000000000000b1" : {
            "basic" : {
                "driver" : "softrouter"
            }
        }
    },
    "ports" : {
        "of:00000000000000b1/1" : {
            "interfaces" : [
                {
                    "name" : "b1-1",
                    "ips"  : [ "172.18.0.101/24" ],
                    "mac"  : "00:00:00:00:01:01"
                }
            ]
        }
    }
}

Step 6

Run ONOS, push the network config to ONOS and activate vRouter app. It is important to register the network config first and then activate vRouter application.

$ onos-netcfg $OC1 ~/vrouter.json
onos> app activate org.onosproject.vrouter

Step 7

Set the controller of the br-router to ONOS.

hyunsun@gateway$ sudo ovs-vsctl set-controller br-router tcp:10.203.255.221:6653

Step 8

Connect to ONOS, you should be able to see FPM connection and routes. Note that FPM only works for the routes added by Quagga. Any duplicate routes added by Kernel should be removed if you want to see them from ONOS routes. In this example, my router node adverts default route(0.0.0.0) and Kernel has its own default route. So, I had to login to the container and remove the default route added by Kernel. But in this case, you should add static route to ONOS machine(10.203.255.221 in this example) for FPM connection.

hyunsun@gateway$ sudo docker exec -i -t gateway /bin/bash
root@gateway:/# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         172.17.0.1      0.0.0.0         UG        0 0          0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U         0 0          0 eth0
172.18.0.0      0.0.0.0         255.255.255.0   U         0 0          0 eth1

root@gateway:/# route add -host 10.203.255.221 gw 172.17.0.1
root@gateway:/# route del default gw 172.17.0.1
root@gateway:/# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         172.18.0.100    0.0.0.0         UG        0 0          0 eth1
10.203.255.221  172.17.0.1      255.255.255.255 UGH       0 0          0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U         0 0          0 eth0
172.18.0.0      0.0.0.0         255.255.255.0   U         0 0          0 eth1

Now check fpm connections and routes from ONOS.

onos> fpm-connections
10.55.25.244:44055 connected since 5m ago
onos> routes
Table: ipv4
   Network            Next Hop
   0.0.0.0/0          172.18.0.100
   Total: 1
onos> next-hops
ip=172.18.0.100, mac=00:00:00:00:01:00, numRoutes=1