Re: fstab.5: FSTAB_RQ

2010-09-23 Thread Otto Moerbeek
On Thu, Sep 23, 2010 at 06:14:10PM +, Thordur Bjornsson wrote:

> On Thu, Sep 23, 2010 at 06:36:43PM +0059, Jason McIntyre wrote:
> > is there a reason why we don;t document FSTAB_RQ?
> Not one that I can think of. If this works as intended
> go ahead (it should).

I don't think getmntoptions() recognizes rq. Beside that, it is really
outdated and makes no difference between userquota and groupquota. I'd
rather remove it than document it. 

-Otto

> 
> > jmc
> > 
> > Index: fstab.5
> > ===
> > RCS file: /cvs/src/share/man/man5/fstab.5,v
> > retrieving revision 1.42
> > diff -u -r1.42 fstab.5
> > --- fstab.5 8 Jun 2009 17:03:15 -   1.42
> > +++ fstab.5 23 Sep 2010 17:36:53 -
> > @@ -183,7 +183,8 @@
> >  If
> >  .Fa fs_type
> >  is
> > -.Dq rw
> > +.Dq rw ,
> > +.Dq rq ,
> >  or
> >  .Dq ro
> >  then the filesystem whose name is given in the
> > @@ -243,7 +244,8 @@
> >  .Xr fsck 8
> >  will assume that the filesystem does not need to be checked.
> >  .Bd -literal
> > -#defineFSTAB_RW"rw"/* read-write device */
> > +#defineFSTAB_RW"rw"/* read/write device */
> > +#defineFSTAB_RQ"rq"/* read/write with quotas *
> >  #defineFSTAB_RO"ro"/* read-only device */
> >  #defineFSTAB_SW"sw"/* swap device */
> >  #defineFSTAB_XX"xx"/* ignore totally */
> > @@ -253,7 +255,7 @@
> > char*fs_file;   /* filesystem path prefix */
> > char*fs_vfstype;/* type of filesystem */
> > char*fs_mntops; /* comma separated mount options */
> > -   char*fs_type;   /* rw, ro, sw, or xx */
> > +   char*fs_type;   /* rw, rq, ro, sw, or xx */
> > int fs_freq;/* dump frequency, in days */
> > int fs_passno;  /* pass number on parallel fsck */
> >  };



Re: Testers needed for strict locking diff; esp i386, amd64, softraid

2010-09-23 Thread Matthew Dempsky
I'd like to commit this.  I've received positive reports from a few
amd64 users and an i386 and softraid user, and all of the locking bugs
exposed so far have already been fixed.

I plan to remove the "#define panic()" hacks and let future locking
problems actually panic; if anyone thinks they should stay in for a
bit longer, let me know.

ok?


