# Open vSwitch for SDN via GRE/IPSEC tunnel



## thomas_l (Mar 19, 2018)

Hey FreeBSD people,

I'm a long term Linux user who would like to include one or more FreeBSD server into his server infrastructure. Last week I set up a virtual management network via Open vSwitch on my Linux machines. This network connects Linux containers over multiple hosts. The network tunneling is works via a GRE tunnel + IPsec. Both can easily be set up via Open vSwitch. 

Now that FreeBSD attracts my interest I'd like to try the same / similar with FreeBSD. I've already managed to create and use BSD jails and connect them via a network bridge. The next task would be to connect this network bridge (with jails attached to it) to the rest of my Linux hosts. This should be possible via Open vSwitch, since it is available for FreeBSD, too.

Unfortunately the FreeBSD version is less documented than the Linux version. I've found this Open vSwitch port for FreeBSD: https://www.freshports.org/net/openvswitch and installed it on my test machine. I expected I could just go for the commands to set up my virtual switch (as on Debian Linux), but there is obviously some more manual work required on FreeBSD (correct me if I'm wrong!):

`### Create database directory
    mkdir -p /var/db/openvswitch

### Create database
    ovsdb-tool create /var/db/openvswitch/conf.db /usr/local/share/openvswitch/vswitch.ovsschema

### Create run directory
    mkdir /var/run/openvswitch

### Create logging directory
    /var/log/openvswitch

### Start all Open vSwitch components
    root@freebsd:/usr/local/share/openvswitch/scripts # ./ovs-ctl start

### Init DB
    ovs-vsctl --no-wait init`

After this procedure I've tried issuing my first command (to create a virtual switch ("bridge"): 

`ovs-vsctl add-br ovsbr0`

Unfortunately this gave me


```
ovs-vsctl: Error detected while setting up 'ovsbr0'.  See ovs-vswitchd log for details.
ovs-vsctl: The default log directory is "/var/log/openvswitch".
```

So I had a look into the log file:


```
2018-03-17T20:22:08.176Z|00007|ofproto|WARN|unknown datapath type system
2018-03-17T20:22:08.176Z|00008|ofproto|WARN|unknown datapath type system
2018-03-17T20:22:08.177Z|00009|ofproto|WARN|could not create datapath ovsbr0 of unknown type system
```

After reading this thread: https://forums.freebsd.org/threads/openvswitch-is-not-creating-bridge-interface.34207/ ... I've tried via this command:

`ovs-vsctl add-br ovsbr0 -- set bridge ovsbr0 datapath_type=netdev`

The "unknown datapath" error is gone, but there are still some errors left:


```
2018-03-17T23:00:41.332Z|00036|netdev_bsd|WARN|opening "/dev/tap" failed: No such file or directory
2018-03-17T23:00:41.341Z|00037|dpif|WARN|failed to create datapath ovs-netdev: No such file or directory
2018-03-17T23:00:41.341Z|00038|ofproto_dpif|ERR|failed to open datapath of type netdev: No such file or directory
2018-03-17T23:00:41.341Z|00039|ofproto|ERR|failed to open datapath ovsbr0: No such file or directory
2018-03-17T23:00:41.342Z|00040|bridge|ERR|failed to create bridge ovsbr0: No such file or directory
```

Like mentioned before, I'm a FreeBSD newbie ... what am I doing wrong? How can I fix this ... and: Is it advisable to run OpenvSwitch on FreeBSD? Has anyone succeeded in this? From my impression Open vSwitch does not seem to "a topic" in the community :S

I'd be very happy if somebody from you experts could show me how to get Open vSwitch running on my FreeBSD machine


----------

