<br><tt><font size=2>Daniel Veillard <veillard@redhat.com> wrote
on 01/13/2010 12:03:22 PM:<br>
<br>
> On Mon, Jan 11, 2010 at 12:55:27PM -0500, Stefan Berger wrote:<br>
> > Hello!<br>
> > </font></tt>
<br><tt><font size=2>[...]<br>
> > raw network throughput performance hit on their system due to
the <br>
> > evaluation of every packet passing through the filtering chains,
do not <br>
> > have to use these capabilities. An initial implementation would
be done <br>
> > for libvirt's Qemu support.<br>
> <br>
>  It's relatively clear that this would not work with devices
exposed<br>
> natively to the domain, say though PCI passthough. I'm wondering what</font></tt>
<br>
<br><tt><font size=2>Future SR-IOV devices may be programmable and provide
at least a subset </font></tt>
<br><tt><font size=2>of the filtering that can be done with this XML. In
that case we would </font></tt>
<br><tt><font size=2>probably need hardware specific drivers in libvirt
that can issue proper</font></tt>
<br><tt><font size=2>ioctl()s with the proper parameters to activate the
corresponding filtering.</font></tt>
<br><tt><font size=2><br>
> other case of limitiations could be found. Also this may not map well<br>
> for other kind of hypervisors like VMWare, right ?</font></tt>
<br>
<br><tt><font size=2>I don't know much about the API that VMWare is exposing.
Maybe only a </font></tt>
<br><tt><font size=2>certain subset of what would be possible with this
XML could be applied </font></tt>
<br><tt><font size=2>to their API, if such functionality exist. Otherwise,
if libvirt</font></tt>
<br><tt><font size=2>can run ebtables and iptables commands on their management
VM and</font></tt>
<br><tt><font size=2>all traffic passes through VM=specific network interface
(tap) in that VM,</font></tt>
<br><tt><font size=2>it *should* work as well.</font></tt>
<br><tt><font size=2><br>
> <br>
> > As stated above, the application of firewall rules on virtual
machines <br>
> > will require some form of XML description that lets the user
choose what <br>
> > type of filtering is to be performed. In effect the user needs
to be able <br>
> > to tell libvirt which ebtables and iptables rules to generate
so that the <br>
> > appropriate filtering can be done. We realize that  ebtables
and iptables <br>
> > have lots of capabilities but think that we need to restrict
which <br>
> > capabilities can actually be 'reached' through this XML.<br>
> > <br>
> > The following proposal is based on an XML as defined by the DMTF
(<br>
> > </font></tt><a href=http://www.dmtf.org/standards/cim/cim_schema_v2230/CIM_Network.pdf><tt><font size=2>http://www.dmtf.org/standards/cim/cim_schema_v2230/CIM_Network.pdf</font></tt></a><tt><font size=2>,
slide <br>
> > 10) with extensions for processing of ARP packets.It gives control
over <br>
> > the evaluation of Ethernet (MAC) frames, ARP packet data and
IP header <br>
> > information. A (draft) XML skeleton in this case could look as
follows:<br>
> <br>
>   Humpf, extending astandard XML schemas is really bad practice.
Even if<br>
> you think that the extension may be accepted later, it may have<br>
> different semantic for the same construct and that's a disaster.<br>
> I would at least put the new elements in a separate namespace to<br>
> avoid something insane if DMTF extends its specification.</font></tt>
<br>
<br><tt><font size=2>Yes, we could do that. As said, this was meant as
a draft.</font></tt>
<br><tt><font size=2><br>
> <br>
> > <FilterEntry> <br>
> >         <Action>DROP|ACCEPT</Action>
  <!-- from FilterEntry --> <br>
> > <br>
> >         <TrafficType>incoming [to VM]|outgoing
[from VM]</TrafficType> <br>
> > <br>
> >         <Hdr8021Filter> <br>
> >                 <HdrSrcMACAddr8021>
  </HdrSrcMACAddr8021> <br>
> >                 <HdrSrcMACMask8021>
  </HdrSrcMACMask8021> <br>
