lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1304465113.1788.48.camel@Joe-Laptop>
Date:	Tue, 03 May 2011 16:25:13 -0700
From:	Joe Perches <joe@...ches.com>
To:	Alexey Dobriyan <adobriyan@...il.com>
Cc:	davem@...emloft.net, netdev@...r.kernel.org,
	Robert Olsson <robert.olsson@....uu.se>
Subject: Re: [PATCH] pktgen: use %pI6c for printing IPv6 addresses

On Wed, 2011-05-04 at 00:23 +0300, Alexey Dobriyan wrote:
> I don't know why %pI6 doesn't compress, but the format specifier is
> kernel-standard, so use it.

Hi again Alexey.

I doubt it matters but the old routine compresses the first
0 it finds rather than the longest consecutive 0 match so
the output could be a bit different.

given:	"0:1:0:0:0:0:0:7"
old:	"::1:0:0:0:0:0:7"
new:	"0:1::7"

I think the patch is an improvement.

> -static unsigned int fmt_ip6(char *s, const char ip[16])
> -{
> -	unsigned int len;
> -	unsigned int i;
> -	unsigned int temp;
> -	unsigned int compressing;
> -	int j;
> -
> -	len = 0;
> -	compressing = 0;
> -	for (j = 0; j < 16; j += 2) {
> -
> -#ifdef V4MAPPEDPREFIX
> -		if (j == 12 && !memcmp(ip, V4mappedprefix, 12)) {
> -			inet_ntoa_r(*(struct in_addr *)(ip + 12), s);
> -			temp = strlen(s);
> -			return len + temp;
> -		}
> -#endif
> -		temp = ((unsigned long)(unsigned char)ip[j] << 8) +
> -		    (unsigned long)(unsigned char)ip[j + 1];
> -		if (temp == 0) {
> -			if (!compressing) {
> -				compressing = 1;
> -				if (j == 0) {
> -					*s++ = ':';
> -					++len;
> -				}
> -			}
> -		} else {
> -			if (compressing) {
> -				compressing = 0;
> -				*s++ = ':';
> -				++len;
> -			}
> -			i = fmt_xlong(s, temp);
> -			len += i;
> -			s += i;
> -			if (j < 14) {
> -				*s++ = ':';
> -				++len;
> -			}
> -		}
> -	}
> -	if (compressing) {
> -		*s++ = ':';
> -		++len;
> -	}
> -	*s = 0;
> -	return len;
> -}


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