netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* %pI4 vs. NIPQUAD: %pI4 doing it wrong?
@ 2008-11-04  1:05 Jay Vosburgh
  2008-11-04  1:07 ` David Miller
  2008-11-04  1:11 ` Julius Volz
  0 siblings, 2 replies; 3+ messages in thread
From: Jay Vosburgh @ 2008-11-04  1:05 UTC (permalink / raw)
  To: netdev; +Cc: Harvey Harrison


	Running the latest net-next-2.6, I notice that %pI4 is
apparently printing IPv4 addresses incorrectly (and differently than the
NIPQUAD it replaced).

	The following is excerpted from the bonding driver's
/proc/net/bonding/bond0 status file:

[...]
ARP IP target/s (n.n.n.n form): 01.0.1.1 (10.0.1.1), 01.02.03.04 (10.20.30.40)

	The first (incorrect) values are from %pI4, the ones in
parentheses (which are correct) I added as a check using NIPQUAD with
this patch:

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 56c823c..ced12ba 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3289,7 +3289,9 @@ static void bond_info_show_master(struct seq_file *seq)
 				continue;
 			if (printed)
 				seq_printf(seq, ",");
-			seq_printf(seq, " %pI4", &bond->params.arp_targets[i]);
+			seq_printf(seq, " %pI4 (%u.%u.%u.%u)",
+				   &bond->params.arp_targets[i],
+				   NIPQUAD(bond->params.arp_targets[i]));
 			printed = 1;
 		}
 		seq_printf(seq, "\n");

	Is anybody else seeing this, or is it just me?

	I'm working on an x86.

	-J

---
	-Jay Vosburgh, IBM Linux Technology Center, fubar@us.ibm.com

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

* Re: %pI4 vs. NIPQUAD: %pI4 doing it wrong?
  2008-11-04  1:05 %pI4 vs. NIPQUAD: %pI4 doing it wrong? Jay Vosburgh
@ 2008-11-04  1:07 ` David Miller
  2008-11-04  1:11 ` Julius Volz
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2008-11-04  1:07 UTC (permalink / raw)
  To: fubar; +Cc: netdev, harvey.harrison

From: Jay Vosburgh <fubar@us.ibm.com>
Date: Mon, 03 Nov 2008 17:05:29 -0800

> 
> 	Running the latest net-next-2.6, I notice that %pI4 is
> apparently printing IPv4 addresses incorrectly (and differently than the
> NIPQUAD it replaced).
> 
> 	The following is excerpted from the bonding driver's
> /proc/net/bonding/bond0 status file:
> 
> [...]
> ARP IP target/s (n.n.n.n form): 01.0.1.1 (10.0.1.1), 01.02.03.04 (10.20.30.40)
> 
> 	The first (incorrect) values are from %pI4, the ones in
> parentheses (which are correct) I added as a check using NIPQUAD with
> this patch:

Harvey posted a fix for this today, which I'll apply soon.

Thanks for checking the archives before reporting a problem.

--------------------

Subject: Re: [PATCH 3/7] net: replace NIPQUAD() in net/netfilter/
From: Harvey Harrison <harvey.harrison@gmail.com>
To: Julius Volz <julius.volz@gmail.com>
Cc: David Miller <davem@davemloft.net>, linux-netdev <netdev@vger.kernel.org>
Date: Mon, 03 Nov 2008 09:43:16 -0800
X-Mailer: Evolution 2.24.1 

On Mon, 2008-11-03 at 17:56 +0100, Julius Volz wrote:
> Hi,
> I just noticed that this breaks IPv4 addresses in IPVS debug output
> (didn't check in other places). It seems that during integer to ASCII
> conversion, the converted digits are output the wrong way around (not
> endianness though). For example, 10.0.0.254 is output as 01.0.0.452.
> Could something be wrong with ip4_addr_string() or put_dec_trunc() in
> lib/vsprintf.c?

Mea Culpa, I was testing with a too-simple case, it does reverse the digits,
can you try this:

From: Harvey Harrison <harvey.harrison@gmail.com>
[PATCH] printk: ipv4 address digits printed in reverse order

put_dec_trunc prints the digits in reverse order and is reversed
inside number(). Continue using put_dec_trunc, but reverse each quad
in ip4_addr_string.

[Noticed by Julius Volz]

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 lib/vsprintf.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index dd7cc7f..6897724 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -620,11 +620,15 @@ static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width,
 			 int precision, int flags)
 {
 	char ip4_addr[4 * 4]; /* (4 * 3 decimal digits), 3 dots and trailing zero */
+	char temp[3];	/* hold each IP quad in reverse order */
 	char *p = ip4_addr;
-	int i;
+	int i, digits;
 
 	for (i = 0; i < 4; i++) {
-		p = put_dec_trunc(p, addr[i]);
+		digits = put_dec_trunc(temp, addr[i]) - temp;
+		/* reverse the digits in the quad */
+		while (digits--)
+			*p++ = temp[digits];
 		if (i != 3)
 			*p++ = '.';
 	}
-- 
1.6.0.3.756.gb776d




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

* Re: %pI4 vs. NIPQUAD: %pI4 doing it wrong?
  2008-11-04  1:05 %pI4 vs. NIPQUAD: %pI4 doing it wrong? Jay Vosburgh
  2008-11-04  1:07 ` David Miller
@ 2008-11-04  1:11 ` Julius Volz
  1 sibling, 0 replies; 3+ messages in thread
From: Julius Volz @ 2008-11-04  1:11 UTC (permalink / raw)
  To: Jay Vosburgh; +Cc: netdev, Harvey Harrison

Hey Jay,

I noticed the same thing and Harvey already posted a fix - Dave just
applied it a second ago :)

Julius

On Tue, Nov 4, 2008 at 2:05 AM, Jay Vosburgh <fubar@us.ibm.com> wrote:
>
>        Running the latest net-next-2.6, I notice that %pI4 is
> apparently printing IPv4 addresses incorrectly (and differently than the
> NIPQUAD it replaced).
>
>        The following is excerpted from the bonding driver's
> /proc/net/bonding/bond0 status file:
>
> [...]
> ARP IP target/s (n.n.n.n form): 01.0.1.1 (10.0.1.1), 01.02.03.04 (10.20.30.40)
>
>        The first (incorrect) values are from %pI4, the ones in
> parentheses (which are correct) I added as a check using NIPQUAD with
> this patch:
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 56c823c..ced12ba 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -3289,7 +3289,9 @@ static void bond_info_show_master(struct seq_file *seq)
>                                continue;
>                        if (printed)
>                                seq_printf(seq, ",");
> -                       seq_printf(seq, " %pI4", &bond->params.arp_targets[i]);
> +                       seq_printf(seq, " %pI4 (%u.%u.%u.%u)",
> +                                  &bond->params.arp_targets[i],
> +                                  NIPQUAD(bond->params.arp_targets[i]));
>                        printed = 1;
>                }
>                seq_printf(seq, "\n");
>
>        Is anybody else seeing this, or is it just me?
>
>        I'm working on an x86.
>
>        -J
>
> ---
>        -Jay Vosburgh, IBM Linux Technology Center, fubar@us.ibm.com
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

end of thread, other threads:[~2008-11-04  1:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-04  1:05 %pI4 vs. NIPQUAD: %pI4 doing it wrong? Jay Vosburgh
2008-11-04  1:07 ` David Miller
2008-11-04  1:11 ` Julius Volz

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