> >                 <HdrDestMACAddr8021>
 </HdrDestMACAddr8021> <br>
> >                 <HdrDestMACMask8021>
 </HdrDestMACMask8021> <br>
> >                 <HdrProtocolID8021>
numeric and/or string? <br>
> > </HdrProtocolID8021> <br>
> >                 <HdrPriorityValue8021></HdrPriorityValue8021>
<br>
> >                 <HdrVLANID8021>
      </HdrVLANID8021> <br>
> >         </Hdr8021Filter> <br>
> > <br>
> >         <ARPFilter> <br>
> >                 <HWType>
      </HWType> <br>
> >                 <ProtocolType>
</ProtocolType> <br>
> >                 <OPCode>
      </OPCode> <br>
> >                 <SrcMACAddr>
  </SrcMACAddr> <br>
> >                 <SrcIPAddr>
   </SrcIPAddr> <br>
> >                 <DestMACAddr>
 </DestMACAddr> <br>
> >                 <DestIPAddr>
  </DestIPAddr> <br>
> >         </ARPFilter> <br>
> > <br>
> >         <IPHeadersFilter> <br>
> >                 <HdrIPVersion>
    </HdrIPVersion> <br>
> >                 <HdrSrcAddress>
   </HdrSrcAddress> <br>
> >                 <HdrSrcMask>
      </HdrSrcMask> <br>
> >                 <HdrDestAddress>
  </HdrDestAddress> <br>
> >                 <HdrDestMask>
     </HdrDestMask> <br>
> >                 <HdrProtocolID>
 numeric and/or string?  </HdrProtocolID> <br>
> >                 <HdrSrcPortStart>
 </HdrSrcPortStart> <br>
> >                 <HdrSrcPortEnd>
   </HdrSrcPortEnd> <br>
> >                 <HdrDestPortStart>
</HdrDestPortStart> <br>
> >                 <HdrDestPortEnd>
  </HdrDestPortEnd> <br>
> >                 <HdrDSCP>
         </HdrDSCP> <br>
> >         </IPHeadersFilter> <br>
> > <br>
> > </FilterEntry> <br>
> <br>
>   hum the types for each values should be made explicit if possible,<br>
> But in general I find that extremely bulky for a single entry, while<br>
> I would expect any domain to have a dozen filters or so just for<br>
> simple stuff. I wonder if empty default should just be dropped, so<br>
> that basically if you're filtering on a MAC address you don't carry<br>
> a bunch of unused fields.</font></tt>
<br>
<br><tt><font size=2>Of course empty XML elements would not be shown. The
above XML is meant </font></tt>
<br><tt><font size=2>to show all the network packet 'elements' that can
be tested and for which </font></tt>
<br><tt><font size=2>also ebtables and iptables support exists. Also only
a certain combination</font></tt>
<br><tt><font size=2>of the above elements would be set for a specific
corresponding ebtables command.</font></tt>
<br>
<br><tt><font size=2>An example for a (template) XML for testing against
MAC spoofing</font></tt>
<br><tt><font size=2>could be this XML here, which drops all IPv4 packets
that don't have</font></tt>
<br><tt><font size=2>the proper MAC address set.</font></tt>
<br>
<br><font size=2 face="Courier New"><FilterEntry></font><font size=3>
</font><font size=2 face="Courier New"><br>
        <Action>DROP</Action></font><font size=3>
</font><font size=2 face="Courier New"><br>
        <TrafficType>outgoing</TrafficType></font><font size=3>
</font><font size=2 face="Courier New"><br>
        <Hdr8021Filter></font><font size=3> </font><font size=2 face="Courier New"><br>
                <HdrSrcMACAddr8021>![THIS_MAC]</HdrSrcMACAddr8021></font><font size=3>
</font><font size=2 face="Courier New"><br>
        </Hdr8021Filter></font><font size=3>
</font><font size=2 face="Courier New"><br>
        <IPHeadersFilter></font><font size=3>
</font><font size=2 face="Courier New"><br>
                <HdrIPVersion>4</HdrIPVersion></font><font size=3>
</font><font size=2 face="Courier New"><br>
        </IPHeadersFilter></font><font size=3>
