Date: Fri, 28 Oct 2005 22:40:19 GMT From: Brooks Davis <brooks@one-eyed-alien.net> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/88119: [patch] partial matching for ifconfig Message-ID: <200510282240.j9SMeIaY007587@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/88119; it has been noted by GNATS. 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200510282240.j9SMeIaY007587>
