Re: bzip2

2013-06-06 Thread Janne Johansson
If it covers that tar needs for tar xjf bla.tbz2 to work then this would
be a good addition.



2013/6/6 Ted Unangst t...@tedunangst.com

 Something that comes up from time to time is the question of whether
 to import bzip2 into base or not. Turns out the question is moot
 because already have imported it. There's a copy in perl. (I didn't
 know this until I happened to be watching a build closer than usual.)

 Since we already have the code built, why not let people use it? This
 is a small perl script that implements the 90% subset of functionality
 people expect from the regular bzip2 and bunzip2 utilities. It's not
 really complete or perfect, but I haven't spent all that much time on
 it.

 --- /dev/null   Wed Jun  5 20:54:56 2013
 +++ bzip2/Makefile  Wed Jun  5 20:51:51 2013
 @@ -0,0 +1,15 @@
 +# $OpenBSD$
 +
 +.include bsd.own.mk
 +
 +MAN=
 +
 +SCRIPT=bzip2.pl
 +LINKS=${BINDIR}/bzip2 ${BINDIR}/bunzip2
 +
 +realinstall:
 +   ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
 \
 +   ${.CURDIR}/${SCRIPT} ${DESTDIR}${BINDIR}/bzip2
 +
 +
 +.include bsd.prog.mk
 --- /dev/null   Wed Jun  5 20:55:02 2013
 +++ bzip2/bzip2.pl  Wed Jun  5 20:53:23 2013
 @@ -0,0 +1,113 @@
 +#!/usr/bin/perl -w
 +# $OpenBSD$
 +# Copyright (c) Ted Unangst t...@openbsd.org
 +#
 +# 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.
 +
 +use strict;
 +use Getopt::Long qw(:config posix_default bundling no_ignore_case);
 +use IO::Compress::Bzip2 qw(bzip2);
 +
 +
 +my $usestdout;
 +my $level = 9;
 +my $reqlevel; # requested level, who cares?
 +GetOptions(
 +   c|stdout = \$usestdout,
 +   1|2|3|4|5|6|7|8|9|fast|best = \$reqlevel
 +);
 +
 +sub bzipfile {
 +   my $fname = shift;
 +   my $ofname;
 +   my $in;
 +   if ($fname ne -) {
 +   if ($usestdout) {
 +   $ofname = -;
 +   } else {
 +   $ofname = $fname . .bz2;
 +   if (-e $ofname) {
 +   warn Output file $ofname already
 exists.\n;
 +   return;
 +   }
 +   }
 +   $in = new IO::File $fname;
 +   if (!$in) {
 +   warn Can't open input file $fname.\n;
 +   return;
 +   }
 +   } else {
 +   $in = -;
 +   $ofname = -;
 +   }
 +   if ($ofname eq -  -t STDOUT) {
 +   warn I won't write compressed data to a terminal.\n;
 +   return;
 +   }
 +   if (not bzip2 $in = $ofname, BlockSize100K = $level) {
 +   warn failz;
 +   return;
 +   }
 +   if ($ofname ne -) {
 +   unlink($fname);
 +   }
 +}
 +
 +sub bunzipfile {
 +print bunzipping\n;
 +   my $fname = shift;
 +   my $ofname;
 +   my $in;
 +   if ($fname ne -) {
 +   if ($usestdout) {
 +   $ofname = -;
 +   } else {
 +   $ofname = $fname;
 +   $ofname =~ s/\.bz2$//;
 +   if (-e $ofname) {
 +   warn Output file $ofname already
 exists.\n;
 +   return;
 +   }
 +   }
 +   $in = new IO::File $fname;
 +   if (!$in) {
 +   warn Can't open input file $fname.\n;
 +   return;
 +   }
 +   } else {
 +   $in = -;
 +   $ofname = -;
 +   }
 +   if (not bunzip2 $in = $ofname) {
 +   warn failz;
 +   return;
 +   }
 +   if ($ofname ne -) {
 +   unlink($fname);
 +   }
 +}
 +
 +my $main;
 +if ($0 =~ /bunzip2$/) {
 +   $main = \bunzipfile;
 +} else {
 +   $main = \bzipfile;
 +}
 +
 +if (@ARGV == 0) {
 +   $main(-);
 +} else {
 +   foreach my $f (@ARGV) {
 +   $main($f);
 +   }
 +}




-- 
May the most significant bit of your life be positive.


Haswell support for inteldrm

2013-06-06 Thread Jonathan Gray
While the recent work in inteldrm should include
support for haswell we don't currently have the agp
parts or match on the pci devices.  This diff updates
things to match on all the devices the linux driver
does with a handful of marketing names found in the
windows driver.

Compile tested only for lack of hardware to test on.

Index: pcidevs
===
RCS file: /cvs/src/sys/dev/pci/pcidevs,v
retrieving revision 1.1677
diff -u -p -r1.1677 pcidevs
--- pcidevs 28 May 2013 15:02:45 -  1.1677
+++ pcidevs 6 Jun 2013 07:10:51 -
@@ -2715,6 +2715,21 @@ product INTEL IOP333_B   0x0372  IOP333 PC
 product INTEL DH89XXCC_SGMII   0x0438  DH89XXCC SGMII
 product INTEL DH89XXCC_SERDES  0x043a  DH89XXCC SerDes
 product INTEL DH89XXCC_BPLANE  0x043c  DH89XXCC backplane
+product INTEL CORE4G_D_GT1 0x0402  HD Graphics
+product INTEL CORE4G_M_GT1 0x0406  HD Graphics
+product INTEL CORE4G_S_GT1 0x040a  HD Graphics
+product INTEL CORE4G_R_GT1_1   0x040b  HD Graphics
+product INTEL CORE4G_R_GT1_2   0x040e  HD Graphics
+product INTEL CORE4G_D_GT2 0x0412  HD Graphics 4400
+product INTEL CORE4G_M_GT2 0x0416  HD Graphics 4600
+product INTEL CORE4G_S_GT2 0x041a  HD Graphics P4600
+product INTEL CORE4G_R_GT2_1   0x041b  HD Graphics
+product INTEL CORE4G_R_GT2_2   0x041e  HD Graphics 4600
+product INTEL CORE4G_D_GT3 0x0422  HD Graphics
+product INTEL CORE4G_M_GT2_2   0x0426  HD Graphics
+product INTEL CORE4G_S_GT3 0x042a  HD Graphics
+product INTEL CORE4G_R_GT3_1   0x042b  HD Graphics
+product INTEL CORE4G_R_GT3_2   0x042e  HD Graphics
 product INTEL DH89XXCC_SFP 0x0440  DH89XXCC SFP
 product INTEL PCEB 0x0482  82375EB EISA
 product INTEL CDC  0x0483  82424ZX Cache/DRAM
