Re: carp shutdown in /etc/rc

2011-02-04 Thread Henning Brauer
* Camiel Dobbelaar c...@sentia.nl [2011-02-04 13:21]:
 With hundreds of (vlan) interfaces, a shutdown takes quite a while.
 Fix below.

hmm. this relies on all carp interfaces being in the carp interface
group. while that is the default, it is not necessarily so.

-- 
Henning Brauer, h...@bsws.de, henn...@openbsd.org
BS Web Services, http://bsws.de
Full-Service ISP - Secure Hosting, Mail and DNS Services
Dedicated Servers, Rootservers, Application Hosting



Re: carp shutdown in /etc/rc

2011-02-04 Thread Stuart Henderson
On 2011/02/04 14:37, Camiel Dobbelaar wrote:
 On 4-2-2011 13:32, Henning Brauer wrote:
  * Camiel Dobbelaar c...@sentia.nl [2011-02-04 13:21]:
  With hundreds of (vlan) interfaces, a shutdown takes quite a while.
  Fix below.
  
  hmm. this relies on all carp interfaces being in the carp interface
  group. while that is the default, it is not necessarily so.
 
 I didn't know that a groupname takes precendence, neither did the
 manpage.  :-)

 +If an interface group with that name exists, all interfaces in the group
 +will be shown.

seems it's more complicated than that - if you remove all interfaces
from group carp, 'ifconfig carp' lists nothing:

$ ifconfig |grep ^carp
carp1: flags=8802BROADCAST,SIMPLEX,MULTICAST mtu 1500
carp2: flags=8802BROADCAST,SIMPLEX,MULTICAST mtu 1500
$ ifconfig carp  
$

but with another type, this doesn't apply:

$ sudo ifconfig bge0 group em
$ ifconfig em | egrep '(0: |groups:)'
bge0: flags=28843UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,NOINET6 mtu 1500
groups: em
$ sudo ifconfig bge0 -group em
$ ifconfig em | egrep '(0: |groups:)'
em0: flags=8b43UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST mtu 
1500
groups: egress



Re: carp shutdown in /etc/rc

2011-02-04 Thread Jason McIntyre
On Fri, Feb 04, 2011 at 02:37:43PM +0100, Camiel Dobbelaar wrote:
 On 4-2-2011 13:32, Henning Brauer wrote:
  * Camiel Dobbelaar c...@sentia.nl [2011-02-04 13:21]:
  With hundreds of (vlan) interfaces, a shutdown takes quite a while.
  Fix below.
  
  hmm. this relies on all carp interfaces being in the carp interface
  group. while that is the default, it is not necessarily so.
 
 I didn't know that a groupname takes precendence, neither did the
 manpage.  :-)
 
 --
 Cam
 Index: ifconfig.8
 ===
 RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v
 retrieving revision 1.212
 diff -u -r1.212 ifconfig.8
 --- ifconfig.823 Dec 2010 08:54:59 -  1.212
 +++ ifconfig.84 Feb 2011 13:32:21 -
 @@ -97,11 +97,15 @@
  .Dq en0 .
  If no optional parameters are supplied, this string can instead be just
  .Dq name .
 -In this case, all interfaces of that type will be displayed.
 +If an interface group with that name exists, all interfaces in the group
 +will be shown.
 +Otherwise, 
 +.Dq name
 +is treated as a type and all interfaces of that type will be displayed.
  For example,
 -.Dq carp
 +.Dq fxp
  will display the current configuration of all
 -.Xr carp 4
 +.Xr fxp 4
  interfaces.
  .It Ar address_family
  Specifies the address family
 

is this a useful distinction (even a valid one)? it sounds confusing to
me.

can you have carp interfaces that are not part of the carp group?

that is, ifconfig carp will display all carp interfaces, or all
interfaces in the carp group. is that not two ways of saying the same
thing?

jmc



Re: carp shutdown in /etc/rc