On Mon, Sep 20, 2010 at 08:00:27PM -0700, Matthew Dempsky wrote:
> I'd really appreciate if people could test the diffs below and report
> back to me.  This adds some warnings about lock API misuse that has
> already caught two bugs in DRM.  Eventually, I want these to be panics
> instead, but using just warnings for now should make it easier for
> people to test.
> 
> Please apply the diff below to an up-to-date -current kernel and check
> dmesg for any stack backtraces.  If you see any, please send them to
> me.
> 
> I'd especially like reports from both i386 and amd64, and also from
> softraid users.
> 
> 
> More details on the diff: this adds per-processor mutex lock counting
> to i386 and amd64, and updates assertwaitok() to check that this value
> is 0.  They also now check that the process that calls mtx_leave() is
> the same that called mtx_enter().  rw_exit*() are changed to call
> rw_assert_{rd,wr}lock() as appropriate.  Finally, mi_switch() also
> calls assertwaitok() now.
> 
> 
> Index: kern/subr_xxx.c
> ===
> RCS file: /cvs/src/sys/kern/subr_xxx.c,v
> retrieving revision 1.10
> diff -u -p -r1.10 subr_xxx.c
> --- kern/subr_xxx.c   21 Sep 2010 01:09:10 -  1.10
> +++ kern/subr_xxx.c   21 Sep 2010 01:45:59 -
> @@ -153,6 +153,9 @@ blktochr(dev_t dev)
>   return (NODEV);
>  }
>  
> +#include 
> +#define panic(x...) do { printf(x); db_stack_dump(); } while (0);
> +
>  /*
>   * Check that we're in a context where it's okay to sleep.
>   */
> @@ -160,4 +163,9 @@ void
>  assertwaitok(void)
>  {
>   splassert(IPL_NONE);
> +#ifdef __HAVE_CPU_MUTEX_LEVEL
> + if (curcpu()->ci_mutex_level != 0)
> + panic("assertwaitok: non-zero mutex count: %d",
> + curcpu()->ci_mutex_level);
> +#endif
>  }
> Index: kern/kern_rwlock.c
> ===
> RCS file: /cvs/src/sys/kern/kern_rwlock.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 kern_rwlock.c
> --- kern/kern_rwlock.c13 Aug 2009 23:12:15 -  1.15
> +++ kern/kern_rwlock.c21 Sep 2010 01:45:59 -
> @@ -107,6 +107,8 @@ rw_exit_read(struct rwlock *rwl)
>  {
>   unsigned long owner = rwl->rwl_owner;
>  
> + rw_assert_rdlock(rwl);
> +
>   if (__predict_false((owner & RWLOCK_WAIT) ||
>   rw_cas(&rwl->rwl_owner, owner, owner - RWLOCK_READ_INCR)))
>   rw_exit(rwl);
> @@ -117,6 +119,8 @@ rw_exit_write(struct rwlock *rwl)
>  {
>   unsigned long owner = rwl->rwl_owner;
>  
> + rw_assert_wrlock(rwl);
> +
>   if (__predict_false((owner & RWLOCK_WAIT) ||
>   rw_cas(&rwl->rwl_owner, owner, 0)))
>   rw_exit(rwl);
> @@ -236,6 +240,11 @@ rw_exit(struct rwlock *rwl)
>   int wrlock = owner & RWLOCK_WRLOCK;
>   unsigned long set;
>  
> + if (wrlock)
> + rw_assert_wrlock(rwl);
> + else
> + rw_assert_rdlock(rwl);
> +
>   do {
>   owner = rwl->rwl_owner;
>   if (wrlock)
> @@ -249,6 +258,10 @@ rw_exit(struct rwlock *rwl)
>   wakeup(rwl);
>  }
>  
> +#include 
> +#define panic(x...) do { printf(x); db_stack_dump(); } while (0);
> +
> +#ifdef DIAGNOSTIC
>  void
>  rw_assert_wrlock(struct rwlock *rwl)
>  {
> @@ -272,3 +285,4 @@ rw_assert_unlocked(struct rwlock *rwl)
>   if (rwl->rwl_owner != 0L)
>   panic("%s: lock held", rwl->rwl_name);
>  }
> +#endif
> Index: kern/sched_bsd.c
> ===
> RCS file: /cvs/src/sys/kern/sched_bsd.c,v
> retrieving revision 1.23
> diff -u -p -r1.23 sched_bsd.c
> --- kern/sched_bsd.c  30 Jun 2010 22:38:17 -  1.23
> +++ kern/sched_bsd.c  21 Sep 2010 01:45:59 -
> @@ -356,6 +356,7 @@ mi_switch(void)
>   int sched_count;
>  #endif
>  
> + assertwaitok();
>   KASSERT(p->p_stat != SONPROC);
>  
>   SCHED_ASSERT_LOCKED();
> Index: arch/amd64/include/cpu.h
> ===
> RCS file: /cvs/src/sys/arch/amd64/include/cpu.h,v
> retrieving revision 1.55
> diff -u -p -r1.55 cpu.h
> --- arch/amd64/include/cpu.h  11 Aug 2010 21:22:44 -  1.55
> +++ arch/amd64/include/cpu.h  21 Sep 2010 01:46:00 -
> @@ -87,6 +87,10 @@ struct cpu_info {
>   int ci_idepth;
>   u_int32_t   ci_imask[NIPL];
>   u_int32_t   ci_iunmask[NIPL];
> +#ifdef DIAGNOSTIC
> + int ci_mutex_level;
> +#define __HAVE_CPU_MUTEX_LEVEL
> +#endif
>  
>   u_int   ci_flags;
>   u_int32_t   ci_ipis;
> Index: arch/amd

Which Of These 5 Marketing Problems Do You Want To Overcome?

2010-09-23 Thread Rich Harshaw
Dear Marketer, Generating new business is tougher than ever, and you might
feel like marketing is a losing battle. I'd like to invite you do download my
FREE audio book (http://mym411.com/) and find real answers that can help you
find solutions to any marketing challenge you may be facing, including:

1.  We have more & more competitors popping up and eating our market
share and making it hard to distinguish our business from the competition.

2.  We're a small business and don't have the budget to compete with the
big boys but we know that we're good at what we do.

3.  We've never done much marketing before and now we need to implement
some kind of marketing plan.

4.  We're getting killed on price by competitors who are selling
low-quality stuff but the customers can't tell the difference until it's too
late.

5.  We're spending a ton of money on advertising and marketing, but don't
seem to be getting much bang for the buck. I can help you overcome any or all
of these problems; the first step is you have to download my free audio book
(http://mym411.com/), "Monopolize Your Marketplace." It will show you new ways
of thinking and executing your marketing.  To download the audio CD program
for FREE, click here (http://mym411.com) or call (888) 777-4886. Warmest
Regards, Rich Harshaw P.S. When you click through to request the CD program
(http://mym411.com/), you can also see several examples of before & after ads,
as well as some testimonials I've gathered over the last 15 years.




Monopolize Your Marketplace
2555 SW Grapevine Pkwy Ste 300 - Grapevine, TX 76051
817-416-4333 - i...@mym411.com



Exclude me from future mailings
(http://go.emaildir3.com/_p_ga4z28tsgart6mtsydvr2jyx7dvubuwx6dfe6kqxrjrv6kyxn
avubutxrd4z2nqxraruza5n_p_/exclude.htm)
Report abuse
(http://go.emaildir3.com/_p_ga4z28tsgart6mtsydvr2jyx7dvubuwx6dfe6kqxrjrv6kyxn
avubutxrd4z2nqxraruza5n_p_/abuse.htm)



Monopolize Your Marketplace, 2555 SW Grapevine Parkway, St 300 Grapevine, TX
76051
This email was intended for: tech@openbsd.org
Remove:
http://go.emaildir3.com/_p_ga4z28tsgart6mtsydvr2jyx7dvubuwx6dfe6kqxrjrv6kyxna
vubutxrd4z2nqxraruza5n_p_/exclude.htm

(Report Abuse) -Only if you feel this email was repeatedly sent to you without
your permission.
http://go.emaildir3.com/_p_ga4z28tsgart6mtsydvr2jyx7dvubuwx6dfe6kqxrjrv6kyxna
vubutxrd4z2nqxraruza5n_p_/abuse.htm



Re: disable wbng

2010-09-23 Thread Stuart Henderson
On 2010/09/23 23:00, Stuart Henderson wrote:
> On 2010/09/23 15:13, Marco Pfatschbacher wrote:
> > On Wed, Sep 22, 2010 at 06:11:58PM +0200, Mike Belopuhov wrote:
> > > there's nothing special about this driver. as it does usual iic_exec's,
> > > i'm not sure what can be actually fixed there.  so if nobody has any
> > > idea what could be done about it, you have my okay to disable it
> > > completely.
> >  
> > It's not the drivers fault, it seems that polling on piixpm(4)
> > causes hangs on ServerWorks HT-1000 chips.
> > 
> > This is what we are running:
> 
> Wow. I didn't think I had that much of a problem with HT-1000 + lm(4),
> certainly nowhere near as noticable as the people with wbng, but this
> makes quite a difference. Think I'll be disabling piixpm on a few
> machines in the fairly near future then...

Or of course maybe the livelocks counter is no longer kept so it's
hard to say what effect this has on my systems right now ;-)



Re: disable wbng

2010-09-23 Thread Stuart Henderson
On 2010/09/23 15:13, Marco Pfatschbacher wrote:
> On Wed, Sep 22, 2010 at 06:11:58PM +0200, Mike Belopuhov wrote:
> > there's nothing special about this driver. as it does usual iic_exec's,
> > i'm not sure what can be actually fixed there.  so if nobody has any
> > idea what could be done about it, you have my okay to disable it
> > completely.
>  
> It's not the drivers fault, it seems that polling on piixpm(4)
> causes hangs on ServerWorks HT-1000 chips.
> 
> This is what we are running:

Wow. I didn't think I had that much of a problem with HT-1000 + lm(4),
certainly nowhere near as noticable as the people with wbng, but this
makes quite a difference. Think I'll be disabling piixpm on a few
machines in the fairly near future then...

> Index: piixpm.c
> ===
> RCS file: /cvs/src/sys/dev/pci/piixpm.c,v
> retrieving revision 1.34
> diff -p -u -r1.34 piixpm.c
> --- piixpm.c  8 Apr 2010 00:23:53 -   1.34
> +++ piixpm.c  23 Sep 2010 13:08:36 -
> @@ -159,6 +159,10 @@ piixpm_attach(struct device *parent, str
>   if (sc->sc_poll)
>   printf(": polling");
>   }
> + if (sc->sc_poll) {
> + printf(" disabled\n");
> + return;
> + }
>  
>   printf("\n");



Zorra de Múltiples Posiciones

2010-09-23 Thread TBX
Zorra de aluminio DUAL $ 540 pesos Capacidad  250 KG
/ Posición en dos ruedas:  Largo 48 cm / Ancho 52 cm / Alto: 132 cm
Posición en cuatro ruedas: Largo 112 cm /  Ancho 52 cm / Alto: 104 cm
/ Medidas de la base: 19 x  46 / Peso 19 KG / Ruedas
fijas: 10" Neumáticas  / Ruedas giratorias 5"
x 1,24



Re: fstab.5: FSTAB_RQ

2010-09-23 Thread Thordur Bjornsson
On Thu, Sep 23, 2010 at 06:36:43PM +0059, Jason McIntyre wrote:
> is there a reason why we don;t document FSTAB_RQ?
Not one that I can think of. If this works as intended
go ahead (it should).

> jmc
> 
> Index: fstab.5
> ===
> RCS file: /cvs/src/share/man/man5/fstab.5,v
> retrieving revision 1.42
> diff -u -r1.42 fstab.5
> --- fstab.5   8 Jun 2009 17:03:15 -   1.42
> +++ fstab.5   23 Sep 2010 17:36:53 -
> @@ -183,7 +183,8 @@
>  If
>  .Fa fs_type
>  is
> -.Dq rw
> +.Dq rw ,
> +.Dq rq ,
>  or
>  .Dq ro
>  then the filesystem whose name is given in the
> @@ -243,7 +244,8 @@
>  .Xr fsck 8
>  will assume that the filesystem does not need to be checked.
>  .Bd -literal
> -#define  FSTAB_RW"rw"/* read-write device */
> +#define  FSTAB_RW"rw"/* read/write device */
> +#define  FSTAB_RQ"rq"/* read/write with quotas *
>  #define  FSTAB_RO"ro"/* read-only device */
>  #define  FSTAB_SW"sw"/* swap device */
>  #define  FSTAB_XX"xx"/* ignore totally */
> @@ -253,7 +255,7 @@
>   char*fs_file;   /* filesystem path prefix */
>   char*fs_vfstype;/* type of filesystem */
>   char*fs_mntops; /* comma separated mount options */
> - char*fs_type;   /* rw, ro, sw, or xx */
> + char*fs_type;   /* rw, rq, ro, sw, or xx */
>   int fs_freq;/* dump frequency, in days */
>   int fs_passno;  /* pass number on parallel fsck */
>  };



fstab.5: FSTAB_RQ

2010-09-23 Thread Jason McIntyre
is there a reason why we don;t document FSTAB_RQ?
jmc

Index: fstab.5
===
RCS file: /cvs/src/share/man/man5/fstab.5,v
retrieving revision 1.42
diff -u -r1.42 fstab.5
--- fstab.5 8 Jun 2009 17:03:15 -   1.42
+++ fstab.5 23 Sep 2010 17:36:53 -
@@ -183,7 +183,8 @@
 If
 .Fa fs_type
 is
-.Dq rw
+.Dq rw ,
+.Dq rq ,
 or
 .Dq ro
 then the filesystem whose name is given in the
@@ -243,7 +244,8 @@
 .Xr fsck 8
 will assume that the filesystem does not need to be checked.
 .Bd -literal
-#defineFSTAB_RW"rw"/* read-write device */
+#defineFSTAB_RW"rw"/* read/write device */
+#defineFSTAB_RQ"rq"/* read/write with quotas *
 #defineFSTAB_RO"ro"/* read-only device */
 #defineFSTAB_SW"sw"/* swap device */
 #defineFSTAB_XX"xx"/* ignore totally */
@@ -253,7 +255,7 @@
char*fs_file;   /* filesystem path prefix */
char*fs_vfstype;/* type of filesystem */
char*fs_mntops; /* comma separated mount options */
-   char*fs_type;   /* rw, ro, sw, or xx */
+   char*fs_type;   /* rw, rq, ro, sw, or xx */
int fs_freq;/* dump frequency, in days */
int fs_passno;  /* pass number on parallel fsck */
 };



jerusalem congress

2010-09-23 Thread International Convention
This mail is intended for therapists, nurses, and medical doctors 

The International Conference on Integrative Medicine will take place in 
Jerusalem 

on October 20-21. 

The conference program and registration details can be found on the internet 

site : www.israelconvention.net



Yours Sincerely



Avraham Fried

Director

The Jerusalem International Conference on Integrative Medicine



Please remove me from the mailing list



Gana dinero desde tu casa

2010-09-23 Thread Miker
Esta la gran oportunidad

Seamos honestos: la vida de la mayorma de las personas es literalmente 
deprimente.

Si, lemste bien.

La mayorma de los seres humanos vive una vida monstona, aburrida, rutinaria 

y en ocasiones angustiante.Y lo peor de todo... es que se dan cuanta de esto 

cuando ya estan a unos pocos aqos de morir! Demasiado tarde... 

Hace click en el siguiente link:  
http://c340fjr8pjy6ru62wa28jdv-p4.hop.clickbank.net/?tid=943ASTRA





Te voy a hacer una pregunta... ?Te parece conocida la siguiente situacisn?:

Te despiertas muy temprano cuando escuchas el despertador (todavma con mucho 

sueqo);

Te apresuras para llegar al trabajo a una hora especmfica;

Pasas de 8 a 12 horas encerrado en una oficina o en un lugar en el cual no 

quieres estar;

Regresas en la noche a tu casa muy cansado y te preparas para iniciar la misma 

rutina al dma siguiente;





Hace click en el siguiente link:  
http://c340fjr8pjy6ru62wa28jdv-p4.hop.clickbank.net/?tid=943ASTRA





Si te identificaste con esta "rutina" monstona y aburrida, no te preocupes...

No eres el znico.

Porque esta es la vida DIARIA de la mayorma de las personas actualmente. Y 

si a todo esto le sumas la angustia y preocupacisn de que no puedes abandonar 

esta rutina debido a las deudas y problemas econsmicos...

La situacisn se vuelve literalmente insoportable.

A esta situacisn aparentemente "sin salida" la llamo: "La Esclavitud Del 
Sistema".





Hace click en el siguiente link: 
http://c340fjr8pjy6ru62wa28jdv-p4.hop.clickbank.net/?tid=943ASTRA



Cordialmente



Mikerven

Escuela De Los Ricos



Re: disable wbng

2010-09-23 Thread Marco Pfatschbacher
On Wed, Sep 22, 2010 at 06:11:58PM +0200, Mike Belopuhov wrote:
> there's nothing special about this driver. as it does usual iic_exec's,
> i'm not sure what can be actually fixed there.  so if nobody has any
> idea what could be done about it, you have my okay to disable it
> completely.
 
It's not the drivers fault, it seems that polling on piixpm(4)
causes hangs on ServerWorks HT-1000 chips.

This is what we are running:

Index: piixpm.c
===
RCS file: /cvs/src/sys/dev/pci/piixpm.c,v
retrieving revision 1.34
diff -p -u -r1.34 piixpm.c
--- piixpm.c8 Apr 2010 00:23:53 -   1.34
+++ piixpm.c23 Sep 2010 13:08:36 -
@@ -159,6 +159,10 @@ piixpm_attach(struct device *parent, str
if (sc->sc_poll)
printf(": polling");
}
+   if (sc->sc_poll) {
+   printf(" disabled\n");
+   return;
+   }
 
printf("\n");



Re: ftp-proxy: /etc/ftp-proxy.conf support

2010-09-23 Thread Pierre-Yves Ritschard
On Thu, Sep 23, 2010 at 2:41 PM, Theo de Raadt wrote:

> It is ridiculous to have to add this amount of stuff to rc.
> Instead, the ftp-proxy code should be changed.
>

I'll use this approach instead then, I was afraid it might be a bit
intrusive.



Re: ftp-proxy: /etc/ftp-proxy.conf support

2010-09-23 Thread Theo de Raadt
It is ridiculous to have to add this amount of stuff to rc.
Instead, the ftp-proxy code should be changed.



Re: the right spot for ifa_add...

2010-09-23 Thread Stuart Henderson
On 2010/09/23 13:44, Henning Brauer wrote:
> oups, one superfluous check forgotten to remove.
> 
> note to self: in main tree on anakin (ryan sez it's the next level of
> krautcomputing) 

works so far, including multicast.



Re: the right spot for ifa_add...

2010-09-23 Thread Henning Brauer
oups, one superfluous check forgotten to remove.

note to self: in main tree on anakin (ryan sez it's the next level of
krautcomputing) 

Index: net/if.c
===
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.225
diff -u -p -r1.225 if.c
--- net/if.c27 Aug 2010 17:08:01 -  1.225
+++ net/if.c23 Sep 2010 11:43:14 -
@@ -157,6 +157,7 @@ int if_group_egress_build(void);
 intifai_cmp(struct ifaddr_item *,  struct ifaddr_item *);
 void   ifa_item_insert(struct sockaddr *, struct ifaddr *, struct ifnet *);
 void   ifa_item_remove(struct sockaddr *, struct ifaddr *, struct ifnet *);
+void   ifa_print_rb(void); /* XXX debug */
 RB_HEAD(ifaddr_items, ifaddr_item) ifaddr_items = 
RB_INITIALIZER(&ifaddr_items);
 RB_PROTOTYPE(ifaddr_items, ifaddr_item, ifai_entry, ifai_cmp);
 RB_GENERATE(ifaddr_items, ifaddr_item, ifai_entry, ifai_cmp);
@@ -722,9 +723,11 @@ if_clone_destroy(const char *name)
return (EINVAL);
 
ifp = ifunit(name);
-   if (ifp == NULL)
-   return (ENXIO);
+   if (ifp == NULL) {
+ifa_print_rb();
 
+   return (ENXIO);
+}
if (ifc->ifc_destroy == NULL)
return (EOPNOTSUPP);
 
@@ -880,32 +883,22 @@ if_congestion_clear(void *arg)
 struct ifaddr *
 ifa_ifwithaddr(struct sockaddr *addr, u_int rdomain)
 {
-   struct ifnet *ifp;
-   struct ifaddr *ifa;
+   struct ifaddr_item *ifai, key;
+
+   bzero(&key, sizeof(key));
+   key.ifai_addr = addr;
+   key.ifai_rdomain = rtable_l2(rdomain);
+
+   ifai = RB_FIND(ifaddr_items, &ifaddr_items, &key);
+   if (ifai)
+   return (ifai->ifai_ifa);
+   return (NULL);  
+}
 
 #defineequal(a1, a2)   \
(bcmp((caddr_t)(a1), (caddr_t)(a2), \
((struct sockaddr *)(a1))->sa_len) == 0)
 
-   rdomain = rtable_l2(rdomain);
-   TAILQ_FOREACH(ifp, &ifnet, if_list) {
-   if (ifp->if_rdomain != rdomain)
-   continue;
-   TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
-   if (ifa->ifa_addr->sa_family != addr->sa_family)
-   continue;
-   if (equal(addr, ifa->ifa_addr))
-   return (ifa);
-   if ((ifp->if_flags & IFF_BROADCAST) && ifa->ifa_broadaddr &&
-   /* IP6 doesn't have broadcast */
-   ifa->ifa_broadaddr->sa_len != 0 &&
-   equal(ifa->ifa_broadaddr, addr))
-   return (ifa);
-   }
-   }
-   return (NULL);
-}
-
 /*
  * Locate the point to point interface with a given destination address.
  */
@@ -2188,12 +2181,26 @@ ifa_add(struct ifnet *ifp, struct ifaddr
TAILQ_INSERT_HEAD(&ifp->if_addrlist, ifa, ifa_list);
else
TAILQ_INSERT_TAIL(&ifp->if_addrlist, ifa, ifa_list);
+   ifa_item_insert(ifa->ifa_addr, ifa, ifp);
+   if (ifp->if_flags & IFF_BROADCAST && ifa->ifa_broadaddr)
+   ifa_item_insert(ifa->ifa_broadaddr, ifa, ifp);
 }
 
 void
 ifa_del(struct ifnet *ifp, struct ifaddr *ifa)
 {
TAILQ_REMOVE(&ifp->if_addrlist, ifa, ifa_list);
+   ifa_item_remove(ifa->ifa_addr, ifa, ifp);
+   if (ifp->if_flags & IFF_BROADCAST && ifa->ifa_broadaddr)
+   ifa_item_remove(ifa->ifa_broadaddr, ifa, ifp);
+}
+
+void
+ifa_update_broadaddr(struct ifnet *ifp, struct ifaddr *ifa, struct sockaddr 
*sa)
+{
+   ifa_item_remove(ifa->ifa_broadaddr, ifa, ifp);
+   ifa->ifa_broadaddr = sa;
+   ifa_item_insert(ifa->ifa_broadaddr, ifa, ifp);
 }
 
 int
@@ -2251,6 +2258,31 @@ ifa_item_remove(struct sockaddr *sa, str
} else
ifai_last->ifai_next = ifai->ifai_next;
pool_put(&ifaddr_item_pl, ifai);
+}
+
+void
+ifa_print_rb(void)
+{
+   struct ifaddr_item *ifai, *p;
+   RB_FOREACH(p, ifaddr_items, &ifaddr_items) {
+   for (ifai = p; ifai; ifai = ifai->ifai_next) {
+   switch (ifai->ifai_addr->sa_family) {
+   case AF_INET:
+   printf("%s", inet_ntoa((satosin(
+   ifai->ifai_addr))->sin_addr));
+   break;
+   case AF_INET6:
+   printf("%s", ip6_sprintf(&(satosin6(
+   ifai->ifai_addr))->sin6_addr));
+   break;
+   case AF_LINK:
+   printf("%s",
+   ether_sprintf(ifai->ifai_addr->sa_data));
+   break;
+   }
+   printf(" on %s\n", ifai->ifai_ifa->ifa_ifp->if_xname);
+   }
+   }
 }
 
 void
Index: net/if.h
===
RCS file: /cvs/src/sys/net/if.h,v
retrieving revision 1.118
diff -u -p -r1.118 if.h
--- n

Re: the right spot for ifa_add...

2010-09-23 Thread Henning Brauer
and if you feel truly adventurous you can try this, which maintains
and uses the rb tree. known broken with ipvshit router advertisement
shit until that shit is fixe^Wmade a little less sucky. did i mention
shit yet?

has a little debug goo in it: if you ifconfig destroy a non-existant
but destroyable if (vether or gif, for instance) the rb tree is dumped
to the console. link-local ipvshit addresses look a bit shittier than
usual because that shit embed the scope id shit in a shitty way so
there's shit in bytes 3 and 4. did i say shit yet?

Index: net/if.c
===
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.225
diff -u -p -r1.225 if.c
--- net/if.c27 Aug 2010 17:08:01 -  1.225
+++ net/if.c23 Sep 2010 11:20:00 -
@@ -157,6 +157,7 @@ int if_group_egress_build(void);
 intifai_cmp(struct ifaddr_item *,  struct ifaddr_item *);
 void   ifa_item_insert(struct sockaddr *, struct ifaddr *, struct ifnet *);
 void   ifa_item_remove(struct sockaddr *, struct ifaddr *, struct ifnet *);
+void   ifa_print_rb(void); /* XXX debug */
 RB_HEAD(ifaddr_items, ifaddr_item) ifaddr_items = 
RB_INITIALIZER(&ifaddr_items);
 RB_PROTOTYPE(ifaddr_items, ifaddr_item, ifai_entry, ifai_cmp);
 RB_GENERATE(ifaddr_items, ifaddr_item, ifai_entry, ifai_cmp);
@@ -722,9 +723,11 @@ if_clone_destroy(const char *name)
return (EINVAL);
 
ifp = ifunit(name);
-   if (ifp == NULL)
-   return (ENXIO);
+   if (ifp == NULL) {
+ifa_print_rb();
 
+   return (ENXIO);
+}
if (ifc->ifc_destroy == NULL)
return (EOPNOTSUPP);
 
@@ -880,32 +883,22 @@ if_congestion_clear(void *arg)
 struct ifaddr *
 ifa_ifwithaddr(struct sockaddr *addr, u_int rdomain)
 {
-   struct ifnet *ifp;
-   struct ifaddr *ifa;
+   struct ifaddr_item *ifai, key;
+
+   bzero(&key, sizeof(key));
+   key.ifai_addr = addr;
+   key.ifai_rdomain = rtable_l2(rdomain);
+
+   ifai = RB_FIND(ifaddr_items, &ifaddr_items, &key);
+   if (ifai)
+   return (ifai->ifai_ifa);
+   return (NULL);  
+}
 
 #defineequal(a1, a2)   \
(bcmp((caddr_t)(a1), (caddr_t)(a2), \
((struct sockaddr *)(a1))->sa_len) == 0)
 
-   rdomain = rtable_l2(rdomain);
-   TAILQ_FOREACH(ifp, &ifnet, if_list) {
-   if (ifp->if_rdomain != rdomain)
-   continue;
-   TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
-   if (ifa->ifa_addr->sa_family != addr->sa_family)
-   continue;
-   if (equal(addr, ifa->ifa_addr))
-   return (ifa);
-   if ((ifp->if_flags & IFF_BROADCAST) && ifa->ifa_broadaddr &&
-   /* IP6 doesn't have broadcast */
-   ifa->ifa_broadaddr->sa_len != 0 &&
-   equal(ifa->ifa_broadaddr, addr))
-   return (ifa);
-   }
-   }
-   return (NULL);
-}
-
 /*
  * Locate the point to point interface with a given destination address.
  */
