From nobody@FreeBSD.org Mon Dec 24 10:03:26 2007 Return-Path: Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5FBFD16A421 for ; Mon, 24 Dec 2007 10:03:24 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 30DB813C47E for ; Mon, 24 Dec 2007 10:03:24 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id lBOA2rHd012970 for ; Mon, 24 Dec 2007 10:02:53 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id lBOA2ruY012968; Mon, 24 Dec 2007 10:02:53 GMT (envelope-from nobody) Message-Id: <200712241002.lBOA2ruY012968@www.freebsd.org> Date: Mon, 24 Dec 2007 10:02:53 GMT From: Krassinir Slavchev To: freebsd-gnats-submit@FreeBSD.org Subject: ifconfig -l [address_family] does not work correct on RELENG-7 X-Send-Pr-Version: www-3.1 X-GNATS-Notify: >Number: 118987 >Category: bin >Synopsis: ifconfig(8): ifconfig -l (address_family) does not work correctly on RELENG-7 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-net >State: closed >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Dec 24 10:10:02 UTC 2007 >Closed-Date: Wed Nov 25 00:06:27 UTC 2009 >Last-Modified: Wed Nov 25 00:10:00 UTC 2009 >Originator: Krassinir Slavchev >Release: RELENG_7 >Organization: Bulinfo Ltd >Environment: FreeBSD 7.0-BETA4 i386 >Description: 'ifconfig -l [address_family]' should display all interfaces from address_family if given but it shows all interfaces. >How-To-Repeat: run 'ifconfig -l ether' on RELENG-7 >Fix: >Release-Note: >Audit-Trail: Responsible-Changed-From-To: freebsd-bugs->freebsd-net Responsible-Changed-By: remko Responsible-Changed-When: Mon Dec 24 22:56:27 UTC 2007 Responsible-Changed-Why: Over to maintainer. http://www.freebsd.org/cgi/query-pr.cgi?pr=118987 From: Will Andrews To: bug-followup@freebsd.org Cc: Subject: Re: bin/118987: ifconfig(8): ifconfig -l (address_family) does not work correctly on RELENG-7 Date: Sat, 31 Jan 2009 03:29:52 -0700 --001636c5986450f9c20461c4cdef Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Here is a patch that fixes this problem (it also fixes the problem for address families besides "ether"). I'm not sure if the method used is the best approach for "ether", but it does at least match some other usage within ifconfig. Unfortunately I don't seem to be able to attach patches correctly for GNATS, so here's a link: http://firepipe.net/ifconfig.c.118987-diff2.txt --Will. --001636c5986450f9c20461c4cdef Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Here is a patch that fixes this problem (it also fixes the problem for addr= ess families besides "ether").  I'm not sure if the meth= od used is the best approach for "ether", but it does at least ma= tch some other usage within ifconfig.  Unfortunately I don't seem = to be able to attach patches correctly for GNATS, so here's a link:
--001636c5986450f9c20461c4cdef-- State-Changed-From-To: open->analyzed State-Changed-By: vwe State-Changed-When: Sat Jan 31 10:31:59 UTC 2009 State-Changed-Why: Will has created a patch for evaluation http://www.freebsd.org/cgi/query-pr.cgi?pr=118987 State-Changed-From-To: analyzed->closed State-Changed-By: will State-Changed-When: Wed Nov 25 00:05:19 UTC 2009 State-Changed-Why: Fixed in r199770 (HEAD). http://www.freebsd.org/cgi/query-pr.cgi?pr=118987 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" >Unformatted: