Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Nov 2009 00:10:02 GMT
From:      dfilter@FreeBSD.ORG (dfilter service)
To:        freebsd-net@FreeBSD.org
Subject:   Re: bin/118987: commit references a PR
Message-ID:  <200911250010.nAP0A2C2069782@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/118987; it has been noted by GNATS.

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/118987: commit references a PR
Date: Wed, 25 Nov 2009 00:01:12 +0000 (UTC)

 Author: will
 Date: Wed Nov 25 00:00:57 2009
 New Revision: 199770
 URL: http://svn.freebsd.org/changeset/base/199770
 
 Log:
   Make ``ifconfig -l ether'' only list interfaces that speak Ethernet.
   
   PR:		118987
   Approved by:	ken (mentor)
 
 Modified:
   head/sbin/ifconfig/ifconfig.c
 
 Modified: head/sbin/ifconfig/ifconfig.c
 ==============================================================================
 --- head/sbin/ifconfig/ifconfig.c	Tue Nov 24 22:37:04 2009	(r199769)
 +++ head/sbin/ifconfig/ifconfig.c	Wed Nov 25 00:00:57 2009	(r199770)
 @@ -147,7 +147,7 @@ main(int argc, char *argv[])
  	struct ifaddrs *ifap, *ifa;
  	struct ifreq paifr;
  	const struct sockaddr_dl *sdl;
 -	char options[1024], *cp;
 +	char options[1024], *cp, *namecp = NULL;
  	const char *ifname;
  	struct option *p;
  	size_t iflen;
 @@ -294,7 +294,7 @@ main(int argc, char *argv[])
  			sdl = (const struct sockaddr_dl *) ifa->ifa_addr;
  		else
  			sdl = NULL;
 -		if (cp != NULL && strcmp(cp, ifa->ifa_name) == 0)
 +		if (cp != NULL && strcmp(cp, ifa->ifa_name) == 0 && !namesonly)
  			continue;
  		iflen = strlcpy(name, ifa->ifa_name, sizeof(name));
  		if (iflen >= sizeof(name)) {
 @@ -308,16 +308,32 @@ main(int argc, char *argv[])
  			continue;
  		if (uponly && (ifa->ifa_flags & IFF_UP) == 0)
  			continue;
 -		ifindex++;
  		/*
  		 * Are we just listing the interfaces?
  		 */
  		if (namesonly) {
 +			if (namecp == cp)
 +				continue;
 +			if (afp != NULL) {
 +				/* special case for "ether" address family */
 +				if (!strcmp(afp->af_name, "ether")) {
 +					if (sdl == NULL ||
 +					    sdl->sdl_type != IFT_ETHER ||
 +					    sdl->sdl_alen != ETHER_ADDR_LEN)
 +						continue;
 +				} else {
 +					if (ifa->ifa_addr->sa_family != afp->af_af)
 +						continue;
 +				}
 +			}
 +			namecp = cp;
 +			ifindex++;
  			if (ifindex > 1)
  				printf(" ");
  			fputs(name, stdout);
  			continue;
  		}
 +		ifindex++;
  
  		if (argc > 0)
  			ifconfig(argc, argv, 0, afp);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911250010.nAP0A2C2069782>