LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

Re: [PATCH net-next 4/6] ipvs: fix sparse warnings for sync msg size

To: Simon Horman <horms@xxxxxxxxxxxx>
Subject: Re: [PATCH net-next 4/6] ipvs: fix sparse warnings for sync msg size
Cc: lvs-devel@xxxxxxxxxxxxxxx, Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
From: Julian Anastasov <ja@xxxxxx>
Date: Fri, 19 Apr 2013 22:35:04 +0300 (EEST)
        Hello,

On Fri, 19 Apr 2013, Simon Horman wrote:

> My idea is as follows:
> 
> From: Simon Horman <horms@xxxxxxxxxxxx>
> 
> ipvs: Use network byte order for sync message size
> 
> struct ip_vs_sync_mesg is both sent across the wire and
> used internally to store IPVS synchronisation messages.
> 
> Up until now the scheme used has been to convert the size field
> to network byte order before sending a message on the wire and
> convert it to host byte order when sending a message.
> 
> This patch changes that scheme to always treat the field
> as being network byte order. This seems appropriate as
> the structure is sent across the wire. And by consistently
> treating the field has network byte order it is now possible
> to take advantage of sparse to flag any future miss-use.
> 
> Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>
> ---
>  net/netfilter/ipvs/ip_vs_sync.c |   15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
> index 8e57077..c73778a 100644
> --- a/net/netfilter/ipvs/ip_vs_sync.c
> +++ b/net/netfilter/ipvs/ip_vs_sync.c
> @@ -255,7 +255,7 @@ struct ip_vs_sync_mesg_v0 {
>  struct ip_vs_sync_mesg {
>       __u8                    reserved;       /* must be zero */
>       __u8                    syncid;
> -     __u16                   size;
> +     __be16                  size;

        It seems v0 should be changed too,
ip_vs_send_sync_msg() handles both versions in sb->mesg.

> @@ -1544,10 +1542,7 @@ ip_vs_send_sync_msg(struct socket *sock, struct 
> ip_vs_sync_mesg *msg)
>       int msize;
>       int ret;
>  
> -     msize = msg->size;
> -
> -     /* Put size in network byte order */
> -     msg->size = htons(msg->size);
> +     msize = ntohs(msg->size);
>  
>       ret = ip_vs_send_async(sock, (char *)msg, msize);
>       if (ret >= 0 || ret == -EAGAIN)

Regards

--
Julian Anastasov <ja@xxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe lvs-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

<Prev in Thread] Current Thread [Next in Thread>