[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] Use libvirt's existing ipv6/ipv4 parser/printer rather than self-written ones



On Tue, Mar 30, 2010 at 10:50:20AM -0400, Stefan Berger wrote:
> This patch changes the network filtering code to use libvirt's existing
> IPv4 and IPv6 address parsers/printers rather than my self-written ones.
> 
> I am introducing a new function in network.c that counts the number of
> bits in a netmask and ensures that the given address is indeed a
> netmask, return -1 on error or values of 0-32 for IPv4 addresses and
> 0-128 for IPv6 addresses. I then based the function checking for valid
> netmask on invoking this function.

  Okay, I don't know why virSocketAddrIsNetmask() code didn't work
for you, I'm sure I had tested it even on weird examples, but the
replacement looks fine to me.

> Signed-off-by: Stefan Berger <stefanb us ibm com>
> 
> ---
>  src/conf/nwfilter_conf.c                  |  181 ++----------------------------
>  src/conf/nwfilter_conf.h                  |    8 -
>  src/nwfilter/nwfilter_ebiptables_driver.c |   46 ++++---
>  src/util/network.c                        |  173 +++++++++++++++-------------
>  src/util/network.h                        |    3 
>  5 files changed, 142 insertions(+), 269 deletions(-)
[...]
> @@ -85,11 +87,7 @@ struct _nwMACAddress {
>  typedef struct _nwIPAddress nwIPAddress;
>  typedef nwIPAddress *nwIPAddressPtr;
>  struct _nwIPAddress {
> -    int isIPv6;
> -    union {
> -        unsigned char ipv4Addr[4];
> -        unsigned char ipv6Addr[16];
> -    } addr;
> +    virSocketAddr addr;
>  };

  A following cleanup to this cleanup might be to remove all nwIPAddress
and just use virSocketAddr, I guess this would make the code simpler
too.

  Thanks for the cleanup, looks fine to me,

   ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]