| 122 | !OpenvSwitch (OVS) is a user-space software defined switch with !OpenFlow support, complete with its own implementation of a controller. It can, and is assumed to be, built as a kernel module throughout this page. |
| 123 | === 2.1.1 Initialization === |
| 124 | OVS has three main components that must be initialized: |
| 125 | * openvswitch_mod.ko, the OVS kernel module |
| 126 | * ovsdb, the database containing configurations |
| 127 | * ovs-vswitchd, the OVS switch daemon |
| 128 | The latter configures itself using the data provided by the former; `ovs-vsctl` is used to modify the contents of the database in order to configure the OVS switch. |
| 129 | |
| 130 | 1. Load openVswitch kernel module |
| 131 | {{{ |
| 132 | cd datapath/linux/ |
| 133 | insmod openvswitch_mod.ko |
| 134 | }}} |
| 135 | Note, OVS and Linux bridging may not be used at the same time. This step will fail if the bridge module (bridge.ko) is loaded. You may need to reboot the node in order to unload bridge.ko. |
| 136 | 2. Start ovs-db: |
| 137 | {{{ |
| 138 | ovsdb/ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \ |
| 139 | --remote=db:Open_vSwitch,manager_options \ |
| 140 | --pidfile --detach |
| 141 | }}} |
| 142 | 3. Initialize the database: |
| 143 | {{{ |
| 144 | utilities/ovs-vsctl --no-wait init |
| 145 | }}} |
| 146 | the `--no-wait` allows the database to be initialized before ovs-vswitchd is invoked. |
| 147 | 4. Start ovs-vswitchd: |
| 148 | {{{ |
| 149 | vswitchd/ovs-vswitchd unix:/usr/local/var/run/openvswitch/db.sock --pidfile --detach |
| 150 | }}} |
| 151 | The 'unix:...db.sock' specifies that the process attach to the socket opened by `ovsdb`. |
| 152 | === 2.1.2 Configuring OVS === |
| 153 | the following only needs to be done once, in the initial configurations. |
| 154 | 1. Add ports: |
| 155 | {{{ |
| 156 | ovs-vsctl add-br br0 |
| 157 | ovs-vsctl add-port br0 eth0.111 |
| 158 | ovs-vsctl add-port br0 eth0.222 |
| 159 | }}} |
| 160 | By the time the 'add-port' commands are used, you should not be able to ping across the two VLANS, even with correct route table entries and packet forwarding enabled in the kernel. Here, br0 is a virtual interface similar to tap0 in the bridge. There should be one virtual interface per virtual switch to be instantiated. By default, ports added to the switch are trunked. Using the option tag=VLAN ID makes the interfaces behave as access ports for the VLAN ID specified: |
| 161 | {{{ |
| 162 | ovs-vsctl add-port br0 eth0.111 tag=111 |
| 163 | ovs-vsctl add-port br0 eth0.222 tag=222 |
| 164 | }}} |
| 165 | However, this is unrelated to what needs to happen here so we will not explore its uses any further (for now). [[BR]][[BR]] |
| 166 | 2. If it has not been done already, initialize the !OpenFlow controller. The procedures for this step differ according to the controller in use, and are discussed in the pages for each respective controller. [[BR]] |
| 167 | A sanity check for this step is to test your virtual switch with the OVS built-in controller, `ovs-controller`, which may be initialized on the same node running OVS: |
| 168 | {{{ |
| 169 | ovs-controller -v ptcp:6633 |
| 170 | }}} |
| 171 | When ovs-controller is used, the controller IP is, unsurprisingly, 127.0.0.1. |
| 172 | 3. Point ovs-vswitchd to the !OpenFlow controller. |
| 173 | {{{ |
| 174 | ovs-vsctl set-controller br0 tcp:172.16.0.14:6633 |
| 175 | }}} |
| 176 | In this example, the OVS process is pointed to a BSN controller (kvm-big) on 172.16.0.14, listening on port 6633^1^. `ovs-vsctl` will spit out a bunch of messages as it attempts to connect to the controller: |
| 177 | {{{ |
| 178 | ##screencap here |
| 179 | }}} |
| 180 | Given that you have a controller ready, the node should be usable once the virtual switch(es) connect(s) to the controller. The function of the switch will be determined by the flow matching rules generated by the conteoller. |