From nobody@FreeBSD.org  Thu Jan  6 15:30:15 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 954FC1065673
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  6 Jan 2011 15:30:15 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (unknown [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 83C418FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  6 Jan 2011 15:30:15 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p06FUFVC025590
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 6 Jan 2011 15:30:15 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p06FUFOJ025589;
	Thu, 6 Jan 2011 15:30:15 GMT
	(envelope-from nobody)
Message-Id: <201101061530.p06FUFOJ025589@red.freebsd.org>
Date: Thu, 6 Jan 2011 15:30:15 GMT
From: Nikolay Denev <ndenev@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ifconfig prints trailing whitespace for interfaces that do not have IFF_BROADCAST (like point to point)
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         153731
>Category:       bin
>Synopsis:       [patch] ifconfig(8): ifconfig prints trailing whitespace for interfaces that do not have IFF_BROADCAST (like point to point)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 06 15:40:05 UTC 2011
>Closed-Date:    
>Last-Modified:  Fri Jan 07 22:08:14 UTC 2011
>Originator:     Nikolay Denev
>Release:        FreeBSD-8-STABLE
>Organization:
>Environment:
FreeBSD zoo.dev 8.2-PRERELEASE FreeBSD 8.2-PRERELEASE #25: Thu Nov 25 10:58:54 CET 2010     ndenev@zoo.dev:/usr/obj/usr/src/sys/ZOO  amd64
>Description:
When showing configuration for interfaces that do not have IFF_BROADCAST enabled, like if_tun, if_gre, etc.
ifconfig prints a trailing whitespace after the netmask.
>How-To-Repeat:
#ifconfig gre0
gre0: flags=b151<UP,POINTOPOINT,RUNNING,PROMISC,LINK0,LINK1,MULTICAST> metric 0 mtu 1476
	tunnel inet x.x.x.x --> y.y.y.y
	inet a.a.a.a --> b.b.b.b netmask 0xfffffffc <- Trailing whitespace here! :)
#
>Fix:
Apply attached patch.

Patch attached with submission follows:

--- sbin/ifconfig/af_inet.c.orig	2011-01-06 16:14:36.682832713 +0100
+++ sbin/ifconfig/af_inet.c	2011-01-06 16:15:24.041648987 +0100
@@ -79,12 +79,12 @@
 	sin = (struct sockaddr_in *)ifa->ifa_netmask;
 	if (sin == NULL)
 		sin = &null_sin;
-	printf("netmask 0x%lx ", (unsigned long)ntohl(sin->sin_addr.s_addr));
+	printf("netmask 0x%lx", (unsigned long)ntohl(sin->sin_addr.s_addr));
 
 	if (ifa->ifa_flags & IFF_BROADCAST) {
 		sin = (struct sockaddr_in *)ifa->ifa_broadaddr;
 		if (sin != NULL && sin->sin_addr.s_addr != 0)
-			printf("broadcast %s", inet_ntoa(sin->sin_addr));
+			printf(" broadcast %s", inet_ntoa(sin->sin_addr));
 	}
 	putchar('\n');
 }


>Release-Note:
>Audit-Trail:
>Unformatted:
