Hi, Cole!<br><br>As I said, I gone through the list archives and got some insight on how to present my ideas.<br><br>I tried to use the thread started by Laine Stump (<a href="https://www.redhat.com/archives/libvir-list/2011-April/msg00591.html">https://www.redhat.com/archives/libvir-list/2011-April/msg00591.html</a>) as a model.<br>

<br>Please, forgive me if my RFC is too verbose: I tried to produce something good.<br><br>In time: I'm willing to implement this idea as part of my postgraduate work.<br><br><br>Index<br>=====<br>1. Incorporating Open vSwitch support to libvirt<br>

2. Background<br>3. Architecture<br>3.1. Option 1<br>3.2. Option 2<br>4. Implementation<br><br>1. Incorporating Open vSwitch support to libvirt<br>================================================<br><br>OpenFlow (<a href="http://www.openflow.org/">http://www.openflow.org/</a>) is a technology from the Software Defined Networks (SDN) fame. Switches supporting it export a software interface that allows special programs (Controllers) to dictate how the forwarding of ethernet frames should be done. That decision can not only be based on traditional layer-2 information (physical address 00:01:02:03:04:aa maps to port 1, address 05:06:07:08:09:bb maps to port 2, and so on) but also on information from a mix of network layers, like VLAN tags, IP addresses and/or TCP ports.<br>

<br>Controllers may take network flexibility and efficiency to a new level, slicing switches' capacity transparently to run concurrent, isolated networks (FlowVisor, <a href="https://openflow.stanford.edu/display/flowvisor/Home">https://openflow.stanford.edu/display/flowvisor/Home</a>). They can also incorporate logic to make the connectivity layer play a greater role in areas like IP routing (RouteFlow, <a href="http://sites.google.com/site/routeflow/">http://sites.google.com/site/routeflow/</a>), network access control (SMAC, <a href="http://www.openflowhub.org/display/Snac/SNAC+Home">http://www.openflowhub.org/display/Snac/SNAC+Home</a>), hosts load-balancing (<a href="http://www.cs.princeton.edu/~jrex/papers/loadwild10.pdf">http://www.cs.princeton.edu/~jrex/papers/loadwild10.pdf</a>) and live migration (<a href="http://conferences.sigcomm.org/sigcomm/2008/papers/p513-ericksonA.pdf">http://conferences.sigcomm.org/sigcomm/2008/papers/p513-ericksonA.pdf</a>).<br>

<br>In a very practical view, as libvirt supports a programmatic definition of network nodes, OpenFlow allows for a programmatic definition of traffic forwarding. An IaaS/cloud environment composed of many physical hosts and extensive use of libvirt for hypervisor management could use OpenFlow for virtualized switches management.<br>

<br>Even tough its current libvirt enables one to define and instantiate virtual networks, those networks are, basically, Linux kernel bridges which configuration (device IP addresses, naming, connections) is stored into network XML files. Linux bridges doesn't offer a programmatic interface, and depend on not-so-easily-customizable approaches (VLANs, tunnels) to properly isolate traffic.<br>

<br>Open vSwitch (or OVS, <a href="http://www.openvswitch.org/">http://www.openvswitch.org/</a>) is a full software implementation of a network switch. It supports standard management interfaces and protocols (e.g. NetFlow, sFlow) and is being used in a multitude of virtual and cloud-based computing (e.g. XenServer, OpenNebula). Even more, OVS can operate in "OpenFlow-mode".<br>

<br>When operating in a traditional ("full switch") fashion, an OVS instance is similar to a Linux bridge - just supporting features that makes them work more like a "real" switch. In this scenario, OVS kernel driver even includes a compatibility layer that allows bridge-utils (and libvirt) to act upon OVS instances just as if they were Linux bridges!<br>

<br>When operating in OpenFlow mode, the OVS instance is called a _datapath_. Host interfaces can be bound to and send traffic through it, but forwarding logic is provided by the Controller process. In this scenario, OpenFlow-based solutions could be leveraged to virtual networks. Even more, OpenFlow-based solutions which use virtual facilities (like VMs and OVS) could use libvirt as part of its frameworks!<br>

<br>I'm proposing changes to libvirt's network XML format. It would allow for "datapath" elements, and it's attributes would allow libvirt to instantiate a OVS datapath, specifying it's controller address and hardware description, for example.<br>

<br>2. Background<br>=============<br><br>To instantiate an OVS datapath (DP), one must call the ovs-openflowd daemon. Some relevant aspects of its syntax are covered below:<br><br>------------------------------- 8< -------------------------------<br>

<br>usage: ovs-openflowd [OPTIONS] DATAPATH [CONTROLLER...]<br><br>Active OpenFlow connection methods:<br>  tcp:IP[:PORT]         PORT (default: 6633) at remote IP<br>  ssl:IP[:PORT]         SSL PORT (default: 6633) at remote IP<br>

  unix:FILE               Unix domain socket named FILE<br><br>Passive OpenFlow connection methods:<br>  ptcp:[PORT][:IP]        listen to TCP PORT (default: 6633) on IP<br>  pssl:[PORT][:IP]        listen for SSL on PORT (default: 6633) on IP<br>

  punix:FILE              listen on Unix domain socket FILE<br><br>OpenFlow options:<br>  -d, --datapath-id=ID    Use ID as the OpenFlow switch ID<br>                          (ID must consist of 16 hex digits)<br>  --mfr-desc=MFR          Identify manufacturer as MFR<br>

  --hw-desc=HW            Identify hardware as HW<br>  --sw-desc=SW            Identify software as SW<br><br>Networking options:<br>  --out-of-band           controller connection is out-of-band<br><br>Daemon options:<br>

  --detach                run in background as daemon<br>  --pidfile[=FILE]        create pidfile (default: /usr/local/var/run/openvswitch/ovs-openflowd.pid)<br><br>------------------------------- 8< -------------------------------<br>

<br>An execution example can be seen below:<br><br># ovs-openflowd --hw-desc=rfovs dp0 tcp:<a href="http://127.0.0.1:6633">127.0.0.1:6633</a> --out-of-band --detach<br><br>This instantiates an OVS datapath with hardware description "rfovs". The datapath name (and Linux virtual interface name) is "dp0". The controller software is running in the same machine as the OVS instance (IP address 127.0.0.1), and can be reached through port 6633/TCP. The connection to the controller must not be done through the datapath itself (out-of-band), and the ovs-openflowd will run as a background daemon.<br>

<br>3. Architecture<br>===============<br><br>libvirt documentation available on <a href="http://www.libvirt.org/formatnetwork.html">http://www.libvirt.org/formatnetwork.html</a> describes the following format to network definition:<br>

<br><network><br>        <!-- General metadata --><br>        <!-- Bridging, naming and forwarding data --><br>        <!-- Addressing data --><br></network><br><br>Based solely in that documentation, the format is somewhat bound to Linux bridges. This is not a problem most of the time, as OVS includes a compatibility module (brcompat_mod) that allows bridge-utils to configure an OVS "full switch" just as if it was a traditional Linux bridge. The syscalls offered also permit libvirt to manage these instances transparently.<br>

<br>However, this format doesn't provide sufficient information to configure a OVS datapath. Next, I propose some options of how the libvirt network format could be changed to provide this facility (and, off course, to implement those changes).<br>

<br>3.1. Option 1: network type<br>---------------------------<br><br>I saw this in an e-mail from Laine Stump in last April (<a href="https://www.redhat.com/archives/libvir-list/2011-April/msg00640.html">https://www.redhat.com/archives/libvir-list/2011-April/msg00640.html</a>). It seems like my preferred ideas about how the change could be accomplished.<br>

<br>The network opening element would be extended to include an optional "type" attribute. It could be defined as "bridge" (the default behaviour, for backwards compatibility) or "ovs-datapath" (the case for which I would like to work):<br>

<br><br><br><network type="bridge"> (THE DEFAULT)<br><br>or<br><br><network type="ovs-datapath"><br><br><br><br>As the "General metadata" from the network format is instrumental to libvirt, it would be necessary to a "ovs-datapath" network.<br>

<br>As the control layer of an OVS datapath lie outside itself, the "Bridging, naming..." section of the network format would be replaced by the following elements/attributes:<br><br><br><br><datapath name="" id="" mfrdesc="" hwdesc="" swdesc=""><br>

<br>    - Mandatory, this element would allow for datapath and OpenFlow general configuration.<br>    - The name attribute would be used to designate the datapath virtual interface. (Mandatory)<br>    - The id, mfrdesc, hwdesc and swdesc attributes would be mapped 1:1 to ovs-openflowd parameters presented before. (Optional)<br>

<br><controller protocol="" address="" port="" outofband=""><br>OR<br><controller protocol="" path=""><br><br>    - Protocol. Would be one of "tcp" or "unix", by now. (Mandatory)<br>

    - Address. Would be an IP address. (Mandatory, if protocol="tcp")<br>    - Path. Would be the path to a UNIX socket to which the controller process is listening. (Mandatory, if protocol="unix")<br>

    - Port. Would be the port to which the controller is listening to. (Optional, default = 6633)<br>    - Outofband. If connection to the controller must be done "in" or "out" of band. (Optional, default = "NO").<br>

    - The controller element itself would be optional, as OVS includes a "controller discovery" process by default. If specified, however, it's mandatory attributes should be respected.<br>    <br>    <br>    <br>

For the sake of a proof-of-concept implementation, this would be the entire (!) scope of the initial change/implementation. After this step, things such as this could be added:<br><br>- An "ssl" option for the "protocol=" attribute, to allow for SSL-encrypted connections between datapaths and its controllers.<br>

- An element to pass SSL connection data (private key, ca cert, etc.) to ovs-openflowd. E.g.: <pki privatekey...><br>- Elements to control networking operation (e.g. max-idle, max-backoff) and rate-limiting of the datapath.<br>

<br>3.2. Option 2: datapath element<br>-------------------------------<br><br>In place of a network type definition, just a new "datapath" element would be added. The network_conf code should test if a "bridge" element is specified in a network definition, and look for a datapath if it can't find one. Addressing data found in a network using the "datapath" element would be ignored.<br>

<br>The datapath element here could be overly long, including description, controller and ssl-related attributes - but the format change would be very minimal:<br><br><br><br><network><br>        <!-- General metadata --><br>

        <datapath name="" descriptions="..." controller_data="..."><br></network><br><br><br><br>Other option would be set those properties as sub-elements of <datapath...>, merging this option with the first:<br>

<br><br><br><network><br>        <!-- General metadata --><br>        <datapath name="" id="" mfrdesc="" hwdesc="" swdesc=""><br>            <controller protocol="" address="" port="" outofband=""><br>

            <pki privatekey...><br>            <networking...><br>        </datapath><br></network><br><br><br><br>Besides being and option, this scenario (in fact, the entire option 2) seems somewhat unclean to me.<br>

<br>4. Implementation<br>=================<br><br>1. I can hack through the network_conf code to make it parse the XML. That's an easy part.<br>2. I can use the bridge driver as a model + your command execution infrastructure (which is very cool, IMHO) to implement an OVS driver.<br>

3. It's not yet very clear to me where is the code that instantiates each network after it's "def" get parsed. Well, after the first two steps, I think that I would need to just hook the parsing and driver functions together in instantiating/virsh/command-line code.<br>

<br>That's all, folks!<br><br>Best regards,<br clear="all">Carlos "Bill" Nilton<br>CISSP, RHCE, ITIL Foundations<br><a href="http://carlosnilton.com.br/" target="_blank">http://carlosnilton.com.br/</a><br><br>


<br><br><div class="gmail_quote">Em 8 de junho de 2011 17:34, Carlos N. A. Corrêa <span dir="ltr"><<a href="mailto:carlos.nilton@gmail.com">carlos.nilton@gmail.com</a>></span> escreveu:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Hi,<br><br>I gathered information about that and I'll produce relevant documentation of my point tonight.<br><br>I'll be glad to do an informed and well structured work. Thanks!<div class="im"><br><br>Best regards,<br clear="all">


Carlos "Bill" Nilton<br>CISSP, RHCE, ITIL Foundations<br><a href="http://carlosnilton.com.br/" target="_blank">http://carlosnilton.com.br/</a><br><br>
<br><br></div><div class="gmail_quote">Em 8 de junho de 2011 15:41, Cole Robinson <span dir="ltr"><<a href="mailto:crobinso@redhat.com" target="_blank">crobinso@redhat.com</a>></span> escreveu:<div><div></div><div class="h5">

<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>On 06/08/2011 07:10 AM, Carlos N. A. Corręa wrote:<br>
> Hi,<br>
><br>
> I'm interested in developing a new network driver for libvirt (one for the<br>
> definition and management of OpenVSwitch datapaths).<br>
><br>
> I've read some of the code already, and by now my general directions are:<br>
><br>
> - Change the function virNetworkDefParseXML in src/conf/network_conf.c to<br>
> define and parse new configuration directives needed by my driver<br>
> - Use src/network/bridge_driver.c as a template for my new driver, replacing<br>
> code from the services provided by the driver (listed on "virNetworkDriver"<br>
> type) with my own code, for my own net type.<br>
><br>
> Have you any other directions in this matter? Any tips? If it works, would<br>
> be this code of any use to you?<br>
><br>
<br>
</div>For a starting point I'd recommend proposing your XML changes to the<br>
list, and describe exactly what the new functionality will enable, and a<br>
few use cases. Probably best to do this before starting any code so you<br>
don't head in a wrong direction.<br>
<br>
Check the past few month ML archives to see how some other developers<br>
have proposed RFCs or XML changes.<br>
<font color="#888888"><br>
- Cole<br>
</font></blockquote></div></div></div><br>
</blockquote></div><br>