From nobody@FreeBSD.org  Fri Oct 28 08:43:40 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0EECB16A41F
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 28 Oct 2005 08:43:40 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id D4B6943D45
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 28 Oct 2005 08:43:39 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j9S8hdIo048224
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 28 Oct 2005 08:43:39 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j9S8hdFd048223;
	Fri, 28 Oct 2005 08:43:39 GMT
	(envelope-from nobody)
Message-Id: <200510280843.j9S8hdFd048223@www.freebsd.org>
Date: Fri, 28 Oct 2005 08:43:39 GMT
From: Ben Wilber <bw@desync.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] partial matching for ifconfig
X-Send-Pr-Version: www-2.3

>Number:         88119
>Category:       bin
>Synopsis:       [patch] partial matching for ifconfig(8)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 28 08:50:16 GMT 2005
>Closed-Date:    Wed Feb 07 03:59:53 GMT 2007
>Last-Modified:  Wed Feb  7 04:20:12 GMT 2007
>Originator:     Ben Wilber
>Release:        7.0-CURRENT
>Organization:
desync
>Environment:
FreeBSD pf1 7.0-CURRENT FreeBSD 7.0-CURRENT #0: Thu Oct 27 01:31:18 UTC 2005     root@pf1:/usr/obj/usr/src/sys/POLLING  i386
>Description:
Allow ifconfig to display interfaces based on a partial match (like sysctl, etc).  For example:

# ifconfig lo
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
        inet6 ::1 prefixlen 128 
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5 
        inet 127.0.0.1 netmask 0xff000000 
lo1: flags=8008<LOOPBACK,MULTICAST> mtu 16384

>How-To-Repeat:
              
>Fix:
http://desync.com/~bw/ifconfig.partialmatch.diff
>Release-Note:
>Audit-Trail:

From: Brooks Davis <brooks@one-eyed-alien.net>
To: Ben Wilber <bw@desync.com>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/88119: [patch] partial matching for ifconfig
Date: Fri, 28 Oct 2005 11:39:57 -0700

 Nice idea.  I'm not convinved of the implementation though.  First, the
 isdigit() check is bogus because of interface renaming.  You might well
 want to match all the wan interfaces on a system with a naming scheme
 like lax-wan, sfo-wan, sea-wan.  I suspect it may also break "ifconfig
 gif create".  Second, this turns something that was previously an error
 into something that works which may be confusing.  My suggestion would
 be to implement a new flag, probably -e, which implements egrep style
 matching using regex(3) (usr.bin/pkill looks like a good example.)  This
 would be both more powerful and avoid the whole issue of POLA
 violations.
 
 -- Brooks

From: bw@desync.com
To: Brooks Davis <brooks@one-eyed-alien.net>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/88119: [patch] partial matching for ifconfig
Date: Fri, 28 Oct 2005 17:42:58 -0400

 Comments inline.
 
 On Fri, Oct 28, 2005 at 11:39:57AM -0700, Brooks Davis wrote:
 > Nice idea.  I'm not convinved of the implementation though.  First, the
 > isdigit() check is bogus because of interface renaming.  You might well
 > want to match all the wan interfaces on a system with a naming scheme
 > like lax-wan, sfo-wan, sea-wan.
 
 That's true.  This functionality might be less useful if your interface
 naming scheme doesn't have some sort of sensible prefix.
 
 The isdigit() call wasn't well thought out with regard to interface
 renaming.  I have revised the patch to match partially only if
 the interface specified doesn't exist.
 
 http://desync.com/~bw/ifconfig.partialmatch.revised.diff
 
 > I suspect it may also break "ifconfig gif create".
 
 It doesn't.
 
 > Second, this turns something that was previously an error
 > into something that works which may be confusing.  My suggestion would
 > be to implement a new flag, probably -e, which implements egrep style
 > matching using regex(3) (usr.bin/pkill looks like a good example.)  This
 > would be both more powerful and avoid the whole issue of POLA
 > violations.
 
 This is a very simple modification, intended to add convenience for those
 of us that use FreeBSD with lots of interfaces.  I don't think the
 addition of a flag or regex matching adds convenience.
 
 > -- Brooks
 
 bw.
 