@@ -2188,12 +2181,26 @@ ifa_add(struct ifnet *ifp, struct ifaddr
TAILQ_INSERT_HEAD(&ifp->if_addrlist, ifa, ifa_list);
else
TAILQ_INSERT_TAIL(&ifp->if_addrlist, ifa, ifa_list);
+   ifa_item_insert(ifa->ifa_addr, ifa, ifp);
+   if (ifp->if_flags & IFF_BROADCAST && ifa->ifa_broadaddr)
+   ifa_item_insert(ifa->ifa_broadaddr, ifa, ifp);
 }
 
 void
 ifa_del(struct ifnet *ifp, struct ifaddr *ifa)
 {
TAILQ_REMOVE(&ifp->if_addrlist, ifa, ifa_list);
+   ifa_item_remove(ifa->ifa_addr, ifa, ifp);
+   if (ifp->if_flags & IFF_BROADCAST && ifa->ifa_broadaddr)
+   ifa_item_remove(ifa->ifa_broadaddr, ifa, ifp);
+}
+
+void
+ifa_update_broadaddr(struct ifnet *ifp, struct ifaddr *ifa, struct sockaddr 
*sa)
+{
+   ifa_item_remove(ifa->ifa_broadaddr, ifa, ifp);
+   ifa->ifa_broadaddr = sa;
+   ifa_item_insert(ifa->ifa_broadaddr, ifa, ifp);
 }
 
 int
