more windows versions for acpi _OSI checks

2016-02-27 Thread Jonathan Gray
Claim to be more versions of windows for _OSI.  Mostly based on the
table in 'How to Identify the Windows Version in ACPI by Using _OSI'.

2001.1 SP1  Windows Server 2003 SP1
2006.1  Windows Server 2008
2006 SP1Windows Vista SP1
2006 SP2Windows Vista SP2
2015Windows 10

Index: dsdt.c
===
RCS file: /cvs/src/sys/dev/acpi/dsdt.c,v
retrieving revision 1.219
diff -u -p -r1.219 dsdt.c
--- dsdt.c  13 Jan 2016 23:11:22 -  1.219
+++ dsdt.c  28 Feb 2016 04:54:21 -
@@ -1479,15 +1479,20 @@ char *aml_valid_osi[] = {
"Windows 2000",
"Windows 2001",
"Windows 2001.1",
+   "Windows 2001.1 SP1",
"Windows 2001 SP0",
"Windows 2001 SP1",
"Windows 2001 SP2",
"Windows 2001 SP3",
"Windows 2001 SP4",
"Windows 2006",
+   "Windows 2006.1",
+   "Windows 2006 SP1",
+   "Windows 2006 SP2",
"Windows 2009",
"Windows 2012",
"Windows 2013",
+   "Windows 2015",
NULL
 };
 



Re: ckqueue functions in lpq and lpd

2016-02-27 Thread Jeremie Courreges-Anglas
Chris Bennett  writes:

> I am having trouble seeing how these two functions are accomplshinig the
> same thing, checking for control files in the spool.
> These files always start with cf.
>
> in lpd.c
> makes sense to me.
>
> /*
>  * Make sure there's some work to do before forking off a child
>  * XXX - could be common w/ lpq
>  */
> static int
> ckqueue(char *cap)
> {
>   struct dirent *d;
>   DIR *dirp;
>   char *spooldir;
>
>   if (cgetstr(cap, "sd", ) >= 0) {
>   dirp = opendir(spooldir);
>   free(spooldir);
>   } else
>   dirp = opendir(_PATH_DEFSPOOL);
>
>   if (dirp == NULL)
>   return (-1);
>   while ((d = readdir(dirp)) != NULL) {
>   if (d->d_name[0] == 'c' && d->d_name[1] == 'f') {
>   closedir(dirp);
>   return (1); /* found a cf file */
>   }
>   }
>   closedir(dirp);
>   return (0);
> }
>
>
> in lpq.c
> does not make sense to me
>
> /* XXX - could be common w/ lpd */
> static int
> ckqueue(char *cap)
> {
>   struct dirent *d;
>   DIR *dirp;
>   char *spooldir;
>
>   if (cgetstr(cap, "sd", ) >= 0) {
>   dirp = opendir(spooldir);
>   free(spooldir);
>   } else
>   dirp = opendir(_PATH_DEFSPOOL);
>
>   if (dirp == NULL)
>   return (-1);
>   while ((d = readdir(dirp)) != NULL) {
>   if (d->d_name[0] != 'c' || d->d_name[1] != 'f')
>   continue;   /* daemon control files only */
>   closedir(dirp);
>   return (1); /* found something */
>   }
>   closedir(dirp);
>   return (0);
> }
>
>
> the line:
> if (d->d_name[0] != 'c' || d->d_name[1] != 'f')
> is excluding files that start with cf,

The test is true for files names that *do not* start with "cf".  The
action is "continue", ie, restart the loop.  I think the code is
correct.

> yet then has the comment that daemon
> controls files are found.
> They both acccomplish the same thing of returning if there are files in the
> spool.

I agree that the lpq.c version is harder to read.  Patches to:
- use the same test in both lpd and lpq (the one from lpd is nicer)
- move ckqueue() to common_source/
would be welcome IMO.

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: rtadvd: remove more dead code

2016-02-27 Thread Jeremie Courreges-Anglas
Alexander Bluhm  writes:

> On Tue, Feb 09, 2016 at 02:17:18AM +0100, J??r??mie Courr??ges-Anglas wrote:
>> 
>> - a few *cnt members of struct rainfo aren't used for anything
>> - the SIOCGIFPREFIX_IN6 ioctl has been deprecated since June 2002
>> - prefix_match() and in6a_site_allrouters are remnants from the
>>   Renumbering code (now in the Attic)
>> 
>> ok?
>
> OK bluhm@
>
> I think you should also kill the function init_prefix() and move
> the remaining 4 lines into make_prefix() in another diff.

duh, thanks.  Here's the diff:

Index: config.c
===
RCS file: /cvs/src/usr.sbin/rtadvd/config.c,v
retrieving revision 1.52
diff -u -p -r1.52 config.c
--- config.c26 Feb 2016 12:33:30 -  1.52
+++ config.c27 Feb 2016 23:13:29 -
@@ -678,21 +678,6 @@ delete_prefix(struct rainfo *rai, struct
make_packet(rai);
 }
 