</font><font size=2 face="Courier New"><br>
</FilterEntry></font><font size=3> </font>
<br>
<br><tt><font size=2><br>
> <br>
> > Since the ebtables and iptables command cannot accept all possible
<br>
> > parameters at the same time, only a certain subset of the above
parameters <br>
> > may be set for any given filter command. Higher level application
writers <br>
> > will likely use a library that lets them choose which features
they would <br>
> > want to have enforced, such as no-broadcast or no-multicast,
enforcement <br>
> > of MAC spoofing prevention or ARP poisoning prevention, which
then <br>
> > generates this lower level XML rules in the appropriate order
of the <br>
> > rules.<br>
> <br>
>    I wonder if a tailored set of simpler XML matching what
is actually<br>
> possible and getting away from the DMTF records wouldn't be better,<br>
> since the original spec is extended on the feature side and the<br>
> applicability is restricted on the implementation side, I'm not sure
I<br>
> see the point of trying to be compatible.</font></tt>
<br>
<br><tt><font size=2>If we want to give the user full control over the
ebtables and iptables features,</font></tt>
<br><tt><font size=2>an XML as the one above would be necessary. A more
higher level XML may look as</font></tt>
<br><tt><font size=2>follows:</font></tt>
<br>
<br><tt><font size=2>     <firewall><br>
      <no-mac-spoofing/><br>
      <no-ip-spoofing address="9.59.241.151"/><br>
      <ether-allow protocols='ARP,IPv4'/><br>
       [...]<br>
    </firewall></font></tt>
