netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@verge.net.au>
To: Vince Busam <vbusam@google.com>
Cc: Julius Volz <juliusv@google.com>,
	netdev@vger.kernel.org, lvs-devel@vger.kernel.org
Subject: [patch] ipvsadm: use strtoul to convert ip addresses from hex
Date: Wed, 20 Aug 2008 15:44:16 +1000	[thread overview]
Message-ID: <20080820054415.GA31393@verge.net.au> (raw)

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)))

             reply	other threads:[~2008-08-20  5:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-20  5:44 Simon Horman [this message]
2008-08-20 10:30 ` [patch] ipvsadm: use strtoul to convert ip addresses from hex Julius Volz
2008-08-20 17:46   ` Vince Busam
2008-08-21  0:48     ` Simon Horman
2008-08-21  0:05   ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080820054415.GA31393@verge.net.au \
    --to=horms@verge.net.au \
    --cc=juliusv@google.com \
    --cc=lvs-devel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vbusam@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).