<br><tt><font size=2>Eric Blake <eblake@redhat.com> wrote on 03/31/2010
02:28:09 PM:<br>
<br>
</font></tt>
<br><tt><font size=2>> <br>
> On 03/30/2010 11:56 AM, Stefan Berger wrote:<br>
> > Subject: Support for learning a VM's IP address<br>
> > <br>
> > This patch implements support for learning a VM's IP address.
It uses<br>
> > the pcap library to listen on the VM's backend network interface
(tap)<br>
> > or the physical ethernet device (macvtap) and tries to capture
packets<br>
> > with source or destination MAC address of the VM and learn from
DHCP<br>
> > Offers, ARP traffic, or first-sent IPv4 packet what the IP address
of<br>
> > the VM's interface is. This then allows to instantiate the network<br>
> > traffic filtering rules without the user having to provide the
IP<br>
> > parameter somewhere in the filter description or in the interface<br>
> > description as a parameter. This only supports to detect the
parameter<br>
> > IP, which is for the assumed single IPv4 address of a VM. There
is not<br>
> > support for interfaces that may have multiple  IP addresses
(IP<br>
> > aliasing) or IPv6 that may then require more than one valid IP
address<br>
> > to be detected. A VM can have multiple independent interfaces
that each<br>
> > uses a different IP address and in that case it will be attempted
to<br>
> > detect each one of the address independently.<br>
> <br>
> Sounds interesting.<br>
> <br>
> > <br>
> > ---<br>
> >  configure.ac            
                 |  
39 ++<br>
> <br>
> Should there also be an adjustment to the .rpm spec files, to mention<br>
> that we now might depend on libpcap (and building of all features<br>
> depends on libpcap-devel)?</font></tt>
<br>
<br><tt><font size=2>Correct.</font></tt>
<br><tt><font size=2><br>
> <br>
> > Index: libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c<br>
> ...<br>
> > +<br>
> > +#ifdef HAVE_LIBPCAP<br>
> > +#include <pcap.h><br>
> > +#endif<br>
> <br>
> Fails 'make syntax-check' if you install cppi (which is now part of
Fedora).</font></tt>
<br>
<br><tt><font size=2>I don't have that install. I know, indentation after
the '#'.</font></tt>
<br><tt><font size=2><br>
> <br>
> > +<br>
> > +#include <fcntl.h><br>
> > +#include <sys/ioctl.h><br>
> > +<br>
> > +#include <arpa/inet.h><br>
> > +#include <net/ethernet.h><br>
> > +#include <netinet/ip.h><br>
> > +#include <netinet/udp.h><br>
> > +#include <net/if_arp.h><br>
> > +#include <linux/if.h><br>
> <br>
> Can we guarantee that this header always exists, or should it be<br>
> conditionally included?</font></tt>
<br>
<br><tt><font size=2>I guess this would only work on Linux, not on OpenSolaris
or mingw. So, yes, conditionally including is probably the right thing.
What would be the right condition to use?</font></tt>
<br><tt><font size=2><br>
> <br>
> > +<br>
> > +<br>
> > +/* structure of an ARP request/reply message */<br>
> > +struct f_arphdr {<br>
> > +    struct arphdr arphdr;<br>
> > +    uint8_t ar_sha[ETH_ALEN];<br>
> > +    uint32_t ar_sip;<br>
> > +    uint8_t ar_tha[ETH_ALEN];<br>
> > +    uint32_t ar_tip;<br>
> > +} __attribute__((packed));<br>
> <br>
> This assumes GCC; do we ever intend to support other compilers?</font></tt>
<br>
<br><tt><font size=2>Hm, it should be #defined in internal.h, I guess that
would solve part of the problem.</font></tt>
<br>
<br><tt><font size=2>Are other compilers already being used ?</font></tt>
<br><tt><font size=2><br>
> <br>
> > +/**<br>
> > + * virNWFilterLearnInit<br>
> > + * Initialization of this layer<br>
> > + */<br>
> > +int<br>
> > +virNWFilterLearnInit(void) {<br>
> > +    pendingLearnReq = virHashCreate(0);<br>
> > +    if (!pendingLearnReq) {<br>
> > +        virReportOOMError();<br>
> > +        return 1;<br>
> > +    }<br>
> > +<br>
> > +    if (virMutexInit(&pendingLearnReqLock)) {<br>
> > +        virNWFilterLearnShutdown();<br>
> > +        return 1;<br>
> > +    }<br>
> <br>
> Is this function leaking memory if it fails mid-way through?  Or
are you<br>
> requiring that the caller will call virNWFilterShutdown even if<br>
> virNWFilterLearnInit returns failure?</font></tt>
<br>
<br><tt><font size=2>No, it shouldn't. Rather than cleaning up the objects
that were created in this function before it failed I call into the shutdown
function to free them.</font></tt>
<br>
<br><tt><font size=2><br>
> <br>
> > Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c<br>
> > ===================================================================<br>
> > --- libvirt-acl.orig/src/nwfilter/nwfilter_gentech_driver.c<br>
> > +++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c<br>
> > @@ -24,6 +24,9 @@<br>
> >  #include <config.h><br>
> >  <br>
> >  #include <stdint.h><br>
> > +#include <sys/socket.h><br>
> > +#include <sys/ioctl.h><br>
> > +#include <linux/if.h><br>
> <br>
> Another instance of using a non-portable header.</font></tt>
<br>
<br><tt><font size=2>Same issue, yes.</font></tt>
<br><tt><font size=2><br>
> <br>
> I've read through the patch, and didn't spot many glaring errors.
 I<br>
> have not tested it, though, and would rather defer to others to also<br>
> look through it before approving it, since it is rather large.</font></tt>
<br>
<br><tt><font size=2>Ok.</font></tt>
<br>
<br><tt><font size=2>  Stefan</font></tt>
<br><tt><font size=2><br>
> <br>
> -- <br>
> Eric Blake   eblake@redhat.com    +1-801-349-2682<br>
> Libvirt virtualization library </font></tt><a href=http://libvirt.org/><tt><font size=2>http://libvirt.org</font></tt></a><tt><font size=2><br>
> <br>
> [attachment "signature.asc" deleted by Stefan Berger/Watson/IBM]
</font></tt>