2011-02-04 Thread Camiel Dobbelaar
On 4-2-2011 15:06, Stuart Henderson wrote:
 On 2011/02/04 14:37, Camiel Dobbelaar wrote:
 On 4-2-2011 13:32, Henning Brauer wrote:
 * Camiel Dobbelaar c...@sentia.nl [2011-02-04 13:21]:
 With hundreds of (vlan) interfaces, a shutdown takes quite a while.
 Fix below.

 hmm. this relies on all carp interfaces being in the carp interface
 group. while that is the default, it is not necessarily so.

 I didn't know that a groupname takes precendence, neither did the
 manpage.  :-)
 
 +If an interface group with that name exists, all interfaces in the group
 +will be shown.
 
 seems it's more complicated than that - if you remove all interfaces
 from group carp, 'ifconfig carp' lists nothing:
 
 $ ifconfig |grep ^carp
 carp1: flags=8802BROADCAST,SIMPLEX,MULTICAST mtu 1500
 carp2: flags=8802BROADCAST,SIMPLEX,MULTICAST mtu 1500
 $ ifconfig carp  
 $
 
 but with another type, this doesn't apply:
 
 $ sudo ifconfig bge0 group em
 $ ifconfig em | egrep '(0: |groups:)'
 bge0: flags=28843UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,NOINET6 mtu 1500
 groups: em
 $ sudo ifconfig bge0 -group em
 $ ifconfig em | egrep '(0: |groups:)'
 em0: flags=8b43UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST mtu 
 1500
 groups: egress

It looks like group carp is never removed from the system, even if it
becomes empty.  That makes sense since some daemons use it as a default.

But the manpage diff is still correct, isn't it?

--
Cam



Re: carp shutdown in /etc/rc

2011-02-04 Thread Stuart Henderson
On 2011/02/04 14:08, Jason McIntyre wrote:
  +If an interface group with that name exists, all interfaces in the group
  +will be shown.
  +Otherwise, 
  +.Dq name
  +is treated as a type and all interfaces of that type will be displayed.
 
 is this a useful distinction (even a valid one)? it sounds confusing to
 me.
 
 can you have carp interfaces that are not part of the carp group?

 that is, ifconfig carp will display all carp interfaces, or all
 interfaces in the carp group. is that not two ways of saying the same
 thing?

yes, e.g. ifconfig carp123 group foo -group carp
this is useful when you want a set of interfaces to failover as a group.



Re: carp shutdown in /etc/rc

2011-02-04 Thread Henning Brauer
* Camiel Dobbelaar c...@sentia.nl [2011-02-04 15:30]:
 On 4-2-2011 15:06, Stuart Henderson wrote:
  On 2011/02/04 14:37, Camiel Dobbelaar wrote:
  On 4-2-2011 13:32, Henning Brauer wrote:
  * Camiel Dobbelaar c...@sentia.nl [2011-02-04 13:21]:
  With hundreds of (vlan) interfaces, a shutdown takes quite a while.
  Fix below.
 
  hmm. this relies on all carp interfaces being in the carp interface
  group. while that is the default, it is not necessarily so.
 
  I didn't know that a groupname takes precendence, neither did the
  manpage.  :-)
  
  +If an interface group with that name exists, all interfaces in the group
  +will be shown.
  
  seems it's more complicated than that - if you remove all interfaces
  from group carp, 'ifconfig carp' lists nothing:
  
  $ ifconfig |grep ^carp
  carp1: flags=8802BROADCAST,SIMPLEX,MULTICAST mtu 1500
  carp2: flags=8802BROADCAST,SIMPLEX,MULTICAST mtu 1500
  $ ifconfig carp  
  $
  
  but with another type, this doesn't apply:
  
  $ sudo ifconfig bge0 group em
  $ ifconfig em | egrep '(0: |groups:)'
  bge0: flags=28843UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,NOINET6 mtu 1500
  groups: em
  $ sudo ifconfig bge0 -group em
  $ ifconfig em | egrep '(0: |groups:)'
  em0: flags=8b43UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST 
  mtu 1500
  groups: egress
 
 It looks like group carp is never removed from the system, even if it
 becomes empty.  That makes sense since some daemons use it as a default.