@@ -2733,8 +2748,53 @@ product INTEL WL_100_2   0x08af  WiFi Link
 product INTEL 80960RP  0x0960  i960 RP PCI-PCI
 product INTEL 80960RM  0x0962  i960 RM PCI-PCI
 product INTEL 80960RN  0x0964  i960 RN PCI-PCI
+product INTEL CORE4G_D_ULT_GT1 0x0a02  HD Graphics
+product INTEL CORE4G_M_ULT_GT1 0x0a06  HD Graphics
+product INTEL CORE4G_S_ULT_GT1 0x0a0a  HD Graphics
+product INTEL CORE4G_R_ULT_GT1_1 0x0a0bHD Graphics
+product INTEL CORE4G_R_ULT_GT1_2 0x0a0eHD Graphics
+product INTEL CORE4G_D_ULT_GT2 0x0a12  HD Graphics
+product INTEL CORE4G_M_ULT_GT2 0x0a16  HD Graphics
+product INTEL CORE4G_S_ULT_GT2 0x0a1a  HD Graphics
+product INTEL CORE4G_R_ULT_GT2_1 0x0a1bHD Graphics
+product INTEL CORE4G_R_ULT_GT2_2 0x0a1eHD Graphics
+product INTEL CORE4G_D_ULT_GT3 0x0a22  HD Graphics
+product INTEL CORE4G_M_ULT_GT3 0x0a26  HD Graphics 5000
+product INTEL CORE4G_S_ULT_GT3 0x0a2a  HD Graphics
+product INTEL CORE4G_R_ULT_GT3_1 0x0a2bHD Graphics
+product INTEL CORE4G_R_ULT_GT3_2 0x0a2eIris Graphics 5100
 product INTEL D2000_IGD0x0be1  Atom D2000/N2000 Video
 product INTEL D2000_HB 0x0bf5  Atom D2000/N2000 Host
+product INTEL CORE4G_D_SDV_GT1 0x0c02  HD Graphics
+product INTEL CORE4G_M_SDV_GT1 0x0c06  HD Graphics
+product INTEL CORE4G_S_SDV_GT1 0x0c0a  HD Graphics
+product INTEL CORE4G_R_SDV_GT1_1 0x0c0bHD Graphics
+product INTEL CORE4G_R_SDV_GT1_2 0x0c0eHD Graphics
+product INTEL CORE4G_D_SDV_GT2 0x0c12  HD Graphics
+product INTEL CORE4G_M_SDV_GT2 0x0c16  HD Graphics
+product INTEL CORE4G_S_SDV_GT2 0x0c1a  HD Graphics
+product INTEL CORE4G_R_SDV_GT2_1 0x0c1bHD Graphics
+product INTEL CORE4G_R_SDV_GT2_2 0x0c1eHD Graphics
+product INTEL CORE4G_D_SDV_GT3 0x0c22  HD Graphics
+product INTEL CORE4G_M_SDV_GT3 0x0c26  HD Graphics
+product INTEL CORE4G_S_SDV_GT3 0x0c2a  HD Graphics
+product INTEL CORE4G_R_SDV_GT3_1 0x0c2bHD Graphics
+product INTEL CORE4G_R_SDV_GT3_2 0x0c2eHD Graphics
+product INTEL CORE4G_D_CRW_GT1 0x0d02  HD Graphics
+product INTEL CORE4G_M_CRW_GT1 0x0d06  HD Graphics
+product INTEL CORE4G_S_CRW_GT1 0x0d0a  HD Graphics
+product INTEL CORE4G_R_CRW_GT1_1 0x0d0bHD Graphics
+product INTEL CORE4G_R_CRW_GT1_2 0x0d0eHD Graphics
+product INTEL CORE4G_D_CRW_GT2 0x0d12  HD Graphics
+product INTEL CORE4G_M_CRW_GT2 0x0d16  HD Graphics
+product INTEL CORE4G_S_CRW_GT2 0x0d1a  HD Graphics
+product INTEL CORE4G_R_CRW_GT2_1 0x0d1bHD Graphics
+product INTEL CORE4G_R_CRW_GT2_2 0x0d1eHD Graphics
+product INTEL CORE4G_D_CRW_GT3 0x0d22  Iris Pro Graphics 5200
+product INTEL CORE4G_M_CRW_GT3 0x0d26  Iris Pro Graphics 5200
+product INTEL CORE4G_S_CRW_GT3 0x0d2a  HD Graphics
+product INTEL CORE4G_R_CRW_GT3_1 0x0d2bHD Graphics
+product INTEL CORE4G_R_CRW_GT3_2 0x0d2eHD Graphics
 product INTEL 825420x1000  PRO/1000 (82542)
 product INTEL 82543GC_FIBER0x1001  PRO/1000F (82543GC)
 product INTEL MODEM56  0x1002  56k Modem
Index: agp_i810.c
===
RCS file: 

Re: put procs on rb tree

2013-06-06 Thread Alexandre Ratchov
On Wed, Jun 05, 2013 at 02:12:36PM -0400, Ted Unangst wrote:
 
 Conclusion? You'll never notice the difference. Personally I have
 a slight preference for improving worst case behavior.

I've a preference for simpler structures; as long if pid lookup is
not a real problem

-- Alexandre



Re: iked address pools

2013-06-06 Thread Peter Hessler
You can use cvs add against a mirror to add files.  Directories
require write access, so that won't work.  Then use cvs diff -Nup to
include all of the (N)ew files.

tech@ is the preferred mailing list for diffs.


On 2013 Jun 05 (Wed) at 23:23:53 -0600 (-0600), Ryan Slack wrote:
:I wish to submit a working implementation of address pools for iked,
:however as it's my first real code contribution and has 643 lines
:(mostly patch context) I'm wondering if posting here is the correct
:channel.
:
:Also, what is the preferred/normal way to include new files in a patch?
:
:--Ryan Slack
:

-- 
Be security conscious -- National Defense is at stake.



Re: bzip2

2013-06-06 Thread Stuart Henderson
On 2013/06/06 08:04, Janne Johansson wrote:
 If it covers that tar needs for tar xjf bla.tbz2 to work then this would
 be a good addition.

