netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] ipvsadm: use strtoul to convert ip addresses from hex
@ 2008-08-20  5:44 Simon Horman
  2008-08-20 10:30 ` Julius Volz
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Horman @ 2008-08-20  5:44 UTC (permalink / raw)
  To: Vince Busam; +Cc: Julius Volz, netdev, lvs-devel

The ip addresses that come out of /proc/net/ip_vs_conn as integers
are in hex not decimal.

Without this change most IP addresses reported as integers end up being
0.0.0.0.

This change is against the development code ipvsadm-1.25-nl-4 from
http://sixpak.org/vince/google/ipvsadm/ . It is not relevant to
ipvsadm-1.24, the current released version.

Signed-off-by: Simon Horman <horms@verge.net.au>

Index: ipvsadm-1.25-nl-4/ipvsadm.c
===================================================================
--- ipvsadm-1.25-nl-4.orig/ipvsadm.c	2008-08-20 15:16:18.000000000 +1000
+++ ipvsadm-1.25-nl-4/ipvsadm.c	2008-08-20 15:16:39.000000000 +1000
@@ -1212,9 +1212,9 @@ static void print_conn(char *buf, unsign
 		inet_pton(AF_INET, temp2, &vaddr.ip);
 		inet_pton(AF_INET, temp3, &daddr.ip);
 	} else {
-		caddr.ip = (__u32) htonl(atoi(temp1));
-		vaddr.ip = (__u32) htonl(atoi(temp2));
-		daddr.ip = (__u32) htonl(atoi(temp3));
+		caddr.ip = (__u32) htonl(strtoul(temp1, NULL, 16));
+		vaddr.ip = (__u32) htonl(strtoul(temp2, NULL, 16));
+		daddr.ip = (__u32) htonl(strtoul(temp3, NULL, 16));
 	}
 
 	if (!(cname = addrport_to_anyname(af, &caddr, cport, proto, format)))

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] ipvsadm: use strtoul to convert ip addresses from hex
  2008-08-20  5:44 [patch] ipvsadm: use strtoul to convert ip addresses from hex Simon Horman
@ 2008-08-20 10:30 ` Julius Volz
  2008-08-20 17:46   ` Vince Busam
  2008-08-21  0:05   ` Simon Horman
  0 siblings, 2 replies; 5+ messages in thread
From: Julius Volz @ 2008-08-20 10:30 UTC (permalink / raw)
  To: Simon Horman; +Cc: Vince Busam, netdev, lvs-devel, wensong

On Wed, Aug 20, 2008 at 7:44 AM, Simon Horman <horms@verge.net.au> wrote:
> The ip addresses that come out of /proc/net/ip_vs_conn as integers
> are in hex not decimal.
>
> Without this change most IP addresses reported as integers end up being
> 0.0.0.0.
>
> This change is against the development code ipvsadm-1.25-nl-4 from
> http://sixpak.org/vince/google/ipvsadm/ . It is not relevant to
> ipvsadm-1.24, the current released version.
>
> Signed-off-by: Simon Horman <horms@verge.net.au>
>
> Index: ipvsadm-1.25-nl-4/ipvsadm.c
> ===================================================================
> --- ipvsadm-1.25-nl-4.orig/ipvsadm.c    2008-08-20 15:16:18.000000000 +1000
> +++ ipvsadm-1.25-nl-4/ipvsadm.c 2008-08-20 15:16:39.000000000 +1000
> @@ -1212,9 +1212,9 @@ static void print_conn(char *buf, unsign
>                inet_pton(AF_INET, temp2, &vaddr.ip);
>                inet_pton(AF_INET, temp3, &daddr.ip);
>        } else {
> -               caddr.ip = (__u32) htonl(atoi(temp1));
> -               vaddr.ip = (__u32) htonl(atoi(temp2));
> -               daddr.ip = (__u32) htonl(atoi(temp3));
> +               caddr.ip = (__u32) htonl(strtoul(temp1, NULL, 16));
> +               vaddr.ip = (__u32) htonl(strtoul(temp2, NULL, 16));
> +               daddr.ip = (__u32) htonl(strtoul(temp3, NULL, 16));
>        }
>
>        if (!(cname = addrport_to_anyname(af, &caddr, cport, proto, format)))

Thanks for this fix! I'm sure Vince will release a new version with
this once there is sunlight in his timezone :)

Do you think it'll make sense to host the new ipvsadm on
linuxvirtualserver.org (marked as experimental, of course) when the
Netlink patches go in? This seems more open than hosting it on our
private servers...

Julius

-- 
Google Switzerland GmbH

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] ipvsadm: use strtoul to convert ip addresses from hex
  2008-08-20 10:30 ` Julius Volz
@ 2008-08-20 17:46   ` Vince Busam
  2008-08-21  0:48     ` Simon Horman
  2008-08-21  0:05   ` Simon Horman
  1 sibling, 1 reply; 5+ messages in thread