<br>
<br><tt><font size=2>This XML only gives the user control over the features
that have been</font></tt>
<br><tt><font size=2>explicitly implemented in libvirt, i.e., the driver
would know what the</font></tt>
<br><tt><font size=2>corresponding ebtables commands are to enforce no-mac-spoofing,
in which</font></tt>
<br><tt><font size=2>order the ebtable rules need to be organized and when
to create new user defined</font></tt>
<br><tt><font size=2>ebtables (ebtables -N) to provide a more efficient
evaluation of the filtering. </font></tt>
<br><tt><font size=2>The XSL trafo that Daniel Berrange mentioned would
likely not be possible </font></tt>
<br><tt><font size=2>with this XML, since the ordering, depending on the
chosen security features, may</font></tt>
<br><tt><font size=2>be tricky to support with a transformation.</font></tt>
<br>
<br><tt><font size=2>In the explicit XML above, the user would be expected
to put the rules into </font></tt>
<br><tt><font size=2>proper order and likely would somehow need to provide
user defined table names </font></tt>
<br><tt><font size=2>into which the individual rules need to be put. With
this XML here, this would</font></tt>
<br><tt><font size=2>be automatically handled by the libvirt implementation.</font></tt>
<br>
<br><tt><font size=2>> <br>
> > Further, we will introduce filter pools where a collection of
the above <br>
> > filter rules can be stored and referenced to by virtual machines'
<br>
> > individual interface. A reference to such a filter pool entry
will be <br>
> > given in the interface description and may look as in the following
draft <br>
> > XML:<br>
> > <br>
> > <interface type='bridge'><br>
> >    <source bridge='virbr0'/><br>
> >    <script path='vif-bridge'/> <br>
> >     <firewall> <br>
> >         <reference profile='generic-layer2'
ip_address='10.0.0.1'/> <br>
> >         <reference profile='VM-specific-layer3'/>
<br>
> >     </firewall><br>
> > </interface><br>
> <br>
>   the devil is in the details, basically how you would template<br>
> the profiles based on the strings in the reference. I.e. what the<br>
> profile would look like and how for example ip_address='10.0.0.1'<br>
> would be instancied in the profile use.</font></tt>
<br>
<br><tt><font size=2>We thought that maybe the </font></tt><font size=2 face="Courier New">HdrSrcMACAddr8021</font><tt><font size=2>
XML element could have [THIS_MAC] </font></tt>
<br><tt><font size=2>as content, which would then need to become concrete
when instantiated.</font></tt>
<br><tt><font size=2>Similarly we could put [THIS_IP] into the XML element
testing for</font></tt>
<br><tt><font size=2>source (and destination) IP address. So the ip_address
above would be</font></tt>
<br><tt><font size=2>passed into the function instantiating the rules for
the VM.</font></tt>
<br><tt><font size=2><br>
> > <br>
> > Further, we would introduce the management of filter 'pools'.
Considering <br>
> > existing functionality in libvirt and CLI commands for similar
type of <br>
> > management functionality, the following CLI commands would be
added:<br>
> > <br>
> > virsh nwfilter-create <file> <br>
> > virsh nwfilter-destroy <profile name> <br>
> > virsh nwfilter-list <options> <br>
> > virsh nwfilter-dumpxml <profile name> <br>
> > virsh nwfilter-update <filename>      (performs
an update on an existing <br>
> > profile replacing all rules) <br>
> > <br>
> > possibly also: <br>
> > <br>
> > virsh nwfilter-edit <profile name> <br>
> > virsh nwfilter-create-from <profile name> <br>
> > <br>
> > <br>
> > Please let us know what you think of this proposal. <br>
> <br>
>   The feature looks interesting ! It looks it should be applicable
to<br>
> at least qemu and xen, I'm not so sure about LXC or VirtualBox, and<br>
> looks unlikely for VMWare unless they have a matching capability (might<br>
> be possible since it's based at least partly on DMTF).</font></tt>
<br>
<br><tt><font size=2>It would work with any technology that uses an ethernet
interface in </font></tt>
<br><tt><font size=2>the host, i.e., a tap or backend interface, through
which all the VM's network </font></tt>
<br><tt><font size=2>traffic passes. All firewall rules would be conditioned
on the VM's interface </font></tt>
<br><tt><font size=2>name  and jump into a VM-specific rules tree.</font></tt>
<br>
<br><tt><font size=2>As for VirtualBox, since it is Qemu based and probably
has a tap interface, </font></tt>
<br><tt><font size=2>this should also work. I have never used LXC, so I
cannot say much about it,</font></tt>
<br><tt><font size=2>but it would also require a network interface in the
host onto which</font></tt>
<br><tt><font size=2>ebtables and iptables could condition their rules
on </font></tt>
<br><tt><font size=2>(ebtables -A ... -i <tap interface name> ...).</font></tt>
<br>
<br>
<br><tt><font size=2>One other thing to consider is whether pools should
actually be used. The problem with</font></tt>
<br><tt><font size=2>the pools may arise when trying to migrate VMs. If
the target host does not have</font></tt>
<br><tt><font size=2>the same named pool, then higher layer software would
need to migrate the firewall rules</font></tt>
<br><tt><font size=2>first so the same rules can be enforced on the target
as well. If, however, the rules </font></tt>
<br><tt><font size=2>are directly in the interface XML of the VM description,
then migration would be </font></tt>
<br><tt><font size=2>done using 'virsh migrate', since the VM description
migrates anyway.</font></tt>
<br>
<br><tt><font size=2>Regards,</font></tt>
<br><tt><font size=2>   Stefan</font></tt>
<br>
<br>
<br>
<br><tt><font size=2><br>
>   I'm not sure reusing the DMTF format actually helps much, it
also has<br>
> its risks due to the extension.<br>
> <br>
> Daniel<br>
> <br>
> -- <br>
> Daniel Veillard      | libxml Gnome XML XSLT toolkit
 </font></tt><a href=http://xmlsoft.org/><tt><font size=2>http://xmlsoft.org/</font></tt></a><tt><font size=2><br>
> daniel@veillard.com  | Rpmfind RPM search engine </font></tt><a href=http://rpmfind.net/><tt><font size=2>http://rpmfind.net/</font></tt></a><tt><font size=2><br>
> </font></tt><a href=http://veillard.com/><tt><font size=2>http://veillard.com/</font></tt></a><tt><font size=2>
| virtualization library  </font></tt><a href=http://libvirt.org/><tt><font size=2>http://libvirt.org/</font></tt></a><tt><font size=2><br>
</font></tt>