[libvirt] [PATCH 02/11] Include length with virSocketAddr data

Eric Blake eblake at redhat.com
Thu Oct 21 19:46:08 UTC 2010


On 10/21/2010 12:17 PM, Daniel P. Berrange wrote:
> Some operations on socket addresses need to know the length of
> the sockaddr struct for the particular address family. This
> info was being discarded when passing around virSocketAddr
> instances. Turn it from a union into a struct containing
> union+socklen_t fields, so length is always kept around.
>
> * src/util/network.h: Add socklen_t field to virSocketAddr
> * src/util/network.c, src/network/bridge_driver.c,
>    src/conf/domain_conf.c: Update to take account of new
>    struct definition.
> ---
>   src/conf/domain_conf.c      |    2 +-
>   src/network/bridge_driver.c |   10 +++---
>   src/util/network.c          |   60 ++++++++++++++++++++++--------------------
>   src/util/network.h          |   12 +++++---
>   4 files changed, 45 insertions(+), 39 deletions(-)

> diff --git a/src/util/network.h b/src/util/network.h
> index 5307c8c..ef92c9b 100644
> --- a/src/util/network.h
> +++ b/src/util/network.h
> @@ -17,11 +17,15 @@
>   # include<sys/socket.h>
>   # include<netdb.h>
>
> -typedef union {
> -    struct sockaddr_storage stor;
> -    struct sockaddr_in inet4;
> -    struct sockaddr_in6 inet6;
> +typedef struct {
> +    union {
> +        struct sockaddr_storage stor;
> +        struct sockaddr_in inet4;
> +        struct sockaddr_in6 inet6;
> +    } data;
> +    socklen_t len;
>   } virSocketAddr;

ACK; and the rest of the patch is compiler-enforced fallout.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org




More information about the libvir-list mailing list