From: Vince Busam @ 2008-08-20 17:46 UTC (permalink / raw)
  To: Julius Volz; +Cc: Simon Horman, netdev, lvs-devel, wensong

Julius Volz wrote:
> On Wed, Aug 20, 2008 at 7:44 AM, Simon Horman <horms@verge.net.au> wrote:
>> The ip addresses that come out of /proc/net/ip_vs_conn as integers
>> are in hex not decimal.
> 
> Thanks for this fix! I'm sure Vince will release a new version with
> this once there is sunlight in his timezone :)

A new version, which also fixes a bug in sorting IPv6 addresses, is up 
at http://sixpak.org/vince/google/ipvsadm/

Vince

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] ipvsadm: use strtoul to convert ip addresses from hex
  2008-08-20 10:30 ` Julius Volz
  2008-08-20 17:46   ` Vince Busam
@ 2008-08-21  0:05   ` Simon Horman
  1 sibling, 0 replies; 5+ messages in thread
From: Simon Horman @ 2008-08-21  0:05 UTC (permalink / raw)
  To: Julius Volz; +Cc: Vince Busam, netdev, lvs-devel, wensong

On Wed, Aug 20, 2008 at 12:30:41PM +0200, Julius Volz wrote:
> On Wed, Aug 20, 2008 at 7:44 AM, Simon Horman <horms@verge.net.au> wrote:
> > The ip addresses that come out of /proc/net/ip_vs_conn as integers
> > are in hex not decimal.
> >
> > Without this change most IP addresses reported as integers end up being
> > 0.0.0.0.
> >
> > This change is against the development code ipvsadm-1.25-nl-4 from
> > http://sixpak.org/vince/google/ipvsadm/ . It is not relevant to
> > ipvsadm-1.24, the current released version.
> >
> > Signed-off-by: Simon Horman <horms@verge.net.au>
> >
> > Index: ipvsadm-1.25-nl-4/ipvsadm.c
> > ===================================================================
> > --- ipvsadm-1.25-nl-4.orig/ipvsadm.c    2008-08-20 15:16:18.000000000 +1000
> > +++ ipvsadm-1.25-nl-4/ipvsadm.c 2008-08-20 15:16:39.000000000 +1000
> > @@ -1212,9 +1212,9 @@ static void print_conn(char *buf, unsign
> >                inet_pton(AF_INET, temp2, &vaddr.ip);
> >                inet_pton(AF_INET, temp3, &daddr.ip);
> >        } else {
> > -               caddr.ip = (__u32) htonl(atoi(temp1));
> > -               vaddr.ip = (__u32) htonl(atoi(temp2));
> > -               daddr.ip = (__u32) htonl(atoi(temp3));
> > +               caddr.ip = (__u32) htonl(strtoul(temp1, NULL, 16));
> > +               vaddr.ip = (__u32) htonl(strtoul(temp2, NULL, 16));
> > +               daddr.ip = (__u32) htonl(strtoul(temp3, NULL, 16));
> >        }
> >
> >        if (!(cname = addrport_to_anyname(af, &caddr, cport, proto, format)))
> 
> Thanks for this fix! I'm sure Vince will release a new version with
> this once there is sunlight in his timezone :)
> 
> Do you think it'll make sense to host the new ipvsadm on
> linuxvirtualserver.org (marked as experimental, of course) when the
> Netlink patches go in? This seems more open than hosting it on our
> private servers...

I think that either hosting it on linuxvirtualserver.org or kernel.org
would be a good idea. Wensong what do you think?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] ipvsadm: use strtoul to convert ip addresses from hex
  2008-08-20 17:46   ` Vince Busam
@ 2008-08-21  0:48     ` Simon Horman
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2008-08-21  0:48 UTC (permalink / raw)
  To: Vince Busam; +Cc: Julius Volz, netdev, lvs-devel, wensong

On Wed, Aug 20, 2008 at 10:46:24AM -0700, Vince Busam wrote:
> Julius Volz wrote:
>> On Wed, Aug 20, 2008 at 7:44 AM, Simon Horman <horms@verge.net.au> wrote:
>>> The ip addresses that come out of /proc/net/ip_vs_conn as integers
>>> are in hex not decimal.
>>
>> Thanks for this fix! I'm sure Vince will release a new version with
>> this once there is sunlight in his timezone :)
>
> A new version, which also fixes a bug in sorting IPv6 addresses, is up  
> at http://sixpak.org/vince/google/ipvsadm/

Thanks. That does fix the 0.0.0.0 problem that I was seeing.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-08-21  0:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-20  5:44 [patch] ipvsadm: use strtoul to convert ip addresses from hex Simon Horman
2008-08-20 10:30 ` Julius Volz
2008-08-20 17:46   ` Vince Busam
2008-08-21  0:48     ` Simon Horman
2008-08-21  0:05   ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).