Re: pool_debug is good, but also bad
> Date: Sun, 03 Apr 2011 18:38:51 -0600 > From: Theo de Raadt > > based on a conversation at the bar. > > POOL_DEBUG is expensive. But we really want it because it finds bugs > before they hurt us. The solution to this is to make it simpler to > turn off. > > This diff starts the kernel with pool debug on, but allows it to be > turned off with sysctl kern.pool_debug=0. This does not gaurantee > that all the pool pages will be unchecked, but it does help. > > This will let people who care about performance turn it off permanently You mean people who care more about performance than the reliability of their (future) kernels ;). > in sysctl.conf; I think we will add a line there for people to know how > to use it. Anyway, the diff makes sense. At least we can tell the knob pushing folks to turn this back on if they're experiencing random memory corruption. > Index: kern/subr_pool.c > === > RCS file: /cvs/src/sys/kern/subr_pool.c,v > retrieving revision 1.100 > diff -u -r1.100 subr_pool.c > --- kern/subr_pool.c 3 Apr 2011 22:07:37 - 1.100 > +++ kern/subr_pool.c 3 Apr 2011 22:59:39 - > @@ -42,7 +42,7 @@ > #include > > #include > - > +#include > > /* > * Pool resource management utility. > @@ -74,6 +74,7 @@ > caddr_t ph_page;/* this page's address */ > caddr_t ph_colored; /* page's colored address */ > int ph_pagesize; > + int ph_magic; > }; > > struct pool_item { > @@ -89,6 +90,7 @@ > #else > #define PI_MAGIC 0xdeafbeef > #endif > +int pool_debug = 1; > > #define POOL_NEEDS_CATCHUP(pp) > \ > ((pp)->pr_nitems < (pp)->pr_minitems) > @@ -441,7 +443,8 @@ > else > ph = pool_get(&phpool, (flags & ~(PR_WAITOK | PR_ZERO)) | > PR_NOWAIT); > - > + if (pool_debug) > + ph->ph_magic = PI_MAGIC; > return (ph); > } > > @@ -611,13 +614,15 @@ > "page %p; item addr %p; offset 0x%x=0x%x", > pp->pr_wchan, ph->ph_page, pi, 0, pi->pi_magic); > #ifdef POOL_DEBUG > - for (ip = (int *)pi, i = sizeof(*pi) / sizeof(int); > - i < pp->pr_size / sizeof(int); i++) { > - if (ip[i] != PI_MAGIC) { > - panic("pool_do_get(%s): free list modified: " > - "page %p; item addr %p; offset 0x%x=0x%x", > - pp->pr_wchan, ph->ph_page, pi, > - i * sizeof(int), ip[i]); > + if (pool_debug && ph->ph_magic) { > + for (ip = (int *)pi, i = sizeof(*pi) / sizeof(int); > + i < pp->pr_size / sizeof(int); i++) { > + if (ip[i] != ph->ph_magic) { > + panic("pool_do_get(%s): free list modified: " > + "page %p; item addr %p; offset 0x%x=0x%x", > + pp->pr_wchan, ph->ph_page, pi, > + i * sizeof(int), ip[i]); > + } > } > } > #endif /* POOL_DEBUG */ > @@ -731,9 +736,11 @@ > #ifdef DIAGNOSTIC > pi->pi_magic = PI_MAGIC; > #ifdef POOL_DEBUG > - for (ip = (int *)pi, i = sizeof(*pi)/sizeof(int); > - i < pp->pr_size / sizeof(int); i++) > - ip[i] = PI_MAGIC; > + if (ph->ph_magic) { > + for (ip = (int *)pi, i = sizeof(*pi)/sizeof(int); > + i < pp->pr_size / sizeof(int); i++) > + ip[i] = ph->ph_magic; > + } > #endif /* POOL_DEBUG */ > #endif /* DIAGNOSTIC */ > > @@ -886,9 +893,11 @@ > #ifdef DIAGNOSTIC > pi->pi_magic = PI_MAGIC; > #ifdef POOL_DEBUG > - for (ip = (int *)pi, i = sizeof(*pi)/sizeof(int); > - i < pp->pr_size / sizeof(int); i++) > - ip[i] = PI_MAGIC; > + if (ph->ph_magic) { > + for (ip = (int *)pi, i = sizeof(*pi)/sizeof(int); > + i < pp->pr_size / sizeof(int); i++) > + ip[i] = ph->ph_magic; > + } > #endif /* POOL_DEBUG */ > #endif /* DIAGNOSTIC */ > cp = (caddr_t)(cp + pp->pr_size); > @@ -1273,14 +1282,16 @@ > 0, pi->pi_magic); > } > #ifdef POOL_DEBUG > - for (ip = (int *)pi, i = sizeof(*pi) / sizeof(int); > - i < pp->pr_size / sizeof(int); i++) { > - if (ip[i] != PI_MAGIC) { > - printf("pool(%s): free list modified: " > - "page %p; item ordinal %d; addr %p " > - "(p %p); offset 0x%x=0x%x\n", > - pp->pr_wchan, ph->ph_page, n, pi, > - page, i * sizeof(int), ip[i]); > +
From now on ETHNOPLUS!
) 2011
Re: fix wcwidth (was: Re: ls(1) multibyte support)
Stefan Sperling wrote: > Change number 2 is the only one that hasn't been committed yet. > According to > http://pubs.opengroup.org/onlinepubs/009695399/functions/wcwidth.html > wcwidth() should return -1 for non-printable characters. > So this change looks good to me. Anyone want to ok it? FWIW, this fixes a bash prompt problem. (When you have a bash prompt that contains unprintable characters, properly bracketed by \[ \], and are in a UTF-8 locale, bash currently becomes confused about the width of the prompt.) -- Christian "naddy" Weisgerber na...@mips.inka.de
no swapping to vnds
Hi, 1) Swapping to svnds has issues (pagedaemon deadlocks) and has been broken since forever. 2) Swapping to vnds makes no sense, why add another layer when you can just swap to a regular file instead ? so stop supporting swapping to vnds. If this turns out to be kosher I have a diff tested that removes vnds in favour of svnds. OK ? Index: uvm/uvm_swap.c === RCS file: /home/thib/cvs/src/sys/uvm/uvm_swap.c,v retrieving revision 1.100 diff -u -p -r1.100 uvm_swap.c --- uvm/uvm_swap.c 21 Dec 2010 20:14:44 - 1.100 +++ uvm/uvm_swap.c 4 Apr 2011 09:14:59 - @@ -912,6 +912,10 @@ swap_on(struct proc *p, struct swapdev * vp = sdp->swd_vp; dev = sdp->swd_dev; + /* no swapping to vnds. */ + if (bdevsw[major(dev)].d_strategy == &vndstrategy) + return (EOPNOTSUPP); + /* * open the swap file (mostly useful for block device files to * let device driver know what is up).
Re: no swapping to vnds
On Mon, Apr 04, 2011 at 09:22:41AM +, Thordur Bjornsson wrote: > Hi, > > 1) Swapping to svnds has issues (pagedaemon deadlocks) and has been >broken since forever. > 2) Swapping to vnds makes no sense, why add another layer when you >can just swap to a regular file instead ? > > so stop supporting swapping to vnds. If this turns out to be kosher > I have a diff tested that removes vnds in favour of svnds. I don't know if this is the right check, but the & is redundant to get the address of a function. -Otto > > > OK ? > > > Index: uvm/uvm_swap.c > === > RCS file: /home/thib/cvs/src/sys/uvm/uvm_swap.c,v > retrieving revision 1.100 > diff -u -p -r1.100 uvm_swap.c > --- uvm/uvm_swap.c21 Dec 2010 20:14:44 - 1.100 > +++ uvm/uvm_swap.c4 Apr 2011 09:14:59 - > @@ -912,6 +912,10 @@ swap_on(struct proc *p, struct swapdev * > vp = sdp->swd_vp; > dev = sdp->swd_dev; > > + /* no swapping to vnds. */ > + if (bdevsw[major(dev)].d_strategy == &vndstrategy) > + return (EOPNOTSUPP); > + > /* >* open the swap file (mostly useful for block device files to >* let device driver know what is up).
Re: no swapping to vnds
On Mon, Apr 04, 2011 at 09:22:41AM +, Thordur Bjornsson wrote: > Hi, > > 1) Swapping to svnds has issues (pagedaemon deadlocks) and has been >broken since forever. > 2) Swapping to vnds makes no sense, why add another layer when you >can just swap to a regular file instead ? > > so stop supporting swapping to vnds. If this turns out to be kosher > I have a diff tested that removes vnds in favour of svnds. > > > OK ? > > > Index: uvm/uvm_swap.c > === > RCS file: /home/thib/cvs/src/sys/uvm/uvm_swap.c,v > retrieving revision 1.100 > diff -u -p -r1.100 uvm_swap.c > --- uvm/uvm_swap.c21 Dec 2010 20:14:44 - 1.100 > +++ uvm/uvm_swap.c4 Apr 2011 09:14:59 - > @@ -912,6 +912,10 @@ swap_on(struct proc *p, struct swapdev * > vp = sdp->swd_vp; > dev = sdp->swd_dev; > > + /* no swapping to vnds. */ > + if (bdevsw[major(dev)].d_strategy == &vndstrategy) > + return (EOPNOTSUPP); > + > /* >* open the swap file (mostly useful for block device files to >* let device driver know what is up). > Makes sense to me. ok krw@. Ken
Re: no swapping to vnds
> Date: Mon, 4 Apr 2011 09:22:41 + > From: Thordur Bjornsson > > Hi, > > 1) Swapping to svnds has issues (pagedaemon deadlocks) and has been >broken since forever. > 2) Swapping to vnds makes no sense, why add another layer when you >can just swap to a regular file instead ? > > so stop supporting swapping to vnds. If this turns out to be kosher > I have a diff tested that removes vnds in favour of svnds. > > > OK ? Doesn't this make it impossible to build kernels without vnd/svnd (RAMDISK)? > Index: uvm/uvm_swap.c > === > RCS file: /home/thib/cvs/src/sys/uvm/uvm_swap.c,v > retrieving revision 1.100 > diff -u -p -r1.100 uvm_swap.c > --- uvm/uvm_swap.c21 Dec 2010 20:14:44 - 1.100 > +++ uvm/uvm_swap.c4 Apr 2011 09:14:59 - > @@ -912,6 +912,10 @@ swap_on(struct proc *p, struct swapdev * > vp = sdp->swd_vp; > dev = sdp->swd_dev; > > + /* no swapping to vnds. */ > + if (bdevsw[major(dev)].d_strategy == &vndstrategy) > + return (EOPNOTSUPP); > + > /* >* open the swap file (mostly useful for block device files to >* let device driver know what is up).
Re: softraid iopoolification
comments inline... On 04/04/2011, at 9:01 AM, Kenneth R Westerback wrote: > Works on my crypto volume. People with other volume types would be nice > to hear from. > > Ken > > Index: softraid.c > === > RCS file: /cvs/src/sys/dev/softraid.c,v > retrieving revision 1.222 > diff -u -p -r1.222 softraid.c > --- softraid.c15 Mar 2011 13:29:41 - 1.222 > +++ softraid.c3 Apr 2011 21:07:48 - > @@ -1805,7 +1805,7 @@ sr_wu_alloc(struct sr_discipline *sd) > for (i = 0; i < no_wu; i++) { > wu = &sd->sd_wu[i]; > wu->swu_dis = sd; > - sr_wu_put(wu); > + sr_wu_put(sd, wu); > } > > return (0); > @@ -1833,17 +1833,15 @@ sr_wu_free(struct sr_discipline *sd) > } > > void > -sr_wu_put(struct sr_workunit *wu) > +sr_wu_put(void *xsd, void *xwu) > { > - struct sr_discipline*sd = wu->swu_dis; > + struct sr_discipline*sd = (struct sr_discipline *)xsd; > + struct sr_workunit *wu = (struct sr_workunit *)xwu; > struct sr_ccb *ccb; > - > int s; > > DNPRINTF(SR_D_WU, "%s: sr_wu_put: %p\n", DEVNAME(sd->sd_sc), wu); > > - s = splbio(); > - > wu->swu_xs = NULL; > wu->swu_state = SR_WU_FREE; > wu->swu_ios_complete = 0; > @@ -1864,9 +1862,12 @@ sr_wu_put(struct sr_workunit *wu) > } > TAILQ_INIT(&wu->swu_ccb); > > + mtx_enter(&sd->sd_wu_mtx); > TAILQ_INSERT_TAIL(&sd->sd_wu_freeq, wu, swu_link); > sd->sd_wu_pending--; > + mtx_leave(&sd->sd_wu_mtx); > > + s = splbio(); > /* wake up sleepers */ > #ifdef DIAGNOSTIC > if (sd->sd_wu_sleep < 0) > @@ -1874,34 +1875,23 @@ sr_wu_put(struct sr_workunit *wu) > #endif /* DIAGNOSTIC */ > if (sd->sd_wu_sleep) > wakeup(&sd->sd_wu_sleep); > - > splx(s); > } > > -struct sr_workunit * > -sr_wu_get(struct sr_discipline *sd, int canwait) > +void * > +sr_wu_get(void *xsd) > { > + struct sr_discipline*sd = (struct sr_discipline *)xsd; > struct sr_workunit *wu; > - int s; > - > - s = splbio(); > > - for (;;) { > - wu = TAILQ_FIRST(&sd->sd_wu_freeq); > - if (wu) { > - TAILQ_REMOVE(&sd->sd_wu_freeq, wu, swu_link); > - wu->swu_state = SR_WU_INPROGRESS; > - sd->sd_wu_pending++; > - break; > - } else if (wu == NULL && canwait) { > - sd->sd_wu_sleep++; > - tsleep(&sd->sd_wu_sleep, PRIBIO, "sr_wu_get", 0); > - sd->sd_wu_sleep--; > - } else > - break; > + mtx_enter(&sd->sd_wu_mtx); > + wu = TAILQ_FIRST(&sd->sd_wu_freeq); > + if (wu) { > + TAILQ_REMOVE(&sd->sd_wu_freeq, wu, swu_link); > + wu->swu_state = SR_WU_INPROGRESS; > + sd->sd_wu_pending++; > } > - > - splx(s); > + mtx_leave(&sd->sd_wu_mtx); > > DNPRINTF(SR_D_WU, "%s: sr_wu_get: %p\n", DEVNAME(sd->sd_sc), wu); > > @@ -1949,19 +1939,9 @@ sr_scsi_cmd(struct scsi_xfer *xs) > goto stuffup; > } > > - /* > - * we'll let the midlayer deal with stalls instead of being clever > - * and sending sr_wu_get !(xs->flags & SCSI_NOSLEEP) in cansleep > - */ > - if ((wu = sr_wu_get(sd, 0)) == NULL) { > - DNPRINTF(SR_D_CMD, "%s: sr_scsi_cmd no wu\n", DEVNAME(sc)); > - xs->error = XS_NO_CCB; > - sr_scsi_done(sd, xs); > - return; > - } > - > - xs->error = XS_NOERROR; > + wu = xs->io; > wu->swu_xs = xs; > + xs->error = XS_NOERROR; scsi_xs_exec sets xs->error to XS_NOERROR before giving it to this func, so this is technically unnecessary. not an issue with this diff exactly, just an interesting factoid. > > /* the midlayer will query LUNs so report sense to stop scanning */ > if (link->target != 0 || link->lun != 0) { > @@ -2049,10 +2029,9 @@ stuffup: > xs->error = XS_DRIVER_STUFFUP; > } > complete: > - if (wu) > - sr_wu_put(wu); > sr_scsi_done(sd, xs); > } > + > int > sr_scsi_ioctl(struct scsi_link *link, u_long cmd, caddr_t addr, int flag) > { > @@ -3042,6 +3021,8 @@ sr_ioctl_createraid(struct sr_softc *sc, > } > > /* setup scsi midlayer */ > + mtx_init(&sd->sd_wu_mtx, IPL_BIO); > + scsi_iopool_init(&sd->sd_iopool, sd, sr_wu_get, sr_wu_put); > if (sd->sd_openings) > sd->sd_link.openings = sd->sd_openings(sd); > else > @@ -3051,6 +3032,7 @@ sr_ioctl_createraid(struct sr_softc *sc, > sd->sd_link.adapter = &sr_switch; > sd->sd_link.adapter_target = SR_MAX_LD; > sd->sd_link.adapter_buswidth = 1; > + sd->sd_link.pool = &sd-
bye bye o43statfs
this one is unused. OK ? Index: sys/mount.h === RCS file: /var/cvs/src/sys/sys/mount.h,v retrieving revision 1.100 diff -u -p -r1.100 mount.h --- sys/mount.h 29 Jun 2010 04:09:32 - 1.100 +++ sys/mount.h 4 Apr 2011 10:28:59 - @@ -314,28 +314,6 @@ struct statfs { union mount_info mount_info;/* per-filesystem mount options */ }; -/* old (pre-4.3) statfs structure with mount options */ -struct o43statfs { - u_int32_t f_flags; /* copy of mount flags */ - int32_tf_bsize; /* fundamental file system block size */ - u_int32_t f_iosize;/* optimal transfer block size */ - u_int32_t f_blocks;/* total data blocks in file system */ - u_int32_t f_bfree; /* free blocks in fs */ - int32_tf_bavail;/* free blocks avail to non-superuser */ - u_int32_t f_files; /* total file nodes in file system */ - u_int32_t f_ffree; /* free file nodes in fs */ - fsid_t f_fsid; /* file system id */ - uid_t f_owner; /* user that mounted the file system */ - u_int32_t f_syncwrites;/* count of sync writes since mount */ - u_int32_t f_asyncwrites; /* count of async writes since mount */ - u_int32_t f_ctime; /* last mount [-u] time */ - u_int32_t f_spare[3]; /* spare for later */ - char f_fstypename[MFSNAMELEN]; /* fs type name */ - char f_mntonname[MNAMELEN];/* directory on which mounted */ - char f_mntfromname[MNAMELEN]; /* mounted file system */ - union mount_info mount_info;/* per-filesystem mount options */ -}; - /* old (pre-2.6) statfs structure */ struct ostatfs { short f_type; /* type of file system (unused; zero) */
Re: no swapping to vnds
On Mon, Apr 04, 2011 at 12:34:17PM +0200, Otto Moerbeek wrote: > On Mon, Apr 04, 2011 at 09:22:41AM +, Thordur Bjornsson wrote: > > > Hi, > > > > 1) Swapping to svnds has issues (pagedaemon deadlocks) and has been > >broken since forever. > > 2) Swapping to vnds makes no sense, why add another layer when you > >can just swap to a regular file instead ? > > > > so stop supporting swapping to vnds. If this turns out to be kosher > > I have a diff tested that removes vnds in favour of svnds. > > I don't know if this is the right check, but the & is redundant to get > the address of a function. It's the easiest check. It's "hard" to map a dev_t to a device since it is MD, so checking for that function is the "best" way I could come up with. And "doh" on the '&'. I'll commit with out it. > -Otto > > > > > > > OK ? > > > > > > Index: uvm/uvm_swap.c > > === > > RCS file: /home/thib/cvs/src/sys/uvm/uvm_swap.c,v > > retrieving revision 1.100 > > diff -u -p -r1.100 uvm_swap.c > > --- uvm/uvm_swap.c 21 Dec 2010 20:14:44 - 1.100 > > +++ uvm/uvm_swap.c 4 Apr 2011 09:14:59 - > > @@ -912,6 +912,10 @@ swap_on(struct proc *p, struct swapdev * > > vp = sdp->swd_vp; > > dev = sdp->swd_dev; > > > > + /* no swapping to vnds. */ > > + if (bdevsw[major(dev)].d_strategy == &vndstrategy) > > + return (EOPNOTSUPP); > > + > > /* > > * open the swap file (mostly useful for block device files to > > * let device driver know what is up).
Re: no swapping to vnds
On 04/04/2011, at 8:43 PM, Thordur Bjornsson wrote: > On Mon, Apr 04, 2011 at 12:34:17PM +0200, Otto Moerbeek wrote: >> On Mon, Apr 04, 2011 at 09:22:41AM +, Thordur Bjornsson wrote: >> >>> Hi, >>> >>> 1) Swapping to svnds has issues (pagedaemon deadlocks) and has been >>> broken since forever. >>> 2) Swapping to vnds makes no sense, why add another layer when you >>> can just swap to a regular file instead ? >>> >>> so stop supporting swapping to vnds. If this turns out to be kosher >>> I have a diff tested that removes vnds in favour of svnds. >> >> I don't know if this is the right check, but the & is redundant to get >> the address of a function. > It's the easiest check. It's "hard" to map a dev_t to a device since > it is MD, so checking for that function is the "best" way I could > come up with. > > And "doh" on the '&'. I'll commit with out it. block drivers look themselves up by comparing to their own functions, so there is a precedent for doing it this way. > > >> -Otto >> >>> >>> >>> OK ? >>> >>> >>> Index: uvm/uvm_swap.c >>> === >>> RCS file: /home/thib/cvs/src/sys/uvm/uvm_swap.c,v >>> retrieving revision 1.100 >>> diff -u -p -r1.100 uvm_swap.c >>> --- uvm/uvm_swap.c 21 Dec 2010 20:14:44 - 1.100 >>> +++ uvm/uvm_swap.c 4 Apr 2011 09:14:59 - >>> @@ -912,6 +912,10 @@ swap_on(struct proc *p, struct swapdev * >>> vp = sdp->swd_vp; >>> dev = sdp->swd_dev; >>> >>> + /* no swapping to vnds. */ >>> + if (bdevsw[major(dev)].d_strategy == &vndstrategy) >>> + return (EOPNOTSUPP); >>> + >>> /* >>> * open the swap file (mostly useful for block device files to >>> * let device driver know what is up).
Disable BSD4.3 COMPAT
tiny tedu moment of mine, disable COMPAT_43 and keep it so for a few releases and if noone complains, nuke it. OK/Thoughts ? Index: conf/GENERIC === RCS file: /var/cvs/src/sys/conf/GENERIC,v retrieving revision 1.172 diff -u -p -r1.172 GENERIC --- conf/GENERIC2 Mar 2011 01:58:56 - 1.172 +++ conf/GENERIC4 Apr 2011 10:50:47 - @@ -28,7 +28,7 @@ optionSYSVSHM # System V-like memory option UVM_SWAP_ENCRYPT# support encryption of pages going to swap -option COMPAT_43 # Kernel compatibility with 4.3BSD +#optionCOMPAT_43 # Kernel compatibility with 4.3BSD option COMPAT_O47 # Compatibility with OpenBSD 4.7 option LKM # loadable kernel modules
Re: bye bye o43statfs
On Mon, Apr 4, 2011 at 3:29 AM, Thordur Bjornsson wrote: > this one is unused. > > OK ? I love the smell of burning bits in the morning. ok guenther
Re: pool_debug is good, but also bad
On Sun, Apr 03, 2011 at 06:38:51PM -0600, Theo de Raadt wrote: > based on a conversation at the bar. > > POOL_DEBUG is expensive. But we really want it because it finds bugs > before they hurt us. The solution to this is to make it simpler to > turn off. > > This diff starts the kernel with pool debug on, but allows it to be > turned off with sysctl kern.pool_debug=0. This does not gaurantee > that all the pool pages will be unchecked, but it does help. > > This will let people who care about performance turn it off permanently > in sysctl.conf; I think we will add a line there for people to know how > to use it. I like this. Means I can turn it off and on easly when I'm testing diffs on my workstations. > > Index: kern/subr_pool.c > === > RCS file: /cvs/src/sys/kern/subr_pool.c,v > retrieving revision 1.100 > diff -u -r1.100 subr_pool.c > --- kern/subr_pool.c 3 Apr 2011 22:07:37 - 1.100 > +++ kern/subr_pool.c 3 Apr 2011 22:59:39 - > @@ -42,7 +42,7 @@ > #include > > #include > - > +#include > > /* > * Pool resource management utility. > @@ -74,6 +74,7 @@ > caddr_t ph_page;/* this page's address */ > caddr_t ph_colored; /* page's colored address */ > int ph_pagesize; > + int ph_magic; > }; > > struct pool_item { > @@ -89,6 +90,7 @@ > #else > #define PI_MAGIC 0xdeafbeef > #endif > +int pool_debug = 1; > > #define POOL_NEEDS_CATCHUP(pp) > \ > ((pp)->pr_nitems < (pp)->pr_minitems) > @@ -441,7 +443,8 @@ > else > ph = pool_get(&phpool, (flags & ~(PR_WAITOK | PR_ZERO)) | > PR_NOWAIT); > - > + if (pool_debug) > + ph->ph_magic = PI_MAGIC; > return (ph); > } > > @@ -611,13 +614,15 @@ > "page %p; item addr %p; offset 0x%x=0x%x", > pp->pr_wchan, ph->ph_page, pi, 0, pi->pi_magic); > #ifdef POOL_DEBUG > - for (ip = (int *)pi, i = sizeof(*pi) / sizeof(int); > - i < pp->pr_size / sizeof(int); i++) { > - if (ip[i] != PI_MAGIC) { > - panic("pool_do_get(%s): free list modified: " > - "page %p; item addr %p; offset 0x%x=0x%x", > - pp->pr_wchan, ph->ph_page, pi, > - i * sizeof(int), ip[i]); > + if (pool_debug && ph->ph_magic) { > + for (ip = (int *)pi, i = sizeof(*pi) / sizeof(int); > + i < pp->pr_size / sizeof(int); i++) { > + if (ip[i] != ph->ph_magic) { > + panic("pool_do_get(%s): free list modified: " > + "page %p; item addr %p; offset 0x%x=0x%x", > + pp->pr_wchan, ph->ph_page, pi, > + i * sizeof(int), ip[i]); > + } > } > } > #endif /* POOL_DEBUG */ > @@ -731,9 +736,11 @@ > #ifdef DIAGNOSTIC > pi->pi_magic = PI_MAGIC; > #ifdef POOL_DEBUG > - for (ip = (int *)pi, i = sizeof(*pi)/sizeof(int); > - i < pp->pr_size / sizeof(int); i++) > - ip[i] = PI_MAGIC; > + if (ph->ph_magic) { > + for (ip = (int *)pi, i = sizeof(*pi)/sizeof(int); > + i < pp->pr_size / sizeof(int); i++) > + ip[i] = ph->ph_magic; > + } > #endif /* POOL_DEBUG */ > #endif /* DIAGNOSTIC */ > > @@ -886,9 +893,11 @@ > #ifdef DIAGNOSTIC > pi->pi_magic = PI_MAGIC; > #ifdef POOL_DEBUG > - for (ip = (int *)pi, i = sizeof(*pi)/sizeof(int); > - i < pp->pr_size / sizeof(int); i++) > - ip[i] = PI_MAGIC; > + if (ph->ph_magic) { > + for (ip = (int *)pi, i = sizeof(*pi)/sizeof(int); > + i < pp->pr_size / sizeof(int); i++) > + ip[i] = ph->ph_magic; > + } > #endif /* POOL_DEBUG */ > #endif /* DIAGNOSTIC */ > cp = (caddr_t)(cp + pp->pr_size); > @@ -1273,14 +1282,16 @@ > 0, pi->pi_magic); > } > #ifdef POOL_DEBUG > - for (ip = (int *)pi, i = sizeof(*pi) / sizeof(int); > - i < pp->pr_size / sizeof(int); i++) { > - if (ip[i] != PI_MAGIC) { > - printf("pool(%s): free list modified: " > - "page %p; item ordinal %d; addr %p " > - "(p %p); offset 0x%x=0x%x\n", > - pp->pr_wchan, ph->ph_page, n, pi, > - page, i * sizeof(int), ip[i]); > + if (pool_debug && ph->ph_magic) { > + for (ip = (int *)pi, i = sizeof(*pi) / sizeof(int); > + i < pp
tweak for mount.h
o Collapse a few _KERNEL's and move some definitions to allow this. o Expose a few NFSMOUNT stuffs (one I will remove, the other I'm going to use later anyways). o Kill a protection for a forward decleration o Kill __STDC__ protection (which is under _KERNEL). OK ? Index: sys/mount.h === RCS file: /cvs/src/sys/sys/mount.h,v retrieving revision 1.101 diff -u -p -r1.101 mount.h --- sys/mount.h 4 Apr 2011 12:50:58 - 1.101 +++ sys/mount.h 4 Apr 2011 12:59:20 - @@ -156,9 +156,7 @@ struct nfs_args3 { /* * NFS mount option flags */ -#ifndef _KERNEL #defineNFSMNT_RESVPORT 0x /* always use reserved ports */ -#endif /* ! _KERNEL */ #defineNFSMNT_SOFT 0x0001 /* soft mount (hard is default) */ #defineNFSMNT_WSIZE0x0002 /* set write size */ #defineNFSMNT_RSIZE0x0004 /* set read size */ @@ -174,9 +172,7 @@ struct nfs_args3 { #defineNFSMNT_LEASETERM0x1000 /* set lease term (nqnfs) */ #defineNFSMNT_READAHEAD0x2000 /* set read ahead */ #defineNFSMNT_DEADTHRESH 0x4000 /* set dead server retry thresh */ -#ifdef _KERNEL /* Coming soon to a system call near you! */ #defineNFSMNT_NOAC 0x8000 /* disable attribute cache */ -#endif /* _KERNEL */ #defineNFSMNT_RDIRPLUS 0x0001 /* Use Readdirplus for V3 */ #defineNFSMNT_READDIRSIZE 0x0002 /* Set readdir size */ @@ -430,6 +426,24 @@ struct mount { #define MNT_DOOMED 0x0800 /* device behind filesystem is gone */ /* + * Flags for various system call interfaces. + * + * waitfor flags to vfs_sync() and getfsstat() + */ +#define MNT_WAIT 1 /* synchronously wait for I/O to complete */ +#define MNT_NOWAIT 2 /* start all I/O, but do not wait for it */ +#define MNT_LAZY 3 /* push data not written by filesystem syncer */ + +/* + * Generic file handle + */ +struct fhandle { + fsid_t fh_fsid;/* File system id of mount point */ + struct fid fh_fid; /* File sys specific id */ +}; +typedef struct fhandle fhandle_t; + +/* * Sysctl CTL_VFS definitions. * * Second level identifier specifies which filesystem. Second level @@ -492,16 +506,12 @@ extern long buflowpages, bufhighpages, b extern int bufcachepercent; extern void bufadjust(int); extern int bufbackoff(void); -#endif /* * Operations supported on mounted file system. */ -#ifdef _KERNEL -#ifdef __STDC__ struct nameidata; struct mbuf; -#endif extern int maxvfsconf; /* highest defined filesystem type */ extern struct vfsconf *vfsconf;/* head of list of filesystem types */ @@ -547,27 +557,8 @@ struct vfsops { #defineVFS_VPTOFH(VP, FIDP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP) #define VFS_CHECKEXP(MP, NAM, EXFLG, CRED) \ (*(MP)->mnt_op->vfs_checkexp)(MP, NAM, EXFLG, CRED) -#endif /* _KERNEL */ -/* - * Flags for various system call interfaces. - * - * waitfor flags to vfs_sync() and getfsstat() - */ -#define MNT_WAIT 1 /* synchronously wait for I/O to complete */ -#define MNT_NOWAIT 2 /* start all I/O, but do not wait for it */ -#define MNT_LAZY 3 /* push data not written by filesystem syncer */ -/* - * Generic file handle - */ -struct fhandle { - fsid_t fh_fsid;/* File system id of mount point */ - struct fid fh_fid; /* File sys specific id */ -}; -typedef struct fhandle fhandle_t; - -#ifdef _KERNEL #include #include /* XXX for AF_MAX */ @@ -587,9 +578,7 @@ struct netexport { struct netcred ne_defexported; /* Default export */ struct radix_node_head *ne_rtable[AF_MAX+1]; /* Individual exports */ }; -#endif /* _KERNEL */ -#ifdef _KERNEL /* * exported vnode operations */ @@ -626,10 +615,7 @@ void vfsinit(void); intvfs_register(struct vfsconf *); intvfs_unregister(struct vfsconf *); #else /* _KERNEL */ - -#ifndef _SYS_STAT_H_ struct stat; -#endif __BEGIN_DECLS intfstatfs(int, struct statfs *);
pmemrange fix
Hi, Test the iterated range, instead of the range chosen to not meet the assert. This has been broken for a long time, but apparently no-one hit it so far. While here, change the KASSERT to a KDASSERT, as it is a validation of internal state of pmemrange. Ok? -- Ariane Index: uvm_pmemrange.c === RCS file: /cvs/src/sys/uvm/uvm_pmemrange.c,v retrieving revision 1.18 diff -u -d -p -r1.18 uvm_pmemrange.c --- uvm_pmemrange.c 28 Aug 2010 22:27:47 - 1.18 +++ uvm_pmemrange.c 4 Apr 2011 14:01:41 - @@ -1630,8 +1630,8 @@ uvm_pmr_rootupdate(struct uvm_pmemrange for (low = RB_NEXT(uvm_pmr_addr, &pmr->addr, low); low != high; low = RB_NEXT(uvm_pmr_addr, &pmr->addr, low)) { - KASSERT(PMR_IS_SUBRANGE_OF(atop(VM_PAGE_TO_PHYS(high_next)), - atop(VM_PAGE_TO_PHYS(high_next)) + high_next->fpgsz, + KDASSERT(PMR_IS_SUBRANGE_OF(atop(VM_PAGE_TO_PHYS(low)), + atop(VM_PAGE_TO_PHYS(low)) + low->fpgsz, start, end)); if (uvm_pmr_pg_to_memtype(low) == memtype) return low;
Re: uvm_map diff - testing required
On Mon, Apr 04, 2011 at 03:00:43PM +0200, Ariane van der Steldt wrote: > Please test this diff to uvm_map on as many architectures as possible. > Contains a number of fixes and a better algorithm. It makes sure random address space allocations happen (and enables it in the kernel) without causing the fragmented mess that the current implementation does. It works by keeping lists of allocatable space in a tree, sorted by size. Whenever an allocation is made, the first entry in the tree and up to 8 entries after it are considered, one of them is randomly chosen. From the chosen area, a random offset is chosen (any address, unless the size tree contains too many segments, in which case only the lowest and highest offsets are chosen). Differences: - The current allocator may fail when memory is available (because it searches forward only), while my implementation won't fail until we really run out of memory. - It keeps a target for fragmentation: if fragmentation is more than the target, allocations happen randomly without creating more fragmentation. - It uses a best-fit algorithm, so is better able to use available space. - It has a proper implementation of guard pages in the kernel. - vm_maps that are vmspaces now have a bit set, in which case the allocator will update the vmspace data (instead of the caller needing to do that). - uvm_map no longer needs a hint address (address is ignored unless MAP_FIXED). Ciao, -- Ariane
Re: Disable BSD4.3 COMPAT
On Mon, Apr 4, 2011 at 7:51 AM, Thordur Bjornsson wrote: > tiny tedu moment of mine, disable COMPAT_43 and keep > it so for a few releases and if noone complains, nuke it. > > OK/Thoughts ? I think this is ok. I looked at a few of the uses, and we seem to be using the linux compat where needed. There is a comment in linux/linux_socket.h that I think is out of date. I'd say you should make sure to test this with a few linux binaries, as that's probably the most relevant use today.
Najniže cene fitnesa - poslednje količine
Velika fitnes akcija! Ne propustite, poslednje koliD ine fitnesa opreme PO NAJNIE=IM CENAMA do sada! Ova posebna ponuda traje do 15. maja 2011! Ne gubite vreme, koliD ine su ograniD ene! Kliknite i poruD ite; Najbolja forma uz najbolje ponude Najbolji fitnes po najniE>im cenama - poslednje koliD ine! Leg Magic Leg Magic s timerom -25% Vaša cena: 5.990 rsd Više ; Ab Rocket Ab Rocket -44% Vaša cena: 4.990 rsd Više ; Curved Sit Up Bench with Dumbbells Curved Sit Up Bench with Dumbbells -29% Vaša cena: 4.990 rsd Više ; Novo, moderno, praktiD no - spremite se za leto! WalkMaxX Sporty - fitnes patike WalkmaxX Sporty NOVO Vaša cena: 3.990 rsd Više ; iRenew - energetska narukvica iRenew narukvica NOVO Vaša cena: 2.990 Više ; PowerBall Autostart PRO PowerBall Autostart NOVO Vaša cena: 5.490 rsd Više ; Pogledajte najbolje fitnes ponude - kliknite ovde! Ovu elektronsku poštu primate, ukoliko ste svojevoljno ostavili svoju e-mail adresu na nekom od sajtova Top Shop-a, uD estvovali u našoj poklon igri ili nagradnom kvizu ili se prijavili za e-D asopis Top Shop-a ili nekog od nasih brendova. Ponude date u ovom e-mailu vaE>e iskljuD ivo za porudE>bine upuDene putem Interneta ili broja telefona 021 489 26 60. Ukoliko ne E>elite više da primate naše elektronske poruke, za odjavljivanje sa naše e-mailing liste, kliknite ovde. Studio Moderna d.o.o., Bulevar vojvode Stepe 30, 21000 Novi Sad, Tel: 021 489 26 60, Fax: 021 489 29 08, E-mail: i...@news.top-shop.rs [IMAGE]If you would no longer like to receive our emails please unsubscribe by clicking here.
Re: softraid iopoolification
On Sun, Apr 03, 2011 at 07:01:04PM -0400, Kenneth R Westerback wrote: > Works on my crypto volume. People with other volume types would be nice > to hear from. > > Ken v2. Use scsi_io_[get|put](), stop trying so hard to avoid calling scsi_done() at SPLBIO as this is nice but not necessary, remove random 'improvements' to make diff as small as possible. Tests still desired! Ken Index: softraid.c === RCS file: /cvs/src/sys/dev/softraid.c,v retrieving revision 1.222 diff -u -p -r1.222 softraid.c --- softraid.c 15 Mar 2011 13:29:41 - 1.222 +++ softraid.c 4 Apr 2011 14:36:04 - @@ -1805,7 +1805,7 @@ sr_wu_alloc(struct sr_discipline *sd) for (i = 0; i < no_wu; i++) { wu = &sd->sd_wu[i]; wu->swu_dis = sd; - sr_wu_put(wu); + sr_wu_put(sd, wu); } return (0); @@ -1833,9 +1833,10 @@ sr_wu_free(struct sr_discipline *sd) } void -sr_wu_put(struct sr_workunit *wu) +sr_wu_put(void *xsd, void *xwu) { - struct sr_discipline*sd = wu->swu_dis; + struct sr_discipline*sd = (struct sr_discipline *)xsd; + struct sr_workunit *wu = (struct sr_workunit *)xwu; struct sr_ccb *ccb; int s; @@ -1864,9 +1865,14 @@ sr_wu_put(struct sr_workunit *wu) } TAILQ_INIT(&wu->swu_ccb); + splx(s); + + mtx_enter(&sd->sd_wu_mtx); TAILQ_INSERT_TAIL(&sd->sd_wu_freeq, wu, swu_link); sd->sd_wu_pending--; + mtx_leave(&sd->sd_wu_mtx); + s = splbio(); /* wake up sleepers */ #ifdef DIAGNOSTIC if (sd->sd_wu_sleep < 0) @@ -1878,30 +1884,20 @@ sr_wu_put(struct sr_workunit *wu) splx(s); } -struct sr_workunit * -sr_wu_get(struct sr_discipline *sd, int canwait) +void * +sr_wu_get(void *xsd) { + struct sr_discipline*sd = (struct sr_discipline *)xsd; struct sr_workunit *wu; - int s; - s = splbio(); - - for (;;) { - wu = TAILQ_FIRST(&sd->sd_wu_freeq); - if (wu) { - TAILQ_REMOVE(&sd->sd_wu_freeq, wu, swu_link); - wu->swu_state = SR_WU_INPROGRESS; - sd->sd_wu_pending++; - break; - } else if (wu == NULL && canwait) { - sd->sd_wu_sleep++; - tsleep(&sd->sd_wu_sleep, PRIBIO, "sr_wu_get", 0); - sd->sd_wu_sleep--; - } else - break; + mtx_enter(&sd->sd_wu_mtx); + wu = TAILQ_FIRST(&sd->sd_wu_freeq); + if (wu) { + TAILQ_REMOVE(&sd->sd_wu_freeq, wu, swu_link); + wu->swu_state = SR_WU_INPROGRESS; + sd->sd_wu_pending++; } - - splx(s); + mtx_leave(&sd->sd_wu_mtx); DNPRINTF(SR_D_WU, "%s: sr_wu_get: %p\n", DEVNAME(sd->sd_sc), wu); @@ -1949,18 +1945,7 @@ sr_scsi_cmd(struct scsi_xfer *xs) goto stuffup; } - /* -* we'll let the midlayer deal with stalls instead of being clever -* and sending sr_wu_get !(xs->flags & SCSI_NOSLEEP) in cansleep -*/ - if ((wu = sr_wu_get(sd, 0)) == NULL) { - DNPRINTF(SR_D_CMD, "%s: sr_scsi_cmd no wu\n", DEVNAME(sc)); - xs->error = XS_NO_CCB; - sr_scsi_done(sd, xs); - return; - } - - xs->error = XS_NOERROR; + wu = xs->io; wu->swu_xs = xs; /* the midlayer will query LUNs so report sense to stop scanning */ @@ -2049,8 +2034,6 @@ stuffup: xs->error = XS_DRIVER_STUFFUP; } complete: - if (wu) - sr_wu_put(wu); sr_scsi_done(sd, xs); } int @@ -3042,6 +3025,8 @@ sr_ioctl_createraid(struct sr_softc *sc, } /* setup scsi midlayer */ + mtx_init(&sd->sd_wu_mtx, IPL_BIO); + scsi_iopool_init(&sd->sd_iopool, sd, sr_wu_get, sr_wu_put); if (sd->sd_openings) sd->sd_link.openings = sd->sd_openings(sd); else @@ -3051,6 +3036,7 @@ sr_ioctl_createraid(struct sr_softc *sc, sd->sd_link.adapter = &sr_switch; sd->sd_link.adapter_target = SR_MAX_LD; sd->sd_link.adapter_buswidth = 1; + sd->sd_link.pool = &sd->sd_iopool; bzero(&saa, sizeof(saa)); saa.saa_sc_link = &sd->sd_link; @@ -3954,9 +3940,9 @@ sr_rebuild_thread(void *arg) lba = blk * sz; /* get some wu */ - if ((wu_r = sr_wu_get(sd, 1)) == NULL) + if ((wu_r = scsi_io_get(&sd->sd_iopool, 0)) == NULL) panic("%s: rebuild exhausted wu_r", DEVNAME(sc)); - if ((wu_w = sr_wu_get(sd, 1)) == NULL) +
Re: softraid iopoolification
this reads fine by me, except for one thing. i worry that it looks like wu's get lists of ccbs attached to them that are released when the wu is released. before iopools there was a wu per call to softraids scsi_cmd handler, but now the same wu can be given to scsi_cmd multiple times. sr_scsi_done should probably clean up the ccb list before the xs and wu are given back to the midlayer. if this isnt a problem and testing goes well, then it has my ok. the wakeups in sr_wu_put are no longer necessary as the iopool code takes over responsibility for sleeping for resources. its just extra code, but it doesnt affect my ok above. dlg On 05/04/2011, at 12:47 AM, Kenneth R Westerback wrote: > On Sun, Apr 03, 2011 at 07:01:04PM -0400, Kenneth R Westerback wrote: >> Works on my crypto volume. People with other volume types would be nice >> to hear from. >> >> Ken > > v2. Use scsi_io_[get|put](), stop trying so hard to avoid calling scsi_done() > at SPLBIO as this is nice but not necessary, remove random 'improvements' to > make diff as small as possible. > > Tests still desired! > > Ken > > Index: softraid.c > === > RCS file: /cvs/src/sys/dev/softraid.c,v > retrieving revision 1.222 > diff -u -p -r1.222 softraid.c > --- softraid.c15 Mar 2011 13:29:41 - 1.222 > +++ softraid.c4 Apr 2011 14:36:04 - > @@ -1805,7 +1805,7 @@ sr_wu_alloc(struct sr_discipline *sd) > for (i = 0; i < no_wu; i++) { > wu = &sd->sd_wu[i]; > wu->swu_dis = sd; > - sr_wu_put(wu); > + sr_wu_put(sd, wu); > } > > return (0); > @@ -1833,9 +1833,10 @@ sr_wu_free(struct sr_discipline *sd) > } > > void > -sr_wu_put(struct sr_workunit *wu) > +sr_wu_put(void *xsd, void *xwu) > { > - struct sr_discipline*sd = wu->swu_dis; > + struct sr_discipline*sd = (struct sr_discipline *)xsd; > + struct sr_workunit *wu = (struct sr_workunit *)xwu; > struct sr_ccb *ccb; > > int s; > @@ -1864,9 +1865,14 @@ sr_wu_put(struct sr_workunit *wu) > } > TAILQ_INIT(&wu->swu_ccb); > > + splx(s); > + > + mtx_enter(&sd->sd_wu_mtx); > TAILQ_INSERT_TAIL(&sd->sd_wu_freeq, wu, swu_link); > sd->sd_wu_pending--; > + mtx_leave(&sd->sd_wu_mtx); > > + s = splbio(); > /* wake up sleepers */ > #ifdef DIAGNOSTIC > if (sd->sd_wu_sleep < 0) > @@ -1878,30 +1884,20 @@ sr_wu_put(struct sr_workunit *wu) > splx(s); > } > > -struct sr_workunit * > -sr_wu_get(struct sr_discipline *sd, int canwait) > +void * > +sr_wu_get(void *xsd) > { > + struct sr_discipline*sd = (struct sr_discipline *)xsd; > struct sr_workunit *wu; > - int s; > > - s = splbio(); > - > - for (;;) { > - wu = TAILQ_FIRST(&sd->sd_wu_freeq); > - if (wu) { > - TAILQ_REMOVE(&sd->sd_wu_freeq, wu, swu_link); > - wu->swu_state = SR_WU_INPROGRESS; > - sd->sd_wu_pending++; > - break; > - } else if (wu == NULL && canwait) { > - sd->sd_wu_sleep++; > - tsleep(&sd->sd_wu_sleep, PRIBIO, "sr_wu_get", 0); > - sd->sd_wu_sleep--; > - } else > - break; > + mtx_enter(&sd->sd_wu_mtx); > + wu = TAILQ_FIRST(&sd->sd_wu_freeq); > + if (wu) { > + TAILQ_REMOVE(&sd->sd_wu_freeq, wu, swu_link); > + wu->swu_state = SR_WU_INPROGRESS; > + sd->sd_wu_pending++; > } > - > - splx(s); > + mtx_leave(&sd->sd_wu_mtx); > > DNPRINTF(SR_D_WU, "%s: sr_wu_get: %p\n", DEVNAME(sd->sd_sc), wu); > > @@ -1949,18 +1945,7 @@ sr_scsi_cmd(struct scsi_xfer *xs) > goto stuffup; > } > > - /* > - * we'll let the midlayer deal with stalls instead of being clever > - * and sending sr_wu_get !(xs->flags & SCSI_NOSLEEP) in cansleep > - */ > - if ((wu = sr_wu_get(sd, 0)) == NULL) { > - DNPRINTF(SR_D_CMD, "%s: sr_scsi_cmd no wu\n", DEVNAME(sc)); > - xs->error = XS_NO_CCB; > - sr_scsi_done(sd, xs); > - return; > - } > - > - xs->error = XS_NOERROR; > + wu = xs->io; > wu->swu_xs = xs; > > /* the midlayer will query LUNs so report sense to stop scanning */ > @@ -2049,8 +2034,6 @@ stuffup: > xs->error = XS_DRIVER_STUFFUP; > } > complete: > - if (wu) > - sr_wu_put(wu); > sr_scsi_done(sd, xs); > } > int > @@ -3042,6 +3025,8 @@ sr_ioctl_createraid(struct sr_softc *sc, > } > > /* setup scsi midlayer */ > + mtx_init(&sd->sd_wu_mtx, IPL_BIO); > + scsi_iopool_init(&sd->sd_iopool, sd, sr_wu_get, sr_wu_put); > if (sd->sd_openings) > sd->sd_link.openings = s
drop ICMP redirects if ipforwaring = 1
Routers need to ingore ICMP redirects in anycase so it would make sense to disable ICMP redirects as soon as ipforwarding is set to 1. The IPv6 counterpart already does this. OK? -- :wq Claudio Index: netinet/ip_icmp.c === RCS file: /cvs/src/sys/netinet/ip_icmp.c,v retrieving revision 1.92 diff -u -p -r1.92 ip_icmp.c --- netinet/ip_icmp.c 13 Sep 2010 09:59:32 - 1.92 +++ netinet/ip_icmp.c 24 Mar 2011 10:39:46 - @@ -313,6 +313,7 @@ icmp_input(struct mbuf *m, ...) void *(*ctlfunc)(int, struct sockaddr *, u_int, void *); int code; extern u_char ip_protox[]; + extern int ipforwarding; int hlen; va_list ap; struct rtentry *rt; @@ -558,7 +559,7 @@ reflect: /* Free packet atttributes */ if (m->m_flags & M_PKTHDR) m_tag_delete_chain(m); - if (icmp_rediraccept == 0) + if (icmp_rediraccept == 0 || ipforwarding == 1) goto freeit; if (code > 3) goto badcode;
Re: horribly slow fsck_ffs pass1 performance
On Saturday, April 2, Amit Kulkarni wrote: > > FreeBSD which is the origin of FFS does a > background fsck, and if Kirk McCusick feels so strongly I will do it > too. FreeBSD was not the origin of the FFS code. Background fsck in freebsd is mainly meant to reduce the amount of time it takes to get to a useable system at boot (after an unclean shutdown). -Toby.
Compiling the kernel with pcc
pcc currently only chokes on some inline functions that need external linkage. gcc isn't pesky about that, but pcc and clang are (rightfully, imo). Anyway, the functions in question are: net/pf.c: pf_addr_compare (was probably ok before r1.729) arch/{amd64,i386}/isa/clock.c: mc146818_read Do those *have* to be inline?
Re: drop ICMP redirects if ipforwaring = 1
On Mon, Apr 4, 2011 at 9:11 AM, Claudio Jeker wrote: > + if (icmp_rediraccept == 0 || ipforwarding == 1) Would "ipforwarding != 0" be more appropriate here? According to sysctl(3), ipforwarding == 2 is a legitimate configuration setting.
Re: wcwidth() fixes in libcurses
On Sun, Apr 03, 2011 at 11:21:35PM +0100, Nicholas Marriott wrote: > > - if (x + len - 1 <= win->_maxx) { > > + if (len >= 0 && x + len - 1 <= win->_maxx) { > > Not sure this is required, astr is a cchar_t * which will come from > setcchar. Right. That already makes sure the string cannot contain non-printable characters. > > @@ -91,9 +92,12 @@ slk_set(int i, const char *astr, int for > > mbrtowc(&wc, p, need, &state); > > if (!iswprint((wint_t) wc)) > > break; > > - if (wcwidth(wc) + numcols > limit) > > + w = wcwidth(wc); > > + if (w >= 0) { > > + if (w + numcols > limit) > > break; > > - numcols += wcwidth(wc); > > + numcols += w; > > + } > > Doesn't iswprint() make this unnecessary? Doh! :) > > for (i = 1; i < len; ++i) { > > - if (wcwidth(wch[i]) != 0) { > > + if (wcwidth(wch[i]) >= 1) { > > This seems sane although the comment at the top of the function says "we > assume" this cannot happen. Then let's shelve this diff until we find a serious problem. Thanks for the review!
Re: wcwidth() fix in libform
On Sun, Apr 03, 2011 at 11:41:47PM +0100, Nicholas Marriott wrote: > Again so it is a cchar_t so I'm not sure it is valid for it to be > nonprintable but this doesn't do any harm. > > Might want to run this stuff past upstream first though? It is better if > we stay in sync if they do want to take it. Now that you've pointed it out I think it's pretty obvious that upstream is using their cchar_t to avoid such issues in the first place. So I don't think we'll need this diff either. > > > On Sun, Apr 03, 2011 at 11:51:53PM +0200, Stefan Sperling wrote: > > Some callers of myWCWIDTH(), a macro alias for cell_width(), > > won't cope with -1. > > > > Index: frm_driver.c > > === > > RCS file: /cvs/src/lib/libform/frm_driver.c,v > > retrieving revision 1.10 > > diff -u -p -r1.10 frm_driver.c > > --- frm_driver.c18 Jan 2011 18:57:51 - 1.10 > > +++ frm_driver.c3 Apr 2011 21:48:02 - > > @@ -322,7 +322,7 @@ cell_width(WINDOW *win, int y, int x) > > result = wcwidth(CharOf(CHDEREF(data))); > > } > > } > > - return result; > > + return result == -1 ? 0 : result; > > } > > > > /*
Re: drop ICMP redirects if ipforwaring = 1
On Mon, Apr 04, 2011 at 10:10:49AM -0700, Matthew Dempsky wrote: > On Mon, Apr 4, 2011 at 9:11 AM, Claudio Jeker > wrote: > > + if (icmp_rediraccept == 0 || ipforwarding == 1) > > Would "ipforwarding != 0" be more appropriate here? According to > sysctl(3), ipforwarding == 2 is a legitimate configuration setting. > Yes, ipforwarding == 2 is legitimate but IMO it is not a full router when forwarding is only done when an IPsec flow is used. I have the feeling that IPsec may need some redirects. This is why I choosed the == 1 check. -- :wq Claudio
Re: wcwidth() fixes in libedit
On Sun, Apr 03, 2011 at 11:26:52PM +0100, Nicholas Marriott wrote: > Hi > > We don't currently build a wide char libedit but comments inline: > > On Sun, Apr 03, 2011 at 11:46:24PM +0200, Stefan Sperling wrote: > > These callers in libedit might get confused if wcwidth() returns -1. > > > > Note how the result ct_visual_width() is used in refresh.c: > > > > refresh.c: h += ct_visual_width(*cp); > > > > > > Index: chartype.c > > === > > RCS file: /cvs/src/lib/libedit/chartype.c,v > > retrieving revision 1.1 > > diff -u -p -r1.1 chartype.c > > --- chartype.c 30 Jun 2010 00:05:35 - 1.1 > > +++ chartype.c 3 Apr 2011 21:37:10 - > > @@ -258,6 +258,9 @@ protected int > > ct_visual_width(Char c) > > { > > int t = ct_chr_class(c); > > +#ifdef WIDECHAR > > + int w; > > +#endif > > switch (t) { > > case CHTYPE_ASCIICTL: > > return 2; /* ^@ ^? etc. */ > > @@ -267,7 +270,8 @@ ct_visual_width(Char c) > > return 0; /* Should this be 1 instead? */ > > #ifdef WIDECHAR > > case CHTYPE_PRINT: > > - return wcwidth(c); > > + w = wcwidth(c); > > + return (w == -1 ? 0 : w); > > Yes makes sense, ok nicm. > > > case CHTYPE_NONPRINT: > > if (c > 0x) /* prefer standard 4-byte display over 5-byte */ > > return 8; /* \U+12345 */ > > Index: refresh.c > > === > > RCS file: /cvs/src/lib/libedit/refresh.c,v > > retrieving revision 1.11 > > diff -u -p -r1.11 refresh.c > > --- refresh.c 30 Jun 2010 00:05:35 - 1.11 > > +++ refresh.c 3 Apr 2011 21:39:42 - > > @@ -160,6 +160,9 @@ re_putc(EditLine *el, Int c, int shift) > > int i, w = Width(c); > > ELRE_DEBUG(1, (__F, "printing %5x '%c'\r\n", c, c)); > > > > + if (w == -1) > > + w = 0; > > Would it be better maybe to do the check in the Width() macro itself? Yes indeed. New diff below. I've also tested the WILDCHAR build now. It has some problems unrelated to this diff. Index: chartype.c === RCS file: /cvs/src/lib/libedit/chartype.c,v retrieving revision 1.1 diff -u -p -r1.1 chartype.c --- chartype.c 30 Jun 2010 00:05:35 - 1.1 +++ chartype.c 3 Apr 2011 21:37:10 - @@ -258,6 +258,9 @@ protected int ct_visual_width(Char c) { int t = ct_chr_class(c); +#ifdef WIDECHAR + int w; +#endif switch (t) { case CHTYPE_ASCIICTL: return 2; /* ^@ ^? etc. */ @@ -267,7 +270,8 @@ ct_visual_width(Char c) return 0; /* Should this be 1 instead? */ #ifdef WIDECHAR case CHTYPE_PRINT: - return wcwidth(c); + w = wcwidth(c); + return (w == -1 ? 0 : w); case CHTYPE_NONPRINT: if (c > 0x) /* prefer standard 4-byte display over 5-byte */ return 8; /* \U+12345 */ Index: chartype.h === RCS file: /cvs/src/lib/libedit/chartype.h,v retrieving revision 1.1 diff -u -p -r1.1 chartype.h --- chartype.h 30 Jun 2010 00:05:35 - 1.1 +++ chartype.h 4 Apr 2011 18:23:52 - @@ -106,7 +106,7 @@ #define Strtol(p,e,b) wcstol(p,e,b) -#define Width(c) wcwidth(c) +#define Width(c) (wcwidth(c) == -1 ? 0 : wcwidth(c)) #else /* NARROW */
Re: wcwidth() fixes in libedit
This is ok nicm I wouldn't be surprised if WIDECHAR build of libedit has other issues, getting it going is still on my list of things to do :-). On Mon, Apr 04, 2011 at 08:30:42PM +0200, Stefan Sperling wrote: > On Sun, Apr 03, 2011 at 11:26:52PM +0100, Nicholas Marriott wrote: > > Hi > > > > We don't currently build a wide char libedit but comments inline: > > > > On Sun, Apr 03, 2011 at 11:46:24PM +0200, Stefan Sperling wrote: > > > These callers in libedit might get confused if wcwidth() returns -1. > > > > > > Note how the result ct_visual_width() is used in refresh.c: > > > > > > refresh.c: h += ct_visual_width(*cp); > > > > > > > > > Index: chartype.c > > > === > > > RCS file: /cvs/src/lib/libedit/chartype.c,v > > > retrieving revision 1.1 > > > diff -u -p -r1.1 chartype.c > > > --- chartype.c30 Jun 2010 00:05:35 - 1.1 > > > +++ chartype.c3 Apr 2011 21:37:10 - > > > @@ -258,6 +258,9 @@ protected int > > > ct_visual_width(Char c) > > > { > > > int t = ct_chr_class(c); > > > +#ifdef WIDECHAR > > > + int w; > > > +#endif > > > switch (t) { > > > case CHTYPE_ASCIICTL: > > > return 2; /* ^@ ^? etc. */ > > > @@ -267,7 +270,8 @@ ct_visual_width(Char c) > > > return 0; /* Should this be 1 instead? */ > > > #ifdef WIDECHAR > > > case CHTYPE_PRINT: > > > - return wcwidth(c); > > > + w = wcwidth(c); > > > + return (w == -1 ? 0 : w); > > > > Yes makes sense, ok nicm. > > > > > case CHTYPE_NONPRINT: > > > if (c > 0x) /* prefer standard 4-byte display over 5-byte */ > > > return 8; /* \U+12345 */ > > > Index: refresh.c > > > === > > > RCS file: /cvs/src/lib/libedit/refresh.c,v > > > retrieving revision 1.11 > > > diff -u -p -r1.11 refresh.c > > > --- refresh.c 30 Jun 2010 00:05:35 - 1.11 > > > +++ refresh.c 3 Apr 2011 21:39:42 - > > > @@ -160,6 +160,9 @@ re_putc(EditLine *el, Int c, int shift) > > > int i, w = Width(c); > > > ELRE_DEBUG(1, (__F, "printing %5x '%c'\r\n", c, c)); > > > > > > + if (w == -1) > > > + w = 0; > > > > Would it be better maybe to do the check in the Width() macro itself? > > Yes indeed. New diff below. > > I've also tested the WILDCHAR build now. > It has some problems unrelated to this diff. > > Index: chartype.c > === > RCS file: /cvs/src/lib/libedit/chartype.c,v > retrieving revision 1.1 > diff -u -p -r1.1 chartype.c > --- chartype.c30 Jun 2010 00:05:35 - 1.1 > +++ chartype.c3 Apr 2011 21:37:10 - > @@ -258,6 +258,9 @@ protected int > ct_visual_width(Char c) > { > int t = ct_chr_class(c); > +#ifdef WIDECHAR > + int w; > +#endif > switch (t) { > case CHTYPE_ASCIICTL: > return 2; /* ^@ ^? etc. */ > @@ -267,7 +270,8 @@ ct_visual_width(Char c) > return 0; /* Should this be 1 instead? */ > #ifdef WIDECHAR > case CHTYPE_PRINT: > - return wcwidth(c); > + w = wcwidth(c); > + return (w == -1 ? 0 : w); > case CHTYPE_NONPRINT: > if (c > 0x) /* prefer standard 4-byte display over 5-byte */ > return 8; /* \U+12345 */ > Index: chartype.h > === > RCS file: /cvs/src/lib/libedit/chartype.h,v > retrieving revision 1.1 > diff -u -p -r1.1 chartype.h > --- chartype.h30 Jun 2010 00:05:35 - 1.1 > +++ chartype.h4 Apr 2011 18:23:52 - > @@ -106,7 +106,7 @@ > > #define Strtol(p,e,b) wcstol(p,e,b) > > -#define Width(c) wcwidth(c) > +#define Width(c) (wcwidth(c) == -1 ? 0 : wcwidth(c)) > > #else /* NARROW */
Re: wcwidth() fixes in libedit
> > Would it be better maybe to do the check in the Width() macro itself? > > Yes indeed. New diff below. > -#define Width(c) wcwidth(c) > +#define Width(c) (wcwidth(c) == -1 ? 0 : wcwidth(c)) But this calls wcwidth() to be invoked twice, which is ugly. As a minimum, make this an inline function. Miod
Re: Compiling the kernel with pcc
On Mon, Apr 04, 2011 at 08:06:57PM +0200, Pascal Stumpf wrote: > pcc currently only chokes on some inline functions that need external > linkage. gcc isn't pesky about that, but pcc and clang are (rightfully, > imo). Anyway, the functions in question are: > > net/pf.c: pf_addr_compare (was probably ok before r1.729) compiles fine with clang here but not pcc, this should likely be reported to ragge it doesn't look like it needs external linkage at all > arch/{amd64,i386}/isa/clock.c:mc146818_read compiles fine with clang/pcc on i386 where it has no inline It seems the amd64 version does though. It could be made static inline or have inline removed like the i386 version.
Re: wcwidth() fixes in libedit
On Mon, Apr 04, 2011 at 06:44:10PM +, Miod Vallat wrote: > > > Would it be better maybe to do the check in the Width() macro itself? > > > > Yes indeed. New diff below. > > > -#define Width(c) wcwidth(c) > > +#define Width(c) (wcwidth(c) == -1 ? 0 : wcwidth(c)) > > But this calls wcwidth() to be invoked twice, which is ugly. As a > minimum, make this an inline function. Oops, already committed. What about this as a follow-up? Index: chartype.c === RCS file: /cvs/src/lib/libedit/chartype.c,v retrieving revision 1.2 diff -u -p -r1.2 chartype.c --- chartype.c 4 Apr 2011 18:48:17 - 1.2 +++ chartype.c 4 Apr 2011 19:01:49 - @@ -358,3 +358,14 @@ ct_chr_class(Char c) else return CHTYPE_NONPRINT; } + +inline int +Width(Int c) +{ +#ifdef WIDECHAR + int w = wcwidth(c); + return (w == -1 ? 0 : w); +#else + return 1; +#endif +} Index: chartype.h === RCS file: /cvs/src/lib/libedit/chartype.h,v retrieving revision 1.2 diff -u -p -r1.2 chartype.h --- chartype.h 4 Apr 2011 18:48:17 - 1.2 +++ chartype.h 4 Apr 2011 19:01:25 - @@ -106,8 +106,6 @@ #define Strtol(p,e,b) wcstol(p,e,b) -#define Width(c) (wcwidth(c) == -1 ? 0 : wcwidth(c)) - #else /* NARROW */ #define ct_mbtowcerror @@ -156,10 +154,9 @@ #define Strtol(p,e,b) strtol(p,e,b) -#define Width(c) 1 - #endif +int Width(Int c); #ifdef WIDECHAR /*
Re: Compiling the kernel with pcc
On Mon, Apr 04, 2011 at 08:06:57PM +0200, Pascal Stumpf wrote: > net/pf.c: pf_addr_compare (was probably ok before r1.729) The current implementation has been discussed. See also: http://www.greenend.org.uk/rjk/2003/03/inline.html The function should be inline within pf.c and callable from pf_norm.c. Defining it inline in pf.c allows faster code there, declaring it non-inline in pfvar.h creates callable code in pf.o. gcc always generates callable code, so it does not matter here. Do pcc and clang compile and link if you put an inline in the pfvar.h declaration? > Do those *have* to be inline? Yes, pf_addr_compare() is used in pf state lookup. So it must be fast. The generated RB functions use it inline. bluhm
Re: Compiling the kernel with pcc
On Mon, Apr 4, 2011 at 11:06 AM, Pascal Stumpf wrote: > pcc currently only chokes on some inline functions that need external > linkage. gcc isn't pesky about that, but pcc and clang are (rightfully, > imo). It's completely legal and defined (by the standard and not just gcc!) for a function to be inline in the file where it's defined and have external linkage. That just means "inline if you can in this file, but still provide a copy callable from other files". That's exactly the semantic we want for pf_addr_compare(). If pcc or clang are complaining about it they're broken or their warning settings are misset. Philip Guenther
AI_FQDN diff, now with man page bits
I haven't heard any objections to my initial AI_FQDN diff, so here's the diff again with updated man page bits. See the original thread for a proof-of-concept diff from djm@ to use this in OpenSSH. The man page mostly only uses "hostname" when referring to the formal argument, so I changed the AI_CANONNAME descriptive text to use "host name" to be consistent with the rest of the file. The AI_FQDN text is based on the AI_CANONNAME text + the MSDN description of Windows's flag. ok? Index: lib/libc/net/getaddrinfo.3 === RCS file: /cvs/src/lib/libc/net/getaddrinfo.3,v retrieving revision 1.47 diff -u -p lib/libc/net/getaddrinfo.3 --- lib/libc/net/getaddrinfo.3 9 Jul 2009 10:14:41 - 1.47 +++ lib/libc/net/getaddrinfo.3 4 Apr 2011 17:53:40 - @@ -126,11 +126,33 @@ If the bit is set, a successful call to .Fn getaddrinfo will return a NUL-terminated string containing the canonical name -of the specified hostname in the +of the specified host name in the .Fa ai_canonname element of the first .Li addrinfo structure returned. +.It Dv AI_FQDN +If the +.Dv AI_FQDN +bit is set, a successful call to +.Fn getaddrinfo +will return a NUL-terminated string containing the fully qualified domain name +of the specified host name in the +.Fa ai_canonname +element of the first +.Li addrinfo +structure returned. +.Pp +This is different than the +.Dv AI_CANONNAME +bit flag that returns the canonical name registered in DNS, +which may be different than the fully qualified domain name +that the host name resolved to. +Only one of the +.Dv AI_FQDN +and +.DV AI_CANONNAME +bits can be set. .It Dv AI_NUMERICHOST If the .Dv AI_NUMERICHOST @@ -438,6 +460,10 @@ function is defined by the draft specification and documented in .Dv "RFC 3493" , .Dq Basic Socket Interface Extensions for IPv6 . +.Pp +The +.Dv AI_FQDN +flag bit first appeared in Windows 7. .Sh BUGS The implementation of .Fn getaddrinfo Index: include/netdb.h === RCS file: /cvs/src/include/netdb.h,v retrieving revision 1.27 diff -u -p include/netdb.h --- include/netdb.h 2 Jun 2009 16:47:50 - 1.27 +++ include/netdb.h 4 Apr 2011 17:53:40 - @@ -155,9 +155,10 @@ struct protoent { #define AI_NUMERICHOST 4 /* don't ever try hostname lookup */ #define AI_EXT 8 /* enable non-portable extensions */ #define AI_NUMERICSERV 16 /* don't ever try servname lookup */ +#define AI_FQDN32 /* return the FQDN that was resolved */ /* valid flags for addrinfo */ #define AI_MASK \ -(AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV) +(AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_FQDN) #define NI_NUMERICHOST 1 /* return the host address, not the name */ #define NI_NUMERICSERV 2 /* return the service address, not the name */ Index: lib/libc/net/getaddrinfo.c === RCS file: /cvs/src/lib/libc/net/getaddrinfo.c,v retrieving revision 1.71 diff -u -p lib/libc/net/getaddrinfo.c --- lib/libc/net/getaddrinfo.c 18 Nov 2009 07:43:22 - 1.71 +++ lib/libc/net/getaddrinfo.c 4 Apr 2011 17:53:40 - @@ -309,7 +309,9 @@ getaddrinfo(const char *hostname, const char *servname if (hints->ai_addrlen || hints->ai_canonname || hints->ai_addr || hints->ai_next) ERR(EAI_BADHINTS); /* xxx */ - if (hints->ai_flags & ~AI_MASK) + if ((hints->ai_flags & ~AI_MASK) != 0 || + (hints->ai_flags & (AI_CANONNAME | AI_FQDN)) == + (AI_CANONNAME | AI_FQDN)) ERR(EAI_BADFLAGS); switch (hints->ai_family) { case PF_UNSPEC: @@ -671,14 +673,13 @@ explore_numeric(const struct addrinfo *pai, const char pai->ai_family == PF_UNSPEC /*?*/) { GET_AI(cur->ai_next, afd, pton); GET_PORT(cur->ai_next, servname); - if ((pai->ai_flags & AI_CANONNAME)) { - /* -* Set the numeric address itself as -* the canonical name, based on a -* clarification in rfc2553bis-03. -*/ - GET_CANONNAME(cur->ai_next, canonname); - } + /* +* Set the numeric address itself as +* the canonical name, based on a +* clarification in rfc2553bis-03. +*/ + GET_CANONNAME(cur->ai_next, canonname); + while (cur && cur->ai_next) cur = cur->ai_next; } else
Re: AI_FQDN diff, now with man page bits
This of course needs a libc minor bump too. On Mon, Apr 04, 2011 at 11:10:54AM -0700, Matthew Dempsky wrote: > I haven't heard any objections to my initial AI_FQDN diff, so here's > the diff again with updated man page bits. See the original thread > for a proof-of-concept diff from djm@ to use this in OpenSSH. > > The man page mostly only uses "hostname" when referring to the formal > argument, so I changed the AI_CANONNAME descriptive text to use "host > name" to be consistent with the rest of the file. The AI_FQDN text is > based on the AI_CANONNAME text + the MSDN description of Windows's > flag. > > ok? > > Index: lib/libc/net/getaddrinfo.3 > === > RCS file: /cvs/src/lib/libc/net/getaddrinfo.3,v > retrieving revision 1.47 > diff -u -p lib/libc/net/getaddrinfo.3 > --- lib/libc/net/getaddrinfo.39 Jul 2009 10:14:41 - 1.47 > +++ lib/libc/net/getaddrinfo.34 Apr 2011 17:53:40 - > @@ -126,11 +126,33 @@ If the > bit is set, a successful call to > .Fn getaddrinfo > will return a NUL-terminated string containing the canonical name > -of the specified hostname in the > +of the specified host name in the > .Fa ai_canonname > element of the first > .Li addrinfo > structure returned. > +.It Dv AI_FQDN > +If the > +.Dv AI_FQDN > +bit is set, a successful call to > +.Fn getaddrinfo > +will return a NUL-terminated string containing the fully qualified domain > name > +of the specified host name in the > +.Fa ai_canonname > +element of the first > +.Li addrinfo > +structure returned. > +.Pp > +This is different than the > +.Dv AI_CANONNAME > +bit flag that returns the canonical name registered in DNS, > +which may be different than the fully qualified domain name > +that the host name resolved to. > +Only one of the > +.Dv AI_FQDN > +and > +.DV AI_CANONNAME > +bits can be set. > .It Dv AI_NUMERICHOST > If the > .Dv AI_NUMERICHOST > @@ -438,6 +460,10 @@ function is defined by the > draft specification and documented in > .Dv "RFC 3493" , > .Dq Basic Socket Interface Extensions for IPv6 . > +.Pp > +The > +.Dv AI_FQDN > +flag bit first appeared in Windows 7. > .Sh BUGS > The implementation of > .Fn getaddrinfo > Index: include/netdb.h > === > RCS file: /cvs/src/include/netdb.h,v > retrieving revision 1.27 > diff -u -p include/netdb.h > --- include/netdb.h 2 Jun 2009 16:47:50 - 1.27 > +++ include/netdb.h 4 Apr 2011 17:53:40 - > @@ -155,9 +155,10 @@ struct protoent { > #define AI_NUMERICHOST 4 /* don't ever try hostname lookup */ > #define AI_EXT 8 /* enable non-portable extensions */ > #define AI_NUMERICSERV 16 /* don't ever try servname lookup */ > +#define AI_FQDN 32 /* return the FQDN that was resolved */ > /* valid flags for addrinfo */ > #define AI_MASK \ > -(AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV) > +(AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_FQDN) > > #define NI_NUMERICHOST 1 /* return the host address, not the > name */ > #define NI_NUMERICSERV 2 /* return the service address, not the > name */ > Index: lib/libc/net/getaddrinfo.c > === > RCS file: /cvs/src/lib/libc/net/getaddrinfo.c,v > retrieving revision 1.71 > diff -u -p lib/libc/net/getaddrinfo.c > --- lib/libc/net/getaddrinfo.c18 Nov 2009 07:43:22 - 1.71 > +++ lib/libc/net/getaddrinfo.c4 Apr 2011 17:53:40 - > @@ -309,7 +309,9 @@ getaddrinfo(const char *hostname, const char *servname > if (hints->ai_addrlen || hints->ai_canonname || > hints->ai_addr || hints->ai_next) > ERR(EAI_BADHINTS); /* xxx */ > - if (hints->ai_flags & ~AI_MASK) > + if ((hints->ai_flags & ~AI_MASK) != 0 || > + (hints->ai_flags & (AI_CANONNAME | AI_FQDN)) == > + (AI_CANONNAME | AI_FQDN)) > ERR(EAI_BADFLAGS); > switch (hints->ai_family) { > case PF_UNSPEC: > @@ -671,14 +673,13 @@ explore_numeric(const struct addrinfo *pai, const char > pai->ai_family == PF_UNSPEC /*?*/) { > GET_AI(cur->ai_next, afd, pton); > GET_PORT(cur->ai_next, servname); > - if ((pai->ai_flags & AI_CANONNAME)) { > - /* > - * Set the numeric address itself as > - * the canonical name, based on a > - * clarification in rfc2553bis-03. > - */ > - GET_CANONNAME(cur->ai_next, canonname); > - } > + /* > + * Set the numeric addre
Re: drop ICMP redirects if ipforwaring = 1
On Mon, Apr 4, 2011 at 11:24 AM, Claudio Jeker wrote: > Yes, ipforwarding == 2 is legitimate but IMO it is not a full router when > forwarding is only done when an IPsec flow is used. I have the feeling > that IPsec may need some redirects. This is why I choosed the == 1 check. Got it, makes sense to me then. Thanks for clarifying. :)
Re: drop ICMP redirects if ipforwaring = 1
On Mon, Apr 04, 2011 at 08:24:38PM +0200, Claudio Jeker wrote: > On Mon, Apr 04, 2011 at 10:10:49AM -0700, Matthew Dempsky wrote: > > On Mon, Apr 4, 2011 at 9:11 AM, Claudio Jeker > > wrote: > > > + if (icmp_rediraccept == 0 || ipforwarding == 1) > > > > Would "ipforwarding != 0" be more appropriate here? According to > > sysctl(3), ipforwarding == 2 is a legitimate configuration setting. > > > > Yes, ipforwarding == 2 is legitimate but IMO it is not a full router when > forwarding is only done when an IPsec flow is used. I have the feeling > that IPsec may need some redirects. This is why I choosed the == 1 check. add a comment to that effect; I had the same thought as matthew.
Re: wcwidth() fixes in libedit
Hi This is fine with me. On Mon, Apr 04, 2011 at 09:04:26PM +0200, Stefan Sperling wrote: > On Mon, Apr 04, 2011 at 06:44:10PM +, Miod Vallat wrote: > > > > Would it be better maybe to do the check in the Width() macro itself? > > > > > > Yes indeed. New diff below. > > > > > -#define Width(c) wcwidth(c) > > > +#define Width(c) (wcwidth(c) == -1 ? 0 : wcwidth(c)) > > > > But this calls wcwidth() to be invoked twice, which is ugly. As a > > minimum, make this an inline function. > > Oops, already committed. What about this as a follow-up? > > Index: chartype.c > === > RCS file: /cvs/src/lib/libedit/chartype.c,v > retrieving revision 1.2 > diff -u -p -r1.2 chartype.c > --- chartype.c4 Apr 2011 18:48:17 - 1.2 > +++ chartype.c4 Apr 2011 19:01:49 - > @@ -358,3 +358,14 @@ ct_chr_class(Char c) > else > return CHTYPE_NONPRINT; > } > + > +inline int > +Width(Int c) > +{ > +#ifdef WIDECHAR > + int w = wcwidth(c); > + return (w == -1 ? 0 : w); > +#else > + return 1; > +#endif > +} > Index: chartype.h > === > RCS file: /cvs/src/lib/libedit/chartype.h,v > retrieving revision 1.2 > diff -u -p -r1.2 chartype.h > --- chartype.h4 Apr 2011 18:48:17 - 1.2 > +++ chartype.h4 Apr 2011 19:01:25 - > @@ -106,8 +106,6 @@ > > #define Strtol(p,e,b) wcstol(p,e,b) > > -#define Width(c) (wcwidth(c) == -1 ? 0 : wcwidth(c)) > - > #else /* NARROW */ > > #define ct_mbtowcerror > @@ -156,10 +154,9 @@ > > #define Strtol(p,e,b) strtol(p,e,b) > > -#define Width(c) 1 > - > #endif > > +int Width(Int c); > > #ifdef WIDECHAR > /*
disgusting routing/network macro cleanup...now with booting kernels
Cleanup of some horrible macros pulled into the network code from the horrible radix code. Now boots and runs! And sends email! Hi, otto@! Index: net/radix.c === RCS file: /cvs/src/sys/net/radix.c,v retrieving revision 1.28 diff -u -p -r1.28 radix.c --- net/radix.c 22 Aug 2010 17:02:04 - 1.28 +++ net/radix.c 4 Apr 2011 18:29:51 - @@ -413,9 +413,9 @@ rn_addmask(void *n_arg, int search, int if (mlen <= skip) return (mask_rnhead->rnh_nodes); if (skip > 1) - Bcopy(rn_ones + 1, addmask_key + 1, skip - 1); + bcopy(rn_ones + 1, addmask_key + 1, skip - 1); if ((m0 = mlen) > skip) - Bcopy(netmask + skip, addmask_key + skip, mlen - skip); + bcopy(netmask + skip, addmask_key + skip, mlen - skip); /* * Trim trailing zeroes. */ @@ -428,23 +428,23 @@ rn_addmask(void *n_arg, int search, int return (mask_rnhead->rnh_nodes); } if (m0 < last_zeroed) - Bzero(addmask_key + m0, last_zeroed - m0); + bzero(addmask_key + m0, last_zeroed - m0); *addmask_key = last_zeroed = mlen; x = rn_search(addmask_key, rn_masktop); if (Bcmp(addmask_key, x->rn_key, mlen) != 0) x = 0; if (x || search) return (x); - R_Malloc(x, struct radix_node *, max_keylen + 2 * sizeof (*x)); + x = malloc(max_keylen + 2 * sizeof(*x), M_RTABLE, M_DONTWAIT); if ((saved_x = x) == 0) return (0); - Bzero(x, max_keylen + 2 * sizeof (*x)); + bzero(x, (unsigned)(max_keylen + 2 * sizeof(*x))); netmask = cp = (caddr_t)(x + 2); - Bcopy(addmask_key, cp, mlen); + bcopy(addmask_key, cp, mlen); x = rn_insert(cp, mask_rnhead, &maskduplicated, x); if (maskduplicated) { log(LOG_ERR, "rn_addmask: mask impossibly already in tree\n"); - Free(saved_x); + free(saved_x, M_RTABLE); return (x); } /* @@ -500,7 +500,7 @@ rn_new_radix_mask(struct radix_node *tt, log(LOG_ERR, "Mask for route not entered\n"); return (0); } - Bzero(m, sizeof *m); + bzero(m, sizeof *m); m->rm_b = tt->rn_b; m->rm_flags = tt->rn_flags; if (tt->rn_flags & RNF_NORMAL) @@ -1003,7 +1003,7 @@ rn_inithead(void **head, int off) if (*head) return (1); - R_Malloc(rnh, struct radix_node_head *, sizeof (*rnh)); + rnh = malloc(sizeof(*rnh), M_RTABLE, M_DONTWAIT); if (rnh == 0) return (0); *head = rnh; @@ -1015,7 +1015,7 @@ rn_inithead0(struct radix_node_head *rnh { struct radix_node *t, *tt, *ttt; - Bzero(rnh, sizeof (*rnh)); + bzero(rnh, sizeof (*rnh)); t = rn_newpair(rn_zeros, off, rnh->rnh_nodes); ttt = rnh->rnh_nodes + 2; t->rn_r = ttt; @@ -1050,10 +1050,10 @@ rn_init() "rn_init: radix functions require max_keylen be set\n"); return; } - R_Malloc(rn_zeros, char *, 3 * max_keylen); + rn_zeros = malloc(3 * max_keylen, M_RTABLE, M_DONTWAIT); if (rn_zeros == NULL) panic("rn_init"); - Bzero(rn_zeros, 3 * max_keylen); + bzero(rn_zeros, 3 * max_keylen); rn_ones = cp = rn_zeros + max_keylen; addmask_key = cplim = rn_ones + max_keylen; while (cp < cplim) Index: net/radix.h === RCS file: /cvs/src/sys/net/radix.h,v retrieving revision 1.16 diff -u -p -r1.16 radix.h --- net/radix.h 28 Jun 2010 18:50:37 - 1.16 +++ net/radix.h 4 Apr 2011 18:29:51 - @@ -98,7 +98,7 @@ extern struct radix_mask { m = rn_mkfreelist; \ rn_mkfreelist = (m)->rm_mklist; \ } else \ - R_Malloc(m, struct radix_mask *, sizeof (*(m)));\ + m = malloc(sizeof(*(m)), M_RTABLE, M_DONTWAIT); \ } while (0) #define MKFree(m) do { \ @@ -132,11 +132,6 @@ struct radix_node_head { }; #ifdef _KERNEL -#define Bcmp(a, b, n) bcmp(((caddr_t)(a)), ((caddr_t)(b)), (unsigned)(n)) -#define Bcopy(a, b, n) bcopy(((caddr_t)(a)), ((caddr_t)(b)), (unsigned)(n)) -#define Bzero(p, n) bzero((caddr_t)(p), (unsigned)(n)); -#define R_Malloc(p, t, n) (p = (t) malloc((unsigned long)(n), M_RTABLE, M_DONTWAIT)) -#define Free(p) free((caddr_t)p, M_RTABLE); void rn_init(void); intrn_inithead(void **, int); Index: net/route.c === RCS file: /cvs/src/sys/net/route.c,v retrieving revision 1.130 diff -u -p -r1.130 route.c
Re: softraid iopoolification
On Mon, Apr 04, 2011 at 10:47:37AM -0400, Kenneth R Westerback wrote: > On Sun, Apr 03, 2011 at 07:01:04PM -0400, Kenneth R Westerback wrote: > > Works on my crypto volume. People with other volume types would be nice > > to hear from. > > > > Ken > > v2. Use scsi_io_[get|put](), stop trying so hard to avoid calling scsi_done() > at SPLBIO as this is nice but not necessary, remove random 'improvements' to > make diff as small as possible. > > Tests still desired! > > Ken v3. Since the scsi layer can optimize things and just re-use a resource it has been told is no longer neede, make sure to re-initialize the work units being given to sr_scsi_cmd(). Ken Index: softraid.c === RCS file: /cvs/src/sys/dev/softraid.c,v retrieving revision 1.222 diff -u -p -r1.222 softraid.c --- softraid.c 15 Mar 2011 13:29:41 - 1.222 +++ softraid.c 4 Apr 2011 19:56:28 - @@ -1805,7 +1805,7 @@ sr_wu_alloc(struct sr_discipline *sd) for (i = 0; i < no_wu; i++) { wu = &sd->sd_wu[i]; wu->swu_dis = sd; - sr_wu_put(wu); + sr_wu_put(sd, wu); } return (0); @@ -1833,9 +1833,10 @@ sr_wu_free(struct sr_discipline *sd) } void -sr_wu_put(struct sr_workunit *wu) +sr_wu_put(void *xsd, void *xwu) { - struct sr_discipline*sd = wu->swu_dis; + struct sr_discipline*sd = (struct sr_discipline *)xsd; + struct sr_workunit *wu = (struct sr_workunit *)xwu; struct sr_ccb *ccb; int s; @@ -1843,65 +1844,37 @@ sr_wu_put(struct sr_workunit *wu) DNPRINTF(SR_D_WU, "%s: sr_wu_put: %p\n", DEVNAME(sd->sd_sc), wu); s = splbio(); - - wu->swu_xs = NULL; - wu->swu_state = SR_WU_FREE; - wu->swu_ios_complete = 0; - wu->swu_ios_failed = 0; - wu->swu_ios_succeeded = 0; - wu->swu_io_count = 0; - wu->swu_blk_start = 0; - wu->swu_blk_end = 0; - wu->swu_collider = NULL; - wu->swu_fake = 0; - wu->swu_flags = 0; - if (wu->swu_cb_active == 1) - panic("%s: sr_wu_put", DEVNAME(sd->sd_sc)); + panic("%s: sr_wu_put got active wu", DEVNAME(sd->sd_sc)); while ((ccb = TAILQ_FIRST(&wu->swu_ccb)) != NULL) { TAILQ_REMOVE(&wu->swu_ccb, ccb, ccb_link); sr_ccb_put(ccb); } + splx(s); + + bzero(wu, sizeof(*wu)); TAILQ_INIT(&wu->swu_ccb); + wu->swu_dis = sd; + mtx_enter(&sd->sd_wu_mtx); TAILQ_INSERT_TAIL(&sd->sd_wu_freeq, wu, swu_link); sd->sd_wu_pending--; - - /* wake up sleepers */ -#ifdef DIAGNOSTIC - if (sd->sd_wu_sleep < 0) - panic("negative wu sleepers"); -#endif /* DIAGNOSTIC */ - if (sd->sd_wu_sleep) - wakeup(&sd->sd_wu_sleep); - - splx(s); + mtx_leave(&sd->sd_wu_mtx); } -struct sr_workunit * -sr_wu_get(struct sr_discipline *sd, int canwait) +void * +sr_wu_get(void *xsd) { + struct sr_discipline*sd = (struct sr_discipline *)xsd; struct sr_workunit *wu; - int s; - - s = splbio(); - for (;;) { - wu = TAILQ_FIRST(&sd->sd_wu_freeq); - if (wu) { - TAILQ_REMOVE(&sd->sd_wu_freeq, wu, swu_link); - wu->swu_state = SR_WU_INPROGRESS; - sd->sd_wu_pending++; - break; - } else if (wu == NULL && canwait) { - sd->sd_wu_sleep++; - tsleep(&sd->sd_wu_sleep, PRIBIO, "sr_wu_get", 0); - sd->sd_wu_sleep--; - } else - break; + mtx_enter(&sd->sd_wu_mtx); + wu = TAILQ_FIRST(&sd->sd_wu_freeq); + if (wu) { + TAILQ_REMOVE(&sd->sd_wu_freeq, wu, swu_link); + sd->sd_wu_pending++; } - - splx(s); + mtx_leave(&sd->sd_wu_mtx); DNPRINTF(SR_D_WU, "%s: sr_wu_get: %p\n", DEVNAME(sd->sd_sc), wu); @@ -1924,6 +1897,7 @@ sr_scsi_cmd(struct scsi_xfer *xs) struct sr_softc *sc = link->adapter_softc; struct sr_workunit *wu = NULL; struct sr_discipline*sd; + struct sr_ccb *ccb; DNPRINTF(SR_D_CMD, "%s: sr_scsi_cmd: scsibus%d xs: %p " "flags: %#x\n", DEVNAME(sc), link->scsibus, xs, xs->flags); @@ -1949,18 +1923,21 @@ sr_scsi_cmd(struct scsi_xfer *xs) goto stuffup; } - /* -* we'll let the midlayer deal with stalls instead of being clever -* and sending sr_wu_get !(xs->flags & SCSI_NOSLEEP) in cansleep -*/ - if ((wu = sr_wu_get(sd, 0)) == NULL) { - DNPRINTF(SR_D_CMD, "%s: sr_scsi_cmd no wu\n", DEVNAME(sc)); - xs->error = XS_NO_CCB; - sr_scsi_done(sd, xs);
fix mbuf leak in sogetopt()
The implementation of SO_PEERCRED is leaking mbufs. > netstat -m 5292 mbufs in use: 46 mbufs allocated to data 4 mbufs allocated to packet headers 43 mbufs allocated to socket names and addresses 5199 mbufs allocated to socket options and quite a few over some time > uptime 10:37PM up 10:25, 12 users, load averages: 0.29, 0.16, 0.10 This diff plugs this leak and stops my laptop from leaking. -- :wq Claudio Index: uipc_socket.c === RCS file: /cvs/src/sys/kern/uipc_socket.c,v retrieving revision 1.89 diff -u -p -r1.89 uipc_socket.c --- uipc_socket.c 4 Apr 2011 11:10:26 - 1.89 +++ uipc_socket.c 4 Apr 2011 20:29:31 - @@ -1567,15 +1573,17 @@ sogetopt(struct socket *so, int level, i struct unpcb *unp = sotounpcb(so); if (unp->unp_flags & UNP_FEIDS) { - *mp = m = m_get(M_WAIT, MT_SOOPTS); m->m_len = sizeof(unp->unp_connid); bcopy((caddr_t)(&(unp->unp_connid)), mtod(m, caddr_t), - (unsigned)m->m_len); - } else - return (ENOTCONN); - } else - return (EOPNOTSUPP); + m->m_len); + break; + } + (void)m_free(m); + return (ENOTCONN); + } + (void)m_free(m); + return (EOPNOTSUPP); break; default:
Re: tun(4) man page - missing includes
On Fri, Mar 25, 2011 at 10:40:38PM +0100, Martin Pelikan wrote: > Hi list, > if anyone tries to develop an application using tun(4), the manpage > misses some includes neccesary for IFT_* and IFF_* constants. > If you switch the order of sys/types.h and sys/socket.h, your program > won't compile (is this considered a bug?) > > Anyone willing to comment/commit? Thanks > > -- > Martin Pelikan > martin, i have been unable to drum up any interest in your diff. so i'd say unless something changes, your diff will not get committed. sorry i can;t give you a more informative reply. jmc > Index: tun.4 > === > RCS file: /cvs/src/share/man/man4/tun.4,v > retrieving revision 1.38 > diff -u -p -r1.38 tun.4 > --- tun.4 23 Sep 2010 01:24:32 - 1.38 > +++ tun.4 25 Mar 2011 21:21:57 - > @@ -36,7 +36,10 @@ > .Cd "pseudo-device tun" > .Pp > .Fd #include > +.Fd #include > +.Fd #include > .Fd #include > +.Fd #include > .Sh DESCRIPTION > The > .Nm
Re: Compiling the kernel with pcc
On Mon, 4 Apr 2011, Alexander Bluhm wrote: > On Mon, Apr 04, 2011 at 08:06:57PM +0200, Pascal Stumpf wrote: > > net/pf.c: pf_addr_compare (was probably ok before r1.729) > > The current implementation has been discussed. See also: > http://www.greenend.org.uk/rjk/2003/03/inline.html > > The function should be inline within pf.c and callable from pf_norm.c. > Defining it inline in pf.c allows faster code there, declaring it > non-inline in pfvar.h creates callable code in pf.o. gcc always > generates callable code, so it does not matter here. > > Do pcc and clang compile and link if you put an inline in the pfvar.h > declaration? clang trunk v128001 has no problem if I __inline in pfvar.h. FYI, I am running on a kernel built using that clang revision. > > > Do those *have* to be inline? > > Yes, pf_addr_compare() is used in pf state lookup. So it must be > fast. The generated RB functions use it inline. > > bluhm
Use km_alloc instead of the single page allocator
First proper use of the new km_alloc. - Change pool constraints to use kmem_pa_mode instead of uvm_constraint_range - Use km_alloc for all backend allocations in pools. - Use km_alloc for the emergmency kentry allocations in uvm_mapent_alloc - Garbage collect uvm_km_getpage, uvm_km_getpage_pla and uvm_km_putpage Please eyeball and test this. //art Index: kern/dma_alloc.c === RCS file: /cvs/src/sys/kern/dma_alloc.c,v retrieving revision 1.5 diff -u -r1.5 dma_alloc.c --- kern/dma_alloc.c2 Apr 2011 17:06:21 - 1.5 +++ kern/dma_alloc.c4 Apr 2011 21:30:57 - @@ -37,7 +37,7 @@ 1 << (i + DMA_BUCKET_OFFSET)); pool_init(&dmapools[i], 1 << (i + DMA_BUCKET_OFFSET), 0, 0, 0, dmanames[i], NULL); - pool_set_constraints(&dmapools[i], &dma_constraint, 1); + pool_set_constraints(&dmapools[i], &kp_dma); pool_setipl(&dmapools[i], IPL_VM); /* XXX need pool_setlowat(&dmapools[i], dmalowat); */ } Index: kern/subr_pool.c === RCS file: /cvs/src/sys/kern/subr_pool.c,v retrieving revision 1.101 diff -u -r1.101 subr_pool.c --- kern/subr_pool.c4 Apr 2011 11:13:55 - 1.101 +++ kern/subr_pool.c4 Apr 2011 21:30:58 - @@ -401,8 +401,7 @@ } /* pglistalloc/constraint parameters */ - pp->pr_crange = &no_constraint; - pp->pr_pa_nsegs = 0; + pp->pr_crange = &kp_dirty; /* Insert this into the list of all pools. */ TAILQ_INSERT_HEAD(&pool_head, pp, pr_poollist); @@ -1013,18 +1012,9 @@ } void -pool_set_constraints(struct pool *pp, struct uvm_constraint_range *range, -int nsegs) +pool_set_constraints(struct pool *pp, struct kmem_pa_mode *mode) { - /* -* Subsequent changes to the constrictions are only -* allowed to make them _more_ strict. -*/ - KASSERT(pp->pr_crange->ucr_high >= range->ucr_high && - pp->pr_crange->ucr_low <= range->ucr_low); - - pp->pr_crange = range; - pp->pr_pa_nsegs = nsegs; + pp->pr_crange = mode; } void @@ -1495,32 +1485,36 @@ void * pool_page_alloc(struct pool *pp, int flags, int *slowdown) { - int kfl = (flags & PR_WAITOK) ? 0 : UVM_KMF_NOWAIT; + struct kmem_dyn_mode kd = KMEM_DYN_INITIALIZER; + + kd.kd_waitok = (flags & PR_WAITOK); + kd.kd_slowdown = slowdown; - return (uvm_km_getpage_pla(kfl, slowdown, pp->pr_crange->ucr_low, - pp->pr_crange->ucr_high, 0, 0)); + return (km_alloc(PAGE_SIZE, &kv_page, pp->pr_crange, &kd)); } void pool_page_free(struct pool *pp, void *v) { - uvm_km_putpage(v); + km_free(v, PAGE_SIZE, &kv_page, pp->pr_crange); } void * pool_large_alloc(struct pool *pp, int flags, int *slowdown) { - int kfl = (flags & PR_WAITOK) ? 0 : UVM_KMF_NOWAIT; - vaddr_t va; + struct kmem_dyn_mode kd = KMEM_DYN_INITIALIZER; + void *v; int s; + kd.kd_waitok = (flags & PR_WAITOK); + kd.kd_slowdown = slowdown; + s = splvm(); - va = uvm_km_kmemalloc_pla(kmem_map, NULL, pp->pr_alloc->pa_pagesz, 0, - kfl, pp->pr_crange->ucr_low, pp->pr_crange->ucr_high, - 0, 0, pp->pr_pa_nsegs); + v = km_alloc(pp->pr_alloc->pa_pagesz, &kv_intrsafe, pp->pr_crange, + &kd); splx(s); - return ((void *)va); + return (v); } void @@ -1529,23 +1523,23 @@ int s; s = splvm(); - uvm_km_free(kmem_map, (vaddr_t)v, pp->pr_alloc->pa_pagesz); + km_free(v, pp->pr_alloc->pa_pagesz, &kv_intrsafe, pp->pr_crange); splx(s); } void * pool_large_alloc_ni(struct pool *pp, int flags, int *slowdown) { - int kfl = (flags & PR_WAITOK) ? 0 : UVM_KMF_NOWAIT; + struct kmem_dyn_mode kd = KMEM_DYN_INITIALIZER; + + kd.kd_waitok = (flags & PR_WAITOK); + kd.kd_slowdown = slowdown; - return ((void *)uvm_km_kmemalloc_pla(kernel_map, uvm.kernel_object, - pp->pr_alloc->pa_pagesz, 0, kfl, - pp->pr_crange->ucr_low, pp->pr_crange->ucr_high, - 0, 0, pp->pr_pa_nsegs)); + return (km_alloc(pp->pr_alloc->pa_pagesz, &kv_any, pp->pr_crange, &kd)); } void pool_large_free_ni(struct pool *pp, void *v) { - uvm_km_free(kernel_map, (vaddr_t)v, pp->pr_alloc->pa_pagesz); + km_free(v, pp->pr_alloc->pa_pagesz, &kv_any, pp->pr_crange); } Index: kern/uipc_mbuf.c === RCS file: /cvs/src/sys/kern/uipc_mbuf.c,v retrieving revision 1.149 diff -u -r1.149 uipc_mbuf.c --- kern/uipc_mbuf.c29 Jan 2011 13:15:39 - 1.149 +++ kern/uipc_mbuf.c4 Apr 2011 21:30:59 - @@ -136,7 +136,7 @@ int i; pool_init(&mbpool, MSIZE, 0, 0, 0, "mbpl", NULL); - pool_set_constraints(&mbp
isprint() needs setlocale(); for usr.bin
For isprint() to work correctly in a UTF-8 locale applications must set up the LC_CTYPE locale before using isprint(). As done for hexdump and tcpdump already. This diff covers all offenders in usr.bin. Index: bc/bc.y === RCS file: /cvs/src/usr.bin/bc/bc.y,v retrieving revision 1.34 diff -u -p -r1.34 bc.y --- bc/bc.y 7 Mar 2011 08:11:15 - 1.34 +++ bc/bc.y 4 Apr 2011 21:32:29 - @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -1088,6 +1089,7 @@ main(int argc, char *argv[]) int p[2]; char*q; + setlocale(LC_CTYPE, ""); init(); setlinebuf(stdout); Index: bgplg/bgplgsh.c === RCS file: /cvs/src/usr.bin/bgplg/bgplgsh.c,v retrieving revision 1.3 diff -u -p -r1.3 bgplgsh.c --- bgplg/bgplgsh.c 2 Apr 2010 21:20:49 - 1.3 +++ bgplg/bgplgsh.c 4 Apr 2011 21:41:52 - @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -225,6 +226,7 @@ main(void) /* Ignore the whitespace character */ rl_basic_word_break_characters = "\t\n\"\\'`@$><=;|&{("; + setlocale(LC_CTYPE, ""); while (!quit) { v = -1; gethostname(prompt, sizeof(prompt) - 2); Index: chpass/chpass.c === RCS file: /cvs/src/usr.bin/chpass/chpass.c,v retrieving revision 1.37 diff -u -p -r1.37 chpass.c --- chpass/chpass.c 27 Oct 2009 23:59:36 - 1.37 +++ chpass/chpass.c 4 Apr 2011 21:34:44 - @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -74,6 +75,9 @@ main(int argc, char *argv[]) #ifdef YP use_yp = _yp_check(NULL); #endif + + setlocale(LC_CTYPE, ""); + /* We need to use the system timezone for date conversions. */ if ((tz = getenv("TZ")) != NULL) { unsetenv("TZ"); Index: cvs/cvs.c === RCS file: /cvs/src/usr.bin/cvs/cvs.c,v retrieving revision 1.151 diff -u -p -r1.151 cvs.c --- cvs/cvs.c 23 Jul 2010 08:31:19 - 1.151 +++ cvs/cvs.c 4 Apr 2011 21:36:04 - @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -188,6 +189,7 @@ main(int argc, char **argv) char fpath[MAXPATHLEN]; tzset(); + setlocale(LC_CTYPE, ""); TAILQ_INIT(&cvs_variables); SLIST_INIT(&repo_locks); Index: diff/diff.c === RCS file: /cvs/src/usr.bin/diff/diff.c,v retrieving revision 1.57 diff -u -p -r1.57 diff.c --- diff/diff.c 16 Jul 2010 23:27:58 - 1.57 +++ diff/diff.c 4 Apr 2011 21:38:23 - @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -87,6 +88,7 @@ main(int argc, char **argv) long l; int ch, dflags, lastch, gotstdin, prevoptind, newarg; + setlocale(LC_CTYPE, ""); oargv = argv; gotstdin = 0; dflags = 0; Index: finger/finger.c === RCS file: /cvs/src/usr.bin/finger/finger.c,v retrieving revision 1.18 diff -u -p -r1.18 finger.c --- finger/finger.c 12 Nov 2009 15:33:21 - 1.18 +++ finger/finger.c 4 Apr 2011 21:41:09 - @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -84,6 +85,8 @@ main(int argc, char *argv[]) struct stat sb; oflag = 1; /* default to old "office" behavior */ + + setlocale(LC_CTYPE, ""); while ((ch = getopt(argc, argv, "lmMpsho")) != -1) switch(ch) { Index: grep/grep.c === RCS file: /cvs/src/usr.bin/grep/grep.c,v retrieving revision 1.43 diff -u -p -r1.43 grep.c --- grep/grep.c 4 Mar 2011 03:11:23 - 1.43 +++ grep/grep.c 4 Apr 2011 21:44:00 - @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -236,6 +237,8 @@ main(int argc, char *argv[]) struct patfile *patfile, *pf_next; long l; char *ep, **expr; + + setlocale(LC_CTYPE, ""); SLIST_INIT(&patfilelh); switch (__progname[0]) { Index: infocmp/infocmp.c === RCS file: /cvs/src/usr.bin/infocmp/infocmp.c,v retrieving revision 1.20 diff -u -p -r1.20 infocmp.c --- infocmp/infocmp.c 12 Jan 2010 23:22:13 - 1.20 +++ infocmp/infocmp.c 4 Apr 2011 21:46:04 - @@ -1291,6 +1291,8 @@ main(int argc, char *argv[]) _nc_progname = _nc_rootname(argv[0]); +setlocale(LC_CTYPE, ""); + /* make sure we have enough space to add two terminal entries *
Logitech Dual Action USB
>From an old thread on misc@, circa Jun 17, 2008: > Re: usb gamepads > So I ended up bying a Logitech Dual Action for $15 at a local store. > This is what shows up in dmesg: > > uhidev2 at uhub1 port 2 configuration 1 interface 0 "Logitech Logitech Dual > Action" rev 1.10/3.00 addr 2 > uhidev2: iclass 3/0 > uhid0 at uhidev2: input=8, output=7, feature=5 > > All the buttons and analog sticks work okay. I tried it with bzflag, > zsnes and generator (r3, the r2 package didn't work with it). I was > also going to try xmame, but the compile bombed and I didn't spell > FLAVOR correctly anyway (used the british spelling... oops). > > Well anyway it's a nice piece of hardware for the price! > > > -- > Stephen Takacs http://perlguru.net/ > 4149 FD56 D078 C988 9027 1EB4 04CC F80F 72CB 09DA Does anyone still have one of these working? Recent snapshots produce only this in dmesg: uhub1: port 1, set config at addr 2 failed uhub1: device problem, disabling port 1 -sl
Re: Use km_alloc instead of the single page allocator
On Mon, Apr 04, 2011 at 03:54:32PM -0600, Artur Grabowski wrote: > First proper use of the new km_alloc. > > - Change pool constraints to use kmem_pa_mode instead of uvm_constraint_range > - Use km_alloc for all backend allocations in pools. > - Use km_alloc for the emergmency kentry allocations in uvm_mapent_alloc > - Garbage collect uvm_km_getpage, uvm_km_getpage_pla and uvm_km_putpage > > Please eyeball and test this. ok ariane -- Ariane
Re: Logitech Dual Action USB
>From an old thread on misc@, circa Jun 17, 2008: > >> Re: usb gamepads >> So I ended up bying a Logitech Dual Action for $15 at a local store. >> This is what shows up in dmesg: >> >> uhidev2 at uhub1 port 2 configuration 1 interface 0 "Logitech Logitech Dual >> Action" rev 1.10/3.00 addr 2 >> uhidev2: iclass 3/0 >> uhid0 at uhidev2: input=8, output=7, feature=5 >> >> All the buttons and analog sticks work okay. I tried it with bzflag, >> zsnes and generator (r3, the r2 package didn't work with it). I was >> also going to try xmame, but the compile bombed and I didn't spell >> FLAVOR correctly anyway (used the british spelling... oops). >> >> Well anyway it's a nice piece of hardware for the price! >> >> >> -- >> Stephen Takacs http://perlguru.net/ >> 4149 FD56 D078 C988 9027 1EB4 04CC F80F 72CB 09DA >... [show rest of quote] > >Does anyone still have one of these working? Recent snapshots produce >only this in dmesg: > >uhub1: port 1, set config at addr 2 failed >uhub1: device problem, disabling port 1 On a different system, the controller is at least recognized: uhidev1 at uhub2 port 1 configuration 1 interface 0 "Logitech Logitech Dual Action" rev 1.10/3.00 addr 2 uhidev1: iclass 3/0 uhid21 at uhidev1: input=8, output=7, feature=5 but does not work in bzflag or pcsx. -sl