From: Brooks Davis <brooks@one-eyed-alien.net>
To: bw@desync.com
Cc: Brooks Davis <brooks@one-eyed-alien.net>, freebsd-gnats-submit@freebsd.org
Subject: Re: bin/88119: [patch] partial matching for ifconfig
Date: Fri, 28 Oct 2005 15:32:02 -0700

 On Fri, Oct 28, 2005 at 05:42:58PM -0400, bw@desync.com wrote:
 > Comments inline.
 > 
 > On Fri, Oct 28, 2005 at 11:39:57AM -0700, Brooks Davis wrote:
 > > Nice idea.  I'm not convinved of the implementation though.  First, the
 > > isdigit() check is bogus because of interface renaming.  You might well
 > > want to match all the wan interfaces on a system with a naming scheme
 > > like lax-wan, sfo-wan, sea-wan.
 > 
 > That's true.  This functionality might be less useful if your interface
 > naming scheme doesn't have some sort of sensible prefix.
 >
 > The isdigit() call wasn't well thought out with regard to interface
 > renaming.  I have revised the patch to match partially only if
 > the interface specified doesn't exist.
 > 
 > http://desync.com/~bw/ifconfig.partialmatch.revised.diff
 
 The manpage entry is problematic in that "match" is poorly defined.
 Also, "if (ifindex == 0)" should probably be "if (ifindex == 0 && argc
 == 0)" so the result of "ifconfig l <stuff>" isn't:
 
 lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
 	inet6 ::1 prefixlen 128
 	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
 	inet 127.0.0.1 netmask 0xff000000
 
 > > Second, this turns something that was previously an error
 > > into something that works which may be confusing.  My suggestion would
 > > be to implement a new flag, probably -e, which implements egrep style
 > > matching using regex(3) (usr.bin/pkill looks like a good example.)  This
 > > would be both more powerful and avoid the whole issue of POLA
 > > violations.
 > 
 > This is a very simple modification, intended to add convenience for those
 > of us that use FreeBSD with lots of interfaces.  I don't think the
 > addition of a flag or regex matching adds convenience.
 
 Thinking about it more I find this to be a significant POLA violation.
 It means you can no longer reliably test for interface existence with:
 
 if ifconfig $ifn > /dev/null 2>&1; then
 ...
 
 As such I believe a new flag is required.  If you used strstr to
 implement grep-like semantics, -g would be appropriate.  I'm not sure
 what flag would be best for prefix matching.  IMO, -e with egrep regexps
 would be best.  Ideally, -l would be enhanced to support this filtering
 as well.
 
 -- Brooks

From: bw@desync.com
To: Brooks Davis <brooks@one-eyed-alien.net>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/88119: [patch] partial matching for ifconfig
Date: Fri, 28 Oct 2005 19:26:58 -0400

 On Fri, Oct 28, 2005 at 03:32:02PM -0700, Brooks Davis wrote:
 > The manpage entry is problematic in that "match" is poorly defined.
 
 I have changed the wording slightly.  "Matching multiple interfaces"
 lends itself to a format such as "ifconfig if0,if1 up", in my opinion.
 
 > Also, "if (ifindex == 0)" should probably be "if (ifindex == 0 && argc
 > == 0)" so the result of "ifconfig l <stuff>" isn't:
 > 
 > lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
 > 	inet6 ::1 prefixlen 128
 > 	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
 > 	inet 127.0.0.1 netmask 0xff000000
 
 I guess you're right; that could be confusing.
 
 > Thinking about it more I find this to be a significant POLA violation.
 > It means you can no longer reliably test for interface existence with:
 > 
 > if ifconfig $ifn > /dev/null 2>&1; then
 > ...
 
 True, fixed.
 
 > As such I believe a new flag is required.  If you used strstr to
 > implement grep-like semantics, -g would be appropriate.  I'm not sure
 > what flag would be best for prefix matching.  IMO, -e with egrep regexps
 > would be best.  Ideally, -l would be enhanced to support this filtering
 > as well.
 
 -l is for use in scripts.  I see no benefit to partial matching in such
 a case.
 
 http://desync.com/~bw/ifconfig.partialmatch.revised2.diff
 
 > -- Brooks
 
 bw.

From: Brooks Davis <brooks@one-eyed-alien.net>
To: bw@desync.com
Cc: Brooks Davis <brooks@one-eyed-alien.net>, freebsd-gnats-submit@freebsd.org
Subject: Re: bin/88119: [patch] partial matching for ifconfig
Date: Sun, 30 Oct 2005 09:18:22 -0800

 On Fri, Oct 28, 2005 at 07:26:58PM -0400, bw@desync.com wrote:
 > On Fri, Oct 28, 2005 at 03:32:02PM -0700, Brooks Davis wrote:
 > > Thinking about it more I find this to be a significant POLA violation.
 > > It means you can no longer reliably test for interface existence with:
 > > 
 > > if ifconfig $ifn > /dev/null 2>&1; then
 > > ...
 > 
 > True, fixed.
 
 I dislike this 'fix'.  If the partial matching is going to be generally
 useful, ifconfig needs to have a valid return status when it's run.
 
 I'm unwilling to commit this feature without it being activated by a flag.
 
 -- Brooks

From: bw@desync.com
To: Brooks Davis <brooks@one-eyed-alien.net>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/88119: [patch] partial matching for ifconfig
Date: Sun, 30 Oct 2005 17:35:30 -0500

 On Sun, Oct 30, 2005 at 09:18:22AM -0800, Brooks Davis wrote:
 > On Fri, Oct 28, 2005 at 07:26:58PM -0400, bw@desync.com wrote:
 > > True, fixed.
 > 
 > I dislike this 'fix'.  If the partial matching is going to be generally
 > useful, ifconfig needs to have a valid return status when it's run.
 
 I'll just point out that OpenBSD's ifconfig returns true when displaying
 interfaces by group.
 
 > I'm unwilling to commit this feature without it being activated by a flag.
 
 You've missed the point of the patch, anyway.  I withdraw my PR.
 
 > -- Brooks
 
 bw.

