From patchwork Mon Nov 3 17:43:16 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Harrison X-Patchwork-Id: 6941 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id AC11FDDF1E for ; Tue, 4 Nov 2008 04:43:26 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750974AbYKCRnW (ORCPT ); Mon, 3 Nov 2008 12:43:22 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750897AbYKCRnW (ORCPT ); Mon, 3 Nov 2008 12:43:22 -0500 Received: from mail-gx0-f15.google.com ([209.85.217.15]:33370 "EHLO mail-gx0-f15.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750835AbYKCRnV (ORCPT ); Mon, 3 Nov 2008 12:43:21 -0500 Received: by gxk8 with SMTP id 8so1029870gxk.1 for ; Mon, 03 Nov 2008 09:43:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=WsKK3Mt1J6VZCAjGsZiVmLOZMjAMp/6eAWuasnL4lxE=; b=HeoztWdKq0EgSym96iUO0td9aIiGXW+BHur/4CzogELq7dxsKsV947q6oTAZz2YBef bHLiRHGUcSUQ29t2cNe8JM4wuo1mKg3WGgH0aSxDKI+DH/jbtmmiCwOf2pLTgDnKSwAs Jo3N7f0T8p/FPPHsbqfJg5OxuME20LD70WwtI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; b=g8xavt0fFuLPCxGmpfFRdvkv2DzQw1mstcc6860qGw4Woe+kXDMHOvzB/ZumAaWLmH kFV3F4n9csWo1F4fh4gvGD6SF2U16uv0VsT5rN7zlf7zFWH8DmkUe2y49+su4WK/X2hG MwdFNjeK44w56WIwiarsdb4rTh3pJz8nvf0/8= Received: by 10.142.223.4 with SMTP id v4mr197461wfg.172.1225734198971; Mon, 03 Nov 2008 09:43:18 -0800 (PST) Received: from ?128.189.232.134? ([128.189.232.134]) by mx.google.com with ESMTPS id 27sm15226974wfa.2.2008.11.03.09.43.18 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 03 Nov 2008 09:43:18 -0800 (PST) Subject: Re: [PATCH 3/7] net: replace NIPQUAD() in net/netfilter/ From: Harvey Harrison To: Julius Volz Cc: David Miller , linux-netdev In-Reply-To: <43ca39800811030856u5acf9601s6aef81887f19f859@mail.gmail.com> References: <1225412025.5574.34.camel@brick> <43ca39800811030856u5acf9601s6aef81887f19f859@mail.gmail.com> Date: Mon, 03 Nov 2008 09:43:16 -0800 Message-Id: <1225734196.5361.5.camel@brick> Mime-Version: 1.0 X-Mailer: Evolution 2.24.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 [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 --- 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++ = '.'; }