i don't think there is is special treatment for the carp group. but
memory is fuzzy. we might very well forget to clean up when a group
becomes empty.

 But the manpage diff is still correct, isn't it?

it's clear the manoage isn't right as-is, that's for sure ;)

-- 
Henning Brauer, h...@bsws.de, henn...@openbsd.org
BS Web Services, http://bsws.de
Full-Service ISP - Secure Hosting, Mail and DNS Services
Dedicated Servers, Rootservers, Application Hosting



Re: carp shutdown in /etc/rc

2011-02-04 Thread Henning Brauer
* Jason McIntyre j...@cava.myzen.co.uk [2011-02-04 15:17]:
 is this a useful distinction (even a valid one)? it sounds confusing to
 me.

yes: ifconfig carp0 -group carp

 can you have carp interfaces that are not part of the carp group?
 
 that is, ifconfig carp will display all carp interfaces, or all
 interfaces in the carp group. is that not two ways of saying the same
 thing?

no, because you can remove carp interfaces from the carp group.
for cloners interfaces are always added to a group with its basename.
cloner: everything that you can ifconfig create + destroy
carpX - carp group
pppoeX - pppoe group
and so on

-- 
Henning Brauer, h...@bsws.de, henn...@openbsd.org
BS Web Services, http://bsws.de
Full-Service ISP - Secure Hosting, Mail and DNS Services
Dedicated Servers, Rootservers, Application Hosting



Re: carp shutdown in /etc/rc

2011-02-04 Thread Tobias Weingartner
On Friday, February 4, Henning Brauer wrote:
 
 i don't think there is is special treatment for the carp group. but
 memory is fuzzy. we might very well forget to clean up when a group
 becomes empty.

There is a bit of an inconsistency when it comes to
'ifconfig foo' style of the ifconfig command.  You
can do 'ifconfig groupname', and it will show all
interfaces in group groupname.  You can also do
'ifconfig dev-prefix', which seems to show all the
interfaces with the particular device prefix.

For example, on my box, if I do 'ifconfig bge', it
will show me all bge* interfaces, even if none of
them are in a group called 'bge'.  So the shutdown
could be correct using 'ifconfig carp', if that
command would return all carp interfaces because
carp is the dev-prefix.  However, since we have
a carp group, it uses that instead...


--Toby.



