Re: merge ping6(8) into ping(8)

2016-09-17 Thread Mikhail
On Sun, Sep 18, 2016 at 12:11 AM, Theo de Raadt  wrote:
>>  > this does 2 things:
>>  > [...]
>>
>> I may recall what I have sent to you in private email, excerpt from
>> FreeBSD ping6 manpage:
>> [...]
>> When we have two binaries I have more trust when one of them is working
>> *only* with IPv4 and another one *only* with IPv6.
>>
>> So, what user problems are you trying to solve with this merge?
>>
>
> Mikhail, with great regret I am informing you that the opinion of some
> random gmail user does not actually matter around here.

It's not about opinion, everyone has it. It's about understanding why
a thing was done. If a person can't answer to the question "why" a
thing was done, I suppose he don't fully understand a solution to a
problem he is trying to solve.

Random gmail users can bring value as much as fullnamed developers.



arm libunwind

2016-09-17 Thread Mark Kettenis
This makes libunwind build on OpenBSD/arm.  And it even works if you
compile the code that uses exceptions with the right compiler options.

ok?

Index: src/AddressSpace.hpp
===
RCS file: /cvs/src/lib/libunwind/src/AddressSpace.hpp,v
retrieving revision 1.3
diff -u -p -r1.3 AddressSpace.hpp
--- src/AddressSpace.hpp5 Sep 2016 18:49:19 -   1.3
+++ src/AddressSpace.hpp18 Sep 2016 06:11:29 -
@@ -35,7 +35,7 @@ namespace libunwind {
 #include "Registers.hpp"
 
 #if _LIBUNWIND_ARM_EHABI
-#if defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
 
 typedef void *_Unwind_Ptr;
 



Re: Manpage for uctuctl(4)

2016-09-17 Thread Visa Hankala
On Sat, Sep 17, 2016 at 02:40:09PM +0100, Rafael Neves wrote:
> Hi, 
> 
> Here follows a manpage for octuctl(4), based on dwctwo(4) manpage.
> I am not sure if the title should stop in Controller or in Interface,
> so I mantained the phrasing of commit.
> 
> Index: share/man/man4/octuctl.4
> ===
> RCS file: share/man/man4/octuctl.4
> diff -N share/man/man4/octuctl.4
> --- /dev/null 1 Jan 1970 00:00:00 -
> +++ share/man/man4/octuctl.4  7 Sep 2016 21:55:30 -
> @@ -0,0 +1,43 @@
> +.\"  $OpenBSD: octuctl.4,v 1.3 2016/02/02 17:38:20 jmc Exp $
> +.\"
> +.\" Copyright (c) 2016 Visa Hankala
> +.\"
> +.\" Permission to use, copy, modify, and distribute this software for any
> +.\" purpose with or without fee is hereby granted, provided that the above
> +.\" copyright notice and this permission notice appear in all copies.
> +.\"
> +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> +.\"
> +.Dd $Mdocdate: July 28 2016 $
> +.Dt OCTUCTL 4
> +.Os
> +.Sh NAME
> +.Nm octuctl
> +.Nd Octeon II USB Controller Interface
> +.Sh SYNOPSIS
> +.Cd "octuctl0 at iobus? irq 56" Pq "octeon"
> +.Cd "ehci0at octuctl?"
> +.Cd "ohci0at octuctl?"
> +.Sh DESCRIPTION
> +The
> +.Nm octuctl
> +driver provides support for the Octeon II USB Controller Interface,
> +which provides an interface to
> +.Xr ehci 4
> +and
> +.Xr ohci 4
> +devices.
> +.Sh SEE ALSO
> +.Xr ehci 4 ,
> +.Xr ohci 4
> +.Sh HISTORY
> +The
> +.Nm
> +driver first appeared in
> +.Ox 6.0 .

My name does not belong to the copyright because I am not the author
of this work.

Is it customary to write manual pages for driver glue?



Re: gnu/usr.bin/binutils*: install vs. ${INSTALL}

2016-09-17 Thread Philip Guenther
On Sat, Sep 17, 2016 at 3:38 PM, Martin Natano  wrote:
> I think we should be using ${INSTALL} here like in all the other
> Makefile's. Ok?

Looks right.  Assuming that works (unlike _my_ last modification to
those...) ok guenther@



gnu/usr.bin/binutils*: install vs. ${INSTALL}

2016-09-17 Thread Martin Natano
I think we should be using ${INSTALL} here like in all the other
Makefile's. Ok?

natano


Index: binutils/Makefile.bsd-wrapper
===
RCS file: /cvs/src/gnu/usr.bin/binutils/Makefile.bsd-wrapper,v
retrieving revision 1.84
diff -u -p -r1.84 Makefile.bsd-wrapper
--- binutils/Makefile.bsd-wrapper   11 Sep 2016 07:42:02 -  1.84
+++ binutils/Makefile.bsd-wrapper   17 Sep 2016 22:35:36 -
@@ -81,8 +81,8 @@ install: maninstall
tooldir=${PREFIX} \
BSDSRCDIR=${BSDSRCDIR} \
INSTALL_MODULES='${INSTALL_MODULES}' \
-   INSTALL_PROGRAM='install -c -S ${INSTALL_STRIP} -o ${BINOWN} -g 
${BINGRP} -m ${BINMODE}' \
-   INSTALL_DATA='install -c -o ${DOCOWN} -g ${DOCGRP} -m 
${NONBINMODE}' \
+   INSTALL_PROGRAM='${INSTALL} -c -S ${INSTALL_STRIP} -o ${BINOWN} -g 
${BINGRP} -m ${BINMODE}' \
+   INSTALL_DATA='${INSTALL} -c -o ${DOCOWN} -g ${DOCGRP} -m 
${NONBINMODE}' \
INSTALL_INFO_HOST_MODULES='${INSTALL_INFO_HOST_MODULES}' \
  install install-info
 
Index: binutils-2.17/Makefile.bsd-wrapper
===
RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/Makefile.bsd-wrapper,v
retrieving revision 1.9
diff -u -p -r1.9 Makefile.bsd-wrapper
--- binutils-2.17/Makefile.bsd-wrapper  11 Sep 2016 07:42:02 -  1.9
+++ binutils-2.17/Makefile.bsd-wrapper  17 Sep 2016 22:35:38 -
@@ -102,8 +102,8 @@ install: maninstall
tooldir=${PREFIX} \
BSDSRCDIR=${BSDSRCDIR} \
INSTALL_MODULES='${INSTALL_MODULES}' \
-   INSTALL_PROGRAM='install -c -S ${INSTALL_STRIP} -o ${BINOWN} -g 
${BINGRP} -m ${BINMODE}' \
-   INSTALL_DATA='install -c -o ${DOCOWN} -g ${DOCGRP} -m 
${NONBINMODE}' \
+   INSTALL_PROGRAM='${INSTALL} -c -S ${INSTALL_STRIP} -o ${BINOWN} -g 
${BINGRP} -m ${BINMODE}' \
+   INSTALL_DATA='${INSTALL} -c -o ${DOCOWN} -g ${DOCGRP} -m 
${NONBINMODE}' \
INSTALL_INFO_HOST_MODULES='${INSTALL_INFO_HOST_MODULES}' \
  install install-info
 



cvs: owner of installed files

2016-09-17 Thread Martin Natano
Next round of wrestling with install permissions. This diff adjusts the
file owner/group for installed files of cvs(1). Ok?

natano


Index: Makefile.bsd-wrapper
===
RCS file: /cvs/src/gnu/usr.bin/cvs/Makefile.bsd-wrapper,v
retrieving revision 1.52
diff -u -p -r1.52 Makefile.bsd-wrapper
--- Makefile.bsd-wrapper21 Oct 2014 00:12:46 -  1.52
+++ Makefile.bsd-wrapper17 Sep 2016 22:25:09 -
@@ -28,21 +28,23 @@ CF=
 config: .FORCE
-rm -f config.cache
PATH="/bin:/usr/bin:/sbin:/usr/sbin" \
-   INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP}" \
-   INSTALL_SCRIPT="${INSTALL} ${INSTALL_COPY}" \
-   ACLOCAL=true AUTOCONF=true AUTOMAKE=true AUTOHEADER=true \
-   MAKEINFO='makeinfo --no-split' \
-   sh ${.CURDIR}/configure --prefix=/usr --mandir=/usr/share/man \
-   --datadir=/usr/libdata ${CF}
+   INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP} -o 
${BINOWN} -g ${BINGRP} -m ${BINMODE}" \
+   INSTALL_SCRIPT="${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 
${BINMODE}" \
+   INSTALL_DATA="${INSTALL} ${INSTALL_COPY} -o ${DOCOWN} -g ${DOCGRP} -m 
${DOCMODE}" \
+   ACLOCAL=true AUTOCONF=true AUTOMAKE=true AUTOHEADER=true \
+   MAKEINFO='makeinfo --no-split' \
+   sh ${.CURDIR}/configure --prefix=/usr --mandir=/usr/share/man \
+   --datadir=/usr/libdata ${CF}
 
 config.status:
PATH="/bin:/usr/bin:/sbin:/usr/sbin" \
-   INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP}" \
-   INSTALL_SCRIPT="${INSTALL} ${INSTALL_COPY}" \
-   ACLOCAL=true AUTOCONF=true AUTOMAKE=true AUTOHEADER=true \
-   MAKEINFO='makeinfo --no-split' \
-   sh ${.CURDIR}/configure --prefix=/usr --mandir=/usr/share/man \
-   --datadir=/usr/libdata ${CF}
+   INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP} -o 
${BINOWN} -g ${BINGRP} -m ${BINMODE}" \
+   INSTALL_SCRIPT="${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 
${BINMODE}" \
+   INSTALL_DATA="${INSTALL} ${INSTALL_COPY} -o ${DOCOWN} -g ${DOCGRP} -m 
${DOCMODE}" \
+   ACLOCAL=true AUTOCONF=true AUTOMAKE=true AUTOHEADER=true \
+   MAKEINFO='makeinfo --no-split' \
+   sh ${.CURDIR}/configure --prefix=/usr --mandir=/usr/share/man \
+   --datadir=/usr/libdata ${CF}
 
 .ifdef NOMAN
 maninstall:
Index: mkinstalldirs
===
RCS file: /cvs/src/gnu/usr.bin/cvs/mkinstalldirs,v
retrieving revision 1.1.1.3
diff -u -p -r1.1.1.3 mkinstalldirs
--- mkinstalldirs   28 Sep 2001 22:45:35 -  1.1.1.3
+++ mkinstalldirs   17 Sep 2016 22:25:09 -
@@ -24,7 +24,7 @@ do
  if test ! -d "$pathcomp"; then
 echo "mkdir $pathcomp"
 
-mkdir "$pathcomp" || lasterr=$?
+install -d -o root -g wheel "$pathcomp" || lasterr=$?
 
 if test ! -d "$pathcomp"; then
  errstatus=$lasterr
Index: contrib/Makefile.in
===
RCS file: /cvs/src/gnu/usr.bin/cvs/contrib/Makefile.in,v
retrieving revision 1.13
diff -u -p -r1.13 Makefile.in
--- contrib/Makefile.in 10 Jun 2003 21:06:17 -  1.13
+++ contrib/Makefile.in 17 Sep 2016 22:25:09 -
@@ -363,7 +363,8 @@ install-data-local:
echo "test ! -e $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; 
\
echo "  && cd $(DESTDIR)$(bindir) && $(LN_S) 
$(contribscriptdir)/`echo $$p|sed '$(transform)'` ."; \
(test ! -e $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'` \
-   && cd $(DESTDIR)$(bindir) && $(LN_S) $(contribscriptdir)/`echo 
$$p|sed '$(transform)'` .) \
+   && cd $(DESTDIR)$(bindir) && $(LN_S) $(contribscriptdir)/`echo 
$$p|sed '$(transform)'` . \
+   && chown root:bin `echo $$p|sed '$(transform)'`) \
  || (echo "Link creation failed" && if test -f $$p; then \
   echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo 
$$p|sed '$(transform)'`"; \
   $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 
'$(transform)'`; \



Build libc++ and libc++abi with -nostdinc++

2016-09-17 Thread Mark Kettenis
Without this, they don't build with clang++ because it tries to use
the installed headers.  Doesn't hurt building with eg++.

ok?


Index: lib/libcxx/Makefile
===
RCS file: /cvs/src/lib/libcxx/Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile
--- lib/libcxx/Makefile 4 Sep 2016 12:48:33 -   1.1
+++ lib/libcxx/Makefile 17 Sep 2016 22:09:30 -
@@ -41,7 +41,7 @@ SRCS+=algorithm.cpp\
 
 CPPFLAGS+= -DLIBCXXABI -I${HDRDIR} \
-DLIBCXX_BUILDING_LIBCXXABI -I${AHDRDIR} -I${UHDRDIR}
-CXXFLAGS+= -nostdlib
+CXXFLAGS+= -nostdlib -nostdinc++
 .if empty(CXXFLAGS:M-std=*)
 CXXFLAGS+= -std=c++11
 .endif
Index: lib/libcxxabi/Makefile
===
RCS file: /cvs/src/lib/libcxxabi/Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile
--- lib/libcxxabi/Makefile  4 Sep 2016 12:48:34 -   1.1
+++ lib/libcxxabi/Makefile  17 Sep 2016 22:09:30 -
@@ -39,7 +39,7 @@ SRCS+=abort_message.cpp\
libunwind.cpp
 
 CPPFLAGS+= -I${SHDRDIR} -I${HDRDIR} -I${UHDRDIR}
-CXXFLAGS+= -nostdlib -funwind-tables
+CXXFLAGS+= -nostdlib -nostdinc++ -funwind-tables
 .if empty(CXXFLAGS:M-std=*)
 CXXFLAGS+= -std=c++11
 .endif



Re: merge ping6(8) into ping(8)

2016-09-17 Thread Theo de Raadt
>  > this does 2 things:
>  > [...]
> 
> I may recall what I have sent to you in private email, excerpt from 
> FreeBSD ping6 manpage:
> 
> 8<8<8<8<8<8<
> There have been many discussions on why we separate ping6 and ping(8).
> Some people argued that it would be more convenient to uniform the ping
> command for both IPv4 and IPv6.  The followings are an answer to the 
> request.
> 
>  From a developer's point of view: since the underling raw sockets API is
> totally different between IPv4 and IPv6, we would end up having two 
> types of code base.  There would actually be less benefit to uniform the 
> two commands into a single command from the developer's standpoint.
> 
>  From an operator's point of view: unlike ordinary network applications 
> like remote login tools, we are usually aware of address family when 
> using network management tools.  We do not just want to know the
> reachability to the host, but want to know the reachability to the host
> via a particular network protocol such as IPv6.  Thus, even if we had a
> unified ping(8) command for both IPv4 and IPv6, we would usually type a
> -6 or -4 option (or something like those) to specify the particular
> address family.  This essentially means that we have two different
> commands.
> 8<8<8<8<8<8<
> 
> When we have two binaries I have more trust when one of them is working 
> *only* with IPv4 and another one *only* with IPv6.
> 
> So, what user problems are you trying to solve with this merge?
> 

Mikhail, with great regret I am informing you that the opinion of some
random gmail user does not actually matter around here.



Re: merge ping6(8) into ping(8)

2016-09-17 Thread Mikhail

> this does 2 things:
> [...]

I may recall what I have sent to you in private email, excerpt from 
FreeBSD ping6 manpage:


8<8<8<8<8<8<
There have been many discussions on why we separate ping6 and ping(8).
Some people argued that it would be more convenient to uniform the ping
command for both IPv4 and IPv6.  The followings are an answer to the 
request.


From a developer's point of view: since the underling raw sockets API is
totally different between IPv4 and IPv6, we would end up having two 
types of code base.  There would actually be less benefit to uniform the 
two commands into a single command from the developer's standpoint.


From an operator's point of view: unlike ordinary network applications 
like remote login tools, we are usually aware of address family when 
using network management tools.  We do not just want to know the

reachability to the host, but want to know the reachability to the host
via a particular network protocol such as IPv6.  Thus, even if we had a
unified ping(8) command for both IPv4 and IPv6, we would usually type a
-6 or -4 option (or something like those) to specify the particular
address family.  This essentially means that we have two different
commands.
8<8<8<8<8<8<

When we have two binaries I have more trust when one of them is working 
*only* with IPv4 and another one *only* with IPv6.


So, what user problems are you trying to solve with this merge?



Re: fix regress in pstat.c

2016-09-17 Thread Rob Pierce
On Sat, Sep 17, 2016 at 09:20:31PM +0200, Theo Buehler wrote:
> While this patch avoids the bug, it isn't quite right: pstat -ft should
> be equivalent to "pstat -f && pstat -t" but...
> 
> $ pstat -ft
> pstat: kvm_openfiles: /dev/mem: Permission denied
> 
> The actual problem is in ttymode(): if kd != NULL (which is the case if
> -f is combined with -t), there are accesses of the kvm datastructures
> without them being properly initialized:
> 
> 879   if (kd != NULL)
> 880   KGET(TTY_NTTY, ntty);
> 
> and
> 
> 896   KGET(TTY_TTYLIST, tty_head);
> 897   for (tp = TAILQ_FIRST(&tty_head); tp;
> 898   tp = TAILQ_NEXT(&tty, tty_link)) {
> 899   KGET2(tp, &tty, sizeof tty, "tty struct");
> 900   tty2itty(&tty, &itty);
> 901   ttyprt(&itty);
> 902   }
> 
> These code paths must not be hit unless need_nlist is true, so expose it
> globally and replace 'kd != NULL' with the proper condition need_nlist
> 
> The following patch works in all affected cases, pstat -t, pstat -f,
> pstat -tf, both as root and non-root as well as pstat -tv as root
> (combinations with -d aren't interesting since pstat exits before
> doing anything else but -d).
> 
> Index: pstat.c
> ===
> RCS file: /var/cvs/src/usr.sbin/pstat/pstat.c,v
> retrieving revision 1.108
> diff -u -p -r1.108 pstat.c
> --- pstat.c   14 Aug 2016 22:47:26 -  1.108
> +++ pstat.c   17 Sep 2016 17:57:38 -
> @@ -89,6 +89,7 @@ struct e_vnode {
>   struct vnode vnode;
>  };
>  
> +int  need_nlist;
>  int  usenumflag;
>  int  totalflag;
>  int  kflag;
> @@ -141,7 +142,7 @@ main(int argc, char *argv[])
>   const char *dformat = NULL;
>   extern char *optarg;
>   extern int optind;
> - int i, need_nlist;
> + int i;
>  
>   hideroot = getuid();
>  
> @@ -869,7 +870,7 @@ ttymode(void)
>   struct itty itty, *itp;
>   size_t nlen;
>  
> - if (kd == 0) {
> + if (!need_nlist) {
>   mib[0] = CTL_KERN;
>   mib[1] = KERN_TTYCOUNT;
>   nlen = sizeof(ntty);
> @@ -879,7 +880,7 @@ ttymode(void)
>   KGET(TTY_NTTY, ntty);
>   (void)printf("%d terminal device%s\n", ntty, ntty == 1 ? "" : "s");
>   (void)printf("%s", hdr);
> - if (kd == 0) {
> + if (!need_nlist) {
>   mib[0] = CTL_KERN;
>   mib[1] = KERN_TTY;
>   mib[2] = KERN_TTY_INFO;
> 

Thanks Theo.

Fixes the regress and works well with your pending pledge diff.

Rob



Re: arm exidx functions

2016-09-17 Thread Philip Guenther
On Sat, 17 Sep 2016, Mark Kettenis wrote:
> > Date: Sat, 17 Sep 2016 09:38:46 -0700
> > From: Philip Guenther 
...
> > Instead of a conditional in the Makefile, can't this all go under 
> > arch/arm?
> 
> It could.  Not sure where exectly I should put it though.  In a new
> dlfcn subdirectory under arch/arm?

Sure, with a .PATH: and a SRCS+= in arch/arm/Makefile.inc


Philip



Re: fix regress in pstat.c

2016-09-17 Thread Theo Buehler
While this patch avoids the bug, it isn't quite right: pstat -ft should
be equivalent to "pstat -f && pstat -t" but...

$ pstat -ft
pstat: kvm_openfiles: /dev/mem: Permission denied

The actual problem is in ttymode(): if kd != NULL (which is the case if
-f is combined with -t), there are accesses of the kvm datastructures
without them being properly initialized:

879 if (kd != NULL)
880 KGET(TTY_NTTY, ntty);

and

896 KGET(TTY_TTYLIST, tty_head);
897 for (tp = TAILQ_FIRST(&tty_head); tp;
898 tp = TAILQ_NEXT(&tty, tty_link)) {
899 KGET2(tp, &tty, sizeof tty, "tty struct");
900 tty2itty(&tty, &itty);
901 ttyprt(&itty);
902 }

These code paths must not be hit unless need_nlist is true, so expose it
globally and replace 'kd != NULL' with the proper condition need_nlist

The following patch works in all affected cases, pstat -t, pstat -f,
pstat -tf, both as root and non-root as well as pstat -tv as root
(combinations with -d aren't interesting since pstat exits before
doing anything else but -d).

Index: pstat.c
===
RCS file: /var/cvs/src/usr.sbin/pstat/pstat.c,v
retrieving revision 1.108
diff -u -p -r1.108 pstat.c
--- pstat.c 14 Aug 2016 22:47:26 -  1.108
+++ pstat.c 17 Sep 2016 17:57:38 -
@@ -89,6 +89,7 @@ struct e_vnode {
struct vnode vnode;
 };
 
+intneed_nlist;
 intusenumflag;
 inttotalflag;
 intkflag;
@@ -141,7 +142,7 @@ main(int argc, char *argv[])
const char *dformat = NULL;
extern char *optarg;
extern int optind;
-   int i, need_nlist;
+   int i;
 
hideroot = getuid();
 
@@ -869,7 +870,7 @@ ttymode(void)
struct itty itty, *itp;
size_t nlen;
 
-   if (kd == 0) {
+   if (!need_nlist) {
mib[0] = CTL_KERN;
mib[1] = KERN_TTYCOUNT;
nlen = sizeof(ntty);
@@ -879,7 +880,7 @@ ttymode(void)
KGET(TTY_NTTY, ntty);
(void)printf("%d terminal device%s\n", ntty, ntty == 1 ? "" : "s");
(void)printf("%s", hdr);
-   if (kd == 0) {
+   if (!need_nlist) {
mib[0] = CTL_KERN;
mib[1] = KERN_TTY;
mib[2] = KERN_TTY_INFO;



pstat and pledge

2016-09-17 Thread Theo de Raadt
I wanted to comment on some changes that are happening in pstat,
relating to pledge.  The commits for pstat are not commited yet, but I
find them interesting.  They show why pledge was designed to fit into
all programs, and why it is worth pledging so many, even trivial
programs.

Way back at the start of history, pstat was a setgid kmem program.  It
would snoop kernel memory.  At least CSRG had been kind enough to
abstract the grovely bits into libkvm to simplify these risky
programs, but still, influence of this program could potentially gain
read-access to kernel memory via that file descriptor.

Around 2001 a few developers including angelos started going through
the various groveling programs to improve the situation.  sysctl nodes
were created which carried much of the information.  Such grovel
programs are intended to work against "live kernels" and "dead
kernels".  The live case is what you are used to using, and using
sysctl for the information was good, the programs would not open kmem
anymore.  The "dead kernel" case is for inspecting the results of a
crash dump.  That code was left, but the setgid bits could be removed.

It took many more generations of changes by (generations?) of
developers to eliminate similar problems in other programs - the ones
which required the most work were ps, top, and netstat.

But a small risk does remain.  It is really tiny, but pledge can help
it.

Imagine you had one bug which could subtly corrupt kernel memory.
Fragments of that kernel memory (or details calculated from them) are
passed out via sysctl.  Generally that result is supposed to be a
coherent output, but what if it could be made incoherent.  Then, what
if a program like pstat contained a 2nd bug which, based upon
incoherent input (from sysctl), would do the wrong thing.

Well, that is where pledge fits in.  The influence from such bugs
would be minimized, since the program has far fewer system call
operations permitted.

When things go wrong, we contain their influence.



fix regress in pstat.c

2016-09-17 Thread Rob Pierce
ttymode() needs nlist, otherwise "pstat -tf" will fail since kd will not be
NULL and the calls from ttymode() to KGET will error as follows:

pstat: cannot read ntty: invalid address (0)
pstat: cannot read tty_head: invalid address (0)

KGET(TTY_NTTY, ntty) and KGET(TTY_TTYLIST, tty_head) both result in a
kvm_read() with an address (globalnl[TTY_NTTY].n_value) of zero.

The following diff resolves this issue.

Took the opportunity to reorder the flags to match the switch statement.

With help from tb@.

Rob

Index: pstat.c
===
RCS file: /cvs/src/usr.sbin/pstat/pstat.c,v
retrieving revision 1.108
diff -u -p -r1.108 pstat.c
--- pstat.c 14 Aug 2016 22:47:26 -  1.108
+++ pstat.c 17 Sep 2016 17:00:28 -
@@ -190,7 +190,7 @@ main(int argc, char *argv[])
if ((dformat == NULL && argc > 0) || (dformat && argc == 0))
usage();
 
-   need_nlist = vnodeflag || dformat;
+   need_nlist = dformat || (fileflag && ttyflag) || vnodeflag;
 
if (nlistf != NULL || memf != NULL) {
if (fileflag || totalflag)



Re: Use who = 0 instead getpid(2) in setprioriy(2) call in watchdog(8)

2016-09-17 Thread Rafael Neves
On Sat, Sep 17, 2016 at 02:36:49PM +0100, Rafael Neves wrote:
> Hi,
> 
> The patch bellow replaces in watchdog(8), the setpriority(2) + getpid(2) 
> idiom with a single
> setpriority(2) with who = 0.
>
[snip]

Sorry, the patch in the original e-mail does not apply, here follows the 
corrected one. 


Index: usr.sbin/watchdogd/watchdogd.c
===
RCS file: /cvs/src/usr.sbin/watchdogd/watchdogd.c,v
retrieving revision 1.15
diff -u -p -r1.15 watchdogd.c
--- usr.sbin/watchdogd/watchdogd.c  16 Jan 2015 06:40:22 -  1.15
+++ usr.sbin/watchdogd/watchdogd.c  17 Sep 2016 16:16:20 -
@@ -152,7 +152,7 @@ main(int argc, char *argv[])
(void)setrlimit(RLIMIT_STACK, &rlim);
 
(void)mlockall(MCL_CURRENT | MCL_FUTURE);
-   setpriority(PRIO_PROCESS, getpid(), -5);
+   setpriority(PRIO_PROCESS, 0, -5);
 
signal(SIGTERM, sighdlr);
 



In renice(8), replace exit(3) call in main() with return

2016-09-17 Thread Rafael Neves
Hi,

The patch bellow replaces an exit(3) call in main() to a return to enable the 
stack protector.


Index: usr.bin/renice/renice.c
===
RCS file: /cvs/src/usr.bin/renice/renice.c,v
retrieving revision 1.19
diff -u -p -r1.19 renice.c
--- usr.bin/renice/renice.c 22 Oct 2015 07:52:29 -  1.19
+++ usr.bin/renice/renice.c 17 Sep 2016 16:16:17 -
@@ -149,7 +149,7 @@ main(int argc, char **argv)
}
if (pri_type == RENICE_NONE)
usage();
-   exit(renice(params, p));
+   return(renice(params, p));
 }
 
 static int



Re: arm exidx functions

2016-09-17 Thread Mark Kettenis
> Date: Sat, 17 Sep 2016 09:38:46 -0700
> From: Philip Guenther 
> 
> On Sat, 17 Sep 2016, Mark Kettenis wrote:
> > Note that libunwind uses __gnu_Unwind_Find_exidx on Linux, so we could
> > follow Linux here and drop the dl_unwind_find_exidx alias.  But my
> > personal preference is to follow the other BSDs here.
> 
> The downside of the name used by the other BSDs is that it's in the 
> application namespace, of course.  

Yup.  Hence the weak attribute.

> > --- dlfcn/Makefile.inc  7 May 2016 19:05:22 -   1.5
> > +++ dlfcn/Makefile.inc  17 Sep 2016 16:04:32 -
> > @@ -5,3 +5,7 @@
> >  .include 
> >  
> >  SRCS+= dlfcn_stubs.c init.c tib.c
> > +
> > +.if ${MACHINE_ARCH} == "arm"
> > +SRCS+= exidx.c
> > +.endif
> 
> Instead of a conditional in the Makefile, can't this all go under 
> arch/arm?

It could.  Not sure where exectly I should put it though.  In a new
dlfcn subdirectory under arch/arm?



Manpage for uctuctl(4)

2016-09-17 Thread Rafael Neves
Hi, 

Here follows a manpage for octuctl(4), based on dwctwo(4) manpage.
I am not sure if the title should stop in Controller or in Interface,
so I mantained the phrasing of commit.

Index: share/man/man4/octuctl.4
===
RCS file: share/man/man4/octuctl.4
diff -N share/man/man4/octuctl.4
--- /dev/null   1 Jan 1970 00:00:00 -
+++ share/man/man4/octuctl.47 Sep 2016 21:55:30 -
@@ -0,0 +1,43 @@
+.\"$OpenBSD: octuctl.4,v 1.3 2016/02/02 17:38:20 jmc Exp $
+.\"
+.\" Copyright (c) 2016 Visa Hankala
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd $Mdocdate: July 28 2016 $
+.Dt OCTUCTL 4
+.Os
+.Sh NAME
+.Nm octuctl
+.Nd Octeon II USB Controller Interface
+.Sh SYNOPSIS
+.Cd "octuctl0 at iobus? irq 56" Pq "octeon"
+.Cd "ehci0at octuctl?"
+.Cd "ohci0at octuctl?"
+.Sh DESCRIPTION
+The
+.Nm octuctl
+driver provides support for the Octeon II USB Controller Interface,
+which provides an interface to
+.Xr ehci 4
+and
+.Xr ohci 4
+devices.
+.Sh SEE ALSO
+.Xr ehci 4 ,
+.Xr ohci 4
+.Sh HISTORY
+The
+.Nm
+driver first appeared in
+.Ox 6.0 .



Re: arm exidx functions

2016-09-17 Thread Philip Guenther
On Sat, 17 Sep 2016, Mark Kettenis wrote:
> Note that libunwind uses __gnu_Unwind_Find_exidx on Linux, so we could
> follow Linux here and drop the dl_unwind_find_exidx alias.  But my
> personal preference is to follow the other BSDs here.

The downside of the name used by the other BSDs is that it's in the 
application namespace, of course.  


> --- dlfcn/Makefile.inc7 May 2016 19:05:22 -   1.5
> +++ dlfcn/Makefile.inc17 Sep 2016 16:04:32 -
> @@ -5,3 +5,7 @@
>  .include 
>  
>  SRCS+=   dlfcn_stubs.c init.c tib.c
> +
> +.if ${MACHINE_ARCH} == "arm"
> +SRCS+=   exidx.c
> +.endif

Instead of a conditional in the Makefile, can't this all go under 
arch/arm?


Code otherwise is ok guenther@



Use who = 0 instead getpid(2) in setprioriy(2) call in watchdog(8)

2016-09-17 Thread Rafael Neves
Hi,

The patch bellow replaces in watchdog(8), the setpriority(2) + getpid(2) idiom 
with a single
setpriority(2) with who = 0.


Index: usr.sbin/watchdogd/watchdogd.c
===
RCS file: /cvs/src/usr.sbin/watchdogd/watchdogd.c,v
retrieving revision 1.15
diff -u -p -r1.15 watchdogd.c
--- usr.sbin/watchdogd/watchdogd.c  16 Jan 2015 06:40:22 -  1.15
+++ usr.sbin/watchdogd/watchdogd.c  7 Sep 2016 21:55:36 -
@@ -152,7 +152,7 @@ main(int argc, char *argv[])
(void)setrlimit(RLIMIT_STACK, &rlim);
 
(void)mlockall(MCL_CURRENT | MCL_FUTURE);
-   setpriority(PRIO_PROCESS, getpid(), -5);
+   setpriority(PRIO_PROCESS, 0, -5);
 
signal(SIGTERM, sighdlr);
 



Change a nice(3) call to setpriority(2) in top(1)

2016-09-17 Thread Rafael Neves
Hi,

I found in top(1) a call to nice(3) that I think that should be changed to 
setpriority(2). When given the -q flag the manpage claims that top will be 
reniced to -20.
This is implemented trough nice(3) taking advantage that a program are loaded 
with 0 niceness priority, so decrementing 20 will give the desired result.
As the goal is to set to a specific priority, I think it could simply use 
setpriority(2).

The patch bellow does that.


Index: usr.bin/top/top.c
===
RCS file: /cvs/src/usr.bin/top/top.c,v
retrieving revision 1.88
diff -u -p -r1.88 top.c
--- usr.bin/top/top.c   5 Nov 2015 17:17:13 -   1.88
+++ usr.bin/top/top.c   17 Sep 2016 16:16:18 -
@@ -227,7 +227,7 @@ parseargs(int ac, char **av)
/* only allow this if user is really root */
if (getuid() == 0) {
/* be very un-nice! */
-   (void) nice(-20);
+   (void) setpriority(PRIO_PROCESS, 0, -20);
break;
}
new_message(MT_delayed,



arm exidx functions

2016-09-17 Thread Mark Kettenis
For some reason ARM wants to be different.  The EABI exception
handling ABI (EHABI for short) uses an ARM.exidx section and the
PT_ARM_EXIDX entry to find the exeption handling information, and libc
(or ld.so) needs to provide a helper function to support this.  In the
GCC world, the function is named __gnu_Unwind_Find_exidx.  In the
llvm/libunwind world, FreeBSD and NetBSD call the function
dl_unwind_find_exidx.  The diff below adds the code and provides the
function under both names (which is what FreeBSD and NetBSD do).

Note that libunwind uses __gnu_Unwind_Find_exidx on Linux, so we could
follow Linux here and drop the dl_unwind_find_exidx alias.  But my
personal preference is to follow the other BSDs here.

With this diff, exception handling works again for C++ code compiled
with g++.  Still chasing down an issue with clang++.  But I'm fairly
certain this code is correct for both use cases.

ok?


Index: arch/arm/Symbols.list
===
RCS file: /cvs/src/lib/libc/arch/arm/Symbols.list,v
retrieving revision 1.3
diff -u -p -r1.3 Symbols.list
--- arch/arm/Symbols.list   30 May 2016 05:18:52 -  1.3
+++ arch/arm/Symbols.list   17 Sep 2016 16:04:32 -
@@ -85,3 +85,7 @@ shortShift64Left
 shortShift96Left
 sub64
 sub96
+
+/* dlfcn */
+dl_unwind_find_exidx
+__gnu_Unwind_Find_exidx
Index: dlfcn/Makefile.inc
===
RCS file: /cvs/src/lib/libc/dlfcn/Makefile.inc,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile.inc
--- dlfcn/Makefile.inc  7 May 2016 19:05:22 -   1.5
+++ dlfcn/Makefile.inc  17 Sep 2016 16:04:32 -
@@ -5,3 +5,7 @@
 .include 
 
 SRCS+= dlfcn_stubs.c init.c tib.c
+
+.if ${MACHINE_ARCH} == "arm"
+SRCS+= exidx.c
+.endif
Index: dlfcn/exidx.c
===
RCS file: dlfcn/exidx.c
diff -N dlfcn/exidx.c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ dlfcn/exidx.c   17 Sep 2016 16:04:32 -
@@ -0,0 +1,75 @@
+/* $OpenBSD$ */
+/*
+ * Copyright (c) 2016 Mark Kettenis 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+
+void *dl_unwind_find_exidx(const void *pc, int *pcount) __attribute__((weak));
+
+struct exidx_data {
+   u_long pc;
+   void *exidx;
+   int *pcount;
+};
+
+struct exidx_entry {
+   uint32_t data[2];
+};
+
+static int
+find_exidx(struct dl_phdr_info *info, size_t size, void *p)
+{
+   struct exidx_data *data = p;
+   const Elf_Phdr *phdr;
+   void *exidx;
+   int count = 0;
+   int found = 0;
+   int i;
+
+   for (i = 0; i < info->dlpi_phnum; i++) {
+   phdr = &info->dlpi_phdr[i];
+   if (data->pc >= info->dlpi_addr + phdr->p_vaddr &&
+   data->pc < info->dlpi_addr + phdr->p_vaddr + phdr->p_memsz)
+   found = 1;
+   if (phdr->p_type == PT_ARM_EXIDX) {
+   exidx = (void *)(info->dlpi_addr + phdr->p_vaddr);
+   count = phdr->p_memsz / sizeof(struct exidx_entry);
+   }
+   }
+
+   if (found && count > 0) {
+   data->exidx = exidx;
+   *data->pcount = count;
+   return 1;
+   }
+
+   return 0;
+}
+
+void *
+dl_unwind_find_exidx(const void *pc, int *pcount)
+{
+   struct exidx_data data;
+
+   data.pc = (u_long)pc;
+   data.pcount = pcount;
+   if (dl_iterate_phdr(find_exidx, &data))
+   return data.exidx;
+   return NULL;
+}
+
+__strong_alias(__gnu_Unwind_Find_exidx, dl_unwind_find_exidx);



Re: little simpler ssh code

2016-09-17 Thread Ted Unangst
Ted Unangst wrote:
> no change, but makes the code a little shorter.

while here, another similar spot.


Index: clientloop.c
===
RCS file: /cvs/src/usr.bin/ssh/clientloop.c,v
retrieving revision 1.287
diff -u -p -r1.287 clientloop.c
--- clientloop.c12 Sep 2016 01:22:38 -  1.287
+++ clientloop.c17 Sep 2016 01:16:46 -
@@ -303,7 +303,7 @@ client_x11_get_proto(const char *display
char xauthfile[PATH_MAX], xauthdir[PATH_MAX];
static char proto[512], data[512];
FILE *f;
-   int got_data = 0, generated = 0, do_unlink = 0, i, r;
+   int got_data = 0, generated = 0, do_unlink = 0, r;
struct stat st;
u_int now, x11_timeout_real;
 
@@ -430,17 +430,16 @@ client_x11_get_proto(const char *display
 * for the local connection.
 */
if (!got_data) {
-   u_int32_t rnd = 0;
+   u_int8_t rnd[16];
+   u_int i;
 
logit("Warning: No xauth data; "
"using fake authentication data for X11 forwarding.");
strlcpy(proto, SSH_X11_PROTO, sizeof proto);
-   for (i = 0; i < 16; i++) {
-   if (i % 4 == 0)
-   rnd = arc4random();
+   arc4random_buf(rnd, sizeof(rnd));
+   for (i = 0; i < sizeof(rnd); i++) {
snprintf(data + 2 * i, sizeof data - 2 * i, "%02x",
-   rnd & 0xff);
-   rnd >>= 8;
+   rnd[i]);
}
}
 
Index: hostfile.c
===
RCS file: /cvs/src/usr.bin/ssh/hostfile.c,v
retrieving revision 1.66
diff -u -p -r1.66 hostfile.c
--- hostfile.c  4 May 2015 06:10:48 -   1.66
+++ hostfile.c  17 Sep 2016 03:15:29 -
@@ -120,14 +120,13 @@ host_hash(const char *host, const char *
u_char salt[256], result[256];
char uu_salt[512], uu_result[512];
static char encoded[1024];
-   u_int i, len;
+   u_int len;
 
len = ssh_digest_bytes(SSH_DIGEST_SHA1);
 
if (name_from_hostfile == NULL) {
/* Create new salt */
-   for (i = 0; i < len; i++)
-   salt[i] = arc4random();
+   arc4random_buf(salt, len);
} else {
/* Extract salt from known host entry */
if (extract_salt(name_from_hostfile, src_len, salt,



Division by zero in ehci(4)

2016-09-17 Thread Martin Pieuchot
One of the non-checked value read from an untrusted descriptor is the
"maximum packet size" of an endpoint.  If a device reports an incorrect
value most of our HC drivers wont work and if this value is 0 ehci(4)
will crash the kernel.

So here's a diff to validate the value read from the device descriptor
which ends up being the value of the default endpoint.

ok?

Index: usb_subr.c
===
RCS file: /cvs/src/sys/dev/usb/usb_subr.c,v
retrieving revision 1.128
diff -u -p -r1.128 usb_subr.c
--- usb_subr.c  12 Sep 2016 07:43:10 -  1.128
+++ usb_subr.c  17 Sep 2016 13:38:02 -
@@ -1023,16 +1027,34 @@ usbd_status
 usbd_new_device(struct device *parent, struct usbd_bus *bus, int depth,
int speed, int port, struct usbd_port *up)
 {
-   struct usbd_device *dev, *adev;
-   struct usbd_device *hub;
+   struct usbd_device *dev, *adev, *hub;
usb_device_descriptor_t *dd;
usbd_status err;
-   int addr;
-   int i;
-   int p;
+   uint32_t mps, mps0;
+   int addr, i, p;
 
DPRINTF(("usbd_new_device bus=%p port=%d depth=%d speed=%d\n",
 bus, port, depth, speed));
+
+   /*
+* Fixed size for ep0 max packet, FULL device variable size is
+* handled below.
+*/
+   switch (speed) {
+   case USB_SPEED_LOW:
+   mps0 = 8;
+   break;
+   case USB_SPEED_HIGH:
+   case USB_SPEED_FULL:
+   mps0 = 64;
+   break;
+   case USB_SPEED_SUPER:
+   mps0 = 512;
+   break;
+   default:
+   return (USBD_INVAL);
+   }
+
addr = usbd_getnewaddr(bus);
if (addr < 0) {
printf("%s: No free USB addresses, new device ignored.\n",
@@ -1054,8 +1076,8 @@ usbd_new_device(struct device *parent, s
dev->def_ep_desc.bDescriptorType = UDESC_ENDPOINT;
dev->def_ep_desc.bEndpointAddress = USB_CONTROL_ENDPOINT;
dev->def_ep_desc.bmAttributes = UE_CONTROL;
-   USETW(dev->def_ep_desc.wMaxPacketSize, USB_MAX_IPACKET);
dev->def_ep_desc.bInterval = 0;
+   USETW(dev->def_ep_desc.wMaxPacketSize, mps0);
 
dev->quirks = &usbd_no_quirk;
dev->address = USB_START_ADDR;
@@ -1063,6 +1085,8 @@ usbd_new_device(struct device *parent, s
dev->depth = depth;
dev->powersrc = up;
dev->myhub = up->parent;
+   dev->speed = speed;
+   dev->langid = USBD_NOLANG;
 
up->device = dev;
 
@@ -1084,8 +1108,6 @@ usbd_new_device(struct device *parent, s
} else {
dev->myhsport = NULL;
}
-   dev->speed = speed;
-   dev->langid = USBD_NOLANG;
 
/* Establish the default pipe. */
err = usbd_setup_pipe(dev, 0, &dev->def_ep, USBD_DEFAULT_INTERVAL,
@@ -1143,36 +1165,33 @@ usbd_new_device(struct device *parent, s
return (err);
}
 
-   if (speed == USB_SPEED_HIGH) {
-   /* Max packet size must be 64 (sec 5.5.3). */
-   if (dd->bMaxPacketSize != USB_2_MAX_CTRL_PACKET) {
-#ifdef DIAGNOSTIC
-   printf("%s: addr=%d bad max packet size %d\n", __func__,
-   addr, dd->bMaxPacketSize);
-#endif
-   dd->bMaxPacketSize = USB_2_MAX_CTRL_PACKET;
-   }
-   }
-
DPRINTF(("usbd_new_device: adding unit addr=%d, rev=%02x, class=%d, "
 "subclass=%d, protocol=%d, maxpacket=%d, len=%d, speed=%d\n",
 addr,UGETW(dd->bcdUSB), dd->bDeviceClass, dd->bDeviceSubClass,
 dd->bDeviceProtocol, dd->bMaxPacketSize, dd->bLength,
 dev->speed));
 
-   if (dd->bDescriptorType != UDESC_DEVICE) {
+   if ((dd->bDescriptorType != UDESC_DEVICE) ||
+   (dd->bLength < USB_DEVICE_DESCRIPTOR_SIZE)) {
usb_free_device(dev);
up->device = NULL;
return (USBD_INVAL);
}
 
-   if (dd->bLength < USB_DEVICE_DESCRIPTOR_SIZE) {
-   usb_free_device(dev);
-   up->device = NULL;
-   return (USBD_INVAL);
+   mps = dd->bMaxPacketSize;
+   if (speed == USB_SPEED_SUPER && mps == 0xff)
+   mps = 512;
+
+   if (mps != mps0) {
+   if ((speed == USB_SPEED_LOW) ||
+   (mps != 8 || mps != 16 || mps != 32 || mps != 64)) {
+   usb_free_device(dev);
+   up->device = NULL;
+   return (USBD_INVAL);
+   }
+   USETW(dev->def_ep_desc.wMaxPacketSize, mps);
}
 
-   USETW(dev->def_ep_desc.wMaxPacketSize, dd->bMaxPacketSize);
 
/* Set the address if the HC didn't do it already. */
if (bus->methods->dev_setaddr != NULL &&



Re: merge ping6(8) into ping(8)

2016-09-17 Thread Florian Obser
... and this does things to the build infrastructure.

It survives make release on amd64, it survived i386 in the past but
I'm currently running another make release. I'm trying armv7, too.

Tests on other archs would be very welcome, thanks!

diff --git distrib/amd64/common/list distrib/amd64/common/list
index 4b4f4b1..153c880 100644
--- distrib/amd64/common/list
+++ distrib/amd64/common/list
@@ -40,7 +40,7 @@ LINK  instbin sbin/mount
 LINK   instbin sbin/mount_cd9660
 LINK   instbin sbin/mount_ffs
 LINK   instbin sbin/newfs
-LINK   instbin sbin/ping
+LINK   instbin sbin/ping sbin/ping6
 LINK   instbin sbin/reboot sbin/halt
 LINK   instbin sbin/restore
 LINK   instbin sbin/route
diff --git distrib/amd64/ramdisk_cd/list.local 
distrib/amd64/ramdisk_cd/list.local
index 79982af..7e149a8 100644
--- distrib/amd64/ramdisk_cd/list.local
+++ distrib/amd64/ramdisk_cd/list.local
@@ -1,8 +1,6 @@
 # $OpenBSD: list.local,v 1.26 2015/10/07 18:02:06 krw Exp $
 
 # add local links; use bin/sh since instbin has already been unlinked
-LINK   instbin sbin/ping6
-
 LINK   instbin sbin/dhclient
 LINK   instbin sbin/bioctl
 
diff --git distrib/armv7/ramdisk/list distrib/armv7/ramdisk/list
index 0d13059..82d100e 100644
--- distrib/armv7/ramdisk/list
+++ distrib/armv7/ramdisk/list
@@ -47,8 +47,7 @@ LINK  instbin sbin/mount_nfs
 LINK   instbin sbin/newfs
 LINK   instbin sbin/newfs_ext2fs
 LINK   instbin sbin/newfs_msdos
-LINK   instbin sbin/ping
-LINK   instbin sbin/ping6
+LINK   instbin sbin/ping sbin/ping6
 LINK   instbin sbin/reboot sbin/halt
 LINK   instbin sbin/route
 LINK   instbin sbin/sysctl
diff --git distrib/hppa/list distrib/hppa/list
index 0e2e181..b0f23b7 100644
--- distrib/hppa/list
+++ distrib/hppa/list
@@ -40,8 +40,7 @@ LINK  instbin 
sbin/mount_cd9660
 LINK   instbin sbin/mount_ffs
 LINK   instbin sbin/mount_nfs
 LINK   instbin sbin/newfs
-LINK   instbin sbin/ping
-LINK   instbin sbin/ping6
+LINK   instbin sbin/ping sbin/ping6
 LINK   instbin sbin/reboot sbin/halt
 LINK   instbin sbin/route
 LINK   instbin sbin/sysctl
diff --git distrib/i386/common/list distrib/i386/common/list
index 17d8e39..3d8b00f 100644
--- distrib/i386/common/list
+++ distrib/i386/common/list
@@ -41,7 +41,7 @@ LINK  instbin sbin/mount
 LINK   instbin sbin/mount_cd9660
 LINK   instbin sbin/mount_ffs
 LINK   instbin sbin/newfs
-LINK   instbin sbin/ping
+LINK   instbin sbin/ping sbin/ping6
 LINK   instbin sbin/reboot sbin/halt
 LINK   instbin sbin/route
 LINK   instbin sbin/sysctl
diff --git distrib/i386/ramdisk_cd/list.local distrib/i386/ramdisk_cd/list.local
index 8a59bc8..18ad5b8 100644
--- distrib/i386/ramdisk_cd/list.local
+++ distrib/i386/ramdisk_cd/list.local
@@ -3,7 +3,6 @@
 # add local links; use bin/sh since instbin has already been unlinked
 LINK   instbin sbin/mount_ext2fs
 LINK   instbin sbin/mount_msdos
-LINK   instbin sbin/ping6
 LINK   instbin sbin/mount_udf
 LINK   instbin sbin/restore
 LINK   instbin sbin/bioctl
diff --git distrib/landisk/ramdisk/list distrib/landisk/ramdisk/list
index ea06d58..ba42a8f 100644
--- distrib/landisk/ramdisk/list
+++ distrib/landisk/ramdisk/list
@@ -45,8 +45,7 @@ LINK  instbin sbin/mount_msdos
 LINK   instbin sbin/mount_nfs
 LINK   instbin sbin/newfs
 LINK   instbin sbin/newfs_msdos
-LINK   instbin sbin/ping
-LINK   instbin sbin/ping6

Re: sys/systm.h: drop read_symtab_from_file() proto

2016-09-17 Thread Mark Kettenis
> Date: Sat, 17 Sep 2016 13:05:01 +0200
> From: Jasper Lievisse Adriaanse 
> 
> This seems to be a leftover from when the actual function itself was removed
> at some point?

ok kettenis@

> Index: systm.h
> ===
> RCS file: /cvs/src/sys/sys/systm.h,v
> retrieving revision 1.117
> diff -u -p -r1.117 systm.h
> --- systm.h   13 Sep 2016 08:32:44 -  1.117
> +++ systm.h   17 Sep 2016 11:04:10 -
> @@ -308,7 +308,6 @@ extern int (*mountroot)(void);
>  #if defined(DDB) || defined(KGDB)
>  /* debugger entry points */
>  void Debugger(void); /* in DDB only */
> -int  read_symtab_from_file(struct proc *,struct vnode *,const char *);
>  #endif
>  
>  #ifdef BOOT_CONFIG
> 
> -- 
> jasper
> 
> 



remove more unreachable code from audio drivers

2016-09-17 Thread Alexandre Ratchov
Last year we made AUDIO_GETDEV ioctl driver independent but forgot
to remove the getdev() methods of all the drivers.

OK?

Index: share/man/man9/audio.9
===
RCS file: /cvs/src/share/man/man9/audio.9,v
retrieving revision 1.25
diff -u -p -u -p -r1.25 audio.9
--- share/man/man9/audio.9  14 Sep 2016 06:12:19 -  1.25
+++ share/man/man9/audio.9  17 Sep 2016 11:28:12 -
@@ -64,7 +64,6 @@ struct audio_hw_if {
 #define SPKR_ON  1
 #define SPKR_OFF 0
 
-   int (*getdev)(void *, struct audio_device *);
int (*setfd)(void *, int);
 
int (*set_port)(void *, struct mixer_ctrl *);
@@ -279,11 +278,6 @@ If supplied, it is called when a half du
 playing and recording.
 It can, e.g., be used to turn the speaker on and off.
 This function returns 0 on success, otherwise an error code.
-.It Fn "int (*getdev)" "void *hdl" "struct audio_device *ret"
-This function fills
-.Fa ret
-with relevant information about the driver and returns 0 on success,
-or it returns an error code on failure.
 .It Fn "int (*setfd)" "void *hdl" "int fd"
 This function is optional.
 If supplied, it is called when the device is opened in full-duplex mode,
Index: sys/arch/hppa/gsc/harmony.c
===
RCS file: /cvs/src/sys/arch/hppa/gsc/harmony.c,v
retrieving revision 1.32
diff -u -p -u -p -r1.32 harmony.c
--- sys/arch/hppa/gsc/harmony.c 14 Sep 2016 06:12:19 -  1.32
+++ sys/arch/hppa/gsc/harmony.c 17 Sep 2016 11:28:12 -
@@ -62,7 +62,6 @@ int harmony_round_blocksize(void *, 
 int harmony_commit_settings(void *);
 int harmony_halt_output(void *);
 int harmony_halt_input(void *);
-int harmony_getdev(void *, struct audio_device *);
 int harmony_set_port(void *, mixer_ctrl_t *);
 int harmony_get_port(void *, mixer_ctrl_t *);
 int harmony_query_devinfo(void *addr, mixer_devinfo_t *);
@@ -88,7 +87,6 @@ struct audio_hw_if harmony_sa_hw_if = {
harmony_halt_output,
harmony_halt_input,
NULL,
-   harmony_getdev,
NULL,
harmony_set_port,
harmony_get_port,
@@ -252,13 +250,6 @@ harmony_attach(parent, self, aux)
if ((rev & CS4215_REV_VER) >= CS4215_REV_VER_E)
sc->sc_hasulinear8 = 1;
 
-   strlcpy(sc->sc_audev.name, ga->ga_name, sizeof(sc->sc_audev.name));
-   snprintf(sc->sc_audev.version, sizeof sc->sc_audev.version,
-   "%u.%u;%u", ga->ga_type.iodc_sv_rev,
-   ga->ga_type.iodc_model, ga->ga_type.iodc_revision);
-   strlcpy(sc->sc_audev.config, sc->sc_dv.dv_xname,
-   sizeof(sc->sc_audev.config));
-
audio_attach_mi(&harmony_sa_hw_if, sc, &sc->sc_dv);
 
timeout_set(&sc->sc_acc_tmo, harmony_acc_tmo, sc);
@@ -547,16 +538,6 @@ harmony_halt_input(void *vsc)
 
/* XXX: disable interrupts */
sc->sc_capturing = 0;
-   return (0);
-}
-
-int
-harmony_getdev(void *vsc, struct audio_device *retp)
-{
-   struct harmony_softc *sc = vsc;
-
-   *retp = sc->sc_audev;
-
return (0);
 }
 
Index: sys/arch/hppa/gsc/harmonyvar.h
===
RCS file: /cvs/src/sys/arch/hppa/gsc/harmonyvar.h,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 harmonyvar.h
--- sys/arch/hppa/gsc/harmonyvar.h  15 Aug 2003 13:25:53 -  1.8
+++ sys/arch/hppa/gsc/harmonyvar.h  17 Sep 2016 11:28:12 -
@@ -78,7 +78,6 @@ struct harmony_channel {
 
 struct harmony_softc {
struct device sc_dv;
-   struct audio_device sc_audev;
 
bus_dma_tag_t sc_dmat;
bus_space_tag_t sc_bt;
Index: sys/arch/luna88k/cbus/nec86.c
===
RCS file: /cvs/src/sys/arch/luna88k/cbus/nec86.c,v
retrieving revision 1.2
diff -u -p -u -p -r1.2 nec86.c
--- sys/arch/luna88k/cbus/nec86.c   14 Sep 2016 06:12:19 -  1.2
+++ sys/arch/luna88k/cbus/nec86.c   17 Sep 2016 11:28:13 -
@@ -63,12 +63,6 @@
 #define NEC_SCR_MASK   0x0f
 #define NEC_SCR_EXT_ENABLE 0x01
 
-struct audio_device nec86_device = {
-   .name   = "PC-9801-86",
-   .version= "",
-   .config = "nec86"
-};
-
 /*
  * Define our interface to the higher level audio driver.
  */
@@ -86,7 +80,6 @@ struct audio_hw_if nec86_hw_if = {
.halt_output= nec86hw_halt_pdma,
.halt_input = nec86hw_halt_pdma,
.speaker_ctl= nec86hw_speaker_ctl,
-   .getdev = nec86getdev,
.setfd  = nec86hw_setfd,
.set_port   = nec86hw_mixer_set_port,
.get_port   = nec86hw_mixer_get_port,
@@ -247,15 +240,4 @@ nec86_attachsubr(struct nec86_softc *sc)
audio_attach_mi(&nec86_hw_if, ysc, &ysc->sc_dev);
sc->sc_attached = 1;
}
-}
-
-/*
- * Various routines to interface to higher level audio driver.
- */
-int
-nec86get

merge ping6(8) into ping(8)

2016-09-17 Thread Florian Obser
this does 2 things:
1) copy missing things from ping6(8) over to ping(8)
2) add
if (v6flag) {
/* do new original v6 stuff */
} else {
/* re-indent already present v4 stuff and wrap else around it /*
}

feel free to review and OK while I fight with the build system :/

diff --git ping.c ping.c
index 0c95139..1be2c71 100644
--- ping.c
+++ ping.c
@@ -123,6 +123,9 @@ struct payload {
 #defineMAXIPLEN60
 #defineMAXICMPLEN  76
 #defineMAXPAYLOAD  (IP_MAXPACKET - MAXIPLEN - ECHOLEN)
+#defineIP6LEN  40
+#defineEXTRA   256 /* for AH and various other headers. 
weird. */
+#defineMAXPAYLOAD6 IPV6_MAXPACKET - IP6LEN - ECHOLEN
 #defineMAXWAIT_DEFAULT 10  /* secs to wait for 
response */
 #defineNROUTES 9   /* number of record 
route slots */
 
@@ -174,6 +177,7 @@ char BSPACE = '\b'; /* characters written for flood 
*/
 char DOT = '.';
 char *hostname;
 int ident; /* process id to identify our packets */
+int v6flag = 0;/* are we ping6? */
 
 /* counters */
 int64_t npackets;  /* max packets to transmit */
@@ -211,6 +215,7 @@ const char  *pr_addr(struct sockaddr *, socklen_t);
 voidpr_pack(u_char *, int, struct msghdr *);
 __dead void usage(void);
 
+/* IPv4 specific functions */
 voidpr_ipopt(int, u_char *);
 int in_cksum(u_short *, int);
 voidpr_icmph(struct icmp *);
@@ -220,6 +225,16 @@ voidpr_iph(struct ip *);
 int map_tos(char *, int *);
 #endif /* SMALL */
 
+/* IPv6 specific functions */
+int get_hoplim(struct msghdr *);
+int get_pathmtu(struct msghdr *, struct sockaddr_in6 *);
+voidpr_icmph6(struct icmp6_hdr *, u_char *);
+voidpr_iph6(struct ip6_hdr *);
+voidpr_exthdrs(struct msghdr *);
+voidpr_ip6opt(void *);
+voidpr_rthdr(void *);
+voidpr_retip6(struct ip6_hdr *, u_char *);
+
 int
 main(int argc, char *argv[])
 {
@@ -227,10 +242,15 @@ main(int argc, char *argv[])
struct itimerval itimer;
struct sockaddr *from, *dst;
struct sockaddr_in from4, dst4;
+   struct sockaddr_in6 from6, dst6;
+   struct cmsghdr *scmsg = NULL;
+   struct in6_pktinfo *pktinfo = NULL;
+   struct icmp6_filter filt;
socklen_t maxsizelen;
int64_t preload;
-   int ch, i, optval = 1, packlen, maxsize, error, s;
-   int df = 0, tos = 0, bufspace = IP_MAXPACKET;
+   int ch, i, optval = 1, packlen, maxsize, error, s4, s6, s;
+   int df = 0, tos = 0, bufspace = IP_MAXPACKET, hoplimit = -1, mflag = 0;
+   int v4sock_errno = 0, v6sock_errno = 0;
u_char *datap, *packet, loop = 1;
u_char ttl = MAXTTL;
char *e, *target, hbuf[NI_MAXHOST], *source = NULL;
@@ -239,19 +259,40 @@ main(int argc, char *argv[])
double intval;
uid_t uid;
u_int rtableid = 0;
+   extern char *__progname;
 
-   if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0)
-   err(1, "socket");
+   if ((s4 = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0)
+   v4sock_errno = errno;
+   if ((s6 = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0)
+   v6sock_errno = errno;
 
/* revoke privs */
uid = getuid();
if (setresuid(uid, uid, uid) == -1)
err(1, "setresuid");
 
+   if (strcmp("ping6", __progname) == 0) {
+   v6flag = 1;
+   if (v6sock_errno != 0)
+   errc(1, v6sock_errno, "socket");
+   s = s6;
+   if (s4 >= 0)
+   close(s4);
+   maxpayload = MAXPAYLOAD6;
+   } else {
+   v6flag = 0;
+   if (v4sock_errno != 0)
+   errc(1, v4sock_errno, "socket");
+   s = s4;
+   if (s6 >= 0)
+   close(s6);
+   maxpayload = MAXPAYLOAD;
+   }
+
preload = 0;
-   maxpayload = MAXPAYLOAD;
datap = &outpack[ECHOLEN + ECHOTMLEN];
-   while ((ch = getopt(argc, argv,
+   while ((ch = getopt(argc, argv, v6flag ?
+   "c:dEefHh:I:i:Ll:mNnp:qS:s:V:vw:" :
"DEI:LRS:c:defHi:l:np:qs:T:t:V:vw:")) != -1) {
switch(ch) {
case 'c':
@@ -283,6 +324,11 @@ main(int argc, char *argv[])
case 'H':
options |= F_HOSTNAME;
break;
+   case 'h':   /* hoplimit */
+   hoplimit = strtonum(optarg, 0, IPV6_MAXHLIM, &errstr);
+   if (errstr)
+   

Re: teach BFD how to send route messages, again

2016-09-17 Thread Peter Hessler
On 2016 Sep 17 (Sat) at 13:15:56 +0200 (+0200), Peter Hessler wrote:
:On 2016 Sep 17 (Sat) at 04:50:29 -0600 (-0600), Theo de Raadt wrote:
::>  route(8) for the ramdisks is not built with SMALL, so adding SMALL
::> won't help.
::
::Then you'll help it.   By compiling them SMALL.
:
:Happilly.
:
:Tested on an amd64 bsd.rd. dhclient, route add, route del, route show,
:all still work, and it's slightly smaller.
:
:textdatabss dec hex
:213397  889636896   259189  3f475 obj/route
:212677  889636896   258469  3f1a5 obj/route-SMALL
:
:
:OK?
:
:Index: distrib/special/route/Makefile
:===
:RCS file: /cvs/openbsd/src/distrib/special/route/Makefile,v
:retrieving revision 1.1
:diff -u -p -u -p -r1.1 Makefile
:--- distrib/special/route/Makefile 23 Dec 2014 17:16:03 -  1.1
:+++ distrib/special/route/Makefile 17 Sep 2016 11:09:59 -
:@@ -4,7 +4,7 @@ PROG=  route
: MAN=  route.8
: SRCS= route.c show.c
: 
:-CFLAGS+=  -Wall
:+CFLAGS+=  -Wall -DSMALL
: 
: route.o .depend lint tags: keywords.h
: 
:

And with sbin/route/route.c updated to use SMALL

Index: sbin/route/route.c
===
RCS file: /cvs/openbsd/src/sbin/route/route.c,v
retrieving revision 1.191
diff -u -p -u -p -r1.191 route.c
--- sbin/route/route.c  15 Sep 2016 12:51:20 -  1.191
+++ sbin/route/route.c  17 Sep 2016 10:57:02 -
@@ -41,6 +41,10 @@
 #include 
 #include 
 
+#ifndef SMALL
+#include 
+#endif
+
 #include 
 #include 
 
@@ -90,6 +94,10 @@ void  sodump(sup, char *);
 char   *priorityname(uint8_t);
 uint8_t getpriority(char *);
 voidprint_getmsg(struct rt_msghdr *, int);
+#ifndef SMALL
+const char *bfd_printstate(unsigned int);
+voidprint_bfdmsg(struct rt_msghdr *);
+#endif
 const char *get_linkstate(int, int);
 voidprint_rtmsg(struct rt_msghdr *, int);
 voidpmsg_common(struct rt_msghdr *);
@@ -1334,7 +1342,9 @@ print_rtmsg(struct rt_msghdr *rtm, int m
printf("\n");
break;
case RTM_BFD:
-   printf("bfd\n");/* XXX - expand*/
+#ifndef SMALL
+   print_bfdmsg(rtm);
+#endif
break;
default:
printf(", priority %d, table %u, ifidx %u, ",
@@ -1526,6 +1536,53 @@ print_getmsg(struct rt_msghdr *rtm, int 
}
 #undef RTA_IGN
 }
+
+#ifndef SMALL
+const char *
+bfd_printstate(unsigned int state)
+{
+   switch (state) {
+   case BFD_STATE_ADMINDOWN:   return("admindown");
+   case BFD_STATE_DOWN:return("down");
+   case BFD_STATE_INIT:return("init");
+   case BFD_STATE_UP:  return("up");
+   }
+   return "invalid";
+}
+
+void
+print_bfdmsg(struct rt_msghdr *rtm)
+{
+   struct bfd_msghdr *bfdm = (struct bfd_msghdr *)rtm;
+
+   printf(" mode ");
+   switch (bfdm->bm_mode) {
+   case BFD_MODE_ASYNC:
+   printf("async");
+   break;
+   case BFD_MODE_DEMAND:
+   printf("demand");
+   break;
+   }
+   printf(" state %s", bfd_printstate(bfdm->bm_state));
+   printf(" remotestate %s", bfd_printstate(bfdm->bm_remotestate));
+   printf(" laststate %s", bfd_printstate(bfdm->bm_laststate));
+
+   printf(" error %d", bfdm->bm_error);
+   printf(" localdiscr %u", bfdm->bm_localdiscr);
+   printf(" remotediscr %u", bfdm->bm_remotediscr);
+   printf(" localdiag %u", bfdm->bm_localdiag);
+   printf(" remotediag %u", bfdm->bm_remotediag);
+   printf(" uptime %lld", bfdm->bm_uptime);
+   printf(" lastuptime %lld", bfdm->bm_lastuptime);
+
+   printf(" mintx %u", bfdm->bm_mintx);
+   printf(" minrx %u", bfdm->bm_minrx);
+   printf(" multiplier %u", bfdm->bm_multiplier);
+
+   pmsg_addrs(((char *)rtm + rtm->rtm_hdrlen), rtm->rtm_addrs);
+}
+#endif /* !SMALL */
 
 void
 pmsg_common(struct rt_msghdr *rtm)



Re: teach BFD how to send route messages, again

2016-09-17 Thread Peter Hessler
On 2016 Sep 17 (Sat) at 04:50:29 -0600 (-0600), Theo de Raadt wrote:
:>  route(8) for the ramdisks is not built with SMALL, so adding SMALL
:> won't help.
:
:Then you'll help it.   By compiling them SMALL.

Happilly.

Tested on an amd64 bsd.rd. dhclient, route add, route del, route show,
all still work, and it's slightly smaller.

textdatabss dec hex
213397  889636896   259189  3f475 obj/route
212677  889636896   258469  3f1a5 obj/route-SMALL


OK?

Index: distrib/special/route/Makefile
===
RCS file: /cvs/openbsd/src/distrib/special/route/Makefile,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 Makefile
--- distrib/special/route/Makefile  23 Dec 2014 17:16:03 -  1.1
+++ distrib/special/route/Makefile  17 Sep 2016 11:09:59 -
@@ -4,7 +4,7 @@ PROG=   route
 MAN=   route.8
 SRCS=  route.c show.c
 
-CFLAGS+=   -Wall
+CFLAGS+=   -Wall -DSMALL
 
 route.o .depend lint tags: keywords.h
 



sys/systm.h: drop read_symtab_from_file() proto

2016-09-17 Thread Jasper Lievisse Adriaanse
This seems to be a leftover from when the actual function itself was removed
at some point?

Index: systm.h
===
RCS file: /cvs/src/sys/sys/systm.h,v
retrieving revision 1.117
diff -u -p -r1.117 systm.h
--- systm.h 13 Sep 2016 08:32:44 -  1.117
+++ systm.h 17 Sep 2016 11:04:10 -
@@ -308,7 +308,6 @@ extern int (*mountroot)(void);
 #if defined(DDB) || defined(KGDB)
 /* debugger entry points */
 void   Debugger(void); /* in DDB only */
-intread_symtab_from_file(struct proc *,struct vnode *,const char *);
 #endif
 
 #ifdef BOOT_CONFIG

-- 
jasper



Re: teach BFD how to send route messages, again

2016-09-17 Thread Theo de Raadt
>  route(8) for the ramdisks is not built with SMALL, so adding SMALL
> won't help.

Then you'll help it.   By compiling them SMALL.  Otherwise they
won't fit, and bfd gets ripped out.



Re: fix clang types on arm

2016-09-17 Thread Patrick Wildt
On Fri, Sep 16, 2016 at 09:04:58PM +0200, Mark Kettenis wrote:
> On OpenBSD we use a consistent set of typedefs across platforms for
> the types specified by the C standard.  In some cases these deviate
> from what the processor-specific ABI says.  The diff below fixes the
> ones relevant for arm, pretty much by following NetBSD.
> 
> ok?

ok patrick@

> 
> Oh, and how do we handle upstreaming these kind of diffs?

Good question.  LLVM folks seem receptive to diffs, but you need to
create a test.  They also seem to like that Phabricator thing, but I'm
not sure if that is really needed and instead you could just send the
diff (+ test) to the mailing list...

> 
> 
> Index: gnu/llvm/tools/clang/lib/Basic/Targets.cpp
> ===
> RCS file: /cvs/src/gnu/llvm/tools/clang/lib/Basic/Targets.cpp,v
> retrieving revision 1.1.1.1
> diff -u -p -r1.1.1.1 Targets.cpp
> --- gnu/llvm/tools/clang/lib/Basic/Targets.cpp3 Sep 2016 22:46:57 
> -   1.1.1.1
> +++ gnu/llvm/tools/clang/lib/Basic/Targets.cpp16 Sep 2016 18:58:59 
> -
> @@ -4275,8 +4275,10 @@ class ARMTargetInfo : public TargetInfo 
>  DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 64;
>  const llvm::Triple &T = getTriple();
>  
> -// size_t is unsigned long on MachO-derived environments, NetBSD and 
> Bitrig.
> +// size_t is unsigned long on MachO-derived environments, NetBSD,
> +// OpenBSD and Bitrig.
>  if (T.isOSBinFormatMachO() || T.getOS() == llvm::Triple::NetBSD ||
> +T.getOS() == llvm::Triple::OpenBSD ||
>  T.getOS() == llvm::Triple::Bitrig)
>SizeType = UnsignedLong;
>  else
> @@ -4284,6 +4286,7 @@ class ARMTargetInfo : public TargetInfo 
>  
>  switch (T.getOS()) {
>  case llvm::Triple::NetBSD:
> +case llvm::Triple::OpenBSD:
>WCharType = SignedInt;
>break;
>  case llvm::Triple::Win32:
> @@ -4475,6 +4478,7 @@ public:
>  
>  switch (getTriple().getOS()) {
>  case llvm::Triple::NetBSD:
> +case llvm::Triple::OpenBSD:
>PtrDiffType = SignedLong;
>break;
>  default:
> 



teach BFD how to send route messages, again

2016-09-17 Thread Peter Hessler
This is a 2nd pass at having BFD send route messages.

I fixed the things pointed out in the first thread, with the following
comments:

 route(8) for the ramdisks is not built with SMALL, so adding SMALL
won't help.

 rt_bfdmsg() is named in the same style, and is in the same place, as
the other functions that send route messages

OK?



Index: sbin/route/route.c
===
RCS file: /cvs/openbsd/src/sbin/route/route.c,v
retrieving revision 1.191
diff -u -p -u -p -r1.191 route.c
--- sbin/route/route.c  15 Sep 2016 12:51:20 -  1.191
+++ sbin/route/route.c  17 Sep 2016 09:42:17 -
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -90,6 +91,8 @@ void   sodump(sup, char *);
 char   *priorityname(uint8_t);
 uint8_t getpriority(char *);
 voidprint_getmsg(struct rt_msghdr *, int);
+const char *bfd_printstate(unsigned int);
+voidprint_bfdmsg(struct rt_msghdr *);
 const char *get_linkstate(int, int);
 voidprint_rtmsg(struct rt_msghdr *, int);
 voidpmsg_common(struct rt_msghdr *);
@@ -1334,7 +1337,7 @@ print_rtmsg(struct rt_msghdr *rtm, int m
printf("\n");
break;
case RTM_BFD:
-   printf("bfd\n");/* XXX - expand*/
+   print_bfdmsg(rtm);
break;
default:
printf(", priority %d, table %u, ifidx %u, ",
@@ -1525,6 +1528,51 @@ print_getmsg(struct rt_msghdr *rtm, int 
putchar('\n');
}
 #undef RTA_IGN
+}
+
+const char *
+bfd_printstate(unsigned int state)
+{
+   switch (state) {
+   case BFD_STATE_ADMINDOWN:   return("admindown");
+   case BFD_STATE_DOWN:return("down");
+   case BFD_STATE_INIT:return("init");
+   case BFD_STATE_UP:  return("up");
+   }
+   return "invalid";
+}
+
+void
+print_bfdmsg(struct rt_msghdr *rtm)
+{
+   struct bfd_msghdr *bfdm = (struct bfd_msghdr *)rtm;
+
+   printf(" mode ");
+   switch (bfdm->bm_mode) {
+   case BFD_MODE_ASYNC:
+   printf("async");
+   break;
+   case BFD_MODE_DEMAND:
+   printf("demand");
+   break;
+   }
+   printf(" state %s", bfd_printstate(bfdm->bm_state));
+   printf(" remotestate %s", bfd_printstate(bfdm->bm_remotestate));
+   printf(" laststate %s", bfd_printstate(bfdm->bm_laststate));
+
+   printf(" error %d", bfdm->bm_error);
+   printf(" localdiscr %u", bfdm->bm_localdiscr);
+   printf(" remotediscr %u", bfdm->bm_remotediscr);
+   printf(" localdiag %u", bfdm->bm_localdiag);
+   printf(" remotediag %u", bfdm->bm_remotediag);
+   printf(" uptime %lld", bfdm->bm_uptime);
+   printf(" lastuptime %lld", bfdm->bm_lastuptime);
+
+   printf(" mintx %u", bfdm->bm_mintx);
+   printf(" minrx %u", bfdm->bm_minrx);
+   printf(" multiplier %u", bfdm->bm_multiplier);
+
+   pmsg_addrs(((char *)rtm + rtm->rtm_hdrlen), rtm->rtm_addrs);
 }
 
 void
Index: sys/net/bfd.h
===
RCS file: /cvs/openbsd/src/sys/net/bfd.h,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 bfd.h
--- sys/net/bfd.h   17 Sep 2016 07:35:05 -  1.7
+++ sys/net/bfd.h   17 Sep 2016 09:38:24 -
@@ -68,6 +68,7 @@ struct bfd_msghdr {
time_t  bm_uptime;
time_t  bm_lastuptime;
int bm_state;
+   int bm_remotestate;
int bm_laststate;
int bm_error;
 
Index: sys/net/route.h
===
RCS file: /cvs/openbsd/src/sys/net/route.h,v
retrieving revision 1.147
diff -u -p -u -p -r1.147 route.h
--- sys/net/route.h 4 Sep 2016 10:32:01 -   1.147
+++ sys/net/route.h 17 Sep 2016 09:33:22 -
@@ -356,6 +356,7 @@ struct mbuf;
 struct socket;
 struct ifnet;
 struct sockaddr_in6;
+struct bfd_config;
 
 voidroute_init(void);
 int route_output(struct mbuf *, ...);
@@ -363,6 +364,7 @@ int  route_usrreq(struct socket *, int, 
   struct mbuf *, struct mbuf *, struct proc *);
 voidrt_ifmsg(struct ifnet *);
 voidrt_ifannouncemsg(struct ifnet *, int);
+voidrt_bfdmsg(struct bfd_config *);
 voidrt_maskedcopy(struct sockaddr *,
struct sockaddr *, struct sockaddr *);
 struct sockaddr *rt_plen2mask(struct rtentry *, struct sockaddr_in6 *);
Index: sys/net/rtsock.c
===
RCS file: /cvs/openbsd/src/sys/net/rtsock.c,v
retrieving revision 1.205
diff -u -p -u -p -r1.205 rtsock.c
--- sys/net/rtsock.c17 Sep 2016 07:35:05 -  1.205
+++ sys/net/rtsock.c17 Sep 2016 09:37:15 -
@@ -1100,6 +1100,11 @@ rt_msg1(int type, struct rt_addrinfo *rt
case RTM_IFANNOUNCE:
len = sizeof(struct if_announcemsghd