-/*
- * Try to get an in6_prefixreq contents for a prefix which matches
- * ipr->ipr_prefix and ipr->ipr_plen and belongs to
- * the interface whose name is ipr->ipr_name[].
- */
-static int
-init_prefix(struct in6_prefixreq *ipr)
-{
-   ipr->ipr_vltime = DEF_ADVVALIDLIFETIME;
-   ipr->ipr_pltime = DEF_ADVPREFERREDLIFETIME;
-   ipr->ipr_raf_onlink = 1;
-   ipr->ipr_raf_auto = 1;
-   return 0;
-}
-
 void
 make_prefix(struct rainfo *rai, int ifindex, struct in6_addr *addr, int plen)
 {
@@ -708,9 +693,11 @@ make_prefix(struct rainfo *rai, int ifin
ipr.ipr_prefix.sin6_family = AF_INET6;
ipr.ipr_prefix.sin6_addr = *addr;
ipr.ipr_plen = plen;
+   ipr.ipr_vltime = DEF_ADVVALIDLIFETIME;
+   ipr.ipr_pltime = DEF_ADVPREFERREDLIFETIME;
+   ipr.ipr_raf_onlink = 1;
+   ipr.ipr_raf_auto = 1;
 
-   if (init_prefix())
-   return; /* init failed by some error */
add_prefix(rai, );
 }
 


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: Remove option COMPAT_LINUX

2016-02-27 Thread Philip Guenther
On Sat, Feb 27, 2016 at 7:59 AM, Christian Weisgerber
 wrote:
> Support for running Linux binaries under emulation is going away.
>
> The patch below removes "option COMPAT_LINUX" and everything directly
> tied to it (kernel configuration, #ifdef sections, etc.) from the
> kernel tree and the corresponding man page documentation.
>
> Further, these files
>
>   sys/arch/i386/i386/linux_machdep.c
>   sys/arch/i386/include/linux_machdep.h
>   sys/sys/ioctl_compat.h
>   share/man/man8/compat_linux.8
>
> can be removed.  (Not part of the patch.)
>
> The actual compat/* code is left untouched since other components
> are still entangled with it.

ok guenther@



Re: kdump: drop Linux emulation

2016-02-27 Thread Philip Guenther
On Sat, Feb 27, 2016 at 2:20 PM, Christian Weisgerber
 wrote:
> This drops the support for Linux emulation from kdump(1).  It is
> functionally independent from the COMPAT_LINUX diff.
>
> I've left the -e switch in place, although there are now no other
> emulations available.

Good enough to remove the dependency on the header files that are
going away.  There's a bunch of emulation bits inside that can go
away, but that can be a second pass.

ok guenther@



tmpfs improvements

2016-02-27 Thread Michael McConville
 * EINVAL is returned in a case where there is insufficient memory.
   ENOMEM makes more sense. This one is ok natano@.

 * There wasn't yet a list of possible errors for tmpfs in mount(2).
   That said, I question the value of maintaining these lists. It's
   almost impossible for them to be comprehensive - for example, some
   *_mount() functions return the error value of library functions like
   copyin(9) and copyout(9) if they fail. Errors like ENOMEM are
   probably sufficiently self-explanatory to be excluded. These lists
   likely make sense for explaining anomalous errors, though.

   This one was was suggested by but not yet reviewed by natano@.

 * The KASSERT() on sys/tmpfs/tmpfs_vfsops.c:160 checks root against
   NULL after calling tmpfs_alloc_node(). However, tmpfs_alloc_node()
   only sets root on success, and in that case the value will always be
   non-null. We should therefore initialize root to NULL. We should
   maybe consider just returning tmpfs_alloc_node()'s error code instead
   of KASSERTing.

 * Replace a few bzeros with memset. Also ok natano@.


Index: lib/libc/sys/mount.2
===
RCS file: /cvs/src/lib/libc/sys/mount.2,v
retrieving revision 1.45
diff -u -p -r1.45 mount.2
--- lib/libc/sys/mount.223 Nov 2015 10:01:45 -  1.45
+++ lib/libc/sys/mount.227 Feb 2016 22:21:51 -
@@ -384,6 +384,18 @@ An I/O error occurred while writing cach
 .Fa dir
 points outside the process's allocated address space.
 .El
+.Pp
+The following errors can occur for a
+.Em tmpfs
+filesystem mount:
+.Bl -tag -width [ENOMEM]
+.It Bq Er ENOMEM
+There is not enough memory available to allocate the mount structures.
+.It Bq Er ENOTSUPP
+The
+.Dv MNT_UPDATE
+flag, which is not yet supported, was set.
+.El
 .Sh SEE ALSO
 .Xr statfs 2 ,
 .Xr mount 8 ,
Index: sys/tmpfs/tmpfs_vfsops.c
===
RCS file: /cvs/src/sys/tmpfs/tmpfs_vfsops.c,v
retrieving revision 1.8
diff -u -p -r1.8 tmpfs_vfsops.c
--- sys/tmpfs/tmpfs_vfsops.c13 Jan 2016 13:01:40 -  1.8
+++ sys/tmpfs/tmpfs_vfsops.c27 Feb 2016 22:21:55 -
@@ -87,7 +87,7 @@ tmpfs_mount(struct mount *mp, const char
 {
struct tmpfs_args args;
tmpfs_mount_t *tmp;
-   tmpfs_node_t *root;
+   tmpfs_node_t *root = NULL;
uint64_t memlimit;
uint64_t nodes;
int error;
@@ -120,7 +120,7 @@ tmpfs_mount(struct mount *mp, const char
 
/* Prohibit mounts if there is not enough memory. */
if (tmpfs_mem_info(1) < TMPFS_PAGES_RESERVED)
-   return EINVAL;
+   return ENOMEM;
 
error = copyin(data, , sizeof(struct tmpfs_args));
if (error)
@@ -180,9 +180,12 @@ tmpfs_mount(struct mount *mp, const char
 
mp->mnt_stat.mount_info.tmpfs_args = args;
 
-   bzero(>mnt_stat.f_mntonname, sizeof(mp->mnt_stat.f_mntonname));
-   bzero(>mnt_stat.f_mntfromname, sizeof(mp->mnt_stat.f_mntfromname));
-   bzero(>mnt_stat.f_mntfromspec, sizeof(mp->mnt_stat.f_mntfromspec));
+   memset(>mnt_stat.f_mntonname, 0,
+   sizeof(mp->mnt_stat.f_mntonname));
+   memset(>mnt_stat.f_mntfromname, 0,
+   sizeof(mp->mnt_stat.f_mntfromname));
+   memset(>mnt_stat.f_mntfromspec, 0,
+   sizeof(mp->mnt_stat.f_mntfromspec));
 
strlcpy(mp->mnt_stat.f_mntonname, path,
sizeof(mp->mnt_stat.f_mntonname) - 1);



ckqueue functions in lpq and lpd

2016-02-27 Thread Chris Bennett
I am having trouble seeing how these two functions are accomplshinig the
same thing, checking for control files in the spool.
These files always start with cf.

in lpd.c
makes sense to me.

/*
 * Make sure there's some work to do before forking off a child
 * XXX - could be common w/ lpq
 */
static int
ckqueue(char *cap)
{
struct dirent *d;
DIR *dirp;
char *spooldir;

if (cgetstr(cap, "sd", ) >= 0) {
dirp = opendir(spooldir);
free(spooldir);
} else
dirp = opendir(_PATH_DEFSPOOL);

if (dirp == NULL)
return (-1);
while ((d = readdir(dirp)) != NULL) {
if (d->d_name[0] == 'c' && d->d_name[1] == 'f') {
closedir(dirp);
return (1); /* found a cf file */
}
}
closedir(dirp);
return (0);
}


in lpq.c
does not make sense to me

/* XXX - could be common w/ lpd */
static int
ckqueue(char *cap)
{
struct dirent *d;
DIR *dirp;
char *spooldir;

if (cgetstr(cap, "sd", ) >= 0) {
dirp = opendir(spooldir);
free(spooldir);
} else
dirp = opendir(_PATH_DEFSPOOL);

if (dirp == NULL)
return (-1);
while ((d = readdir(dirp)) != NULL) {
if (d->d_name[0] != 'c' || d->d_name[1] != 'f')
continue;   /* daemon control files only */
closedir(dirp);
return (1); /* found something */
}
closedir(dirp);
return (0);
}


the line:
if (d->d_name[0] != 'c' || d->d_name[1] != 'f')
is excluding files that start with cf, yet then has the comment that daemon
controls files are found.
They both acccomplish the same thing of returning if there are files in the
spool.

Thanks,
Chris



kdump: drop Linux emulation

2016-02-27 Thread Christian Weisgerber
This drops the support for Linux emulation from kdump(1).  It is
functionally independent from the COMPAT_LINUX diff.

I've left the -e switch in place, although there are now no other
emulations available.


Index: kdump.1
===
RCS file: /cvs/src/usr.bin/kdump/kdump.1,v
retrieving revision 1.28
diff -u -p -r1.28 kdump.1
--- kdump.1 26 Feb 2016 21:46:39 -  1.28
+++ kdump.1 27 Feb 2016 22:02:29 -
@@ -62,8 +62,6 @@ By default, values are printed out in he
 .It Fl e Ar emulation
 Interpret system call maps assuming the named emulation instead of
 .Qq native .
-For example, to view trace output from a Linux binary, use
-.Fl e Ar linux .
 .It Fl f Ar file
 Display the specified file instead of
 .Pa ktrace.out .
Index: kdump.c
===
RCS file: /cvs/src/usr.bin/kdump/kdump.c,v
retrieving revision 1.120
diff -u -p -r1.120 kdump.c
--- kdump.c 10 Nov 2015 04:30:59 -  1.120
+++ kdump.c 27 Feb 2016 22:03:37 -
@@ -84,8 +84,6 @@ pid_t pid_opt = -1;
 
 #include 
 
-#include 
-
 #define KTRACE
 #define PTRACE
 #define NFSCLIENT
@@ -95,8 +93,6 @@ pid_t pid_opt = -1;
 #define SYSVSHM
 #define ACCOUNTING
 #include 
-
-#include 
 #undef KTRACE
 #undef PTRACE
 #undef NFSCLIENT
@@ -114,7 +110,6 @@ struct emulation {
 
 static struct emulation emulations[] = {
{ "native", syscallnames,   SYS_MAXSYSCALL },
-   { "linux",  linux_syscallnames, LINUX_SYS_MAXSYSCALL },
{ NULL, NULL,   0 }
 };
 
-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



arm: support Allwinner A20 Ethernet

2016-02-27 Thread Patrick Wildt
Hi,

the Allwinner A10 and A20 SoC include an EMAC, but it's only used in
few devices like the Cubieboard.  The A20, like the A31 and A80, contain
a GMAC, which is a Synopsys Designware controller.  This is commonly
used on the Banana Pi, Lamobo R1, Cubieboard 2 and more.  This diff
is the complete diff I worked on to support the GMAC.  It's based on
NetBSD's DWC driver plus some glue code.

Unfortunately this diff currently (probably) only works on the
Cubieboard 2, or devices similarly wired.  Not every device is wired
the same, and we currently have no way to distinguish A20 based devices.
Once we are able to parse a device tree it will be much easier to set up
the clock and tx delay per board.

Patrick

diff --git sys/arch/armv7/conf/GENERIC sys/arch/armv7/conf/GENERIC
index b55771d..6858d75 100644
--- sys/arch/armv7/conf/GENERIC
+++ sys/arch/armv7/conf/GENERIC
@@ -93,6 +93,7 @@ sxidog*   at sunxi?   # watchdog timer
 sxirtc*at sunxi?   # Real Time Clock
 sxiuart*   at sunxi?   # onboard UARTs
 sxie*  at sunxi?
+awge*  at sunxi?
 ahci*  at sunxi?   # AHCI/SATA (shim)
 ehci*  at sunxi?   # EHCI (shim)
 usb*   at ehci?#flags 0x1
diff --git sys/arch/armv7/conf/RAMDISK sys/arch/armv7/conf/RAMDISK
index 8c0c22b..d857d2b 100644
--- sys/arch/armv7/conf/RAMDISK
+++ sys/arch/armv7/conf/RAMDISK
@@ -91,6 +91,7 @@ sxidog*   at sunxi?   # watchdog timer
 sxirtc*at sunxi?   # Real Time Clock
 sxiuart*   at sunxi?   # onboard UARTs
 sxie*  at sunxi?
+awge*  at sunxi?
 ahci*  at sunxi?   # AHCI/SATA (shim)
 ehci*  at sunxi?   # EHCI (shim)
 usb*   at ehci?#flags 0x1
diff --git sys/arch/armv7/sunxi/files.sunxi sys/arch/armv7/sunxi/files.sunxi
index 80c4ba4..96f8832 100644
--- sys/arch/armv7/sunxi/files.sunxi
+++ sys/arch/armv7/sunxi/files.sunxi
@@ -48,3 +48,7 @@ file  arch/armv7/sunxi/sxiuart.c  sxiuart
 device sxie: ether, ifnet, mii, ifmedia
 attach sxie at sunxi
 file   arch/armv7/sunxi/sxie.c sxie
+
+# A20 GMAC
+attach awge at sunxi with sxige
+file   arch/armv7/sunxi/sxige.csxige
diff --git sys/arch/armv7/sunxi/sun7i.c sys/arch/armv7/sunxi/sun7i.c
index 53978f3..73ecd24 100644
--- sys/arch/armv7/sunxi/sun7i.c
+++ sys/arch/armv7/sunxi/sun7i.c
@@ -100,12 +100,11 @@ struct armv7_dev sxia20_devs[] = {
  .irq = { UART7_IRQ }
},
 
-   /* EMAC */
-   { .name = "sxie",
+   /* GMAC */
+   { .name = "awge",
  .unit = 0,
- .mem = {  { EMAC_ADDR, EMAC_SIZE },
-   { SXIESRAM_ADDR, SXIESRAM_SIZE } },
- .irq = { EMAC_IRQ}
+ .mem = { { GMAC_ADDR, GMAC_SIZE } },
+ .irq = { GMAC_IRQ }
},
 
/* SATA/AHCI */
diff --git sys/arch/armv7/sunxi/sunxi.c sys/arch/armv7/sunxi/sunxi.c
index dac0348..256169e 100644
--- sys/arch/armv7/sunxi/sunxi.c
+++ sys/arch/armv7/sunxi/sunxi.c
@@ -77,7 +77,7 @@ struct board_dev sun7i_devs[] = {
{ "sxiuart",5 },
{ "sxiuart",6 },
{ "sxiuart",7 },
-   { "sxie",   0 },
+   { "awge",   0 },
{ "ahci",   0 },
{ "ehci",   0 },
{ "ehci",   1 },
diff --git sys/arch/armv7/sunxi/sxiccmu.c sys/arch/armv7/sunxi/sxiccmu.c
index ddfc415..16481a1 100644
--- sys/arch/armv7/sunxi/sxiccmu.c
+++ sys/arch/armv7/sunxi/sxiccmu.c
@@ -64,6 +64,24 @@
 #defineCCMU_AHB_GATING_EMAC(1 << 17)
 #defineCCMU_AHB_GATING_SATA(1 << 25)
 
+#defineCCMU_AHB_GATING10x64
+#defineCCMU_AHB_GATING_MALI400 (1 << 20)
+#defineCCMU_AHB_GATING_MP  (1 << 18)
+#defineCCMU_AHB_GATING_GMAC(1 << 17)
+#defineCCMU_AHB_GATING_DE_FE1  (1 << 15)
+#defineCCMU_AHB_GATING_DE_FE0  (1 << 14)
+#defineCCMU_AHB_GATING_DE_BE1  (1 << 13)
+#defineCCMU_AHB_GATING_DE_BE0  (1 << 12)
+#defineCCMU_AHB_GATING_HDMI(1 << 11)
+#defineCCMU_AHB_GATING_CSI1(1 << 9)
+#defineCCMU_AHB_GATING_CSI0(1 << 8)
+#defineCCMU_AHB_GATING_LCD1(1 << 5)
+#defineCCMU_AHB_GATING_LCD0(1 << 4)
+#defineCCMU_AHB_GATING_TVE1(1 << 3)
+#defineCCMU_AHB_GATING_TVE0(1 << 2)
+#defineCCMU_AHB_GATING_TVD (1 << 1)
+#defineCCMU_AHB_GATING_VE  (1 << 0)
+
 #defineCCMU_APB_GATING00x68
 #defineCCMU_APB_GATING_PIO (1 << 5)
 #defineCCMU_APB_GATING10x6c
@@ -89,6 +107,20 @@
 #defineCCMU_USB1_RESET (1 << 1)
 #defineCCMU_USB0_RESET (1 << 0)
 

Re: diff -e: mishandling of bare dots

2016-02-27 Thread Martin Natano
Last chance to voice objections. I plan to commit this in the next days.

natano


> Index: diffreg.c
> ===
> RCS file: /cvs/src/usr.bin/diff/diffreg.c,v
> retrieving revision 1.90
> diff -u -p -r1.90 diffreg.c
> --- diffreg.c 26 Oct 2015 12:52:27 -  1.90
> +++ diffreg.c 21 Feb 2016 16:01:43 -
> @@ -1075,8 +1075,9 @@ proceed:
>* back and restart where we left off.
>*/
>   diff_output(".\n");
> - diff_output("%ds/.//\n", a);
> - a += i;
> + diff_output("%ds/.//\n", a + i - 1);
> + b = a + i - 1;
> + a = b + 1;
>   c += i;
>   goto restart;
>   }
> 



Re: Correct error number in crypto(9)

2016-02-27 Thread Michael McConville
Mike Belopuhov wrote:
> On 27 February 2016 at 08:21, Michael McConville  wrote:
> > Michael McConville wrote:
> >> Michael McConville wrote:
> >> > Does this make sense?
> >>
> >> I just realized that the allocation failure checks earlier in the
> >> function return ENOBUFS. This probably makes more sense for the sake of
> >> consistency.
> >
> > The best I can tell, the only use of this function is in
> > sys/crypto/crypto.c:157. It's accessed through a pointer stored in a
> > struct by crypto_register(). That usage doesn't seem to be affected
> > by the below change, considering that the outcome would be no
> > different than that of the other ENOBUFS failures above it.
> >
> 
> So why change it to ENOMEM then?  Nothing there returns it.
> I think this is just needless churn.

I was proposing to change it from EINVAL to ENOBUFS.

I don't think it's churn. The current returned error code seems
objectively wrong to me, and all other allocation failures in this
function return ENOBUFS. deraadt supported it but asked me to ensure
that it wouldn't affect downstream error handling.



Re: Fix overflow check in sys/netinet6/in6.c

2016-02-27 Thread Stefan Kempf
Martin Pieuchot wrote:
> On 17/02/16(Wed) 20:38, Stefan Kempf wrote:
> > Martin Pieuchot wrote:
> > It looks like NetBSD removed the SIOCSIFALIFETIME_IN6 ioctl a long time
> > ago, along with the overflow checks, saying that this ioctl could never
> > have worked:
> > http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/netinet6/in6.c?rev=1.132=text/x-cvsweb-markup_with_tag=MAIN
> 
> Indeed we should remove it as well.

Here's a diff to remove this ioctl, now that the tree is unlocked.
Nothing in base uses it.

ok?

Index: netinet6/in6.c
===
RCS file: /cvs/src/sys/netinet6/in6.c,v
retrieving revision 1.183
diff -u -p -r1.183 in6.c
--- netinet6/in6.c  21 Jan 2016 11:23:48 -  1.183
+++ netinet6/in6.c  27 Feb 2016 17:24:02 -
@@ -253,7 +253,6 @@ in6_control(struct socket *so, u_long cm
case SIOCSPFXFLUSH_IN6:
case SIOCSRTRFLUSH_IN6:
case SIOCGIFALIFETIME_IN6:
-   case SIOCSIFALIFETIME_IN6:
case SIOCGIFSTAT_IN6:
case SIOCGIFSTAT_ICMP6:
sa6 = >ifr_addr;
@@ -337,26 +336,6 @@ in6_control(struct socket *so, u_long cm
if (ia6 == NULL)
return (EADDRNOTAVAIL);
break;
-   case SIOCSIFALIFETIME_IN6:
-   {
-   struct in6_addrlifetime *lt;
-
-   if (!privileged)
-   return (EPERM);
-   if (ia6 == NULL)
-   return (EADDRNOTAVAIL);
-   /* sanity for overflow - beware unsigned */
-   lt = >ifr_ifru.ifru_lifetime;
-   if (lt->ia6t_vltime != ND6_INFINITE_LIFETIME
-&& lt->ia6t_vltime + time_second < time_second) {
-   return EINVAL;
-   }
-   if (lt->ia6t_pltime != ND6_INFINITE_LIFETIME
-&& lt->ia6t_pltime + time_second < time_second) {
-   return EINVAL;
-   }
-   break;
-   }
}
 
switch (cmd) {
@@ -425,21 +404,6 @@ in6_control(struct socket *so, u_long cm
} else
retlt->ia6t_preferred = maxexpire;
}
-   break;
-
-   case SIOCSIFALIFETIME_IN6:
-   ia6->ia6_lifetime = ifr->ifr_ifru.ifru_lifetime;
-   /* for sanity */
-   if (ia6->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
-   ia6->ia6_lifetime.ia6t_expire =
-   time_second + ia6->ia6_lifetime.ia6t_vltime;
-   } else
-   ia6->ia6_lifetime.ia6t_expire = 0;
-   if (ia6->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
-   ia6->ia6_lifetime.ia6t_preferred =
-   time_second + ia6->ia6_lifetime.ia6t_pltime;
-   } else
-   ia6->ia6_lifetime.ia6t_preferred = 0;
break;
 
case SIOCAIFADDR_IN6:
Index: netinet6/in6_var.h
===
RCS file: /cvs/src/sys/netinet6/in6_var.h,v
retrieving revision 1.59
diff -u -p -r1.59 in6_var.h
--- netinet6/in6_var.h  21 Jan 2016 11:23:48 -  1.59
+++ netinet6/in6_var.h  27 Feb 2016 17:24:02 -
@@ -405,7 +405,6 @@ struct  in6_rrenumreq {
 #define SIOCSRTRFLUSH_IN6  _IOWR('i', 80, struct in6_ifreq)
 
 #define SIOCGIFALIFETIME_IN6   _IOWR('i', 81, struct in6_ifreq)
-#define SIOCSIFALIFETIME_IN6   _IOWR('i', 82, struct in6_ifreq)
 #define SIOCGIFSTAT_IN6_IOWR('i', 83, struct in6_ifreq)
 #define SIOCGIFSTAT_ICMP6  _IOWR('i', 84, struct in6_ifreq)
 



pkg_info(1): fix return value description for -e

2016-02-27 Thread Patrik Lundin
Hello,

The '-e' option to pkg_info is currently described in the following way:
===
If the package identified by pkg-name is not currently installed, return
0, otherwise return 1.
===

However, it behaves the other way around:
===
$ pkg_info -e 'vim-*-no_x11' 
inst:vim-7.4.900-no_x11
$ echo $?
0

$ pkg_info -e 'vim-*-no_x12'
$ echo $?
1
===

Diff to man page below (removing a negation always feels good).

-- 
Patrik Lundin

Index: pkg_info.1
===
RCS file: /cvs/src/usr.sbin/pkg_add/pkg_info.1,v
retrieving revision 1.51
diff -u -p -u -r1.51 pkg_info.1
--- pkg_info.1  7 Oct 2015 17:52:38 -   1.51
+++ pkg_info.1  27 Feb 2016 16:41:45 -
@@ -87,7 +87,7 @@ allows you to test for the presence of a
 prerequisite) package from a script.
 If the package identified by
 .Ar pkg-name
-is not currently installed, return 0, otherwise return 1.
+is currently installed, return 0, otherwise return 1.
 In addition, the names of any package(s) found installed are printed to
 stdout unless turned off using the
 .Fl q



zaurus: mistyped constant in zboot code

2016-02-27 Thread Christian Weisgerber
This very much looks like a typo in the zboot code.
Anybody with a Zaurus want to test?

Index: compat_linux.h
===
RCS file: /cvs/src/sys/arch/zaurus/stand/zboot/compat_linux.h,v
retrieving revision 1.8
diff -u -p -r1.8 compat_linux.h
--- compat_linux.h  16 Jun 2007 00:26:33 -  1.8
+++ compat_linux.h  27 Feb 2016 16:41:58 -
@@ -66,7 +66,7 @@ struct proc;
 #define CS8LINUX_CS8
 
 #define TIOCGETA   LINUX_TCGETS
-#define TIOCSETA   LINUX_TCGETS
+#define TIOCSETA   LINUX_TCSETS
 #define TIOCSETAW  LINUX_TCSETSW
 #define TIOCSETAF  LINUX_TCSETSF
 
-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



Re: arm: store curcpu pointer in thread id register

2016-02-27 Thread Patrick Wildt
On Fri, Feb 26, 2016 at 08:59:41PM -0800, Philip Guenther wrote:
> On Sat, Feb 20, 2016 at 1:49 PM, Patrick Wildt  wrote:
> > since ARMv6 the coprocessor provides special registers to store software
> > defined values.  Those registers are:
> >
> >   * TPIDRURW -> kernel RW, user RW
> >   * TPIDRURO -> kernel RW, user RO
> >   * TPIDRPRW -> kernel RW
> >
> > TPIDRPRW is typically used to store the pointer to the curcpu struct,
> > while TPIDRURO is used to point to the TCB.
> >
> > The following diff implements using TPIDRPRW to store and retrieve the
> > curcpu struct pointer.  This will especially be helpful in future MP
> > efforts.  I have guarded it for ARMv7 only, as that's the only hardware
> > I have that supports it and I was able to test on.
> 
> I don't know arm, but of those choices that makes sense.
> 
> 
> > If TCB_GET()'s only user is libpthread, then it could make sense to
> > store the TCB pointer in TPIDRURO.  If it's possible that it's also
> > used in ports, then the arm packages won't be compatible to
> > armish/zaurus anymore.  But the TCB stuff is not part of this diff.
> 
> The userland bits in  should match the platform's ABI
> for the thread register.  The last time I tried to figure this out
> from the arm ABI docs I wanted to stab someone, but I was hopefully
> just looking at the wrong docs.  Looking at the bits in FreeBSD I see
> 
> static inline void
> set_tls(void *tls)
> {
> __asm __volatile("mcr p15, 0, %0, c13, c0, 3" : : "r" (tls));
> }
> 
> so, uh, whichever register that sets is presumably the correct one for 
> userland.

Yep, that's TPIDRURO.  It's not a lot of work to use this register, but
it might just not work out as zaurus and armv7 use the same packages.

> 
> (What is it with the arm docs giving N names to registers without a
> "here's the mapping" table splatted somewhere obvious?)

No idea.  ARM's "Infocenter" is really hard to read.  Instead I always
have a copy of the ARM ARM and Cortex-XX PDFs around.

> 
> 
> Philip Guenther
> 



Remove option COMPAT_LINUX

2016-02-27 Thread Christian Weisgerber
Support for running Linux binaries under emulation is going away.

The patch below removes "option COMPAT_LINUX" and everything directly
tied to it (kernel configuration, #ifdef sections, etc.) from the
kernel tree and the corresponding man page documentation.

Further, these files

  sys/arch/i386/i386/linux_machdep.c
  sys/arch/i386/include/linux_machdep.h
  sys/sys/ioctl_compat.h
  share/man/man8/compat_linux.8

can be removed.  (Not part of the patch.)

The actual compat/* code is left untouched since other components
are still entangled with it.


Index: sys/arch/i386/conf/GENERIC
===
RCS file: /cvs/src/sys/arch/i386/conf/GENERIC,v
retrieving revision 1.811
diff -u -p -r1.811 GENERIC
--- sys/arch/i386/conf/GENERIC  11 Jan 2016 22:00:16 -  1.811
+++ sys/arch/i386/conf/GENERIC  27 Feb 2016 14:32:50 -
@@ -24,8 +24,6 @@ optionMTRR# CPU memory range 
attribu
 #optionKGDB# Remote debugger support; exclusive of 
DDB
 #option"KGDB_DEVNAME=\"com\"",KGDBADDR=0x2f8,KGDBRATE=9600
 
-option COMPAT_LINUX# binary compatibility with Linux
-
 option NTFS# NTFS support
 option HIBERNATE   # Hibernate support
 
Index: sys/arch/i386/conf/files.i386
===
RCS file: /cvs/src/sys/arch/i386/conf/files.i386,v
retrieving revision 1.228
diff -u -p -r1.228 files.i386
--- sys/arch/i386/conf/files.i386   8 Jan 2016 15:54:13 -   1.228
+++ sys/arch/i386/conf/files.i386   27 Feb 2016 14:33:30 -
@@ -258,10 +258,6 @@ file   arch/i386/i386/vm86.c   vm86
 file   arch/i386/i386/kvm86.c  kvm86
 file   arch/i386/i386/kvm86call.S  kvm86
 
-# Linux binary compatibility (COMPAT_LINUX)
-include "compat/linux/files.linux"
-file   arch/i386/i386/linux_machdep.c  compat_linux
-
 device bios {}
 attach bios at mainbus
 file   arch/i386/i386/bios.c   bios needs-count
Index: sys/arch/i386/i386/genassym.cf
===
RCS file: /cvs/src/sys/arch/i386/i386/genassym.cf,v
retrieving revision 1.37
diff -u -p -r1.37 genassym.cf
--- sys/arch/i386/i386/genassym.cf  12 Apr 2015 18:37:53 -  1.37
+++ sys/arch/i386/i386/genassym.cf  27 Feb 2016 14:34:19 -
@@ -48,10 +48,6 @@ include 
 include 
 include 
 
-if COMPAT_LINUX > 0
-include 
-endif
-
 if MULTIPROCESSOR
 include 
 endif
@@ -131,14 +127,6 @@ struct mbuf
 member m_next
 member m_data
 member m_len
-
-# Linux frame offsets
-ifdef COMPAT_LINUX
-struct linux_sigframe  LINUX_SIGF_
-member HANDLER sf_handler
-member SC  sf_sc
-struct linux_sigcontextLINUX_
-endif
 
 # Interrupt metering
 if NISA > 0
Index: sys/arch/i386/i386/locore.s
===
RCS file: /cvs/src/sys/arch/i386/i386/locore.s,v
retrieving revision 1.163
diff -u -p -r1.163 locore.s
--- sys/arch/i386/i386/locore.s 26 Feb 2016 02:25:09 -  1.163
+++ sys/arch/i386/i386/locore.s 27 Feb 2016 14:36:51 -
@@ -46,9 +46,6 @@
 
 #include 
 #include 
-#ifdef COMPAT_LINUX
-#include 
-#endif
 
 #include 
 #include 
@@ -704,27 +701,6 @@ NENTRY(sigcode)
int $0x80   # exit if sigreturn fails
.globl  _C_LABEL(esigcode)
 _C_LABEL(esigcode):
-
-/*/
-
-/*/
-
-#ifdef COMPAT_LINUX
-/*
- * Signal trampoline; copied to top of user stack.
- */
-NENTRY(linux_sigcode)
-   call*LINUX_SIGF_HANDLER(%esp)
-   lealLINUX_SIGF_SC(%esp),%ebx # scp (the call may have clobbered the
-   # copy at SIGF_SCP(%esp))
-   pushl   %eax# junk to fake return address
-   movl$LINUX_SYS_sigreturn,%eax
-   int $0x80   # enter kernel with args on stack
-   movl$LINUX_SYS_exit,%eax
-   int $0x80   # exit if sigreturn fails
-   .globl  _C_LABEL(linux_esigcode)
-_C_LABEL(linux_esigcode):
-#endif
 
 /*/
 
Index: sys/arch/i386/i386/trap.c
===
RCS file: /cvs/src/sys/arch/i386/i386/trap.c,v
retrieving revision 1.123
diff -u -p -r1.123 trap.c
--- sys/arch/i386/i386/trap.c   28 Jun 2015 01:11:27 -  1.123
+++ sys/arch/i386/i386/trap.c   27 Feb 2016 14:38:07 -
@@ -67,10 +67,6 @@
 #endif
 
 #include 
-#ifdef COMPAT_LINUX
-#include 
-extern struct emul emul_linux_elf;
-#endif
 #ifdef KVM86
 #include 
 #define KVM86MODE (kvm86_incall)
@@ -582,11 +578,6 @@ syscall(struct trapframe *frame)
 
switch 

Re: /32 routes don't stick

2016-02-27 Thread Matthieu Herrb
On Sat, Feb 27, 2016 at 03:20:49PM +0100, Martin Pieuchot wrote:
> On 26/02/16(Fri) 17:38, Matthieu Herrb wrote:
> > My hosting ISP is using a routing model where every machine has
> > a IP address with a /32 mask and uses a default route specificed at
> > the link level.
> [...]
> > For OpenBSD this setup maps to
> > 
> > hostname.em0:
> > 
> > inet 92.224.149.DDD/32
> > ! route add 91.224.148.0/32 -link -iface em0
> > 
> > /etc/mygate:
> > 
> > 91.224.148.0
> > 
> > While this works when configured manually (an ARP request is generated
> > by the route add -link command and both the ARP and route entries show
> > up), it tends to not beeing stable (ie the default route disapears):
> > 
> > 1. on boot while I explicitely see the '! route' command output in
> >   dmesg -s, the default route doesn't work after the boot, the /32
> >   route has disapeared once the machine reaches the login: prompt to
> >   let me connect on console and check it. If I run the command manualy
> >   again, the route becomes active again and is useable.
> >   So it seems that something flushes the ARP table after executing the
> >   route command in /etc/hostname.if
> > 
> > 2. but if I quiese the network for 20mn to let the ARP entry for the
> >   router time out, then again the associated route disapears.
> > 
> > I can work around these problems by putting a permanent ARP entry for
> > the router in rc.local, but I'd like to know if there isn't some kind
> > of bug that needs to be fixed there.
> > 
> > This kind of routing setup seems popular among cloud style VM hosting
> > providers, and with the growing support for running OpenBSD as a
> > guest, I guess this is going to become a more frequent issue.
> 
> The problem here is that you're generating the route entry manually so
> when the ARP timer will expire the entry will be removed.

Yes that matches my analysis.
> 
> Instead of adding a "link" entry I would add a cloning route that will
> generate it.  The first diff below changes route(8) to not add a
> RTF_GATEWAY flag when creating a RTF_CLONING entry.  With it you should
> be able to add a working cloning route with:
> 
> # route add 91.224.148.0 -netmask 255.255.255.255 -cloning 92.224.149.DDD
> 
> Note that the CIDR notation wont work due to another route(8)
> limitation.

Yes with your first patch that works.
> 
> If this approach is acceptable, the second diff makes sure RTF_CLONING
> is never set with RTF_GATEWAY or RTF_HOST.  Claudio do you think this
> could have any drawback?

I've also included it in the kernel on that machine for testing.

> 
> Index: route.c
> ===
> RCS file: /cvs/src/sbin/route/route.c,v
> retrieving revision 1.182
> diff -u -p -r1.182 route.c
> --- route.c   3 Dec 2015 08:00:49 -   1.182
> +++ route.c   27 Feb 2016 14:02:56 -
> @@ -629,7 +629,7 @@ newroute(int argc, char **argv)
>   flags |= RTF_UP;
>   if (ishost)
>   flags |= RTF_HOST;
> - if (iflag == 0)
> + if (iflag == 0 && !(flags & RTF_CLONING))
>   flags |= RTF_GATEWAY;
>   for (attempts = 1; ; attempts++) {
>   errno = 0;
> 
> 
> 
> 
> Index: net/rtsock.c
> ===
> RCS file: /cvs/src/sys/net/rtsock.c,v
> retrieving revision 1.186
> diff -u -p -r1.186 rtsock.c
> --- net/rtsock.c  12 Jan 2016 09:27:46 -  1.186
> +++ net/rtsock.c  27 Feb 2016 14:09:56 -
> @@ -558,6 +558,12 @@ route_output(struct mbuf *m, ...)
>   rtm->rtm_flags &= ~(RTF_DONE|RTF_CLONED);
>   rtm->rtm_fmask &= RTF_FMASK;
>  
> + if ((rtm->rtm_flags & (RTF_CLONING|RTF_GATEWAY|RTF_HOST)) ==
> + (RTF_CLONING|RTF_GATEWAY|RTF_HOST)) {
> + error = EINVAL;
> + goto fail;
> + }
> +
>   if (rtm->rtm_priority != 0) {
>   if (rtm->rtm_priority > RTP_MAX ||
>   rtm->rtm_priority == RTP_LOCAL) {

-- 
Matthieu Herrb


signature.asc
Description: PGP signature


Re: /32 routes don't stick

2016-02-27 Thread Martin Pieuchot
On 26/02/16(Fri) 17:38, Matthieu Herrb wrote:
> My hosting ISP is using a routing model where every machine has
> a IP address with a /32 mask and uses a default route specificed at
> the link level.
[...]
> For OpenBSD this setup maps to
> 
> hostname.em0:
> 
> inet 92.224.149.DDD/32
> ! route add 91.224.148.0/32 -link -iface em0
> 
> /etc/mygate:
> 
> 91.224.148.0
> 
> While this works when configured manually (an ARP request is generated
> by the route add -link command and both the ARP and route entries show
> up), it tends to not beeing stable (ie the default route disapears):
> 
> 1. on boot while I explicitely see the '! route' command output in
>   dmesg -s, the default route doesn't work after the boot, the /32
>   route has disapeared once the machine reaches the login: prompt to
>   let me connect on console and check it. If I run the command manualy
>   again, the route becomes active again and is useable.
>   So it seems that something flushes the ARP table after executing the
>   route command in /etc/hostname.if
> 
> 2. but if I quiese the network for 20mn to let the ARP entry for the
>   router time out, then again the associated route disapears.
> 
> I can work around these problems by putting a permanent ARP entry for
> the router in rc.local, but I'd like to know if there isn't some kind
> of bug that needs to be fixed there.
> 
> This kind of routing setup seems popular among cloud style VM hosting
> providers, and with the growing support for running OpenBSD as a
> guest, I guess this is going to become a more frequent issue.

The problem here is that you're generating the route entry manually so
when the ARP timer will expire the entry will be removed.

Instead of adding a "link" entry I would add a cloning route that will
generate it.  The first diff below changes route(8) to not add a
RTF_GATEWAY flag when creating a RTF_CLONING entry.  With it you should
be able to add a working cloning route with:

# route add 91.224.148.0 -netmask 255.255.255.255 -cloning 92.224.149.DDD

Note that the CIDR notation wont work due to another route(8) limitation.

If this approach is acceptable, the second diff makes sure RTF_CLONING
is never set with RTF_GATEWAY or RTF_HOST.  Claudio do you think this
could have any drawback?

Index: route.c
===
RCS file: /cvs/src/sbin/route/route.c,v
retrieving revision 1.182
diff -u -p -r1.182 route.c
--- route.c 3 Dec 2015 08:00:49 -   1.182
+++ route.c 27 Feb 2016 14:02:56 -
@@ -629,7 +629,7 @@ newroute(int argc, char **argv)
flags |= RTF_UP;
if (ishost)
flags |= RTF_HOST;
-   if (iflag == 0)
+   if (iflag == 0 && !(flags & RTF_CLONING))
flags |= RTF_GATEWAY;
for (attempts = 1; ; attempts++) {
errno = 0;




Index: net/rtsock.c
===
RCS file: /cvs/src/sys/net/rtsock.c,v
retrieving revision 1.186
diff -u -p -r1.186 rtsock.c
--- net/rtsock.c12 Jan 2016 09:27:46 -  1.186
+++ net/rtsock.c27 Feb 2016 14:09:56 -
@@ -558,6 +558,12 @@ route_output(struct mbuf *m, ...)
rtm->rtm_flags &= ~(RTF_DONE|RTF_CLONED);
rtm->rtm_fmask &= RTF_FMASK;
 
+   if ((rtm->rtm_flags & (RTF_CLONING|RTF_GATEWAY|RTF_HOST)) ==
+   (RTF_CLONING|RTF_GATEWAY|RTF_HOST)) {
+   error = EINVAL;
+   goto fail;
+   }
+
if (rtm->rtm_priority != 0) {
if (rtm->rtm_priority > RTP_MAX ||
rtm->rtm_priority == RTP_LOCAL) {



Re: Correct error number in crypto(9)

2016-02-27 Thread Mike Belopuhov
On 27 February 2016 at 08:21, Michael McConville  wrote:
> Michael McConville wrote:
>> Michael McConville wrote:
>> > Does this make sense?
>>
>> I just realized that the allocation failure checks earlier in the
>> function return ENOBUFS. This probably makes more sense for the sake of
>> consistency.
>
> The best I can tell, the only use of this function is in
> sys/crypto/crypto.c:157. It's accessed through a pointer stored in a
> struct by crypto_register(). That usage doesn't seem to be affected by
> the below change, considering that the outcome would be no different
> than that of the other ENOBUFS failures above it.
>

So why change it to ENOMEM then?  Nothing there returns it.
I think this is just needless churn.



[patch] add UTF-8 support to column(1)

2016-02-27 Thread Martijn van Duren
Hello tech@,

Here's my attempt to implement UTF-8 support in column(1).
Besides the general UTF-8 conversions it does several other things to 
make it behave properly. Full changelist is as follow:
- Make separator and input full UTF-8 aware.
- Do proper character width count. This also fixes some indentation 
issues where the old code assumed that a tab also was one column wide.
- Replace tabs between columns with spaces. The old code worked fine, 
but with UTF-8 and oxtabs in stty enabled the column positioning can get
way off, and we can't expect everyone to run with "stty -oxtabs". Found
with the help of nicm@.

OK? 

martijn@

Index: column.c
===
RCS file: /cvs/src/usr.bin/column/column.c,v
retrieving revision 1.22
diff -u -p -r1.22 column.c
--- column.c3 Nov 2015 04:55:44 -   1.22
+++ column.c27 Feb 2016 12:21:35 -
@@ -36,15 +36,24 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
+#include 
+
+struct li {
+   int  width;
+   char*str;
+};
 
 void  c_columnate(void);
 void *ereallocarray(void *, size_t, size_t);
 void *ecalloc(size_t, size_t);
 void  input(FILE *);
+int   isu8start(unsigned char);
 void  maketbl(void);
 void  print(void);
 void  r_columnate(void);
@@ -54,9 +63,9 @@ int termwidth = 80;   /* default terminal
 
 int entries;   /* number of records */
 int eval;  /* exit value */
-int maxlength; /* longest record */
-char **list;   /* array of pointers to records */
-char *separator = "\t ";   /* field separator for table option */
+int maxwidth;  /* longest record */
+struct li *list;   /* array of  to records */
+wchar_t *separator = L"\t ";   /* field separator for table option */
 
 int
 main(int argc, char *argv[])
@@ -66,6 +75,7 @@ main(int argc, char *argv[])
int ch, tflag, xflag;
char *p;
const char *errstr;
+   int slen;
 
if (ioctl(1, TIOCGWINSZ, ) == -1 || !win.ws_col) {
if ((p = getenv("COLUMNS")) && *p != '\0') {
@@ -79,6 +89,8 @@ main(int argc, char *argv[])
if (pledge("stdio rpath", NULL) == -1)
err(1, "pledge");
 
+   setlocale(LC_CTYPE, "");
+
tflag = xflag = 0;
while ((ch = getopt(argc, argv, "c:s:tx")) != -1)
switch(ch) {
@@ -88,7 +100,13 @@ main(int argc, char *argv[])
errx(1, "%s: %s", errstr, optarg);
break;
case 's':
-   separator = optarg;
+   slen = strlen(optarg)+1;
+   if ((separator = reallocarray(NULL, slen,
+   sizeof(*separator))) == NULL)
+   err(1, NULL);
+   if (mbstowcs(separator, optarg,
+   slen * sizeof(*separator)) == (size_t)-1)
+   err(1, "Unable to set separator");
break;
case 't':
tflag = 1;
@@ -125,69 +143,59 @@ main(int argc, char *argv[])
 
if (tflag)
maketbl();
-   else if (maxlength >= termwidth)
+   else if (maxwidth >= termwidth)
print();
else if (xflag)
c_columnate();
else
r_columnate();
-   exit(eval);
+   return eval;
 }
 
 #defineTAB 8
 void
 c_columnate(void)
 {
-   int chcnt, col, cnt, endcol, numcols;
-   char **lp;
+   int col, numcols;
+   struct li *lp;
 
-   maxlength = (maxlength + TAB) & ~(TAB - 1);
-   numcols = termwidth / maxlength;
-   endcol = maxlength;
-   for (chcnt = col = 0, lp = list;; ++lp) {
-   chcnt += printf("%s", *lp);
+   maxwidth = (maxwidth + TAB) & ~(TAB - 1);
+   if ((numcols = termwidth / maxwidth) == 0)
+   numcols = 1;
+   for (col = 0, lp = list;; ++lp) {
+   printf("%s", lp->str);
if (!--entries)
break;
if (++col == numcols) {
-   chcnt = col = 0;
-   endcol = maxlength;
+   col = 0;
putchar('\n');
} else {
-   while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) <= endcol) {
-   (void)putchar('\t');
-   chcnt = cnt;
-   }
-   endcol += maxlength;
+   while (lp->width++ < maxwidth)
+   (void)putchar(' ');
}
}
-   if (chcnt)
-   putchar('\n');
+   putchar('\n');
 }
 
 void
 r_columnate(void)
 {
-   int base, chcnt, cnt, col, endcol, numcols, numrows, row;
+   int base, 

TSIG authentication in libasr

2016-02-27 Thread Peter J. Philipp
Hi,

I have a patch for TSIG authentication in libasr.  It is enabled by the "tsig"
keyword in /etc/resolv.conf.  My /etc/resolv.conf looks like this:

search centroid.eu
#nameserver 192.168.34.1
nameserver 200.46.208.61
tsig secret-key.:DONTTRY
lookup file bind

The HMAC over the TSIG is SHA256-HMAC by default but this can be expanded if
willed.

I have tested this by relinking ping and running chrome on websites that I
never visited before, it works.  If you need help setting this up on a BIND
nameserver so that it can recurse a TSIG authenticated lookup, let me know
I can share my example.

The code follows.  If there is an interest for this, I'll clean it up and 
write a manpage, I worked on getting this working as a start.


? asr.patch
Index: asr.c
===
RCS file: /cvs/src/lib/libc/asr/asr.c,v
retrieving revision 1.50
diff -u -p -u -r1.50 asr.c
--- asr.c   16 Dec 2015 16:32:30 -  1.50
+++ asr.c   27 Feb 2016 10:26:33 -
@@ -527,6 +527,7 @@ pass0(char **tok, int n, struct asr_ctx 
 {
int  i, j, d;
const char  *e;
+   char*p;
struct sockaddr_storage ss;
 
if (!strcmp(tok[0], "nameserver")) {
@@ -548,6 +549,32 @@ pass0(char **tok, int n, struct asr_ctx 
return;
ac->ac_domain = strdup(tok[1]);
 
+   } else if (!strcmp(tok[0], "tsig")) {
+   if (n != 2)
+   return;
+   if (ac->ac_use_tsig)
+   return;
+
+   p = strchr(tok[1], ':');
+   if (p == NULL)
+   return;
+
+   *p = '\0';
+   if (_asr_dname_from_fqdn(tok[1], ac->ac_tsig_key, 
sizeof(ac->ac_tsig_key)) == -1)
+   return;
+
+   /* RFC 4635 */
+   if (_asr_dname_from_fqdn("hmac-sha256.", ac->ac_dn_algorithm, 
sizeof(ac->ac_dn_algorithm)) == -1)
+   return;
+
+   p++;
+   ac->ac_use_tsig = 1;
+   
+   ac->ac_dn_algorithm_len = strlen(ac->ac_dn_algorithm);
+   ac->ac_algorithm_size = 32;
+
+   ac->ac_tsig_password = strdup(p);
+   
} else if (!strcmp(tok[0], "lookup")) {
/* ensure that each lookup is only given once */
for (i = 1; i < n; i++)
Index: asr_private.h
===
RCS file: /cvs/src/lib/libc/asr/asr_private.h,v
retrieving revision 1.38
diff -u -p -u -r1.38 asr_private.h
--- asr_private.h   16 Dec 2015 16:32:30 -  1.38
+++ asr_private.h   27 Feb 2016 10:26:33 -
@@ -135,7 +135,13 @@ struct asr_ctx {
int  ac_nstimeout;
int  ac_nsretries;
struct sockaddr *ac_ns[ASR_MAXNS];
-
+   /* pjp below */
+   int  ac_use_tsig;
+   char*ac_tsig_password;
+   char ac_tsig_key[MAXDNAME];
+   char ac_dn_algorithm[MAXDNAME];
+   int  ac_dn_algorithm_len;
+   int  ac_algorithm_size;
 };
 
 struct asr {
@@ -301,6 +307,7 @@ __BEGIN_HIDDEN_DECLS
 void _asr_pack_init(struct asr_pack *, char *, size_t);
 int _asr_pack_header(struct asr_pack *, const struct asr_dns_header *);
 int _asr_pack_query(struct asr_pack *, uint16_t, uint16_t, const char *);
+int _asr_tsig_query(struct asr_pack *, const struct asr_dns_header *, struct 
asr_ctx *, const char *, uint16_t);
 void _asr_unpack_init(struct asr_unpack *, const char *, size_t);
 int _asr_unpack_header(struct asr_unpack *, struct asr_dns_header *);
 int _asr_unpack_query(struct asr_unpack *, struct asr_dns_query *);
@@ -308,6 +315,7 @@ int _asr_unpack_rr(struct asr_unpack *, 
 int _asr_sockaddr_from_str(struct sockaddr *, int, const char *);
 ssize_t _asr_dname_from_fqdn(const char *, char *, size_t);
 ssize_t _asr_addr_as_fqdn(const char *, int, char *, size_t);
+void _asr_hmac_sha256(u_char *text, int text_len, u_char *key, int key_len, 
char *digest);
 
 /* asr.c */
 static void *_asr_resolver(void);
Index: asr_utils.c
===
RCS file: /cvs/src/lib/libc/asr/asr_utils.c,v
retrieving revision 1.13
diff -u -p -u -r1.13 asr_utils.c
--- asr_utils.c 9 Sep 2015 15:49:34 -   1.13
+++ asr_utils.c 27 Feb 2016 10:26:34 -
@@ -32,6 +32,8 @@
 #include 
 #include 
 
+#include 
+
 #include "asr_private.h"
 
 static int dname_check_label(const char *, size_t);
@@ -373,6 +375,14 @@ pack_data(struct asr_pack *p, const void
 }
 
 static int
+pack_u32(struct asr_pack *p, uint32_t v)
+{
+   v = htonl(v);
+
+   return (pack_data(p, , 4));
+}
+
+static int
 pack_u16(struct asr_pack *p, uint16_t v)
 {
v = htons(v);
@@ -415,6 +425,89 @@ _asr_pack_query(struct asr_pack *p, uint
 }
 
 int
+_asr_tsig_query(struct asr_pack *p, const struct 

Grammar fix in www/faq/pf/carp.html

2016-02-27 Thread Victor SLiNv
This fix a small fragment sentence in carp.html




Index: carp.html
===
RCS file: /cvs/www/faq/pf/carp.html,v
retrieving revision 1.46
diff -u -p -r1.46 carp.html
--- carp.html 24 Jan 2016 21:40:35 - 1.46
+++ carp.html 26 Feb 2016 18:05:56 -
@@ -231,7 +231,7 @@ members to fail-over together.

 net.inet.carp.log
 Log state changes, bad packets and other errors.
-May be between 0 and 7, corresponding with syslog(3) priorities.
+This value may be between 0 and 7, corresponding with syslog(3) priorities.
 The default is 2 (state changes only).