ksh completion for [, :, $

2011-02-04 Thread Alexander Polakov
Hi there,

I sent this diff to bugs@ some time ago but haven't got any replies.
Probably tech@ is a better place for it.

The problem is known as bz#6006/user.

The fix is taken from mksh (rev.1.4 for [ and rev.1.184 for others).
It adds quoting character (QCHAR) when [, $, ` are prepended by \ to make
them be interpreted literally (like if they were enclosed in ' ').
It also adds : to the list of escaped characters.
Original commit message:

revision 1.184
date: 2009-10-30 00:57:36 +;  author: tg;  state: Exp;  lines: +10 -8;  
commitid: 1004AEA39BD3F10ECFA;
make tab completing filenames with ':' '=' '$' '`' work as well as
others (colon and equals sign need to be simply escaped, while dollar
sign and accent gravis need double escaping like opening square brak-
ket did back then); add = to C_QUOTE to simplify (doesn't break any-
thing) and sort these strings asciibetically while here


Index: bin/ksh/edit.c
===
RCS file: /cvs/src/bin/ksh/edit.c,v
retrieving revision 1.34
diff -u -r1.34 edit.c
--- bin/ksh/edit.c  20 May 2010 01:13:07 -  1.34
+++ bin/ksh/edit.c  4 Feb 2011 17:58:48 -
@@ -365,6 +365,11 @@
continue;
}
 
+   /* specially escape escaped [ or $ or ` for globbing */
+   if (escaping  (toglob[i] == '[' ||
+   toglob[i] == '$' || toglob[i] == '`'))
+   toglob[idx++] = QCHAR;
+
toglob[idx] = toglob[i];
idx++;
if (escaping) escaping = 0;
@@ -378,7 +383,7 @@
s = pushs(SWSTR, ATEMP);
s-start = s-str = toglob;
source = s;
-   if (yylex(ONEWORD) != LWORD) {
+   if (yylex(ONEWORD|LQCHAR) != LWORD) {
source = sold;
internal_errorf(0, fileglob: substitute error);
return 0;
@@ -821,7 +826,7 @@
int rval = 0;
 
for (add = 0, wlen = len; wlen - add  0; add++) {
-   if (strchr(\#$'()*;=?[\\]`{|}, s[add]) ||
+   if (strchr(\#$'()*:;=?[\\]`{|}, s[add]) ||
strchr(ifs, s[add])) {
if (putbuf_func(s, add) != 0) {
rval = -1;
Index: bin/ksh/lex.c
===
RCS file: /cvs/src/bin/ksh/lex.c,v
retrieving revision 1.44
diff -u -r1.44 lex.c
--- bin/ksh/lex.c   3 Jul 2008 17:52:08 -   1.44
+++ bin/ksh/lex.c   4 Feb 2011 17:58:48 -
@@ -411,6 +411,13 @@
}
}
break;
+   case QCHAR:
+   if (cf  LQCHAR) {
+   *wp++ = QCHAR;
+   *wp++ = getsc();
+   break;
+   }
+   /* fallthrough */
default:
*wp++ = CHAR, *wp++ = c;
}
Index: bin/ksh/lex.h
===
RCS file: /cvs/src/bin/ksh/lex.h,v
retrieving revision 1.11
diff -u -r1.11 lex.h
--- bin/ksh/lex.h   29 May 2006 18:22:24 -  1.11
+++ bin/ksh/lex.h   4 Feb 2011 17:58:48 -
@@ -113,6 +113,7 @@
 #define CMDWORD BIT(8) /* parsing simple command (alias related) */
 #define HEREDELIM BIT(9)   /* parsing ,- delimiter */
 #define HEREDOC BIT(10)/* parsing heredoc */
+#define LQCHAR BIT(11) /* source string contains QCHAR */
 
 #defineHERES   10  /* max  in line */
 

-- 
Alexander Polakov | plhk.ru



Re: carp shutdown in /etc/rc

2011-02-04 Thread Henning Brauer
* Tobias Weingartner weing...@tepid.org [2011-02-04 20:19]:
 On Friday, February 4, Henning Brauer wrote:
  i don't think there is is special treatment for the carp group. but
  memory is fuzzy. we might very well forget to clean up when a group
  becomes empty.
 There is a bit of an inconsistency when it comes to
 'ifconfig foo' style of the ifconfig command.  You
 can do 'ifconfig groupname', and it will show all
 interfaces in group groupname.  You can also do
 'ifconfig dev-prefix', which seems to show all the
 interfaces with the particular device prefix.

the latter is really a backwards compat thing. that was already there
before i wrote ifgroups, kinda... it might be time to fling off these
restraints. 

 For example, on my box, if I do 'ifconfig bge', it
 will show me all bge* interfaces, even if none of
 them are in a group called 'bge'.  So the shutdown
 could be correct using 'ifconfig carp', if that
 command would return all carp interfaces because
 carp is the dev-prefix.  However, since we have
 a carp group, it uses that instead...

yes, i dislike that.

we decided against an automatic group for non-cloners. i do remember
discussions about it, i think i had those initially. i can't really
remember the reasoning for dropping these, but i have to admit i see
little use in them. which probably was the reason.

-- 
Henning Brauer, h...@bsws.de, henn...@openbsd.org
BS Web Services, http://bsws.de
Full-Service ISP - Secure Hosting, Mail and DNS Services
Dedicated Servers, Rootservers, Application Hosting



Re: carp shutdown in /etc/rc

2011-02-04 Thread Ted Unangst
On Fri, Feb 4, 2011 at 7:21 AM, Camiel Dobbelaar c...@sentia.nl wrote:
 With hundreds of (vlan) interfaces, a shutdown takes quite a while.
# bring carp interfaces down gracefully
 -   ifconfig | while read a b; do
 +   ifconfig carp | while read a b; do

going back to the original issue, does ifconfig | grep carp | while
read a b make things faster?