That needs support for -d (and -c but we have that already).



Switch mfii(4) to msi, testing required.

2013-06-06 Thread Christiano F. Haesbaert
Hi,

We would like to switch mfii(4) to msi, there is a family of supermicro
X9 motherboards with incorrect ioapic routing, so they only work properly
though msi.

If you have a system with a mfii(4) device, please give this diff a spin
and report back.

So far I was able to test on:

Supermicro X9DRH + Symbios Logic MegaRAID SAS2208
Fujitsu primergy RX300 S7 + Symbios Logic MegaRAID SAS2208

Index: dev/pci/mfii.c
===
RCS file: /cvs/src/sys/dev/pci/mfii.c,v
retrieving revision 1.12
diff -d -u -p -r1.12 mfii.c
--- dev/pci/mfii.c  25 Aug 2012 07:03:04 -  1.12
+++ dev/pci/mfii.c  6 Jun 2013 10:47:23 -
@@ -307,7 +307,7 @@ mfii_attach(struct device *parent, struc
/* disable interrupts */
mfii_write(sc, MFI_OMSK, 0x);
 
-   if (pci_intr_map(pa, ih) != 0) {
+   if (pci_intr_map_msi(pa, ih) != 0  pci_intr_map(pa, ih) != 0) {
printf(: unable to map interrupt\n);
goto pci_unmap;
}



Re: bzip2

2013-06-06 Thread Mark Kettenis
 Date: Wed, 05 Jun 2013 20:59:39 -0400
 From: Ted Unangst t...@tedunangst.com
 
 Something that comes up from time to time is the question of whether
 to import bzip2 into base or not. Turns out the question is moot
 because already have imported it. There's a copy in perl. (I didn't
 know this until I happened to be watching a build closer than usual.)
 
 Since we already have the code built, why not let people use it? This
 is a small perl script that implements the 90% subset of functionality
 people expect from the regular bzip2 and bunzip2 utilities. It's not
 really complete or perfect, but I haven't spent all that much time on
 it.

full disclosure
I'm a Perl hater
/full disclosure

I've ranted before about implementing standard tools in Perl.  The
user experience just isn't the same as with C code.

But even more so than with nl(1), why would we want to use something
that's different from what everybody else uses?  If we want bzip2 in
base (and I think there are good reasons for having it) we should
simply use the standard bzip2 code.

 --- /dev/null Wed Jun  5 20:54:56 2013
 +++ bzip2/MakefileWed Jun  5 20:51:51 2013
 @@ -0,0 +1,15 @@
 +# $OpenBSD$
 +
 +.include bsd.own.mk
 +
 +MAN=
 +
 +SCRIPT=bzip2.pl
 +LINKS=${BINDIR}/bzip2 ${BINDIR}/bunzip2
 +
 +realinstall:
 + ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
 + ${.CURDIR}/${SCRIPT} ${DESTDIR}${BINDIR}/bzip2
 +
 +
 +.include bsd.prog.mk
 --- /dev/null Wed Jun  5 20:55:02 2013
 +++ bzip2/bzip2.plWed Jun  5 20:53:23 2013
 @@ -0,0 +1,113 @@
 +#!/usr/bin/perl -w
 +# $OpenBSD$
 +# Copyright (c) Ted Unangst t...@openbsd.org
 +#
 +# 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.
 +
 +use strict;
 +use Getopt::Long qw(:config posix_default bundling no_ignore_case);
 +use IO::Compress::Bzip2 qw(bzip2);
 +
 +
 +my $usestdout;
 +my $level = 9;
 +my $reqlevel; # requested level, who cares?
 +GetOptions(
 + c|stdout = \$usestdout,
 + 1|2|3|4|5|6|7|8|9|fast|best = \$reqlevel
 +);
 +
 +sub bzipfile {
 + my $fname = shift;
 + my $ofname;
 + my $in;
 + if ($fname ne -) {
 + if ($usestdout) {
 + $ofname = -;
 + } else {
 + $ofname = $fname . .bz2;
 + if (-e $ofname) {
 + warn Output file $ofname already exists.\n;
 + return;
 + }
 + }
 + $in = new IO::File $fname;
 + if (!$in) {
 + warn Can't open input file $fname.\n;
 + return;
 + }
 + } else {
 + $in = -;
 + $ofname = -;
 + }
 + if ($ofname eq -  -t STDOUT) {
 + warn I won't write compressed data to a terminal.\n;
 + return;
 + }
 + if (not bzip2 $in = $ofname, BlockSize100K = $level) {
 + warn failz;
 + return;
 + }
 + if ($ofname ne -) {
 + unlink($fname);
 + }
 +}
 +
 +sub bunzipfile {
 +print bunzipping\n;
 + my $fname = shift;
 + my $ofname;
 + my $in;
 + if ($fname ne -) {
 + if ($usestdout) {
 + $ofname = -;
 + } else {
 + $ofname = $fname;
 + $ofname =~ s/\.bz2$//;
 + if (-e $ofname) {
 + warn Output file $ofname already exists.\n;
 + return;
 + }
 + }
 + $in = new IO::File $fname;
 + if (!$in) {
 + warn Can't open input file $fname.\n;
 + return;
 + }
 + } else {
 + $in = -;
 + $ofname = -;
 + }
 + if (not bunzip2 $in = $ofname) {
 + warn failz;
 + return;
 + }
 + if ($ofname ne -) {
 + unlink($fname);
 + }
 +}
 +
 +my $main;
 +if ($0 =~ /bunzip2$/) {
 + $main = \bunzipfile;
 +} else {
 + $main = \bzipfile;
 +}
 +
 +if (@ARGV == 0) {
 + $main(-);
 +} else {
 + foreach my $f (@ARGV) {
 + $main($f);
 + }
 +}
 
 



Re: bzip2

2013-06-06 Thread David Coppa
On Thu, Jun 6, 2013 at 2:20 PM, Mark Kettenis mark.kette...@xs4all.nl wrote:

 full disclosure
 I'm a Perl hater
 /full disclosure

 I've ranted before about implementing standard tools in Perl.  The
 user experience just isn't the same as with C code.

 But even more so than with nl(1), why would we want to use something
 that's different from what everybody else uses?  If we want bzip2 in
 base (and I think there are good reasons for having it) we should
 simply use the standard bzip2 code.

Seconded.

ciao,
David



Re: bzip2

2013-06-06 Thread Damien Miller
On Thu, 6 Jun 2013, David Coppa wrote:

  But even more so than with nl(1), why would we want to use something
  that's different from what everybody else uses?  If we want bzip2 in
  base (and I think there are good reasons for having it) we should
  simply use the standard bzip2 code.
 
 Seconded.

Thirded



sysctl fix

2013-06-06 Thread Sylvestre Gallon
Hi tech@

I was currently trying to get the fuse sysctls working when I found a bug
in sbin/sysctl.c

If you look at sys/kern/vfs_init.c MOUNT_FUSEFS use the biggest typenum : 18.
So when the function vfsinit in sbin/sysctl.c gets VFS_MAXTYPENUM it gets 
18, but this value will never be reached in the for statement...

I jump on the occasion to remove all compilation warnings for sysctl.

Cheers,

Index: sysctl.c
===
RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.189
diff -u -p -u -p -r1.189 sysctl.c
--- sysctl.c16 Apr 2013 22:06:48 -  1.189
+++ sysctl.c6 Jun 2013 12:07:38 -
@@ -268,7 +268,8 @@ void
 listall(char *prefix, struct list *lp)
 {
char *cp, name[BUFSIZ];
-   int lvl2, len;
+   size_t len;
+   int lvl2;
 
if (lp-list == NULL)
return;
@@ -861,7 +862,7 @@ parse(char *string, int flags)
}
if (special  RNDSTATS) {
struct rndstats *rndstats = (struct rndstats *)buf;
-   int i;
+   size_t i;
 
if (!nflag)
(void)printf(%s%s, string, equ);
@@ -1025,7 +1026,7 @@ parse_ports(char *portspec, int *port, i
 
 void
 parse_baddynamic(int mib[], size_t len, char *string, void **newvalp,
-size_t *newsizep, int flags, int nflag)
+size_t *newsizep, int flags, int nf)
 {
static u_int32_t newbaddynamic[DP_MAPSIZE];
int port, high_port, baddynamic_loaded = 0, full_list_set = 0;
@@ -1043,7 +1044,7 @@ parse_baddynamic(int mib[], size_t len, 
size, 0, 0) == -1) {
if (flags == 0)
return;
-   if (!nflag)
+   if (!nf)
printf(%s: , string);
puts(kernel does contain bad dynamic 
port tables);
@@ -1138,8 +1139,8 @@ vfsinit(void)
}
mib[2] = VFS_CONF;
buflen = sizeof vfc;
-   for (loc = lastused, cnt = 1; cnt  maxtypenum; cnt++) {
-   mib[3] = cnt - 1;
+   for (loc = lastused, cnt = 0; cnt  maxtypenum; cnt++) {
+   mib[3] = cnt;
if (sysctl(mib, 4, vfc, buflen, (void *)0, (size_t)0)  0) {
if (errno == EOPNOTSUPP)
continue;
@@ -1280,13 +1281,13 @@ sysctl_bios(char *string, char **bufpp, 
mib[2] = indx;
if (indx == BIOS_DISKINFO) {
if (*bufpp == NULL) {
-   char name[BUFSIZ];
+   char str[BUFSIZ];
 
/* scan all the bios devices */
for (indx = 0; indx  256; indx++) {
-   snprintf(name, sizeof(name), %s.%u,
+   snprintf(str, sizeof(str), %s.%u,
string, indx);
-   parse(name, 1);
+   parse(str, 1);
}
return (-1);
}
@@ -1782,10 +1783,10 @@ sysctl_forkstat(char *string, char **buf
 int
 sysctl_malloc(char *string, char **bufpp, int mib[], int flags, int *typep)
 {
-   int indx, stor, i;
+   int indx, stor;
char *name, bufp[SYSCTL_BUFSIZ], *buf, *ptr;
struct list lp;
-   size_t size;
+   size_t size, i;
 
if (*bufpp == NULL) {
listall(string, kernmalloclist);
@@ -2282,7 +2283,7 @@ sysctl_tc(char *string, char **bufpp, in
 int
 sysctl_sensors(char *string, char **bufpp, int mib[], int flags, int *typep)
 {
-   char *devname, *typename;
+   char *name, *typename;
int dev, numt, i;
enum sensor_type type;
struct sensordev snsrdev;
@@ -2312,7 +2313,7 @@ sysctl_sensors(char *string, char **bufp
 * provided below hw.sensors tree.
 * The first branch of hw.sensors tree is the device name.
 */
-   if ((devname = strsep(bufpp, .)) == NULL) {
+   if ((name = strsep(bufpp, .)) == NULL) {
warnx(%s: incomplete specification, string);
return (-1);
}
@@ -2325,11 +2326,11 @@ sysctl_sensors(char *string, char **bufp
if (errno == ENOENT)
break;
}
-   if (strcmp(devname, snsrdev.xname) == 0)
+   if (strcmp(name, snsrdev.xname) == 0)
break;
}
-   if (strcmp(devname, snsrdev.xname) != 0) {
-   warnx(%s: sensor device not found: %s, string, devname);
+   if (strcmp(name, snsrdev.xname) != 0) {
+   warnx(%s: sensor device not found: %s, string, name);
return (-1);
}
if (*bufpp == 

Re: sysctl fix

2013-06-06 Thread Alexey E. Suslikov
Sylvestre Gallon ccna.syl at gmail.com writes:

  at  at  -2586,6 +2587,7  at  at  struct emulname {
  } *emul_names;
  int  emul_num, nemuls;
  int  emul_init(void);
 +int  emulcmp(const void *, const void *);

this seems unrelated to rest of changes you've made. no?



Re: sysctl fix

2013-06-06 Thread Sylvestre Gallon
On Thu, Jun 6, 2013 at 4:39 PM, Alexey E. Suslikov
alexey.susli...@gmail.com wrote:
 int  emulcmp(const void *, const void *);

using WARNINGS=yes make it remove the following warning :

sysctl.c:2697: warning: no previous prototype for 'emulcmp'

Cheers,


--
Sylvestre Gallon



Re: bzip2

2013-06-06 Thread Ted Unangst
On Thu, Jun 06, 2013 at 14:20, Mark Kettenis wrote:
 I've ranted before about implementing standard tools in Perl.  The
 user experience just isn't the same as with C code.
 
 But even more so than with nl(1), why would we want to use something
 that's different from what everybody else uses?  If we want bzip2 in
 base (and I think there are good reasons for having it) we should
 simply use the standard bzip2 code.

I don't have a problem with importing bzip2, per se. But iirc previous
discussions basically ended with it adds more code and will slow down
builds. But we've already been slowing down builds for the past two
years. Adding another copy of the C version returns us to the bloat
discussion. I'm trying to dance around that objection by using code
that already has been imported and built.

It's not so much that I really need bzip2 in base. But having paid the
cost to build, I'd like some return on that investment. At least
that's my rationale.



Re: bzip2

2013-06-06 Thread Theo de Raadt
On Thu, Jun 06, 2013 at 14:20, Mark Kettenis wrote:
 I've ranted before about implementing standard tools in Perl.  The
 user experience just isn't the same as with C code.
 
 But even more so than with nl(1), why would we want to use something
 that's different from what everybody else uses?  If we want bzip2 in
 base (and I think there are good reasons for having it) we should
 simply use the standard bzip2 code.

I don't have a problem with importing bzip2, per se. But iirc previous
discussions basically ended with it adds more code and will slow down
builds.

If I recall, previous discussions were not about but then we can use it
as a complete replacement for gzip or use it for the install media or ...,
as if this is a general replacement algorithm.

But we've already been slowing down builds for the past two
years. Adding another copy of the C version returns us to the bloat
discussion. I'm trying to dance around that objection by using code
that already has been imported and built.

If it is now very common, we might as well put it in base properly.

It's not so much that I really need bzip2 in base. But having paid the
cost to build, I'd like some return on that investment. At least
that's my rationale.

If the code built in base will just be picked up by perl, fine.

It is primarily used by ports.

If anyone thinks using this for the install or boot media is going to
help, don't say a word until you can prove it on all platforms.



Re: sysctl fix

2013-06-06 Thread Ted Unangst
On Thu, Jun 06, 2013 at 15:39, Sylvestre Gallon wrote:
 Hi tech@
 
 I was currently trying to get the fuse sysctls working when I found a bug
 in sbin/sysctl.c
 
 If you look at sys/kern/vfs_init.c MOUNT_FUSEFS use the biggest typenum : 18.
 So when the function vfsinit in sbin/sysctl.c gets VFS_MAXTYPENUM it gets
 18, but this value will never be reached in the for statement...
 
 I jump on the occasion to remove all compilation warnings for sysctl.

Unfortunately, this makes it hard to see the real change. Can you do
just the fix as a diff please? I'm happy to fix the warnings too, but
separately.



Re: bzip2

2013-06-06 Thread Christian Weisgerber
Theo de Raadt dera...@cvs.openbsd.org wrote:

 It is primarily used by ports.

Before t2k13, there were 739 .tar.bz2|.tbz2 distfiles--compared to
268 .tar.xz|.txz ones.  I don't know how fast that balance is
shifting.

There are some 40 ports that directly depend on libbz2, and some
10 more that pull it in indirectly by way of libarchive or such.

-- 
Christian naddy Weisgerber  na...@mips.inka.de



Re: sysctl fix

2013-06-06 Thread Ted Unangst
On Thu, Jun 06, 2013 at 11:42, patrick keshishian wrote:

 Just curious, how do the variable name changes help any
 warrnings?
 
 nflag - nf

-Wshadow. nflag is a global, which becomes hidden by giving a local
parameter the same name. The code is kind of silly anyway, since the
only call to that function passes the global in, so the local version
will never have a different value. Could just delete the parameter
entirely.



Re: bzip2

2013-06-06 Thread Mark Kettenis
 Date: Thu, 6 Jun 2013 09:48:24 -0600 (MDT)
 From: Theo de Raadt dera...@cvs.openbsd.org
 
 On Thu, Jun 06, 2013 at 14:20, Mark Kettenis wrote:
  I've ranted before about implementing standard tools in Perl.  The
  user experience just isn't the same as with C code.
  
  But even more so than with nl(1), why would we want to use something
  that's different from what everybody else uses?  If we want bzip2 in
  base (and I think there are good reasons for having it) we should
  simply use the standard bzip2 code.
 
 I don't have a problem with importing bzip2, per se. But iirc previous
 discussions basically ended with it adds more code and will slow down
 builds.
 
 If I recall, previous discussions were not about but then we can use it
 as a complete replacement for gzip or use it for the install media or ...,
 as if this is a general replacement algorithm.

Somebody said /usr/bin is full ;).

 But we've already been slowing down builds for the past two
 years. Adding another copy of the C version returns us to the bloat
 discussion. I'm trying to dance around that objection by using code
 that already has been imported and built.
 
 If it is now very common, we might as well put it in base properly.

These days I see more .tar.bz2 than .tar.gz.  However, I think .bz2
usage is declining in favour of .xz.

 It is primarily used by ports.

Dunno about others, but I download lots of source code to take a look
at it, and it usually comes as a .tar.bz2 these days.  Installing
bzip2 is typically one of the first things I do on a machine.



Re: sysctl fix

2013-06-06 Thread Sylvestre Gallon
Hi,

Sorry for the last mistakes. Here is a new diff that allow the
maxtypenum to be reached.

Cheers,

Index: sysctl.c
===
RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.189
diff -u -p -r1.189 sysctl.c
--- sysctl.c16 Apr 2013 22:06:48 -  1.189
+++ sysctl.c6 Jun 2013 21:19:32 -
@@ -1138,8 +1138,8 @@ vfsinit(void)
}
mib[2] = VFS_CONF;
buflen = sizeof vfc;
-   for (loc = lastused, cnt = 1; cnt  maxtypenum; cnt++) {
-   mib[3] = cnt - 1;
+   for (loc = lastused, cnt = 0; cnt  maxtypenum; cnt++) {
+   mib[3] = cnt;
if (sysctl(mib, 4, vfc, buflen, (void *)0, (size_t)0)  0) {
if (errno == EOPNOTSUPP)
continue;



Re: sysctl fix

2013-06-06 Thread Sylvestre Gallon
Here is a second one to add fuse sysctls.

Cheers,

Index: sys/miscfs/fuse/fusefs.h
===
RCS file: /cvs/src/sys/miscfs/fuse/fusefs.h,v
retrieving revision 1.1
diff -u -p -r1.1 fusefs.h
--- sys/miscfs/fuse/fusefs.h3 Jun 2013 15:50:56 -   1.1
+++ sys/miscfs/fuse/fusefs.h6 Jun 2013 21:41:36 -
@@ -18,6 +18,23 @@
 #ifndef __FUSEFS_H__
 #define __FUSEFS_H__
 
+/* sysctl defines */
+#define FUSEFS_NB_OPENDEVS 1   /* # of fuse devices opened */
+#define FUSEFS_INFBUFS 2   /* # of in fbufs */
+#define FUSEFS_WAITFBUFS   3   /* # of fbufs waiting for a response */
+#define FUSEFS_POOL_NBPAGES4   /* # total fusefs size */
+#define FUSEFS_MAXID   5   /* number of valid fusefs ids */
+
+#define FUSEFS_NAMES { \
+   { 0, 0}, \
+   { fusefs_open_devices, CTLTYPE_INT }, \
+   { fusefs_fbufs_in, CTLTYPE_INT }, \
+   { fusefs_fbufs_wait, CTLTYPE_INT }, \
+   { fusefs_pool_pages, CTLTYPE_INT }, \
+}
+
+#ifdef  _KERNEL
+
 struct fuse_msg;
 
 struct fusefs_mnt {
@@ -42,21 +59,6 @@ struct fusefs_mnt {
 extern struct vops fusefs_vops;
 extern struct pool fusefs_fbuf_pool;
 
-/* sysctl defines */
-#define FUSEFS_NB_OPENDEVS 1   /* # of fuse devices opened */
-#define FUSEFS_INFBUFS 2   /* # of in fbufs */
-#define FUSEFS_WAITFBUFS   3   /* # of fbufs waiting for a response */
-#define FUSEFS_POOL_NBPAGES4   /* # total fusefs size */
-#define FUSEFS_MAXID   5   /* number of valid fusefs ids */
-
-#define FUSEFS_NAMES { \
-   { 0, 0}, \
-   { fusefs_open_devices, CTLTYPE_INT }, \
-   { fusefs_fbufs_in, CTLTYPE_INT }, \
-   { fusefs_fbufs_wait, CTLTYPE_INT }, \
-   { fusefs_pool_pages, CTLTYPE_INT }, \
-}
-
 /* fuse helpers */
 #define TSLEEP_TIMEOUT 5
 void update_vattr(struct mount *mp, struct vattr *v);
@@ -82,4 +84,5 @@ void fuse_device_set_fmp(struct fusefs_m
 /* #define FUSE_DEBUG_VNOP
 #define FUSE_DEBUG */
 
+#endif /* _KERNEL */
 #endif /* __FUSEFS_H__ */
Index: sbin/sysctl/sysctl.c
===
RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.189
diff -u -p -r1.189 sysctl.c
--- sbin/sysctl/sysctl.c16 Apr 2013 22:06:48 -  1.189
+++ sbin/sysctl/sysctl.c6 Jun 2013 21:41:37 -
@@ -88,6 +88,8 @@
 #include ufs/ufs/inode.h
 #include ufs/ffs/ffs_extern.h
 
+#include miscfs/fuse/fusefs.h
+
 #include nfs/nfsproto.h
 #include nfs/nfs.h
 
@@ -1103,6 +1105,7 @@ debuginit(void)
 struct ctlname vfsgennames[] = CTL_VFSGENCTL_NAMES;
 struct ctlname ffsname[] = FFS_NAMES;
 struct ctlname nfsname[] = FS_NFS_NAMES;
+struct ctlname fusefsname[] = FUSEFS_NAMES;
 struct list *vfsvars;
 int *vfs_typenums;
 
@@ -1156,6 +1159,10 @@ vfsinit(void)
if (!strcmp(vfc.vfc_name, MOUNT_NFS)) {
vfsvars[cnt].list = nfsname;
vfsvars[cnt].size = NFS_MAXID;
+   }
+   if (!strcmp(vfc.vfc_name, MOUNT_FUSEFS)) {
+   vfsvars[cnt].list = fusefsname;
+   vfsvars[cnt].size = FUSEFS_MAXID;
}
vfs_typenums[cnt] = vfc.vfc_typenum;
strlcat(names[loc], vfc.vfc_name, sizeof names - loc);
Index: sbin/sysctl/sysctl.8
===
RCS file: /cvs/src/sbin/sysctl/sysctl.8,v
retrieving revision 1.169
diff -u -p -r1.169 sysctl.8
--- sbin/sysctl/sysctl.82 Jun 2013 21:37:03 -   1.169
+++ sbin/sysctl/sysctl.86 Jun 2013 21:41:37 -
@@ -399,6 +399,10 @@ and a few require a kernel compiled with
 .It vfs.ffs.dirhash_maxmem Ta integer Ta yes
 .It vfs.ffs.dirhash_mem Ta integer Ta no
 .It vfs.nfs.iothreads Ta integer Ta yes
+.It vfs.fuse.fusefs_open_devices Ta integer Ta no
+.It vfs.fuse.fusefs_fbufs_in Ta integer Ta no
+.It vfs.fuse.fusefs_fbufs_wait Ta integer Ta no
+.It vfs.fuse.fusefs_pool_pages Ta integer Ta no
 .El
 .Pp
 The
@@ -449,6 +453,8 @@ definitions for second level ddb identif
 definitions for second level vfs identifiers
 .It Aq Pa nfs/nfs.h
 definitions for third level NFS identifiers
+.It Aq Pa miscfs/fuse/fusefs.h
+definitions for third level fusefs identifiers
 .It Aq Pa ufs/ffs/ffs_extern.h
 definitions for third level FFS identifiers
 .It Aq Pa machine/cpu.h



Re: sysctl fix

2013-06-06 Thread Sylvestre Gallon
And here the third one that removes all warns for :

WARNINGS=yes make

Cheers,

Index: sysctl.c
===
RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.189
diff -u -p -u -p -r1.189 sysctl.c
--- sysctl.c16 Apr 2013 22:06:48 -  1.189
+++ sysctl.c6 Jun 2013 12:07:38 -
@@ -268,7 +268,8 @@ void
 listall(char *prefix, struct list *lp)
 {
char *cp, name[BUFSIZ];
-   int lvl2, len;
+   size_t len;
+   int lvl2;
 
if (lp-list == NULL)
return;
@@ -861,7 +862,7 @@ parse(char *string, int flags)
}
if (special  RNDSTATS) {
struct rndstats *rndstats = (struct rndstats *)buf;
-   int i;
+   size_t i;
 
if (!nflag)
(void)printf(%s%s, string, equ);
@@ -1025,7 +1026,7 @@ parse_ports(char *portspec, int *port, i
 
 void
 parse_baddynamic(int mib[], size_t len, char *string, void **newvalp,
-size_t *newsizep, int flags, int nflag)
+size_t *newsizep, int flags, int nf)
 {
static u_int32_t newbaddynamic[DP_MAPSIZE];
int port, high_port, baddynamic_loaded = 0, full_list_set = 0;
@@ -1043,7 +1044,7 @@ parse_baddynamic(int mib[], size_t len, 
size, 0, 0) == -1) {
if (flags == 0)
return;
-   if (!nflag)
+   if (!nf)
printf(%s: , string);
puts(kernel does contain bad dynamic 
port tables);
@@ -1280,13 +1281,13 @@ sysctl_bios(char *string, char **bufpp, 
mib[2] = indx;
if (indx == BIOS_DISKINFO) {
if (*bufpp == NULL) {
-   char name[BUFSIZ];
+   char str[BUFSIZ];
 
/* scan all the bios devices */
for (indx = 0; indx  256; indx++) {
-   snprintf(name, sizeof(name), %s.%u,
+   snprintf(str, sizeof(str), %s.%u,
string, indx);
-   parse(name, 1);
+   parse(str, 1);
}
return (-1);
}
@@ -1782,10 +1783,10 @@ sysctl_forkstat(char *string, char **buf
 int
 sysctl_malloc(char *string, char **bufpp, int mib[], int flags, int *typep)
 {
-   int indx, stor, i;
+   int indx, stor;
char *name, bufp[SYSCTL_BUFSIZ], *buf, *ptr;
struct list lp;
-   size_t size;
+   size_t size, i;
 
if (*bufpp == NULL) {
listall(string, kernmalloclist);
@@ -2282,7 +2283,7 @@ sysctl_tc(char *string, char **bufpp, in
 int
 sysctl_sensors(char *string, char **bufpp, int mib[], int flags, int *typep)
 {
-   char *devname, *typename;
+   char *name, *typename;
int dev, numt, i;
enum sensor_type type;
struct sensordev snsrdev;
@@ -2312,7 +2313,7 @@ sysctl_sensors(char *string, char **bufp
 * provided below hw.sensors tree.
 * The first branch of hw.sensors tree is the device name.
 */
-   if ((devname = strsep(bufpp, .)) == NULL) {
+   if ((name = strsep(bufpp, .)) == NULL) {
warnx(%s: incomplete specification, string);
return (-1);
}
@@ -2325,11 +2326,11 @@ sysctl_sensors(char *string, char **bufp
if (errno == ENOENT)
break;
}
-   if (strcmp(devname, snsrdev.xname) == 0)
+   if (strcmp(name, snsrdev.xname) == 0)
break;
}
-   if (strcmp(devname, snsrdev.xname) != 0) {
-   warnx(%s: sensor device not found: %s, string, devname);
+   if (strcmp(name, snsrdev.xname) != 0) {
+   warnx(%s: sensor device not found: %s, string, name);
return (-1);
}
if (*bufpp == NULL) {
@@ -2586,6 +2587,7 @@ struct emulname {
 } *emul_names;
 intemul_num, nemuls;
 intemul_init(void);
+intemulcmp(const void *, const void *);
 
 int
 sysctl_emul(char *string, char *newval, int flags)



Re: sysctl fix

2013-06-06 Thread Ted Unangst
On Thu, Jun 06, 2013 at 23:53, Sylvestre Gallon wrote:
 Hi,
 
 Sorry for the last mistakes. Here is a new diff that allow the
 maxtypenum to be reached.
 
 Cheers,
 
 Index: sysctl.c
 ===
 RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
 retrieving revision 1.189
 diff -u -p -r1.189 sysctl.c
 --- sysctl.c  16 Apr 2013 22:06:48 -  1.189
 +++ sysctl.c  6 Jun 2013 21:19:32 -
 @@ -1138,8 +1138,8 @@ vfsinit(void)
 }
 mib[2] = VFS_CONF;
 buflen = sizeof vfc;
 - for (loc = lastused, cnt = 1; cnt  maxtypenum; cnt++) {
 - mib[3] = cnt - 1;
 + for (loc = lastused, cnt = 0; cnt  maxtypenum; cnt++) {
 + mib[3] = cnt;

I think we want to keep starting at 1. 0 isn't a valid vfc_typenum.
(doesn't really matter, but better correct than not.)

I can fix this before commit, you don't need to send a new diff.



Re: bzip2

2013-06-06 Thread Darren Tucker
On Thu, Jun 6, 2013 at 11:48 AM, Theo de Raadt dera...@cvs.openbsd.org wrote:
[...]
 If anyone thinks using this for the install or boot media is going to
 help, don't say a word until you can prove it on all platforms.

Has anyone looked at zopfli[1] for the install media?  It's a (apache
2 licensed) slightly better but much slower gzip compressor that still
produces gzip-compatible output.

For an amd64 ramdiskA it makes a bsd.gz that's 48k smaller than gzip
(in ~16 seconds) and should compatible with the bootloader.  I tried
it once in a vm and it booted ok.

$ time gzip -9cn bsd.strip bsd.gz
real0m0.648s
user0m0.610s
sys 0m0.000s

$ time zopfli -c bsd.strip bsd.zopfli.gz
real0m17.409s
user0m16.810s
sys 0m0.580s

$ ls -l bsd.gz bsd.zopfli.gz
-rw-r--r--  1 dtucker  wsrc  1349508 Jun  6 15:40 bsd.gz
-rw-r--r--  1 dtucker  wsrc  1310302 Jun  6 15:42 bsd.zopfli.gz

[1] https://code.google.com/p/zopfli/

-- 
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4  37C9 C982 80C7 8FF4 FA69
Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.



[PATCH] iked address pools

2013-06-06 Thread Ryan Slack
The following provides address pools for iked. It's nothing fancy, but
it seems to work, at least in the cursory testing done against the
Windows 7 client.

Each policy gets it's own pool, configured by config address start
ip - end ip.
There is a hard limit of 65536 addresses (8kb) per pool, which should be plenty.
There is NO ipv6 support, partly because I'm not really sure how or
why it would be needed.
A request for a specific ip that is available in the pool will be honoured.

Comments please!

--Ryan Slack


Index: addr_pool.c
===
RCS file: addr_pool.c
diff -N addr_pool.c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ addr_pool.c 7 Jun 2013 03:05:46 -
@@ -0,0 +1,188 @@
+
+#include sys/socket.h
+
+#include netinet/in.h
+
+#include stdlib.h
+#include string.h
+#include errno.h
+#include err.h
+
+#include iked.h
+
+int
+addr_pool_init_mask(struct addr_pool* pool,
+   struct sockaddr_storage *address, u_int8_t prefixlengh)
+{
+   struct sockaddr_in  *a4;
+   /* struct sockaddr_in6  *a6; */
+
+   if(pool == NULL) return(-1);
+
+   memcpy(pool-addr, address, sizeof(pool-addr));
+
+   switch(address-ss_family){
+   case AF_INET:
+   if (!(16  prefixlengh  prefixlengh  30)) {
+   log_warnx(%s: prefixlengh (%d) out of range [16:30],
+ __func__,prefixlengh);
+   return(-1);
+   }
+   //pool-mask = prefixlen2mask(prefixlengh);
+   pool-size = (1(32 - prefixlengh)) - 2;
+
+   a4 = (struct sockaddr_in *)pool-addr;
+   a4-sin_addr.s_addr = ntohl(a4-sin_addr.s_addr) + 1;
+   a4-sin_addr.s_addr = htonl(a4-sin_addr.s_addr);
+
+   break;
+   case AF_INET6:
+   default:
+   errno = EAFNOSUPPORT;
+   log_warn(%s: ,__func__);
+   return (-1);
+   }
+
+   return(0);
+}
+
+int
+addr_pool_init_range(struct addr_pool* pool,
+struct sockaddr_storage *start,
+struct sockaddr_storage *end)
+{
+   struct sockaddr_in  *a4, *b4;
+   //struct sockaddr_in6   *a6, *b6;
+   uint32_t size_l;
+
+   if(pool == NULL || start == NULL || end == NULL) return(-1);
+
+   if (start-ss_family != end-ss_family) {
+   log_debug(%s: address family mismatch, __func__);
+   return (-1);
+   }
+
+
+   switch(start-ss_family){
+   case AF_INET:
+   a4 = (struct sockaddr_in *)start;
+   b4 = (struct sockaddr_in *)end;
+
+   size_l = ntohl(b4-sin_addr.s_addr) -
ntohl(a4-sin_addr.s_addr) + 1;
+
+   if ( size_l  ADDR_POOL_SIZE_MAX ) {
+   log_warnx(%s: size (%d) out of range
(%d),__func__, size_l, ADDR_POOL_SIZE_MAX);
+   return(-1);
+   }
+   pool-size = size_l;
+
+   break;
+   case AF_INET6:
+   default:
+   errno = EAFNOSUPPORT;
+   log_warn(%s: , __func__);
+   return (-1);
+   }
+
+   memcpy(pool-addr, start, sizeof(pool-addr));
+
+   return(0);
+}
+
+
+int
+addr_pool_alloc(struct addr_pool* pool)
+{
+   if((pool-pool = bit_alloc(pool-size))==NULL)
+   return (-1);
+
+   log_debug(%s: %s+%d, __func__,
+ print_host(pool-addr, NULL, 0), pool-size);
+
+   return(0);
+}
+
+int
+addr_pool_free(struct addr_pool* pool){
+   if(pool-size)
+   free(pool-pool);
+   return (0);
+}
+
+int
+addr_pool_reqest(struct addr_pool* pool, struct sockaddr_storage *address)
+{
+   struct sockaddr_in *a4;
+   //struct sockaddr_in6 *sa6,*pa6;
+   u_int32_t h_addr;
+   int32_t i;
+   if(pool-addr.ss_family != address-ss_family){
+   log_debug(%s: address family mismatch, __func__);
+   return(-1);
+   }
+   switch(pool-addr.ss_family){
+   case AF_INET:
+   a4 = ((struct sockaddr_in *)address);
+   h_addr = ntohl(((struct
sockaddr_in*)pool-addr)-sin_addr.s_addr);
+   i = ntohl(a4-sin_addr.s_addr) - h_addr;
+   if (0 = i  (uint32_t)i  pool-size 
!bit_test(pool-pool,i)) {
+   bit_set(pool-pool,i);
+   } else {
+   bit_ffc(pool-pool,pool-size,i);
+   bit_set(pool-pool,i);
+   a4-sin_addr.s_addr = htonl(h_addr + i);
+   }
+   log_debug(%s: assigned %s [%d], __func__,
+ print_host(address, NULL, 0), i);
+
+   break;
+   case AF_INET6:
+   default:
+   errno = EAFNOSUPPORT;
+   log_warn(%s: , __func__);
+   return (-1);
+   }
+
+   return (0);
+}
+
+int
+addr_pool_release(struct addr_pool* pool, struct sockaddr_storage 

Re: bzip2

2013-06-06 Thread Theo de Raadt
 On Thu, Jun 6, 2013 at 11:48 AM, Theo de Raadt dera...@cvs.openbsd.org 
 wrote:
 [...]
  If anyone thinks using this for the install or boot media is going to
  help, don't say a word until you can prove it on all platforms.
 
 Has anyone looked at zopfli[1] for the install media?  It's a (apache
 2 licensed) slightly better but much slower gzip compressor that still
 produces gzip-compatible output.
 
 For an amd64 ramdiskA it makes a bsd.gz that's 48k smaller than gzip
 (in ~16 seconds) and should compatible with the bootloader.  I tried
 it once in a vm and it booted ok.
 
 $ time gzip -9cn bsd.strip bsd.gz
 real0m0.648s
 user0m0.610s
 sys 0m0.000s
 
 $ time zopfli -c bsd.strip bsd.zopfli.gz
 real0m17.409s
 user0m16.810s
 sys 0m0.580s
 
 $ ls -l bsd.gz bsd.zopfli.gz
 -rw-r--r--  1 dtucker  wsrc  1349508 Jun  6 15:40 bsd.gz
 -rw-r--r--  1 dtucker  wsrc  1310302 Jun  6 15:42 bsd.zopfli.gz
 
 [1] https://code.google.com/p/zopfli/

I don't know where we'd put it in the tree.

If we did add it, it would only benefit the fast architectures, since
the others cannot afford the additional build time.  Developers would
use up the space gains quickly.  Right now a few architectures are
neck and neck regarding which install media are close to full.  Older
architectures would hit full install media issues first.  A smaller
contingent of developers who take care of those architectures would
have to deal with the fallout, creating further friction...

I understand where the suggestion comes from, but also seea more
downsides than benefits.