From: Brooks Davis <brooks@one-eyed-alien.net>
To: bw@desync.com
Cc: Brooks Davis <brooks@one-eyed-alien.net>, freebsd-gnats-submit@freebsd.org
Subject: Re: bin/88119: [patch] partial matching for ifconfig
Date: Mon, 31 Oct 2005 16:04:42 -0800

 On Sun, Oct 30, 2005 at 05:35:30PM -0500, bw@desync.com wrote:
 > On Sun, Oct 30, 2005 at 09:18:22AM -0800, Brooks Davis wrote:
 > > On Fri, Oct 28, 2005 at 07:26:58PM -0400, bw@desync.com wrote:
 > > > True, fixed.
 > > 
 > > I dislike this 'fix'.  If the partial matching is going to be generally
 > > useful, ifconfig needs to have a valid return status when it's run.
 > 
 > I'll just point out that OpenBSD's ifconfig returns true when displaying
 > interfaces by group.
 
 The OpenBSD group stuff is based on a concept that is invalid today.
 The <drivername><unitnumber> model has a long history, but it poorly
 suited to reality, hense interface renaming.  Once names are arbitrary,
 treating the driver name as a group no longer makes sense (not that
 it ever made much sense given that we name interfaces by driver
 implementation and have dozens of implementations.)
 
 I thank your for your submission and for discussing this, I just can't
 convince myself that the POLA volations this creates are worth the
 convenience.  Ifconfig has too many users and is used in too many
 scripts to change it lightly.
 
 -- Brooks

From: Bruce M Simpson <bms@incunabulum.net>
To: freebsd-gnats-submit@FreeBSD.org
Cc: Ben Wilber <bw@desync.com>
Subject: Re: bin/88119: [patch] partial matching for ifconfig(8)
Date: Wed, 07 Feb 2007 03:39:19 +0000

 OK to close this PR? 7.x has the interface group thing now, though it 
 hasn't been backported yet.
State-Changed-From-To: open->closed 
State-Changed-By: bms 
State-Changed-When: Wed Feb 7 03:59:35 UTC 2007 
State-Changed-Why:  
Submitter says OK to close 

http://www.freebsd.org/cgi/query-pr.cgi?pr=88119 

From: ben wilber <ben@desync.com>
To: Bruce M Simpson <bms@incunabulum.net>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/88119: [patch] partial matching for ifconfig(8)
Date: Tue, 6 Feb 2007 22:48:34 -0500

 --Apple-Mail-13--760614073
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=US-ASCII;
 	delsp=yes;
 	format=flowed
 
 Yes, perfect.  Thanks!
 
 On Feb 6, 2007, at 10:39 PM, Bruce M Simpson wrote:
 
 > OK to close this PR? 7.x has the interface group thing now, though  
 > it hasn't been backported yet.
 
 
 --Apple-Mail-13--760614073
 Content-Transfer-Encoding: base64
 Content-Type: application/pkcs7-signature;
 	name=smime.p7s
 Content-Disposition: attachment;
 	filename=smime.p7s
 
 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIFmTCCAlIw
 ggG7oAMCAQICEHKTDjJMIaVOOL7caifFFXgwDQYJKoZIhvcNAQEEBQAwYjELMAkGA1UEBhMCWkEx
 JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQ
 ZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA2MDUxNzAwMjQzMloXDTA3MDUxNzAwMjQz
 MlowQDEfMB0GA1UEAxMWVGhhd3RlIEZyZWVtYWlsIE1lbWJlcjEdMBsGCSqGSIb3DQEJARYOYmVu
 QGRlc3luYy5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKHM8H9SDqgpFXwZuXkmS4/O
 +Q2MoKKyN0r/Z8djWDkmgyud9FHKxCl2bNYKc40CHefcoQrKeG20kJMxvtwKQSICmZNRDmPnpiA0
 tcCGRm2i5W0x3kH8BNSRebDoTU8UMGNqCZ6CUeoltyAibYxSjIqoRMDgZs8IDgGd3ngZPxabAgMB
 AAGjKzApMBkGA1UdEQQSMBCBDmJlbkBkZXN5bmMuY29tMAwGA1UdEwEB/wQCMAAwDQYJKoZIhvcN
 AQEEBQADgYEAlPkmsdhmpCm0IkU5bh77NhSqQez+V4n0ubptWISMMI5PoUoHo6xWbq0dVH8UoQaR
 ohzoncVWHvnYAq+J8PHVpR2bqSFR5jpp4nFUiqoEB6YV0D28u2HlPfuS3+JWlNuhmPiNprNoZpar
 nQUV7kakYMwVArr8DxglPI2i40XzEr0wggM/MIICqKADAgECAgENMA0GCSqGSIb3DQEBBQUAMIHR
 MQswCQYDVQQGEwJaQTEVMBMGA1UEC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