@@ -2210,6 +2217,8 @@ ifa_item_insert(struct sockaddr *sa, str
 {
struct ifaddr_item  *ifai, *p;
 
+   if (!sa->sa_family)
+   return;
ifai = pool_get(&ifaddr_item_pl, PR_WAITOK);
ifai->ifai_addr = sa;
ifai->ifai_ifa = ifa;
@@ -2251,6 +2260,31 @@ ifa_item_remove(struct sockaddr *sa, str
} else
ifai_last->ifai_next = ifai->ifai_next;
pool_put(&ifaddr_item_pl, ifai);
+}
+
+void
+ifa_print_rb(void)
+{
+   struct ifaddr_item *ifai, *p;
+   RB_FOREACH(p, ifaddr_items, &ifaddr_items) {
+   for (ifai = p; ifai; ifai = ifai->ifai_next) {
+   switch (ifai->ifai_addr->sa_family) {
+   case AF_INET:
+   printf("%s", inet_ntoa((satosin(
+   ifai->ifai_addr))->sin_addr));
+   break;
+   case AF_INET6:
+   

ftp-proxy: /etc/ftp-proxy.conf support

2010-09-23 Thread Pierre-Yves Ritschard
tech@,

This allows the use of a /etc/ftp-proxy.conf file, containing
argument lines which will be fed to ftp-proxy one by one.
This solves the case of having to start multiple ftp-proxy
instances at startup.

I've retained the original behavior in order not to break things
should this go in, it can go away later I guess (or should it
go right now ?).

Thoughts ?

- pyr

Index: etc/rc
===
RCS file: /cvs/src/etc/rc,v
retrieving revision 1.341
diff -u -p -r1.341 rc
--- etc/rc  6 Sep 2010 17:10:19 -   1.341
+++ etc/rc  23 Sep 2010 11:15:13 -
@@ -99,6 +99,22 @@ wsconsctl_conf()
done
 }
 
+ftpproxy_conf()
+{
+   test -s /etc/ftp-proxy.conf || return
+
+   # delete comments and blank lines
+   local save_IFS="$IFS"
+   IFS="
+"
+   set -- `stripcom /etc/ftp-proxy.conf`
+   IFS="$save_IFS"
+   while [ $# -ge 1 ]; do
+   ftp-proxy $1
+   shift
+   done
+}
+
 random_seed()
 {
if [ -f /var/db/host.random -a "X$random_seed_done" = "X" ]; then
@@ -751,7 +767,10 @@ if [ X"${ftpd_flags}" != X"NO" ]; then
echo -n ' ftpd';/usr/libexec/ftpd ${ftpd_flags}
 fi
 
-if [ X"${ftpproxy_flags}" != X"NO" ]; then
+if [ X"${ftpproxy}" = X"YES" ]; then
+   ftpproxy_conf
+   echo -n ' ftp-proxy';
+elif [ X"${ftpproxy_flags}" != X"NO" ]; then
echo -n ' ftp-proxy';   /usr/sbin/ftp-proxy ${ftpproxy_flags}
 fi
 
Index: etc/rc.conf
===
RCS file: /cvs/src/etc/rc.conf,v
retrieving revision 1.139
diff -u -p -r1.139 rc.conf
--- etc/rc.conf 29 Jul 2010 13:55:48 -  1.139
+++ etc/rc.conf 23 Sep 2010 11:15:13 -
@@ -38,7 +38,8 @@ lpd_flags=NO  # for normal use: "" (or "
 sensorsd_flags=NO  # for normal use: ""
 hotplugd_flags=NO  # for normal use: ""
 watchdogd_flags=NO # for normal use: ""
-ftpproxy_flags=NO  # for normal use: ""
+ftpproxy=NO# for normal use: "" (needs /etc/ftp-proxy.conf)
+ftpproxy_flags=NO  # for normal use: "" (runs a single ftp-proxy)
 hostapd_flags=NO   # for normal use: ""
 ifstated_flags=NO  # for normal use: ""
 relayd_flags=NO# for normal use: ""
Index: usr.sbin/ftp-proxy/ftp-proxy.8
===
RCS file: /cvs/src/usr.sbin/ftp-proxy/ftp-proxy.8,v
retrieving revision 1.14
diff -u -p -r1.14 ftp-proxy.8
--- usr.sbin/ftp-proxy/ftp-proxy.8  21 Nov 2009 13:59:31 -  1.14
+++ usr.sbin/ftp-proxy/ftp-proxy.8  23 Sep 2010 11:15:13 -
@@ -172,6 +172,7 @@ anchor "ftp-proxy/*"
 pass in quick proto tcp to port ftp rdr-to 127.0.0.1 port 8021
 .Ed
 .Sh SEE ALSO
+.Xr ftp-proxy.conf 5 ,
 .Xr ftp 1 ,
 .Xr pf 4 ,
 .Xr pf.conf 5
Index: usr.sbin/ftp-proxy/ftp-proxy.conf.5
===
RCS file: usr.sbin/ftp-proxy/ftp-proxy.conf.5
diff -N usr.sbin/ftp-proxy/ftp-proxy.conf.5
--- /dev/null   1 Jan 1970 00:00:00 -
+++ usr.sbin/ftp-proxy/ftp-proxy.conf.5 23 Sep 2010 11:15:13 -
@@ -0,0 +1,53 @@
+.\" $OpenBSD$
+.\"
+.\" Copyright (c) 2010 Pierre-Yves Ritschard 
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd $Mdocdate$
+.Dt FTP-PROXY.CONF 5
+.Os
+.Sh NAME
+.Nm ftp-proxy.conf
+.Nd configuration of multiple ftp-proxy instances at startup
+.Sh DESCRIPTION
+.Nm
+contains a list of
+.Xr ftp-proxy 8
+arguments is read at system startup by
+.Xr rc 8
+during the boot sequence.
+.Pp
+The file is made up of
+.Xr ftp-proxy 8
+argument lines.
+Each line corresponds to a separate ftp-proxy instances which will
+be started.
+Comments are designated by a hash mark.
+Blank lines are ignored.
+.Sh FILES
+.Bl -tag -width /etc/ftp-proxy.conf -compact
+.It Pa /etc/ftp-proxy.conf
+.El
+.Sh EXAMPLES
+To start a generic instance for outbound ftp which will bind on
+10.0.0.1 and listens on the 8021 tcp port as well as a specific
+instance forwarding inbound ftp to the 10.0.0.2 internal host
+listening on the 8022 tcp port, one would use the following lines:
+.Bd -literal -offset indent
+-a 10.0.0.1
+-R 10.0.0.2 -p 8022
+.Ed
+.Sh SEE ALSO
+.Xr rc 8 ,
+.Xr ftp-proxy 8
Index: usr.sbin/ftp-prox

Re: Kill suser() call in tunopen()?

2010-09-23 Thread Henning Brauer
* Stefan Sperling  [2010-09-23 12:49]:
> > We already have knobs to control who can open tun(4) devices: they're
> > called filesystem permissions.
> It's just about having another barrier by default.

that's beyond ridiculous.

> It boils down to whether we're paranoid enough to believe that someone
> might be able to circumvent tun device file permissions without the admin's
> consent, for whatever reason.

ridiculous.

if "someone" is able to "circumvent file system permisions without the
admin's consent, for whatever reason" we have way bigger problems than
tun. 

-- 
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: Kill suser() call in tunopen()?

2010-09-23 Thread Stefan Sperling
On Wed, Sep 22, 2010 at 07:04:35PM -0700, Matthew Dempsky wrote:
> On Wed, Sep 22, 2010 at 07:09:55PM +0200, Stefan Sperling wrote:
> > FreeBSD has a sysctl to disable the super user check for tap devices
> > (the equivalent of OpenBSD's tun device with the link0 flag set),
> > off by default:
> > http://svn.freebsd.org/viewvc/base/head/sys/net/if_tap.c?revision=205222&view=markup
> > SYSCTL_INT(_net_link_tap, OID_AUTO, user_open, CTLFLAG_RW, &tapuopen, 0,
> > "Allow user to open /dev/tap (based on node permissions)");
> > 
> > I suppose that's a bit safer than relying on device file perms alone,
> > in case the perms get changed accidentally or via some attack vector.
> 
> I think that's ridiculous.  How do you prevent the sysctl accidentally
> changing too then?

You don't.

> We already have knobs to control who can open tun(4) devices: they're
> called filesystem permissions.

It's just about having another barrier by default.
It boils down to whether we're paranoid enough to believe that someone
might be able to circumvent tun device file permissions without the admin's
consent, for whatever reason.

But whatever. My complaint has been registered. I'll think about it
some more. If I care enough I'll send a diff.

> > A tap device can inject arbitrary packets on the local network,
> > like a raw socket.
> 
> Yes, but only on the local tun(4) interface's virtual network.  It
> doesn't let you inject arbitrary packets on other interfaces.

Depends. A tun device can do layer 2, and can be part of a bridge.

> There's no more risk to having an attacker holding a tun(4) device
> than there is from one directly connecting to an Ethernet port on your
> machine.

That is true.



Re: Kill suser() call in tunopen()?

2010-09-23 Thread Stefan Sperling
On Wed, Sep 22, 2010 at 07:09:55PM +0200, Stefan Sperling wrote:
> In case you didn't know, there already is a way for non-privileged users
> to open a tun/tap device if the admin allows sudo -C.
> See the qemu port's README.OpenBSD for an example.

Theo pointed out that this doesn't work.
The sudo -C workaround assumes that the user can run "sudo sh".
So users get full privs and then drop them, rather than starting out
will tun-only privs. I stand corrected.



Re: merge pms and pmsi + added support for some of mouse

2010-09-23 Thread Alexandr Shadchin
2010/9/23 Kenneth R Westerback :
>
> Doesn't apply. pckbc/pms.c and pms_intelli.c are rejected on -current.
>
>  Ken
>

Regen

-- 
Alexandr Shadchin

Index: distrib/notes/sparc64/hardware
===
RCS file: /cvs/src/distrib/notes/sparc64/hardware,v
retrieving revision 1.151
diff -u -p -r1.151 hardware
--- distrib/notes/sparc64/hardware  9 Apr 2009 16:02:24 -   1.151
+++ distrib/notes/sparc64/hardware  23 Sep 2010 09:41:30 -
@@ -490,7 +490,7 @@ Supported devices {:-include-:}:
Sun mice on Zilog serial ports (zstty)
Sun mice on NS16550 serial ports (com)
USB mice (ums)
-   PS/2 mice (pms or pmsi)
+   PS/2 mice (pms)

Framebuffers
SBUS framebuffers:
Index: distrib/sets/lists/man/mi
===
RCS file: /cvs/src/distrib/sets/lists/man/mi,v
retrieving revision 1.1062
diff -u -p -r1.1062 mi
--- distrib/sets/lists/man/mi   23 Sep 2010 04:55:48 -  1.1062
+++ distrib/sets/lists/man/mi   23 Sep 2010 09:41:31 -
@@ -2001,7 +2001,6 @@
 ./usr/share/man/cat4/piixpm.0
 ./usr/share/man/cat4/pim.0
 ./usr/share/man/cat4/pms.0
-./usr/share/man/cat4/pmsi.0
 ./usr/share/man/cat4/pnp.0
 ./usr/share/man/cat4/ppb.0
 ./usr/share/man/cat4/ppp.0
Index: share/man/man4/Makefile
===
RCS file: /cvs/src/share/man/man4/Makefile,v
retrieving revision 1.514
diff -u -p -r1.514 Makefile
--- share/man/man4/Makefile 19 Aug 2010 15:45:35 -  1.514
+++ share/man/man4/Makefile 23 Sep 2010 09:42:04 -
@@ -79,7 +79,6 @@ MLINKS+=isa.4 isadma.4
 MLINKS+=isapnp.4 pnp.4
 MLINKS+=netintro.4 networking.4
 MLINKS+=pcmcia.4 pcic.4
-MLINKS+=pms.4 pmsi.4
 MLINKS+=pty.4 ptm.4
 MLINKS+=random.4 arandom.4
 MLINKS+=random.4 srandom.4 random.4 urandom.4
Index: share/man/man4/pckbc.4
===
RCS file: /cvs/src/share/man/man4/pckbc.4,v
retrieving revision 1.17
diff -u -p -r1.17 pckbc.4
--- share/man/man4/pckbc.4  22 Jul 2010 07:41:59 -  1.17
+++ share/man/man4/pckbc.4  23 Sep 2010 09:42:04 -
@@ -36,7 +36,6 @@
 .Cd "pckbc* at ebus? " Pq "sparc64"
 .Cd "pckbd* at pckbc?"
 .Cd "pms*   at pckbc?"
-.Cd "pmsi*  at pckbc?"
 .Sh DESCRIPTION
 The
 .Nm
@@ -69,5 +68,4 @@ device flags to 1.
 .Xr isa 4 ,
 .Xr pckbd 4 ,
 .Xr pms 4 ,
-.Xr pmsi 4 ,
 .Xr boot_config 8
Index: share/man/man4/pms.4
===
RCS file: /cvs/src/share/man/man4/pms.4,v
retrieving revision 1.11
diff -u -p -r1.11 pms.4
--- share/man/man4/pms.419 Oct 2007 06:29:36 -  1.11
+++ share/man/man4/pms.423 Sep 2010 09:42:05 -
@@ -37,16 +37,13 @@
 .Dt PMS 4
 .Os
 .Sh NAME
-.Nm pms ,
-.Nm pmsi
+.Nm pms
 .Nd PS/2 auxiliary port mouse driver
 .Sh SYNOPSIS
 .Cd "pms* at pckbc?"
 .Cd "pms* at gsckbc?" Pq "hppa"
 .Cd "pms* at mkbc?" Pq "sgi"
-.Cd "pmsi* at pckbc?"
 .Cd "wsmouse* at pms? mux 0"
-.Cd "wsmouse* at pmsi? mux 0"
 .Sh DESCRIPTION
 The
 .Nm pms
@@ -60,12 +57,13 @@ the PS/2 input port controller found on
 .Xr pckbc 4 ,
 the standard PC keyboard controller found on most other machines.
 .Dq pms
-is a generic driver which supports 2 coordinate axes and 3 buttons.
-The
-.Dq pmsi
-variant provides specific support for wheel mice of the
+is a generic driver which supports mice using common variants of the PS/2
+protocol, including wheel mice of the
 .Dq IntelliMouse
-breed; wheel movements are mapped to a third (z-) axis.
+breed.
+Wheel movements are mapped to a third (z-) axis.
+The driver is
+believed to work with both 3-button and 5-button mice with scroll wheels.
 Mouse related data are accessed by
 .Xr wsmouse 4
 devices.
Index: share/man/man4/man4.i386/lms.4
===
RCS file: /cvs/src/share/man/man4/man4.i386/lms.4,v
retrieving revision 1.10
diff -u -p -r1.10 lms.4
--- share/man/man4/man4.i386/lms.4  31 May 2007 19:19:55 -  1.10
+++ share/man/man4/man4.i386/lms.4  23 Sep 2010 09:42:05 -
@@ -53,6 +53,5 @@ devices.
 .Xr isa 4 ,
 .Xr mms 4 ,
 .Xr pms 4 ,
-.Xr pmsi 4 ,
 .Xr ums 4 ,
 .Xr wsmouse 4
Index: share/man/man4/man4.i386/mms.4
===
RCS file: /cvs/src/share/man/man4/man4.i386/mms.4,v
retrieving revision 1.9
diff -u -p -r1.9 mms.4
--- share/man/man4/man4.i386/mms.4  31 May 2007 19:19:55 -  1.9
+++ share/man/man4/man4.i386/mms.4  23 Sep 2010 09:42:05 -
@@ -53,6 +53,5 @@ devices.
 .Xr isa 4 ,
 .Xr lms 4 ,
 .Xr pms 4 ,
-.Xr pmsi 4 ,
 .Xr ums 4 ,
 .Xr wsmouse 4
Index: sys/arch/alpha/conf/GENERIC
===
RCS file: /cvs/src/sys/arch/alpha/conf/GENERIC,v
retrieving revision 1.215
diff -u -p -r1.

Re: m_pad: ghostbuster's dream

2010-09-23 Thread Bret S. Lambert
On Thu, Sep 23, 2010 at 11:12:48AM +0200, Mike Belopuhov wrote:
> On Thu, Sep 23, 2010 at 09:57 +0200, Bret S. Lambert wrote:
> > No objection in principle (consolidation of code in mbufs is
> > one of my currently-stalled-by-dayjob projects); comment inline.
> > 
> > > 
> > > OK?
> > > 
> > > Index: netinet/ip_esp.c
> > > ===
> > > RCS file: /home/cvs/src/sys/netinet/ip_esp.c,v
> > > retrieving revision 1.112
> > > diff -u -p -r1.112 ip_esp.c
> > > --- netinet/ip_esp.c  22 Sep 2010 13:40:05 -  1.112
> > > +++ netinet/ip_esp.c  22 Sep 2010 15:47:38 -
> > > @@ -932,9 +932,10 @@ esp_output(struct mbuf *m, struct tdb *t
> > >* Add padding -- better to do it ourselves than use the crypto engine,
> > >* although if/when we support compression, we'd have to do that.
> > >*/
> > > - pad = (u_char *) m_pad(m, padding + alen);
> > > + mo = m_inject(m, m->m_pkthdr.len, padding + alen, M_DONTWAIT);
> > > + pad = mtod(mo, u_char *);
> > 
> > Sure, but this code creates a NULL pointer dereference;
> > mtod() isn't a function that does anything smart, as
> > is evidenced by the explanation in the mbuf man page:
> > 
> > #define mtod(m,t)   ((t)((m)->m_data))
> > 
> 
> /* Yeurk! */
> 
> new diff.  thanks for looking through!

It looks sane enough to me, although you might also take a look
at m_pulldown to ensure X contiguous bytes at offset Y in an mbuf
chain, as, IIRC, that has the possibility of not requiring a new
mbuf allocation if there truly is enough space in an existing mbuf.

But, it's your bikeshed, you can choose whether it's grape- or
strawberry-flavored.

>
> Index: netinet/ip_esp.c
> ===
> RCS file: /home/cvs/src/sys/netinet/ip_esp.c,v
> retrieving revision 1.112
> diff -u -p -r1.112 ip_esp.c
> --- netinet/ip_esp.c  22 Sep 2010 13:40:05 -  1.112
> +++ netinet/ip_esp.c  23 Sep 2010 09:05:40 -
> @@ -932,12 +932,13 @@ esp_output(struct mbuf *m, struct tdb *t
>* Add padding -- better to do it ourselves than use the crypto engine,
>* although if/when we support compression, we'd have to do that.
>*/
> - pad = (u_char *) m_pad(m, padding + alen);
> - if (pad == NULL) {
> - DPRINTF(("esp_output(): m_pad() failed for SA %s/%08x\n",
> + mo = m_inject(m, m->m_pkthdr.len, padding + alen, M_DONTWAIT);
> + if (mo == NULL) {
> + DPRINTF(("esp_output(): m_inject failed for SA %s/%08x\n",
>   ipsp_address(tdb->tdb_dst), ntohl(tdb->tdb_spi)));
>   return ENOBUFS;
>   }
> + pad = mtod(mo, u_char *);
>  
>   /* Self-describing or random padding ? */
>   if (!(tdb->tdb_flags & TDBF_RANDOMPADDING))
> @@ -1178,77 +1179,4 @@ checkreplaywindow32(u_int32_t seq, u_int
>  
>   *bitmap |= (((u_int32_t) 1) << diff);
>   return 0;
> -}
> -
> -/*
> - * m_pad(m, n) pads  with  bytes at the end. The packet header
> - * length is updated, and a pointer to the first byte of the padding
> - * (which is guaranteed to be all in one mbuf) is returned.
> - */
> -
> -caddr_t
> -m_pad(struct mbuf *m, int n)
> -{
> - struct mbuf *m0, *m1;
> - int len, pad;
> - caddr_t retval;
> -
> - if (n <= 0) {  /* No stupid arguments. */
> - DPRINTF(("m_pad(): pad length invalid (%d)\n", n));
> - m_freem(m);
> - return NULL;
> - }
> -
> - len = m->m_pkthdr.len;
> - pad = n;
> - m0 = m;
> -
> - while (m0->m_len < len) {
> - len -= m0->m_len;
> - m0 = m0->m_next;
> - }
> -
> - if (m0->m_len != len) {
> - DPRINTF(("m_pad(): length mismatch (should be %d instead of "
> - "%d)\n", m->m_pkthdr.len,
> - m->m_pkthdr.len + m0->m_len - len));
> -
> - m_freem(m);
> - return NULL;
> - }
> -
> - /* Check for zero-length trailing mbufs, and find the last one. */
> - for (m1 = m0; m1->m_next; m1 = m1->m_next) {
> - if (m1->m_next->m_len != 0) {
> - DPRINTF(("m_pad(): length mismatch (should be %d "
> - "instead of %d)\n", m->m_pkthdr.len,
> - m->m_pkthdr.len + m1->m_next->m_len));
> -
> - m_freem(m);
> - return NULL;
> - }
> -
> - m0 = m1->m_next;
> - }
> -
> - if ((m0->m_flags & M_EXT) ||
> - m0->m_data + m0->m_len + pad >= &(m0->m_dat[MLEN])) {
> - /* Add an mbuf to the chain. */
> - MGET(m1, M_DONTWAIT, MT_DATA);
> - if (m1 == 0) {
> - m_freem(m0);
> - DPRINTF(("m_pad(): cannot append\n"));
> - return NULL;
> - }
> -
> - m0->m_next = m1;
> - m0 = m1;
> - m0->m_len = 0;
> - }
> -
> - retval = m0->m

Re: merge pms and pmsi + added support for some of mouse

2010-09-23 Thread Kenneth R Westerback
On Wed, Sep 22, 2010 at 09:33:04PM -0400, Kenneth R Westerback wrote:
> I haven't confirmed w/o the diff, but with the diff I have a problem
> on my eeePC 1000HE. I boot, then suspend with FN-ZZ, then resume
> by hitting a key, then I type 'startx'. At this point I experience
> a long delay before X actually starts.
> 
>  Ken
> 

Confirmed that this unfortunate behaviour exists w/o your diff as well
as with it.

 Ken



Re: m_pad: ghostbuster's dream

2010-09-23 Thread Mike Belopuhov
On Thu, Sep 23, 2010 at 09:57 +0200, Bret S. Lambert wrote:
> No objection in principle (consolidation of code in mbufs is
> one of my currently-stalled-by-dayjob projects); comment inline.
> 
> > 
> > OK?
> > 
> > Index: netinet/ip_esp.c
> > ===
> > RCS file: /home/cvs/src/sys/netinet/ip_esp.c,v
> > retrieving revision 1.112
> > diff -u -p -r1.112 ip_esp.c
> > --- netinet/ip_esp.c22 Sep 2010 13:40:05 -  1.112
> > +++ netinet/ip_esp.c22 Sep 2010 15:47:38 -
> > @@ -932,9 +932,10 @@ esp_output(struct mbuf *m, struct tdb *t
> >  * Add padding -- better to do it ourselves than use the crypto engine,
> >  * although if/when we support compression, we'd have to do that.
> >  */
> > -   pad = (u_char *) m_pad(m, padding + alen);
> > +   mo = m_inject(m, m->m_pkthdr.len, padding + alen, M_DONTWAIT);
> > +   pad = mtod(mo, u_char *);
> 
> Sure, but this code creates a NULL pointer dereference;
> mtod() isn't a function that does anything smart, as
> is evidenced by the explanation in the mbuf man page:
> 
> #define mtod(m,t)   ((t)((m)->m_data))
> 

/* Yeurk! */

new diff.  thanks for looking through!

Index: netinet/ip_esp.c
===
RCS file: /home/cvs/src/sys/netinet/ip_esp.c,v
retrieving revision 1.112
diff -u -p -r1.112 ip_esp.c
--- netinet/ip_esp.c22 Sep 2010 13:40:05 -  1.112
+++ netinet/ip_esp.c23 Sep 2010 09:05:40 -
@@ -932,12 +932,13 @@ esp_output(struct mbuf *m, struct tdb *t
 * Add padding -- better to do it ourselves than use the crypto engine,
 * although if/when we support compression, we'd have to do that.
 */
-   pad = (u_char *) m_pad(m, padding + alen);
-   if (pad == NULL) {
-   DPRINTF(("esp_output(): m_pad() failed for SA %s/%08x\n",
+   mo = m_inject(m, m->m_pkthdr.len, padding + alen, M_DONTWAIT);
+   if (mo == NULL) {
+   DPRINTF(("esp_output(): m_inject failed for SA %s/%08x\n",
ipsp_address(tdb->tdb_dst), ntohl(tdb->tdb_spi)));
return ENOBUFS;
}
+   pad = mtod(mo, u_char *);
 
/* Self-describing or random padding ? */
if (!(tdb->tdb_flags & TDBF_RANDOMPADDING))
@@ -1178,77 +1179,4 @@ checkreplaywindow32(u_int32_t seq, u_int
 
*bitmap |= (((u_int32_t) 1) << diff);
return 0;
-}
-
-/*
- * m_pad(m, n) pads  with  bytes at the end. The packet header
- * length is updated, and a pointer to the first byte of the padding
- * (which is guaranteed to be all in one mbuf) is returned.
- */
-
-caddr_t
-m_pad(struct mbuf *m, int n)
-{
-   struct mbuf *m0, *m1;
-   int len, pad;
-   caddr_t retval;
-
-   if (n <= 0) {  /* No stupid arguments. */
-   DPRINTF(("m_pad(): pad length invalid (%d)\n", n));
-   m_freem(m);
-   return NULL;
-   }
-
-   len = m->m_pkthdr.len;
-   pad = n;
-   m0 = m;
-
-   while (m0->m_len < len) {
-   len -= m0->m_len;
-   m0 = m0->m_next;
-   }
-
-   if (m0->m_len != len) {
-   DPRINTF(("m_pad(): length mismatch (should be %d instead of "
-   "%d)\n", m->m_pkthdr.len,
-   m->m_pkthdr.len + m0->m_len - len));
-
-   m_freem(m);
-   return NULL;
-   }
-
-   /* Check for zero-length trailing mbufs, and find the last one. */
-   for (m1 = m0; m1->m_next; m1 = m1->m_next) {
-   if (m1->m_next->m_len != 0) {
-   DPRINTF(("m_pad(): length mismatch (should be %d "
-   "instead of %d)\n", m->m_pkthdr.len,
-   m->m_pkthdr.len + m1->m_next->m_len));
-
-   m_freem(m);
-   return NULL;
-   }
-
-   m0 = m1->m_next;
-   }
-
-   if ((m0->m_flags & M_EXT) ||
-   m0->m_data + m0->m_len + pad >= &(m0->m_dat[MLEN])) {
-   /* Add an mbuf to the chain. */
-   MGET(m1, M_DONTWAIT, MT_DATA);
-   if (m1 == 0) {
-   m_freem(m0);
-   DPRINTF(("m_pad(): cannot append\n"));
-   return NULL;
-   }
-
-   m0->m_next = m1;
-   m0 = m1;
-   m0->m_len = 0;
-   }
-
-   retval = m0->m_data + m0->m_len;
-   m0->m_len += pad;
-   m->m_pkthdr.len += pad;
-
-   return retval;
 }
Index: netinet/ip_ipsp.h
===
RCS file: /home/cvs/src/sys/netinet/ip_ipsp.h,v
retrieving revision 1.144
diff -u -p -r1.144 ip_ipsp.h
--- netinet/ip_ipsp.h   9 Jul 2010 16:58:06 -   1.144
+++ netinet/ip_ipsp.h   22 Sep 2010 15:49:32 -
@@ -624,9 +624,6 @@ extern int tcp_signature_tdb_input(struc
 extern int tcp_signature_tdb_output(struct mbuf *

cac(4) iopoolification again

2010-09-23 Thread Kenneth R Westerback
Move cac(4) to iopool and eliminate XS_NO_CCB. Tests sought. You
have been warned.

 Ken

Index: cac.c
===
RCS file: /cvs/src/sys/dev/ic/cac.c,v
retrieving revision 1.41
diff -u -p -r1.41 cac.c
--- cac.c   20 Sep 2010 06:17:49 -  1.41
+++ cac.c   23 Sep 2010 04:54:35 -
@@ -103,9 +103,9 @@ struct scsi_adapter cac_switch = {
cac_scsi_cmd, cacminphys, 0, 0,
 };
 
-struct cac_ccb *cac_ccb_alloc(struct cac_softc *, int);
+void   *cac_ccb_alloc(void *);
 void   cac_ccb_done(struct cac_softc *, struct cac_ccb *);
-void   cac_ccb_free(struct cac_softc *, struct cac_ccb *);
+void   cac_ccb_free(void *, void *);
 intcac_ccb_poll(struct cac_softc *, struct cac_ccb *, int);
 intcac_ccb_start(struct cac_softc *, struct cac_ccb *);
 intcac_cmd(struct cac_softc *sc, int command, void *data, int datasize,
@@ -156,6 +156,8 @@ cac_init(struct cac_softc *sc, int start
 
SIMPLEQ_INIT(&sc->sc_ccb_free);
SIMPLEQ_INIT(&sc->sc_ccb_queue);
+   mtx_init(&sc->sc_ccb_mtx, IPL_BIO);
+   scsi_iopool_init(&sc->sc_iopool, sc, cac_ccb_alloc, cac_ccb_free);
 
 size = sizeof(struct cac_ccb) * CAC_MAX_CCBS;
 
@@ -204,7 +206,9 @@ cac_init(struct cac_softc *sc, int start
}
 
ccb->ccb_paddr = sc->sc_ccbs_paddr + i * sizeof(struct cac_ccb);
+   mtx_enter(&sc->sc_ccb_mtx);
SIMPLEQ_INSERT_TAIL(&sc->sc_ccb_free, ccb, ccb_chain);
+   mtx_leave(&sc->sc_ccb_mtx);
}
 
/* Start firmware background tasks, if needed. */
@@ -344,11 +348,18 @@ cac_cmd(struct cac_softc *sc, int comman
command, drive, blkno, data, datasize, flags, xs);
 #endif
 
-   if ((ccb = cac_ccb_alloc(sc, 0)) == NULL) {
-#ifdef CAC_DEBUG
-   printf("%s: unable to alloc CCB\n", sc->sc_dv.dv_xname);
-#endif
-   return (ENOMEM);
+   if (xs) {
+   ccb = xs->io;
+   /*
+* The xs may have been restarted by the scsi layer, so
+* ensure the ccb starts in the proper state.
+*/
+   ccb->ccb_flags = 0;
+   } else {
+   /* Internal command. Need to get our own ccb. */
+   ccb = scsi_io_get(&sc->sc_iopool, SCSI_POLL | SCSI_NOSLEEP);
+   if (ccb == NULL)
+   return (EBUSY);
}
 
if ((flags & (CAC_CCB_DATA_IN | CAC_CCB_DATA_OUT)) != 0) {
@@ -396,11 +407,9 @@ cac_cmd(struct cac_softc *sc, int comman
ccb->ccb_xs = xs;
 
if (!xs || xs->flags & SCSI_POLL) {
-
/* Synchronous commands musn't wait. */
if ((*sc->sc_cl->cl_fifo_full)(sc)) {
-   cac_ccb_free(sc, ccb);
-   rv = ENOMEM; /* Causes XS_NO_CCB, i/o is retried. */
+   rv = EBUSY;
} else {
ccb->ccb_flags |= CAC_CCB_ACTIVE;
(*sc->sc_cl->cl_submit)(sc, ccb);
@@ -409,6 +418,9 @@ cac_cmd(struct cac_softc *sc, int comman
} else
rv = cac_ccb_start(sc, ccb);
 
+   if (xs == NULL)
+   scsi_io_put(&sc->sc_iopool, ccb);
+
return (rv);
 }
 
@@ -419,8 +431,9 @@ int
 cac_ccb_poll(struct cac_softc *sc, struct cac_ccb *wantccb, int timo)
 {
struct cac_ccb *ccb;
-   int s, t = timo * 100;
+   int t;
 
+   t = timo * 100;
do {
for (; t--; DELAY(10))
if ((ccb = (*sc->sc_cl->cl_completed)(sc)) != NULL)
@@ -429,9 +442,7 @@ cac_ccb_poll(struct cac_softc *sc, struc
printf("%s: timeout\n", sc->sc_dv.dv_xname);
return (EBUSY);
}
-   s = splbio();
cac_ccb_done(sc, ccb);
-   splx(s);
} while (ccb != wantccb);
 
return (0);
@@ -439,17 +450,27 @@ cac_ccb_poll(struct cac_softc *sc, struc
 
 /*
  * Enqueue the specified command (if any) and attempt to start all enqueued
- * commands.  Must be called at splbio.
+ * commands.
  */
 int
 cac_ccb_start(struct cac_softc *sc, struct cac_ccb *ccb)
 {
-   if (ccb != NULL)
+   if (ccb != NULL) {
+   mtx_enter(&sc->sc_ccb_mtx);
SIMPLEQ_INSERT_TAIL(&sc->sc_ccb_queue, ccb, ccb_chain);
+   mtx_leave(&sc->sc_ccb_mtx);
+   }
 
-   while ((ccb = SIMPLEQ_FIRST(&sc->sc_ccb_queue)) != NULL &&
-   !(*sc->sc_cl->cl_fifo_full)(sc)) {
+   while (!(*sc->sc_cl->cl_fifo_full)(sc)) {
+   mtx_enter(&sc->sc_ccb_mtx);
+   if (SIMPLEQ_EMPTY(&sc->sc_ccb_queue)) {
+   mtx_leave(&sc->sc_ccb_mtx);
+   break;
+   }
+   ccb = SIMPLEQ_FIRST(&sc->sc_ccb_queue);
SIMPLEQ_REMOVE_HEAD(&sc->sc_ccb_queue, ccb_chain);
+   mtx_leave(&sc->sc_ccb_mtx);
+
ccb->c

Re: merge pms and pmsi + added support for some of mouse

2010-09-23 Thread Alexandr Shadchin
2010/9/23 Kenneth R Westerback :
> I haven't confirmed w/o the diff, but with the diff I have a problem
> on my eeePC 1000HE. I boot, then suspend with FN-ZZ, then resume
> by hitting a key, then I type 'startx'. At this point I experience
> a long delay before X actually starts.
>
>  Ken
>

Try a new diff. I made adjustments to match the style(9).
Also found an error in function pms_change_state(...):
...
case PMS_STATE_ENABLED:
   ...
   cmd[0] = PMS_RESET;
   ...
   pckbc_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 1);

corrected for
...
case PMS_STATE_ENABLED:
   ...
   pckbc_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 1);
   ...
   cmd[0] = PMS_RESET;

-- 
Alexandr Shadchin

Index: distrib/notes/sparc64/hardware
===
RCS file: /cvs/src/distrib/notes/sparc64/hardware,v
retrieving revision 1.151
diff -u -p -r1.151 hardware
--- distrib/notes/sparc64/hardware  9 Apr 2009 16:02:24 -   1.151
+++ distrib/notes/sparc64/hardware  22 Sep 2010 19:07:58 -
@@ -490,7 +490,7 @@ Supported devices {:-include-:}:
Sun mice on Zilog serial ports (zstty)
Sun mice on NS16550 serial ports (com)
USB mice (ums)
-   PS/2 mice (pms or pmsi)
+   PS/2 mice (pms)

Framebuffers
SBUS framebuffers:
Index: distrib/sets/lists/man/mi
===
RCS file: /cvs/src/distrib/sets/lists/man/mi,v
retrieving revision 1.1061
diff -u -p -r1.1061 mi
--- distrib/sets/lists/man/mi   25 Aug 2010 19:21:26 -  1.1061
+++ distrib/sets/lists/man/mi   22 Sep 2010 19:07:59 -
@@ -2002,7 +2002,6 @@
 ./usr/share/man/cat4/piixpm.0
 ./usr/share/man/cat4/pim.0
 ./usr/share/man/cat4/pms.0
-./usr/share/man/cat4/pmsi.0
 ./usr/share/man/cat4/pnp.0
 ./usr/share/man/cat4/ppb.0
 ./usr/share/man/cat4/ppp.0
Index: share/man/man4/Makefile
===
RCS file: /cvs/src/share/man/man4/Makefile,v
retrieving revision 1.514
diff -u -p -r1.514 Makefile
--- share/man/man4/Makefile 19 Aug 2010 15:45:35 -  1.514
+++ share/man/man4/Makefile 22 Sep 2010 19:08:25 -
@@ -79,7 +79,6 @@ MLINKS+=isa.4 isadma.4
 MLINKS+=isapnp.4 pnp.4
 MLINKS+=netintro.4 networking.4
 MLINKS+=pcmcia.4 pcic.4
-MLINKS+=pms.4 pmsi.4
 MLINKS+=pty.4 ptm.4
 MLINKS+=random.4 arandom.4
 MLINKS+=random.4 srandom.4 random.4 urandom.4
Index: share/man/man4/pckbc.4
===
RCS file: /cvs/src/share/man/man4/pckbc.4,v
retrieving revision 1.17
diff -u -p -r1.17 pckbc.4
--- share/man/man4/pckbc.4  22 Jul 2010 07:41:59 -  1.17
+++ share/man/man4/pckbc.4  22 Sep 2010 19:08:25 -
@@ -36,7 +36,6 @@
 .Cd "pckbc* at ebus? " Pq "sparc64"
 .Cd "pckbd* at pckbc?"
 .Cd "pms*   at pckbc?"
-.Cd "pmsi*  at pckbc?"
 .Sh DESCRIPTION
 The
 .Nm
@@ -69,5 +68,4 @@ device flags to 1.
 .Xr isa 4 ,
 .Xr pckbd 4 ,
 .Xr pms 4 ,
-.Xr pmsi 4 ,
 .Xr boot_config 8
Index: share/man/man4/pms.4
===
RCS file: /cvs/src/share/man/man4/pms.4,v
retrieving revision 1.11
diff -u -p -r1.11 pms.4
--- share/man/man4/pms.419 Oct 2007 06:29:36 -  1.11
+++ share/man/man4/pms.422 Sep 2010 19:08:25 -
@@ -37,16 +37,13 @@
 .Dt PMS 4
 .Os
 .Sh NAME
-.Nm pms ,
-.Nm pmsi
+.Nm pms
 .Nd PS/2 auxiliary port mouse driver
 .Sh SYNOPSIS
 .Cd "pms* at pckbc?"
 .Cd "pms* at gsckbc?" Pq "hppa"
 .Cd "pms* at mkbc?" Pq "sgi"
-.Cd "pmsi* at pckbc?"
 .Cd "wsmouse* at pms? mux 0"
-.Cd "wsmouse* at pmsi? mux 0"
 .Sh DESCRIPTION
 The
 .Nm pms
@@ -60,12 +57,13 @@ the PS/2 input port controller found on
 .Xr pckbc 4 ,
 the standard PC keyboard controller found on most other machines.
 .Dq pms
-is a generic driver which supports 2 coordinate axes and 3 buttons.
-The
-.Dq pmsi
-variant provides specific support for wheel mice of the
+is a generic driver which supports mice using common variants of the PS/2
+protocol, including wheel mice of the
 .Dq IntelliMouse
-breed; wheel movements are mapped to a third (z-) axis.
+breed.
+Wheel movements are mapped to a third (z-) axis.
+The driver is
+believed to work with both 3-button and 5-button mice with scroll wheels.
 Mouse related data are accessed by
 .Xr wsmouse 4
 devices.
Index: share/man/man4/man4.i386/lms.4
===
RCS file: /cvs/src/share/man/man4/man4.i386/lms.4,v
retrieving revision 1.10
diff -u -p -r1.10 lms.4
--- share/man/man4/man4.i386/lms.4  31 May 2007 19:19:55 -  1.10
+++ share/man/man4/man4.i386/lms.4  22 Sep 2010 19:08:25 -
@@ -53,6 +53,5 @@ devices.
 .Xr isa 4 ,
 .Xr mms 4 ,
 .Xr pms 4 ,
-.Xr pmsi 4 ,
 .Xr ums 4 ,
 .Xr wsmouse 4
Index: share/man/man4/man4.i386/mms.4
===
RCS fi

Re: m_pad: ghostbuster's dream

2010-09-23 Thread Bret S. Lambert
On Wed, Sep 22, 2010 at 06:28:38PM +0200, Mike Belopuhov wrote:
> m_pad was introduced with an "ipsec package" import in openbsd
> in 1997.  m_inject was introduced in 1999 but this code wasn't
> changed.
> 
> m_pad is equivalent to m_inject with an offset equal to the
> actual data length.
> 
> Doesn't break anything here, but additional tests won't harm.

No objection in principle (consolidation of code in mbufs is
one of my currently-stalled-by-dayjob projects); comment inline.

> 
> OK?
> 
> Index: netinet/ip_esp.c
> ===
> RCS file: /home/cvs/src/sys/netinet/ip_esp.c,v
> retrieving revision 1.112
> diff -u -p -r1.112 ip_esp.c
> --- netinet/ip_esp.c  22 Sep 2010 13:40:05 -  1.112
> +++ netinet/ip_esp.c  22 Sep 2010 15:47:38 -
> @@ -932,9 +932,10 @@ esp_output(struct mbuf *m, struct tdb *t
>* Add padding -- better to do it ourselves than use the crypto engine,
>* although if/when we support compression, we'd have to do that.
>*/
> - pad = (u_char *) m_pad(m, padding + alen);
> + mo = m_inject(m, m->m_pkthdr.len, padding + alen, M_DONTWAIT);
> + pad = mtod(mo, u_char *);

Sure, but this code creates a NULL pointer dereference;
mtod() isn't a function that does anything smart, as
is evidenced by the explanation in the mbuf man page:

#define mtod(m,t)   ((t)((m)->m_data))

>   if (pad == NULL) {
> - DPRINTF(("esp_output(): m_pad() failed for SA %s/%08x\n",
> + DPRINTF(("esp_output(): m_inject failed for SA %s/%08x\n",
>   ipsp_address(tdb->tdb_dst), ntohl(tdb->tdb_spi)));
>   return ENOBUFS;
>   }
> @@ -1178,77 +1179,4 @@ checkreplaywindow32(u_int32_t seq, u_int
>  
>   *bitmap |= (((u_int32_t) 1) << diff);
>   return 0;
> -}
> -
> -/*
> - * m_pad(m, n) pads  with  bytes at the end. The packet header
> - * length is updated, and a pointer to the first byte of the padding
> - * (which is guaranteed to be all in one mbuf) is returned.
> - */
> -
> -caddr_t
> -m_pad(struct mbuf *m, int n)
> -{
> - struct mbuf *m0, *m1;
> - int len, pad;
> - caddr_t retval;
> -
> - if (n <= 0) {  /* No stupid arguments. */
> - DPRINTF(("m_pad(): pad length invalid (%d)\n", n));
> - m_freem(m);
> - return NULL;
> - }
> -
> - len = m->m_pkthdr.len;
> - pad = n;
> - m0 = m;
> -
> - while (m0->m_len < len) {
> - len -= m0->m_len;
> - m0 = m0->m_next;
> - }
> -
> - if (m0->m_len != len) {
> - DPRINTF(("m_pad(): length mismatch (should be %d instead of "
> - "%d)\n", m->m_pkthdr.len,
> - m->m_pkthdr.len + m0->m_len - len));
> -
> - m_freem(m);
> - return NULL;
> - }
> -
> - /* Check for zero-length trailing mbufs, and find the last one. */
> - for (m1 = m0; m1->m_next; m1 = m1->m_next) {
> - if (m1->m_next->m_len != 0) {
> - DPRINTF(("m_pad(): length mismatch (should be %d "
> - "instead of %d)\n", m->m_pkthdr.len,
> - m->m_pkthdr.len + m1->m_next->m_len));
> -
> - m_freem(m);
> - return NULL;
> - }
> -
> - m0 = m1->m_next;
> - }
> -
> - if ((m0->m_flags & M_EXT) ||
> - m0->m_data + m0->m_len + pad >= &(m0->m_dat[MLEN])) {
> - /* Add an mbuf to the chain. */
> - MGET(m1, M_DONTWAIT, MT_DATA);
> - if (m1 == 0) {
> - m_freem(m0);
> - DPRINTF(("m_pad(): cannot append\n"));
> - return NULL;
> - }
> -
> - m0->m_next = m1;
> - m0 = m1;
> - m0->m_len = 0;
> - }
> -
> - retval = m0->m_data + m0->m_len;
> - m0->m_len += pad;
> - m->m_pkthdr.len += pad;
> -
> - return retval;
>  }
> Index: netinet/ip_ipsp.h
> ===
> RCS file: /home/cvs/src/sys/netinet/ip_ipsp.h,v
> retrieving revision 1.144
> diff -u -p -r1.144 ip_ipsp.h
> --- netinet/ip_ipsp.h 9 Jul 2010 16:58:06 -   1.144
> +++ netinet/ip_ipsp.h 22 Sep 2010 15:49:32 -
> @@ -624,9 +624,6 @@ extern int tcp_signature_tdb_input(struc
>  extern int tcp_signature_tdb_output(struct mbuf *, struct tdb *,
>  struct mbuf **, int, int);
>  
> -/* Padding */
> -extern caddr_t m_pad(struct mbuf *, int);
> -
>  /* Replay window */
>  extern int checkreplaywindow32(u_int32_t, u_int32_t, u_int32_t *, u_int32_t,
>  u_int32_t *, int);



netcat(1): check local port val

2010-09-23 Thread Mark Lumsden
Add a check to the user supplied value of the local port.

I haven't used the return value of strtonum since pflag is used later as a 
pointer.

ok?

-mark


Index: netcat.c
===
RCS file: /cvs/src/usr.bin/nc/netcat.c,v
retrieving revision 1.98
diff -u -p -r1.98 netcat.c
--- netcat.c3 Jul 2010 04:44:51 -   1.98
+++ netcat.c23 Sep 2010 07:13:51 -
@@ -174,6 +174,9 @@ main(int argc, char *argv[])
Pflag = optarg;
break;
case 'p':
+   strtonum(optarg, 1, PORT_MAX, &errstr);
+   if (errstr)
+   errx(1, "source port %s: %s", errstr, optarg);
pflag = optarg;
break;
case 'r':



Re: patch to add RequestHeader directive to httpd mod_headers.c

2010-09-23 Thread Sebastian Reitenbach
On Wednesday 22 September 2010 11:19:28 pm Landry Breuil wrote:
> On Wed, Sep 22, 2010 at 05:20:04PM +0200, Sebastian Reitenbach wrote:
> > Alexander Hall wrote:
> > > I don't have any actual interest in the change myself, nor the time to
> > > test it, but now at least the diff has the fixes I expected to see
> > > regarding my prior concerns.
> >
> > Anyone else who would test or comment on this one?
> > Tested so far by me: telnetting to apache, and see what comes back, so
> > the old headers still seem to work for me. Tested the new RequestHeader
> > directive in conjunction with mod_proxy configured as reverse proxy.
> > Have seen with tcpdump that the headers were sent to the application
> > server.
>
> I've read the diff and i see nothing wrong with it. I suppose you tried
> all set/append/add/unset actions ?
Thanks, and yes, all four work for me as documented, for all three header 
types.


Sebastian


> Can someone more confident in userland doublecheck and okay it ?
>
> Landry