iked(8): fix wrong "break" placement

2020-04-02 Thread Wataru Ashihara
Found by Yasuhiro Ohishi @iij.
ok?


Index: sbin/iked/control.c
===
RCS file: /cvs/src/sbin/iked/control.c,v
retrieving revision 1.28
diff -u -r1.28 control.c
--- sbin/iked/control.c 22 Mar 2020 15:59:05 -  1.28
+++ sbin/iked/control.c 3 Apr 2020 04:21:35 -
@@ -309,10 +309,10 @@
break;
case IMSG_CTL_RESET_ID:
proc_forward_imsg(>sc_ps, , PROC_IKEV2, -1);
+   break;
case IMSG_CTL_SHOW_SA:
proc_forward_imsg(>sc_ps, , PROC_IKEV2, -1);
c->flags |= CTL_CONN_NOTIFY;
-   break;
break;
default:
log_debug("%s: error handling imsg %d",
Index: sbin/iked/crypto.c
===



Re: iked(8): fix ntohs/htons inversion

2020-04-02 Thread Wataru Ashihara
Sorry, I forgot to set my name in the email's "From" header.
I'm Wataru Ashihara.


On 2020/04/03 13:11
w...@iij.ad.jp wrote:

> ok?
> 
> 
> Index: sbin/iked/iked.c
> ===
> RCS file: /cvs/src/sbin/iked/iked.c,v
> retrieving revision 1.41
> diff -u -r1.41 iked.c
> --- sbin/iked/iked.c  16 Jan 2020 20:05:00 -  1.41
> +++ sbin/iked/iked.c  3 Apr 2020 04:07:19 -
> @@ -228,17 +228,17 @@
>   ss.ss_family = AF_INET;
>  
>   if ((env->sc_opts & IKED_OPT_NATT) == 0 && env->sc_nattport == 
> IKED_NATT_PORT)
> - config_setsocket(env, , ntohs(IKED_IKE_PORT), PROC_IKEV2);
> + config_setsocket(env, , htons(IKED_IKE_PORT), PROC_IKEV2);
>   if ((env->sc_opts & IKED_OPT_NONATT) == 0)
> - config_setsocket(env, , ntohs(env->sc_nattport), PROC_IKEV2);
> + config_setsocket(env, , htons(env->sc_nattport), PROC_IKEV2);
>  
>   bzero(, sizeof(ss));
>   ss.ss_family = AF_INET6;
>  
>   if ((env->sc_opts & IKED_OPT_NATT) == 0 && env->sc_nattport == 
> IKED_NATT_PORT)
> - config_setsocket(env, , ntohs(IKED_IKE_PORT), PROC_IKEV2);
> + config_setsocket(env, , htons(IKED_IKE_PORT), PROC_IKEV2);
>   if ((env->sc_opts & IKED_OPT_NONATT) == 0)
> - config_setsocket(env, , ntohs(env->sc_nattport), PROC_IKEV2);
> + config_setsocket(env, , htons(env->sc_nattport), PROC_IKEV2);
>  
>   /*
>* pledge in the parent process:
> 



iked(8): fix ntohs/htons inversion

2020-04-02 Thread wsh
ok?


Index: sbin/iked/iked.c
===
RCS file: /cvs/src/sbin/iked/iked.c,v
retrieving revision 1.41
diff -u -r1.41 iked.c
--- sbin/iked/iked.c16 Jan 2020 20:05:00 -  1.41
+++ sbin/iked/iked.c3 Apr 2020 04:07:19 -
@@ -228,17 +228,17 @@
ss.ss_family = AF_INET;
 
if ((env->sc_opts & IKED_OPT_NATT) == 0 && env->sc_nattport == 
IKED_NATT_PORT)
-   config_setsocket(env, , ntohs(IKED_IKE_PORT), PROC_IKEV2);
+   config_setsocket(env, , htons(IKED_IKE_PORT), PROC_IKEV2);
if ((env->sc_opts & IKED_OPT_NONATT) == 0)
-   config_setsocket(env, , ntohs(env->sc_nattport), PROC_IKEV2);
+   config_setsocket(env, , htons(env->sc_nattport), PROC_IKEV2);
 
bzero(, sizeof(ss));
ss.ss_family = AF_INET6;
 
if ((env->sc_opts & IKED_OPT_NATT) == 0 && env->sc_nattport == 
IKED_NATT_PORT)
-   config_setsocket(env, , ntohs(IKED_IKE_PORT), PROC_IKEV2);
+   config_setsocket(env, , htons(IKED_IKE_PORT), PROC_IKEV2);
if ((env->sc_opts & IKED_OPT_NONATT) == 0)
-   config_setsocket(env, , ntohs(env->sc_nattport), PROC_IKEV2);
+   config_setsocket(env, , htons(env->sc_nattport), PROC_IKEV2);
 
/*
 * pledge in the parent process:



Avoid selwakeup() in kqueue_wakeup()

2020-04-02 Thread Visa Hankala
selwakeup(sip) calls KNOTE(>si_note, 0), which implies that
kqueue_wakeup() should not call selwakeup() directly. Otherwise,
a contrived program can trigger deep recursion.

The diff below moves selwakeup() from kqueue_wakeup() to kqueue_task().
In addition to preventing the recursion, this change is necessary with
the current select/poll implementation to make kqueue_wakeup() free of
the kernel lock.

OK?

Index: kern/kern_event.c
===
RCS file: src/sys/kern/kern_event.c,v
retrieving revision 1.129
diff -u -p -r1.129 kern_event.c
--- kern/kern_event.c   2 Apr 2020 07:00:25 -   1.129
+++ kern/kern_event.c   3 Apr 2020 03:44:00 -
@@ -1102,7 +1102,12 @@ kqueue_task(void *arg)
 {
struct kqueue *kq = arg;
 
-   KNOTE(>kq_sel.si_note, 0);
+   if (kq->kq_state & KQ_SEL) {
+   kq->kq_state &= ~KQ_SEL;
+   selwakeup(>kq_sel);
+   } else {
+   KNOTE(>kq_sel.si_note, 0);
+   }
KQRELE(kq);
 }
 
@@ -1114,10 +1119,7 @@ kqueue_wakeup(struct kqueue *kq)
kq->kq_state &= ~KQ_SLEEP;
wakeup(kq);
}
-   if (kq->kq_state & KQ_SEL) {
-   kq->kq_state &= ~KQ_SEL;
-   selwakeup(>kq_sel);
-   } else if (!SLIST_EMPTY(>kq_sel.si_note)) {
+   if ((kq->kq_state & KQ_SEL) || !SLIST_EMPTY(>kq_sel.si_note)) {
/* Defer activation to avoid recursion. */
KQREF(kq);
if (!task_add(systq, >kq_task))



Re: EV_SET(2) shadows variable

2020-04-02 Thread Philip Guenther
On Tue, Mar 31, 2020 at 11:24 PM Martin Pieuchot  wrote:

> The current form of EV_SET(2) declares a `kevp' variable.  This can
> cause to subtle bugs hard to discover if one uses a variable of the
> same to retrieve events.
>
> Diff below prefixes the locally declared variable by an underscore,
> like it it done in FD_ZERO(), which should be good enough to prevent
> surprises.
>
> Is it the right way to correct such issue?  How many underscores are
> enough?  Can the standards gurus tell me?
>

tl;dr: this should use a variable that starts with either two underbars
(__kevp) or an underbar and a capital (_Kevp).  The same is true of
FD_ZERO().

The namespace of identifiers that begin with a single underbar is only
"reserved for use as identifiers with file scope in both the ordinary and
tag name spaces".  That means it's perfectly legal for an application to
declare a *local* variable with such a name.  So, this should be legal:

#include 
#include 
#include 
#include 
int main(void)
{
struct fd_set _p;
struct kevent _kevp;
FD_ZERO(&_p):
EV_SET(&_kevp, 0, 0, 0, 0, 0, 0);
return 0;
}


...but it currently blows up on the FD_ZERO() and would blow up in the
EV_SET() with your proposed diff.


Philip Guenther


vi: add expandtab option

2020-04-02 Thread Todd C . Miller
In vim, the expandtab option expands tabs to spaces in insert mode
as well as when shifting and indenting/outdenting.  This is very
useful when working on a code-base where the style dictates using
spaces instead of tabs for indentation.

NetBSD added an implementation of expandtab to their vi some time
ago, but theirs doesn't convert tabs to spaces in insert mode.  I've
adapted the NetBSD patch and added support for expanding tabs in
insert mode, unless escaped via ^V.

The option is off by default (of course).

Comments?  Please, no tabs vs spaces flame wars.

 - todd

Index: usr.bin/vi/common/options.c
===
RCS file: /cvs/src/usr.bin/vi/common/options.c,v
retrieving revision 1.27
diff -u -p -u -r1.27 options.c
--- usr.bin/vi/common/options.c 21 May 2019 09:24:58 -  1.27
+++ usr.bin/vi/common/options.c 2 Apr 2020 20:43:14 -
@@ -69,6 +69,8 @@ OPTLIST const optlist[] = {
{"escapetime",  NULL,   OPT_NUM,0},
 /* O_ERRORBELLS4BSD */
{"errorbells",  NULL,   OPT_0BOOL,  0},
+/* O_EXPANDTAB NetBSD 5.0 */
+   {"expandtab",   NULL,   OPT_0BOOL,  0},
 /* O_EXRC  System V (undocumented) */
{"exrc",NULL,   OPT_0BOOL,  0},
 /* O_EXTENDED4.4BSD */
@@ -207,6 +209,7 @@ static OABBREV const abbrev[] = {
{"co",  O_COLUMNS}, /*   4.4BSD */
{"eb",  O_ERRORBELLS},  /* 4BSD */
{"ed",  O_EDCOMPATIBLE},/* 4BSD */
+   {"et",  O_EXPANDTAB},   /* NetBSD 5.0 */
{"ex",  O_EXRC},/* System V (undocumented) */
{"ht",  O_HARDTABS},/* 4BSD */
{"ic",  O_IGNORECASE},  /* 4BSD */
Index: usr.bin/vi/docs/USD.doc/vi.man/vi.1
===
RCS file: /cvs/src/usr.bin/vi/docs/USD.doc/vi.man/vi.1,v
retrieving revision 1.77
diff -u -p -u -r1.77 vi.1
--- usr.bin/vi/docs/USD.doc/vi.man/vi.1 4 Oct 2019 20:12:01 -   1.77
+++ usr.bin/vi/docs/USD.doc/vi.man/vi.1 2 Apr 2020 22:05:31 -
@@ -1606,6 +1606,11 @@ and
 characters to move forward to the next
 .Ar shiftwidth
 column boundary.
+If the
+.Cm expandtab
+option is set, only insert
+.Aq space
+characters.
 .Pp
 .It Aq Cm erase
 .It Aq Cm control-H
@@ -2343,6 +2348,16 @@ key mapping.
 .Nm ex
 only.
 Announce error messages with a bell.
+.It Cm expandtab , et Bq off
+Expand
+.Aq tab
+characters to
+.Aq space
+when inserting, replacing or shifting text, autoindenting,
+indenting with
+.Aq Ic control-T ,
+or outdenting with
+.Aq Ic control-D .
 .It Cm exrc , ex Bq off
 Read the startup files in the local directory.
 .It Cm extended Bq off
Index: usr.bin/vi/docs/USD.doc/vi.ref/set.opt.roff
===
RCS file: /cvs/src/usr.bin/vi/docs/USD.doc/vi.ref/set.opt.roff,v
retrieving revision 1.12
diff -u -p -u -r1.12 set.opt.roff
--- usr.bin/vi/docs/USD.doc/vi.ref/set.opt.roff 8 Aug 2016 15:09:33 -   
1.12
+++ usr.bin/vi/docs/USD.doc/vi.ref/set.opt.roff 2 Apr 2020 22:05:27 -
@@ -96,7 +96,9 @@ the first nonblank character of the line
 Lines are indented using tab characters to the extent possible (based on
 the value of the
 .OP tabstop
-option) and then using space characters as necessary.
+option, and if
+.OP expandtab
+is not set) and then using space characters as necessary.
 For commands inserting text into the middle of a line, any blank characters
 to the right of the cursor are discarded, and the first nonblank character
 to the right of the cursor is aligned as described above.
@@ -400,6 +402,17 @@ only.
 error messages are normally presented in inverse video.
 If that is not possible for the terminal, setting this option causes
 error messages to be announced by ringing the terminal bell.
+.KY expandtab
+.IP "expandtab, et [off]"
+Expand
+.LI 
+characters to
+.LI 
+when inserting, replacing or shifting text, autoindenting,
+indenting with
+.CO ,
+or outdenting with
+.CO .
 .KY exrc
 .IP "exrc, ex [off]"
 If this option is turned on in the EXINIT environment variables,
Index: usr.bin/vi/ex/ex_shift.c
===
RCS file: /cvs/src/usr.bin/vi/ex/ex_shift.c,v
retrieving revision 1.8
diff -u -p -u -r1.8 ex_shift.c
--- usr.bin/vi/ex/ex_shift.c6 Jan 2016 22:28:52 -   1.8
+++ usr.bin/vi/ex/ex_shift.c2 Apr 2020 20:53:16 -
@@ -127,10 +127,13 @@ shift(SCR *sp, EXCMD *cmdp, enum which r
 * Build a new indent string and count the number of
 * characters it uses.
 */
-   for (tbp = bp, newidx = 0;
-   newcol >= O_VAL(sp, O_TABSTOP); ++newidx) {
-   *tbp++ = '\t';
-   newcol -= O_VAL(sp, O_TABSTOP);
+   tbp = bp;

Re: macppc libunwind without altivec

2020-04-02 Thread Mark Kettenis
> Date: Thu, 2 Apr 2020 16:05:09 -0400
> From: George Koehler 
> 
> Hello tech,
> 
> powerpc libunwind is broken on machines without altivec.  It crashes
> SIGILL when code (built with base-clang++) throws a C++ exception,
> because libunwind always saves the altivec registers.  You don't have
> altivec if sysctl machdep.altivec is 0.  I believe that G3 cpus don't
> have altivec, and G4 and G5 do have it.
> 
> This diff defers saving the altivec registers until we need to access
> them.  I took the idea from arm, which defers saving VFP registers.
> The diff fixes a small C++ demo on my G3.  I didn't try other C++
> code; I was building ports with macppc base-clang but stopped at an
> error from lang/python/3.7.
> 
> Registers_arm has members like "bool _saved_vfp_d0_d15;" to know if
> VFP got saved.  I can't add a "bool _saved_vrs" to Registers_ppc,
> because some assertions would fail, because unw_context_t would be
> too small.  I don't enlarge unw_context_t (an opaque struct of 117 * 8
> bytes) because it is in /usr/include/c++/v1/libunwind.h and I don't
> want to change the ABI.  I instead check if vrsave != 0; vrsave is a
> bitset of altivec registers in use (Altivec Programming Environments
> Manual, ALTIVECPEM.pdf, section 2.3.3).
> 
> libunwind operates on a saved context, not real registers.  If a
> compiler exists that would tell libunwind to set v31 when vrsave == 0,
> this diff would break it.  I have no bool to check if I have already
> saved the vrs but vrsave == 0.
> 
> I also stop using the red zone, because it doesn't exist: a signal
> handler may clobber anything below the stack pointer.
> 
> Is the diff OK to commit?  It applies to src/lib/libunwind but you
> build it in src/lib/libcxxabi
> 
> $ cat thrown.cpp
> #include 
> #include 
> 
> using std::cout;
> using std::runtime_error;
> 
> int
> main()
> {
>   try {
>   throw runtime_error("ouch");
>   } catch(runtime_error e) {
>   cout << "caught " << e.what() << "\n";
>   }
> }
> $ clang++ -o thrown thrown.cpp
> $ ./thrown  # without the fix
> Illegal instruction (core dumped) 
> $ ./thrown  # with the fixed libc++abi.so.2.0
> caught ouch

ok kettenis@

> Index: src/Registers.hpp
> ===
> RCS file: /cvs/src/lib/libunwind/src/Registers.hpp,v
> retrieving revision 1.8
> diff -u -p -r1.8 Registers.hpp
> --- src/Registers.hpp 17 Jun 2019 22:28:51 -  1.8
> +++ src/Registers.hpp 2 Apr 2020 16:40:32 -
> @@ -630,7 +630,7 @@ private:
>  unsigned int __lr; /* Link register */
>  unsigned int __ctr;/* Count register */
>  unsigned int __mq; /* MQ register (601 only) */
> -unsigned int __vrsave; /* Vector Save Register */
> +mutable unsigned int __vrsave; /* Vector Save Register */
>};
>  
>struct ppc_float_state_t {
> @@ -640,9 +640,11 @@ private:
>  unsigned int __fpscr; /* floating point status register */
>};
>  
> +  void saveVectorRegisters() const;
> +
>ppc_thread_state_t _registers;
>ppc_float_state_t  _floatRegisters;
> -  v128   _vectorRegisters[32]; // offset 424
> +  mutable v128   _vectorRegisters[32]; // offset 424
>  };
>  
>  inline Registers_ppc::Registers_ppc(const void *registers) {
> @@ -657,10 +659,8 @@ inline Registers_ppc::Registers_ppc(cons
>   sizeof(_floatRegisters));
>static_assert(sizeof(ppc_thread_state_t) + sizeof(ppc_float_state_t) == 
> 424,
>  "expected vector register offset to be 424 bytes");
> -  memcpy(_vectorRegisters,
> - static_cast(registers) + 
> sizeof(ppc_thread_state_t) +
> - sizeof(ppc_float_state_t),
> - sizeof(_vectorRegisters));
> +  // no values until saveVectorRegisters()
> +  memset(&_vectorRegisters, 0, sizeof(_vectorRegisters));
>  }
>  
>  inline Registers_ppc::Registers_ppc() {
> @@ -780,6 +780,7 @@ inline uint32_t Registers_ppc::getRegist
>case UNW_PPC_CR7:
>  return (_registers.__cr & 0x000F);
>case UNW_PPC_VRSAVE:
> +saveVectorRegisters();
>  return _registers.__vrsave;
>}
>_LIBUNWIND_ABORT("unsupported ppc register");
> @@ -932,6 +933,7 @@ inline void Registers_ppc::setRegister(i
>  _registers.__cr |= (value & 0x000F);
>  return;
>case UNW_PPC_VRSAVE:
> +saveVectorRegisters();
>  _registers.__vrsave = value;
>  return;
>  // not saved
> @@ -976,12 +978,14 @@ inline bool Registers_ppc::validVectorRe
>  
>  inline v128 Registers_ppc::getVectorRegister(int regNum) const {
>assert(validVectorRegister(regNum));
> +  saveVectorRegisters();
>v128 result = _vectorRegisters[regNum - UNW_PPC_V0];
>return result;
>  }
>  
>  inline void Registers_ppc::setVectorRegister(int regNum, v128 value) {
>assert(validVectorRegister(regNum));
> +  saveVectorRegisters();
>_vectorRegisters[regNum - UNW_PPC_V0] = value;
>  }
>  
> Index: src/UnwindRegistersRestore.S
> 

mixerctl: use /dev/audioctl0 instead of /dev/mixer by default

2020-04-02 Thread Alexandre Ratchov
The /dev/audioctlN files, when used in O_WRONLY mode offer the same
functionality as /dev/mixerN.

Ports don't use /dev/mixerN anymore, by switching mixerctl(4) to
/dev/audioctlN too, we remove the last /dev/mixerN user.

OK?

Index: mixerctl.1
===
RCS file: /cvs/src/usr.bin/mixerctl/mixerctl.1,v
retrieving revision 1.35
diff -u -p -r1.35 mixerctl.1
--- mixerctl.1  30 Jul 2018 17:24:25 -  1.35
+++ mixerctl.1  2 Apr 2020 20:22:34 -
@@ -68,7 +68,7 @@ This is the default, if no parameters ar
 .It Fl f Ar file
 Specify an alternative audio mixing device.
 The default is
-.Pa /dev/mixer0 .
+.Pa /dev/audioctl0 .
 .It Fl n
 Suppress printing of the variable name.
 .It Fl q
@@ -153,7 +153,7 @@ The audio mixer device to use.
 .El
 .Sh FILES
 .Bl -tag -width "/etc/mixerctl.confXXX" -compact
-.It Pa /dev/mixer0
+.It Pa /dev/audioctl0
 Default mixer audio device.
 .It Pa /etc/mixerctl.conf
 .Nm
Index: mixerctl.c
===
RCS file: /cvs/src/usr.bin/mixerctl/mixerctl.c,v
retrieving revision 1.32
diff -u -p -r1.32 mixerctl.c
--- mixerctl.c  28 Jun 2019 13:35:02 -  1.32
+++ mixerctl.c  2 Apr 2020 20:22:34 -
@@ -249,7 +249,7 @@ main(int argc, char **argv)
int ndev;
 
if ((file = getenv("MIXERDEVICE")) == 0 || *file == '\0')
-   file = "/dev/mixer";
+   file = "/dev/audioctl0";
 
while ((ch = getopt(argc, argv, "af:nqtvw")) != -1) {
switch (ch) {
@@ -284,15 +284,12 @@ main(int argc, char **argv)
if (argc == 0 && tflag == 0)
aflag = 1;
 
-   if (unveil(file, "rw") == -1)
+   if (unveil(file, "w") == -1)
err(1, "unveil");
 
-   if ((fd = open(file, O_RDWR)) == -1) {
+   if ((fd = open(file, O_WRONLY)) == -1) {
if (unveil(file, "r") == -1)
err(1, "unveil");
-
-   if ((fd = open(file, O_RDONLY)) == -1)
-   err(1, "%s", file);
}
 
if (unveil(NULL, NULL) == -1)



Re: libossaudio: start using sndio

2020-04-02 Thread Alexandre Ratchov
On Thu, Apr 02, 2020 at 05:21:45PM +0100, Stuart Henderson wrote:
> On 2020/04/02 17:13, Landry Breuil wrote:
> > On Wed, Apr 01, 2020 at 07:27:12PM +0200, Alexandre Ratchov wrote:
> > > ping!
> > > 
> > > FWIW, the diff below affects the following ports:
> > >   - emulators/gambatte
> > >   - gstreamer-0.10 mixer plugin
> > >   - sysutils/conky
> > >   - sysutils/gkrellm
> > >   - sysutil/tpb
> > >   - telephony/iaxclient
> > >   - anything depending on gstreamer, ex xfce4-mixer
> > > 
> > > If you use one of above ports and want to test, just apply this diff
> > > to src/lib/libossaudio in base, rebuild it and reinstall it. The ABI
> > > is not changing, so no need to rebuild or update ports.
> 
> btw, most of these ports are either not really used (tpb, iaxclient),
> or where the mixer functionality isn't hugely important (conky, gkrellm),
> so Landry's tests here should cover things fairly well.

I've tested conky and gkrellm, it works. They show the new controls,
but this is an improvement, imho



macppc libunwind without altivec

2020-04-02 Thread George Koehler
Hello tech,

powerpc libunwind is broken on machines without altivec.  It crashes
SIGILL when code (built with base-clang++) throws a C++ exception,
because libunwind always saves the altivec registers.  You don't have
altivec if sysctl machdep.altivec is 0.  I believe that G3 cpus don't
have altivec, and G4 and G5 do have it.

This diff defers saving the altivec registers until we need to access
them.  I took the idea from arm, which defers saving VFP registers.
The diff fixes a small C++ demo on my G3.  I didn't try other C++
code; I was building ports with macppc base-clang but stopped at an
error from lang/python/3.7.

Registers_arm has members like "bool _saved_vfp_d0_d15;" to know if
VFP got saved.  I can't add a "bool _saved_vrs" to Registers_ppc,
because some assertions would fail, because unw_context_t would be
too small.  I don't enlarge unw_context_t (an opaque struct of 117 * 8
bytes) because it is in /usr/include/c++/v1/libunwind.h and I don't
want to change the ABI.  I instead check if vrsave != 0; vrsave is a
bitset of altivec registers in use (Altivec Programming Environments
Manual, ALTIVECPEM.pdf, section 2.3.3).

libunwind operates on a saved context, not real registers.  If a
compiler exists that would tell libunwind to set v31 when vrsave == 0,
this diff would break it.  I have no bool to check if I have already
saved the vrs but vrsave == 0.

I also stop using the red zone, because it doesn't exist: a signal
handler may clobber anything below the stack pointer.

Is the diff OK to commit?  It applies to src/lib/libunwind but you
build it in src/lib/libcxxabi

$ cat thrown.cpp
#include 
#include 

using std::cout;
using std::runtime_error;

int
main()
{
try {
throw runtime_error("ouch");
} catch(runtime_error e) {
cout << "caught " << e.what() << "\n";
}
}
$ clang++ -o thrown thrown.cpp
$ ./thrown  # without the fix
Illegal instruction (core dumped) 
$ ./thrown  # with the fixed libc++abi.so.2.0
caught ouch

Index: src/Registers.hpp
===
RCS file: /cvs/src/lib/libunwind/src/Registers.hpp,v
retrieving revision 1.8
diff -u -p -r1.8 Registers.hpp
--- src/Registers.hpp   17 Jun 2019 22:28:51 -  1.8
+++ src/Registers.hpp   2 Apr 2020 16:40:32 -
@@ -630,7 +630,7 @@ private:
 unsigned int __lr; /* Link register */
 unsigned int __ctr;/* Count register */
 unsigned int __mq; /* MQ register (601 only) */
-unsigned int __vrsave; /* Vector Save Register */
+mutable unsigned int __vrsave; /* Vector Save Register */
   };
 
   struct ppc_float_state_t {
@@ -640,9 +640,11 @@ private:
 unsigned int __fpscr; /* floating point status register */
   };
 
+  void saveVectorRegisters() const;
+
   ppc_thread_state_t _registers;
   ppc_float_state_t  _floatRegisters;
-  v128   _vectorRegisters[32]; // offset 424
+  mutable v128   _vectorRegisters[32]; // offset 424
 };
 
 inline Registers_ppc::Registers_ppc(const void *registers) {
@@ -657,10 +659,8 @@ inline Registers_ppc::Registers_ppc(cons
  sizeof(_floatRegisters));
   static_assert(sizeof(ppc_thread_state_t) + sizeof(ppc_float_state_t) == 424,
 "expected vector register offset to be 424 bytes");
-  memcpy(_vectorRegisters,
- static_cast(registers) + sizeof(ppc_thread_state_t) +
- sizeof(ppc_float_state_t),
- sizeof(_vectorRegisters));
+  // no values until saveVectorRegisters()
+  memset(&_vectorRegisters, 0, sizeof(_vectorRegisters));
 }
 
 inline Registers_ppc::Registers_ppc() {
@@ -780,6 +780,7 @@ inline uint32_t Registers_ppc::getRegist
   case UNW_PPC_CR7:
 return (_registers.__cr & 0x000F);
   case UNW_PPC_VRSAVE:
+saveVectorRegisters();
 return _registers.__vrsave;
   }
   _LIBUNWIND_ABORT("unsupported ppc register");
@@ -932,6 +933,7 @@ inline void Registers_ppc::setRegister(i
 _registers.__cr |= (value & 0x000F);
 return;
   case UNW_PPC_VRSAVE:
+saveVectorRegisters();
 _registers.__vrsave = value;
 return;
 // not saved
@@ -976,12 +978,14 @@ inline bool Registers_ppc::validVectorRe
 
 inline v128 Registers_ppc::getVectorRegister(int regNum) const {
   assert(validVectorRegister(regNum));
+  saveVectorRegisters();
   v128 result = _vectorRegisters[regNum - UNW_PPC_V0];
   return result;
 }
 
 inline void Registers_ppc::setVectorRegister(int regNum, v128 value) {
   assert(validVectorRegister(regNum));
+  saveVectorRegisters();
   _vectorRegisters[regNum - UNW_PPC_V0] = value;
 }
 
Index: src/UnwindRegistersRestore.S
===
RCS file: /cvs/src/lib/libunwind/src/UnwindRegistersRestore.S,v
retrieving revision 1.8
diff -u -p -r1.8 UnwindRegistersRestore.S
--- src/UnwindRegistersRestore.S17 Jun 2019 22:28:51 -  1.8
+++ src/UnwindRegistersRestore.S2 Apr 2020 16:40:33 -
@@ -476,11 

Re: libossaudio: start using sndio

2020-04-02 Thread Alexandre Ratchov
On Thu, Apr 02, 2020 at 05:13:49PM +0200, Landry Breuil wrote:
> On Wed, Apr 01, 2020 at 07:27:12PM +0200, Alexandre Ratchov wrote:
> > ping!
> > 
> > FWIW, the diff below affects the following ports:
> > - emulators/gambatte
> > - gstreamer-0.10 mixer plugin
> > - sysutils/conky
> > - sysutils/gkrellm
> > - sysutil/tpb
> > - telephony/iaxclient
> > - anything depending on gstreamer, ex xfce4-mixer
> > 
> > If you use one of above ports and want to test, just apply this diff
> > to src/lib/libossaudio in base, rebuild it and reinstall it. The ABI
> > is not changing, so no need to rebuild or update ports.
> 
> I've briefly tested it with xfce4-mixer which uses gst 0.10 - on a t430u
> with:
> 
> azalia0 at pci0 dev 27 function 0 "Intel 7 Series HD Audio" rev 0x04: msi
> azalia0: codecs: Realtek ALC269, Intel/0x2806, using Realtek ALC269
> 
> previously, it saw two controls, one for the output acting/wired to
> mixerctl values inputs.dac-0:1 & inputs.dac-2:3 (ie both changes upon
> control changes), and one for the input wired to inputs.mic
> 
> with the diff, xfce4-mixer now sees the 3 expected controls:
> * 'volume', wired to aucatctl 'master' / sndioctl 'output.level' value
> * 'input gain', wired to mixerctl record.volume, record.adc-0:1 &
> * record.adc-2:3 (and to sndioctl hw/input.level)
> * 'output gain', wired to mixerctl outputs.master, inputs.dac-0:1 &
> * inputs.dac-2:3 (and to sndioctl hw/output.level)
> 
> trying to toggle the 'mute' button in xfce4-mixer (for the 'input gain'
> only) leads to 'Error setting mixer recording devices (0x0): Invalid
> argument' msgs on stderr but im not sure it matters.
> 

This is "ok", it tries to select the input source, but as there's only
one choice exposed it complains on stderr.

> toggling the mute button for volume and input gain set the level to 0
> instead of toggling the hw/output.mute button but im not sure it's a big
> deal either.

This is expected as well. The mute controls, instead xfce4-mixer saves
the current level and sets it to zero. When the control is unmuted, it
sets the level to the saved value.

> all in all that seems an improvement to me, at least does what's
> expected for gst 0.10/xfce4-mixer.
> 

Many thanks for looking at this.



UPDATE: xserver 1.20.8

2020-04-02 Thread Matthieu Herrb
Hi,

The patch below updates the X server to version 1.20.8.

Apply the patch in ${XSRCDIR}/xserver with patch -p0 -E and then
rebuild Xenocara according to release(8).

Comments, ok ?

Index: ChangeLog
===
RCS file: /cvs/OpenBSD/xenocara/xserver/ChangeLog,v
retrieving revision 1.35
diff -u -p -u -r1.35 ChangeLog
--- ChangeLog   26 Jan 2020 13:48:54 -  1.35
+++ ChangeLog   2 Apr 2020 17:59:06 -
@@ -1,3 +1,414 @@
+commit f84ad082557f9cde6b8faa373eca6a0a89ba7d56
+Author: Matt Turner 
+Date:   Sun Mar 29 13:02:03 2020 -0700
+
+xserver 1.20.8
+
+Signed-off-by: Matt Turner 
+
+commit 8837279869309317c110afb6f2f3c24484c77657
+Author: Jon Turney 
+Date:   Wed Apr 17 11:37:11 2019 +0100
+
+Fix old-style definition warning for xf86OSInputThreadInit()
+
+../hw/xfree86/os-support/stub/stub_init.c: In function 
‘xf86OSInputThreadInit’:
+../hw/xfree86/os-support/stub/stub_init.c:29:1: warning: old-style 
function definition [-Wold-style-definition]
+
+(cherry picked from commit 7c266cafed14b38c039091651069ae9888c3a8ae)
+
+commit 0c012f968b4e02a2bc892ce71f7bea9bd3f7fb22
+Author: Jon Turney 
+Date:   Wed Mar 13 14:57:14 2019 +
+
+Add xf86OSInputThreadInit to stub os-support as well
+
+stub os support also needs to provide xf86OSInputThreadInit, omitted in
+ea1527a8
+
+(cherry picked from commit c020769dbfb965740c8441d8242b738ef572a7c9)
+
+commit b259485975078087fe6bde2b9e1eccf4ae14120c
+Author: Michel Dänzer 
+Date:   Tue Mar 17 11:45:22 2020 +0100
+
+xwayland: Delete all frame_callback_list nodes in xwl_unrealize_window
+
+We were only calling xwl_present_unrealize_window for the toplevel
+window, but the list can contain entries from child windows as well,
+in which case we were leaving dangling pointers to freed memory.
+
+Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/1000
+Fixes: c5067feaeea1 "xwayland: Use single frame callback for Present
+ flips and normal updates"
+Reviewed-by: Olivier Fourdan 
+Tested-by: Olivier Fourdan 
+(cherry picked from commit 5e91587302e85fd6f0e8d5ffbe30182e18c6913f)
+
+commit a033571644d277dc49a489f7ae32c4ad92856543
+Author: Jonas Ådahl 
+Date:   Fri Sep 13 17:11:27 2019 +0200
+
+xwayland/glamor-gbm: Handle DRM_FORMAT_MOD_INVALID gracefully
+
+The compositor may send DRM_FORMAT_MOD_INVALID instead of a list of
+modifiers for various reasons. Handle this gracefully by ignoring it.
+
+Without this, if a compositor would send DRM_FORMAT_MOD_INVALID, it'd
+result in empty windows provided by Xwayland.
+
+Signed-off-by: Jonas Ådahl 
+Reviewed-by: Olivier Fourdan 
+Reviewed-by: Michel Dänzer 
+(cherry picked from commit edf964434eac10ffbe27cc883e3ab95505669aee)
+
+commit 3c48bd50ad33f2a533ac76afa38d6e3906ebc28a
+Author: Arthur Williams 
+Date:   Sun Oct 6 18:55:35 2019 +
+
+dix: Check for NULL spriteInfo in GetPairedDevice
+
+There is a race when reseting the XServer that causes spriteInfo to be
+NULL in GetPairedDevice resulting a segfault and subsequent crash. The
+problem was noticed when opening a connection, creating master devices,
+destroying master devices and closing the connection during testing.
+
+Signed-off-by: Arthur Williams 
+
+
+(cherry picked from commit e693c9657f98c334e9921ca2f8ebf710497c0c6a)
+
+commit 1610ef1d6b5ba99da9d1a639f3b65b2e61514a7d
+Author: David Seifert 
+Date:   Fri Jan 24 12:49:44 2020 +0100
+
+Fix building with `-fno-common`
+
+* GCC 10 will switch the default to `-fno-common`.
+  https://gcc.gnu.org/PR85678
+
+Bug: https://bugs.gentoo.org/705880
+Signed-off-by: Matt Turner 
+
+commit 2a185dd22ddb5b0d7d2ef5948591028766bb9530
+Author: Michel Dänzer 
+Date:   Mon Mar 2 18:09:31 2020 +0100
+
+xwayland: Use frame callbacks for Present vblank events
+
+Instead of only the fallback timer.
+
+Fixes https://gitlab.freedesktop.org/xorg/xserver/issues/854
+
+v2:
+* Drop unused frame_callback member of struct xwl_present_window
+  (Olivier Fourdan)
+
+Reviewed-by: Olivier Fourdan 
+(cherry picked from commit 9b31358c52e951883bf7c01c953a9da080542244)
+
+commit 99a6d6b15e0757a4652a569a1b2070c76a00b567
+Author: Michel Dänzer 
+Date:   Wed Nov 27 18:04:06 2019 +0100
+
+xwayland: Use single frame callback for Present flips and normal updates
+
+Using a list of Present windows that need to be called back.
+
+This prepares for the following change, there should be no change in
+observed behaviour.
+
+v2:
+* Use xwl_window_create_frame_callback instead of making the
+  frame_listener struct non-static (Olivier Fourdan)
+
+Reviewed-by: Olivier Fourdan 
+(cherry picked from commit c5067feaeea115761f0a72f37407c6e5e943d1a1)
+
+commit 

Re: PATCH: rad(8) Better PIO default lifetimes

2020-04-02 Thread Fernando Gont

Hi, Florian,

On 2/4/20 15:08, Florian Obser wrote:
[...]

After talking to Fernando I came up with this much simpler patch:



Will come back with comments on your patch, but wanted to note a couple 
of things bellow:




[...]


Other aspects of draft-gont-6man-slaac-renum are still being discussed
in the 6man WG, these numbers don't seem to be too contentious though.


Exactly. In fact, I believe The default Valid Lifetime shouldn't be 
longer than 2 * Router Lifetime. -- at the end of the day, with a 
default Router Lifetime of 1800 seconds, the Valid Lifetime would become 
1 hour.


And if the router disappears for that long, e.g. TCP timers would ahve 
already gone off way before.


The reason I set the Valid Lifetime as 28 * Router Lifetime was because 
a colleague expressed concerns (on the ietf v6ops list) about a short 
Valid Lifetime, and I didn't want to have the draft shot down just 
because of that. At the end of the day, even reducing the Valid Lifetime 
from 1 month to 1 day was a big win ;-)





On the other hand I don't think we are in a big hurry to get this in
and we can wait a bit on how this plays out. Administrators can
already set these values by themselves in rad.conf

I'm also not opposed to this and I do agree that the current defaults
from RFC 4861 are way to high (7 days prefered lifetime and 30 days
valid lifetime).


FWIW, Linux radvd() has long deviated from RFC4861. They use:
Valid Lifetime: 86400 seconds (1 day)
Preferred Lifetime: 14400 seconds (4 hours)

(see https://github.com/reubenhwk/radvd/blob/master/radvd.conf.5.man)




Due to hardware issues I'm currently not using rad(8). My ISP provided
cpe sends router advertisements with considerably lower lifetimes then
the rfc defaults.
The vltime is 14.5 hours and 12 seconds(?!) and the pltime 6.5 hours
and 12 seconds.


The values in the RFC are insane. In fact, when talking to one of the 
original authors of Neighbor Discovery, he noted that it's probably an 
historical artifact how the timers got screwed up the way they are (in 
the spec).





Thoughts from people who are actually running this?

Oh, and we need to update the manpage.

p.s.: And I see that tab vs. space is still messed up in the defines
even after I tried to fix it :/ Maybe I should just let that part go


I can try clean that up and update the manpage if that helps.

Thanks!
--
Fernando Gont
e-mail: ferna...@gont.com.ar || fg...@si6networks.com
PGP Fingerprint: 7809 84F5 322E 45C7 F1C9 3945 96EE A9EF D076 FFF1





Re: d_poll() inconsistencies

2020-04-02 Thread Mark Kettenis
> Date: Thu, 2 Apr 2020 20:12:08 +0200
> From: Martin Pieuchot 
> Content-Type: text/plain; charset=utf-8
> 
> While reviewing the all current .d_poll() functions I found those two
> which are incoherent with the rest.
> 
> - Most of the devices return POLLERR when the device is no longer valid,
>   for whatever reason, uhid(4) returns POLLHUP in one of the cases.

POSIX says:

POLLHUP

  A device has been disconnected, or a pipe or FIFO has been closed by
  the last process that had it open for writing. Once set, the hangup
  state of a FIFO shall persist until some process opens the FIFO for
  writing or until all read-only file descriptors for the FIFO are
  closed. This event and POLLOUT are mutually-exclusive; a stream can
  never be writable if a hangup has occurred. However, this event and
  POLLIN, POLLRDNORM, POLLRDBAND, or POLLPRI are not
  mutually-exclusive. This flag is only valid in the revents bitmask;
  it shall be ignored in the events member.

So POLLHUP makes sense for devices that can be disconnected.

> - fusepoll() return EINVAL which isn't a POLL* value, here again POLLERR
>   is what is wanted.

This one is ok.

> Index: dev/usb/uhid.c
> ===
> RCS file: /cvs/src/sys/dev/usb/uhid.c,v
> retrieving revision 1.77
> diff -u -p -r1.77 uhid.c
> --- dev/usb/uhid.c20 Feb 2020 16:56:52 -  1.77
> +++ dev/usb/uhid.c2 Apr 2020 18:08:03 -
> @@ -420,7 +420,7 @@ uhidpoll(dev_t dev, int events, struct p
>   return (POLLERR);
>  
>   if (usbd_is_dying(sc->sc_hdev.sc_udev))
> - return (POLLHUP);
> + return (POLLERR);
>  
>   s = splusb();
>   if (events & (POLLOUT | POLLWRNORM))
> Index: miscfs/fuse/fuse_device.c
> ===
> RCS file: /cvs/src/sys/miscfs/fuse/fuse_device.c,v
> retrieving revision 1.31
> diff -u -p -r1.31 fuse_device.c
> --- miscfs/fuse/fuse_device.c 20 Feb 2020 16:56:52 -  1.31
> +++ miscfs/fuse/fuse_device.c 2 Apr 2020 18:08:03 -
> @@ -523,7 +523,7 @@ fusepoll(dev_t dev, int events, struct p
>  
>   fd = fuse_lookup(minor(dev));
>   if (fd == NULL)
> - return (EINVAL);
> + return (POLLERR);
>  
>   if (events & (POLLIN | POLLRDNORM))
>   if (!SIMPLEQ_EMPTY(>fd_fbufs_in))
> 
> 



d_poll() inconsistencies

2020-04-02 Thread Martin Pieuchot
While reviewing the all current .d_poll() functions I found those two
which are incoherent with the rest.

- Most of the devices return POLLERR when the device is no longer valid,
  for whatever reason, uhid(4) returns POLLHUP in one of the cases.

- fusepoll() return EINVAL which isn't a POLL* value, here again POLLERR
  is what is wanted.

ok?

Index: dev/usb/uhid.c
===
RCS file: /cvs/src/sys/dev/usb/uhid.c,v
retrieving revision 1.77
diff -u -p -r1.77 uhid.c
--- dev/usb/uhid.c  20 Feb 2020 16:56:52 -  1.77
+++ dev/usb/uhid.c  2 Apr 2020 18:08:03 -
@@ -420,7 +420,7 @@ uhidpoll(dev_t dev, int events, struct p
return (POLLERR);
 
if (usbd_is_dying(sc->sc_hdev.sc_udev))
-   return (POLLHUP);
+   return (POLLERR);
 
s = splusb();
if (events & (POLLOUT | POLLWRNORM))
Index: miscfs/fuse/fuse_device.c
===
RCS file: /cvs/src/sys/miscfs/fuse/fuse_device.c,v
retrieving revision 1.31
diff -u -p -r1.31 fuse_device.c
--- miscfs/fuse/fuse_device.c   20 Feb 2020 16:56:52 -  1.31
+++ miscfs/fuse/fuse_device.c   2 Apr 2020 18:08:03 -
@@ -523,7 +523,7 @@ fusepoll(dev_t dev, int events, struct p
 
fd = fuse_lookup(minor(dev));
if (fd == NULL)
-   return (EINVAL);
+   return (POLLERR);
 
if (events & (POLLIN | POLLRDNORM))
if (!SIMPLEQ_EMPTY(>fd_fbufs_in))



Re: PATCH: rad(8) Better PIO default lifetimes (was: Re: Improve handling of IPv6 SLAAC renumbering scenarios)

2020-04-02 Thread Florian Obser
On Fri, Mar 27, 2020 at 11:10:25PM -0300, Fernando Gont wrote:
> Florian/folks,
> 
> This is an improved version:
> 
> Essentially, if the lifetime of a prefix is not specified (i.e., the admin
> relies on the default values), the Preferred Lifetime is set to the Router
> Lifetime, and the Valid Lifetime is set to Router Lifetime * 48 (one day)
> 
> This improve the state of affairs for renumbering events on the router side.
> 

After talking to Fernando I came up with this much simpler patch:

diff --git parse.y parse.y
index 8e0a899470f..88b31364816 100644
--- parse.y
+++ parse.y
@@ -964,8 +964,8 @@ conf_get_ra_prefix(struct in6_addr *addr, int prefixlen)
if (prefix == NULL)
errx(1, "%s: calloc", __func__);
prefix->prefixlen = prefixlen;
-   prefix->vltime = ADV_VALID_LIFETIME;
-   prefix->pltime = ADV_PREFERRED_LIFETIME;
+   prefix->pltime = ra_options->router_lifetime;
+   prefix->vltime = VLTIME_PLTIME_FACTOR * prefix->pltime;
prefix->lflag = 1;
prefix->aflag = 1;
 
diff --git rad.h rad.h
index 09cc9cf204e..3d58c3558fc 100644
--- rad.h
+++ rad.h
@@ -29,8 +29,7 @@
 #defineMAX_RTR_ADV_INTERVAL600
 #defineMIN_RTR_ADV_INTERVAL200
 #defineADV_DEFAULT_LIFETIME3 * MAX_RTR_ADV_INTERVAL
-#defineADV_PREFERRED_LIFETIME  604800  /* 7 days */
-#define ADV_VALID_LIFETIME 2592000 /* 30 days */
+#defineVLTIME_PLTIME_FACTOR48
 #defineMAX_SEARCH  1025/* MAXDNAME in arpa/nameser.h */
 #defineDEFAULT_RDNS_LIFETIME   600 * 1.5
 

Other aspects of draft-gont-6man-slaac-renum are still being discussed
in the 6man WG, these numbers don't seem to be too contentious though.

On the other hand I don't think we are in a big hurry to get this in
and we can wait a bit on how this plays out. Administrators can
already set these values by themselves in rad.conf

I'm also not opposed to this and I do agree that the current defaults
from RFC 4861 are way to high (7 days prefered lifetime and 30 days
valid lifetime).

Due to hardware issues I'm currently not using rad(8). My ISP provided
cpe sends router advertisements with considerably lower lifetimes then
the rfc defaults.
The vltime is 14.5 hours and 12 seconds(?!) and the pltime 6.5 hours
and 12 seconds.

Thoughts from people who are actually running this?

Oh, and we need to update the manpage.

p.s.: And I see that tab vs. space is still messed up in the defines
even after I tried to fix it :/ Maybe I should just let that part go


-- 
I'm not entirely sure you are real.



Re: pipex(4) man page fix

2020-04-02 Thread Iain R. Learmonth
Hi,

On 02/04/2020 12:47, Vitaliy Makkoveev wrote:
> +.Xr pppax 4 ,

I guess you meant pppac here.

Thanks,
Iain.



Re: libossaudio: start using sndio

2020-04-02 Thread Stuart Henderson
On 2020/04/02 17:13, Landry Breuil wrote:
> On Wed, Apr 01, 2020 at 07:27:12PM +0200, Alexandre Ratchov wrote:
> > ping!
> > 
> > FWIW, the diff below affects the following ports:
> > - emulators/gambatte
> > - gstreamer-0.10 mixer plugin
> > - sysutils/conky
> > - sysutils/gkrellm
> > - sysutil/tpb
> > - telephony/iaxclient
> > - anything depending on gstreamer, ex xfce4-mixer
> > 
> > If you use one of above ports and want to test, just apply this diff
> > to src/lib/libossaudio in base, rebuild it and reinstall it. The ABI
> > is not changing, so no need to rebuild or update ports.

btw, most of these ports are either not really used (tpb, iaxclient),
or where the mixer functionality isn't hugely important (conky, gkrellm),
so Landry's tests here should cover things fairly well.

> I've briefly tested it with xfce4-mixer which uses gst 0.10 - on a t430u
> with:
> 
> azalia0 at pci0 dev 27 function 0 "Intel 7 Series HD Audio" rev 0x04: msi
> azalia0: codecs: Realtek ALC269, Intel/0x2806, using Realtek ALC269
> 
> previously, it saw two controls, one for the output acting/wired to
> mixerctl values inputs.dac-0:1 & inputs.dac-2:3 (ie both changes upon
> control changes), and one for the input wired to inputs.mic
> 
> with the diff, xfce4-mixer now sees the 3 expected controls:
> * 'volume', wired to aucatctl 'master' / sndioctl 'output.level' value
> * 'input gain', wired to mixerctl record.volume, record.adc-0:1 &
> * record.adc-2:3 (and to sndioctl hw/input.level)
> * 'output gain', wired to mixerctl outputs.master, inputs.dac-0:1 &
> * inputs.dac-2:3 (and to sndioctl hw/output.level)
> 
> trying to toggle the 'mute' button in xfce4-mixer (for the 'input gain'
> only) leads to 'Error setting mixer recording devices (0x0): Invalid
> argument' msgs on stderr but im not sure it matters.
> 
> toggling the mute button for volume and input gain set the level to 0
> instead of toggling the hw/output.mute button but im not sure it's a big
> deal either.
> 
> all in all that seems an improvement to me, at least does what's
> expected for gst 0.10/xfce4-mixer.



iked(8): boolify

2020-04-02 Thread Wataru Ashihara
It would save our time of thinking and reading the source (i.e.
eliminate the process of "what if the variable 'mobike' was 2 or more?
...aha it's just a bool").

This is still work in progress. I would continue if you maintainers are
positive on this proposal.


Index: sbin/iked/config.c
===
RCS file: /cvs/src/sbin/iked/config.c,v
retrieving revision 1.55
diff -u -r1.55 config.c
--- sbin/iked/config.c  24 Mar 2020 13:32:36 -  1.55
+++ sbin/iked/config.c  2 Apr 2020 15:45:44 -
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -39,7 +40,7 @@
 #include "ikev2.h"
 
 struct iked_sa *
-config_new_sa(struct iked *env, int initiator)
+config_new_sa(struct iked *env, bool initiator)
 {
struct iked_sa  *sa;
 
@@ -451,7 +452,7 @@
  */
 
 int
-config_setcoupled(struct iked *env, unsigned int couple)
+config_setcoupled(struct iked *env, bool couple)
 {
unsigned int type;
 
@@ -465,11 +466,11 @@
 config_getcoupled(struct iked *env, unsigned int type)
 {
return (pfkey_couple(env->sc_pfkey, >sc_sas,
-   type == IMSG_CTL_COUPLE ? 1 : 0));
+   type == IMSG_CTL_COUPLE));
 }
 
 int
-config_setmode(struct iked *env, unsigned int passive)
+config_setmode(struct iked *env, bool passive)
 {
unsigned int type;
 
@@ -482,17 +483,17 @@
 int
 config_getmode(struct iked *env, unsigned int type)
 {
-   uint8_t  old;
+   bool old;
unsigned char   *mode[] = { "active", "passive" };
 
-   old = env->sc_passive ? 1 : 0;
-   env->sc_passive = type == IMSG_CTL_PASSIVE ? 1 : 0;
+   old = env->sc_passive;
+   env->sc_passive = (type == IMSG_CTL_PASSIVE);
 
if (old == env->sc_passive)
return (0);
 
log_debug("%s: mode %s -> %s", __func__,
-   mode[old], mode[env->sc_passive]);
+   mode[old ? 1 : 0], mode[env->sc_passive ? 1 : 0]);
 
return (0);
 }
@@ -848,22 +849,22 @@
 int
 config_setmobike(struct iked *env)
 {
-   unsigned int boolval;
+   bool val;
 
-   boolval = env->sc_mobike;
+   val = env->sc_mobike;
proc_compose(>sc_ps, PROC_IKEV2, IMSG_CTL_MOBIKE,
-   , sizeof(boolval));
+   , sizeof(val));
return (0);
 }
 
 int
 config_getmobike(struct iked *env, struct imsg *imsg)
 {
-   unsigned int boolval;
+   bool mobike;
 
-   IMSG_SIZE_CHECK(imsg, );
-   memcpy(, imsg->data, sizeof(boolval));
-   env->sc_mobike = boolval;
+   IMSG_SIZE_CHECK(imsg, );
+   memcpy(, imsg->data, sizeof(mobike));
+   env->sc_mobike = mobike;
log_debug("%s: %smobike", __func__, env->sc_mobike ? "" : "no ");
return (0);
 }
@@ -871,22 +872,22 @@
 int
 config_setfragmentation(struct iked *env)
 {
-   unsigned int boolval;
+   bool fragmentation;
 
-   boolval = env->sc_frag;
+   fragmentation = env->sc_frag;
proc_compose(>sc_ps, PROC_IKEV2, IMSG_CTL_FRAGMENTATION,
-   , sizeof(boolval));
+   , sizeof(fragmentation));
return (0);
 }
 
 int
 config_getfragmentation(struct iked *env, struct imsg *imsg)
 {
-   unsigned int boolval;
+   bool fragmentation;
 
-   IMSG_SIZE_CHECK(imsg, );
-   memcpy(, imsg->data, sizeof(boolval));
-   env->sc_frag = boolval;
+   IMSG_SIZE_CHECK(imsg, );
+   memcpy(, imsg->data, sizeof(fragmentation));
+   env->sc_frag = fragmentation;
log_debug("%s: %sfragmentation", __func__, env->sc_frag ? "" : "no ");
return (0);
 }
Index: sbin/iked/crypto.c
===
RCS file: /cvs/src/sbin/iked/crypto.c,v
retrieving revision 1.23
diff -u -r1.23 crypto.c
--- sbin/iked/crypto.c  14 Feb 2020 13:02:31 -  1.23
+++ sbin/iked/crypto.c  2 Apr 2020 15:45:44 -
@@ -21,6 +21,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -504,7 +505,7 @@
if (prf == NULL || prf->hash_priv == NULL)
fatalx("dsa_new: invalid PRF");
dsa.dsa_priv = prf->hash_priv;
-   dsa.dsa_hmac = 1;
+   dsa.dsa_hmac = true;
break;
case IKEV2_AUTH_DSS_SIG:
dsa.dsa_priv = EVP_dss1();
Index: sbin/iked/iked.c
===
RCS file: /cvs/src/sbin/iked/iked.c,v
retrieving revision 1.41
diff -u -r1.41 iked.c
--- sbin/iked/iked.c16 Jan 2020 20:05:00 -  1.41
+++ sbin/iked/iked.c2 Apr 2020 15:45:44 -
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -261,10 +262,10 @@
config_setmobike(env);
config_setfragmentation(env);
config_setnattport(env);
-   config_setcoupled(env, env->sc_decoupled ? 0 : 1);
+   config_setcoupled(env, !env->sc_decoupled);
config_setocsp(env);
/* Must 

Re: libossaudio: start using sndio

2020-04-02 Thread Landry Breuil
On Wed, Apr 01, 2020 at 07:27:12PM +0200, Alexandre Ratchov wrote:
> ping!
> 
> FWIW, the diff below affects the following ports:
>   - emulators/gambatte
>   - gstreamer-0.10 mixer plugin
>   - sysutils/conky
>   - sysutils/gkrellm
>   - sysutil/tpb
>   - telephony/iaxclient
>   - anything depending on gstreamer, ex xfce4-mixer
> 
> If you use one of above ports and want to test, just apply this diff
> to src/lib/libossaudio in base, rebuild it and reinstall it. The ABI
> is not changing, so no need to rebuild or update ports.

I've briefly tested it with xfce4-mixer which uses gst 0.10 - on a t430u
with:

azalia0 at pci0 dev 27 function 0 "Intel 7 Series HD Audio" rev 0x04: msi
azalia0: codecs: Realtek ALC269, Intel/0x2806, using Realtek ALC269

previously, it saw two controls, one for the output acting/wired to
mixerctl values inputs.dac-0:1 & inputs.dac-2:3 (ie both changes upon
control changes), and one for the input wired to inputs.mic

with the diff, xfce4-mixer now sees the 3 expected controls:
* 'volume', wired to aucatctl 'master' / sndioctl 'output.level' value
* 'input gain', wired to mixerctl record.volume, record.adc-0:1 &
* record.adc-2:3 (and to sndioctl hw/input.level)
* 'output gain', wired to mixerctl outputs.master, inputs.dac-0:1 &
* inputs.dac-2:3 (and to sndioctl hw/output.level)

trying to toggle the 'mute' button in xfce4-mixer (for the 'input gain'
only) leads to 'Error setting mixer recording devices (0x0): Invalid
argument' msgs on stderr but im not sure it matters.

toggling the mute button for volume and input gain set the level to 0
instead of toggling the hw/output.mute button but im not sure it's a big
deal either.

all in all that seems an improvement to me, at least does what's
expected for gst 0.10/xfce4-mixer.



iwm/iwx: fix tx result reporting

2020-04-02 Thread Stefan Sperling
While working on iwm Tx aggregation and revisiting some parts of MiRA,
I have noticed a rate-control problem in iwm and iwx (this also affects
iwn, but I am leaving that for later since iwn already does Tx aggregation
and requires a more elaborate fix).

Rate control algorithms will choose a Tx rate and then gather feedback
from drivers on per-frame basis, with the assumption that feedback
provided by drivers is always based on frames which have been transmitted
at the most recently chosen rate.

During a transmit burst, e.g. while tcpbench is running, iwm and iwx will
queue up to 224 frames on the Tx ring (256 would fit, but our driver stops
queuing new frames after 224 have been queued; an easy way to tell whether
this condition has been reached is to check whether ifconfig reports the
OACTIVE interface flag).

The problem is that rate control will make decisions a lot more often than
just every 224 frames. Which means that results get reported and evaluated
even if they do not correspond to the most recently chosen rate, spoiling
the data available to the rate control algorithm.

This change prevents this problem by only reporting frames which match
the currently chosen Tx rate. Since the algorithms do not advance unless
their choose() function is called this effectively flushes out frames
queued at any previously chosen rates and restarts reporting as soon as
frames with the expected rate are being processed.

ok?

(I am also tweaking how iwx reports retries to AMRR; this is just to reduce
complexity and differences to iwm, and shouldn't make a big difference)

diff 144217ab9d3715f0cf6c417288c8a50500b221fa 
addfc4a92b67df7f2aa49c5af241e149413d0015
blob - 2dbd3cac8dc4eddb316034b37b5ce951868b019a
blob + c9d48475e122021d2738076c838a2d8ef03cf48b
--- sys/dev/pci/if_iwx.c
+++ sys/dev/pci/if_iwx.c
@@ -336,7 +336,7 @@ voidiwx_rx_frame(struct iwx_softc *, struct mbuf *, 
i
struct ieee80211_rxinfo *, struct mbuf_list *);
 void   iwx_enable_ht_cck_fallback(struct iwx_softc *, struct iwx_node *);
 void   iwx_rx_tx_cmd_single(struct iwx_softc *, struct iwx_rx_packet *,
-   struct iwx_node *);
+   struct iwx_node *, int, int);
 void   iwx_rx_tx_cmd(struct iwx_softc *, struct iwx_rx_packet *,
struct iwx_rx_data *);
 void   iwx_rx_bmiss(struct iwx_softc *, struct iwx_rx_packet *,
@@ -3563,7 +3563,7 @@ iwx_enable_ht_cck_fallback(struct iwx_softc *sc, struc
 
 void
 iwx_rx_tx_cmd_single(struct iwx_softc *sc, struct iwx_rx_packet *pkt,
-struct iwx_node *in)
+struct iwx_node *in, int txmcs, int txrate)
 {
struct ieee80211com *ic = >sc_ic;
struct ieee80211_node *ni = >in_ni;
@@ -3577,19 +3577,23 @@ iwx_rx_tx_cmd_single(struct iwx_softc *sc, struct iwx_
txfail = (status != IWX_TX_STATUS_SUCCESS &&
status != IWX_TX_STATUS_DIRECT_DONE);
 
-   /* Update rate control statistics. */
+   /*
+* Update rate control statistics.
+* Only report frames which were actually queued with the currently
+* selected Tx rate. Because Tx queues are relatively long we may
+* encounter previously selected rates here during Tx bursts.
+* Providing feedback based on such frames can lead to suboptimal
+* Tx rate control decisions.
+*/
if ((ni->ni_flags & IEEE80211_NODE_HT) == 0 || in->ht_force_cck) {
-   in->in_amn.amn_txcnt++;
-   if (in->ht_force_cck) {
-   /*
-* We want to move back to OFDM quickly if possible.
-* Only show actual Tx failures to AMRR, not retries.
-*/
+   if (txrate == ni->ni_txrate) {
+   in->in_amn.amn_txcnt++;
if (txfail)
in->in_amn.amn_retrycnt++;
-   } else if (tx_resp->failure_frame > 0)
-   in->in_amn.amn_retrycnt++;
-   } else if (ic->ic_fixed_mcs == -1) {
+   if (tx_resp->failure_frame > 0)
+   in->in_amn.amn_retrycnt++;
+   }
+   } else if (ic->ic_fixed_mcs == -1 && txmcs == ni->ni_txmcs) {
in->in_mn.frames += tx_resp->frame_count;
in->in_mn.ampdu_size = le16toh(tx_resp->byte_cnt);
in->in_mn.agglen = tx_resp->frame_count;
@@ -3650,7 +3654,7 @@ iwx_rx_tx_cmd(struct iwx_softc *sc, struct iwx_rx_pack
if (txd->m == NULL)
return;
 
-   iwx_rx_tx_cmd_single(sc, pkt, txd->in);
+   iwx_rx_tx_cmd_single(sc, pkt, txd->in, txd->txmcs, txd->txrate);
iwx_txd_done(sc, txd);
 
/*
@@ -4304,6 +4308,8 @@ iwx_tx(struct iwx_softc *sc, struct mbuf *m, struct ie
}
data->m = m;
data->in = in;
+   data->txmcs = ni->ni_txmcs;
+   data->txrate = ni->ni_txrate;
 
/* Fill TX descriptor. */
num_tbs = 2 + data->map->dm_nsegs;
blob - 

Re: Fix pipex(4) pipex_ioctl() access to not owned sessions (kernel crash too)

2020-04-02 Thread Vitaliy Makkoveev
Sorry, screenshot was from pached kernel. Screenshot from clean kernel
included.


Fix pipex(4) pipex_ioctl() access to not owned sessions (kernel crash too)

2020-04-02 Thread Vitaliy Makkoveev
pipex(4) has pipex_ioctl() interface for pipex_session related routines.
pipex_ioctl() calls should be done with pipex_iface_contex, so any
operations should be done with pipex_sessions owned by passed
pipex_iface_contex. pipex_session check ownership is missing within
pipex_ioctl() so anybody can do pipex_ioctl() commands PIPEXDSESSION,
PIPEXCSESSION, PIPEXGSTAT and PIPEXGCLOSED on any pipex_session.
PIPEXDSESSION on foreign pppx(4) owned pipex_session will crash kernel.
Code to reproduce and screenshot attached below. Diffs below add
pipes_session ownrship check to pipex_ioctl() internals.

 cut begin

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 

#define PIPEX_CLOSE_TIMEOUT 30

int main(void)
{
int fd_pppx, fd_pppac;
struct pipex_session_req reqa;
struct pipex_session_close_req reqd;

if((fd_pppx=open("/dev/pppx0", O_RDWR))<0){
err(1, "open(pppx0)");
}

if((fd_pppac=open("/dev/pppac0", O_RDWR))<0){
err(1, "open(pppac0)");
}

memset(, 0, sizeof(reqa));
reqa.pr_protocol=PIPEX_PROTO_L2TP;
reqa.pr_peer_mru=1024;
reqa.pr_local_address.ss_family=AF_INET;
reqa.pr_local_address.ss_len=sizeof(struct sockaddr_in);
reqa.pr_peer_address.ss_family=AF_INET;
reqa.pr_peer_address.ss_len=sizeof(struct sockaddr_in);
inet_aton("10.0.0.1", _ip_srcaddr);
inet_aton("10.0.0.2", _ip_address);
inet_aton("255.255.255.255", _ip_netmask);

if(ioctl(fd_pppx, PIPEXASESSION, )<0){
err(1, "ioctl(fd_pppx, PIPEXASESSION)");
}

memset(, 0, sizeof(reqd));
reqd.pcr_protocol=PIPEX_PROTO_L2TP;

if(ioctl(fd_pppac, PIPEXDSESSION, )<0){
err(1, "ioctl(fd_ppaac, PIPEDSESSION)");
}

sleep(PIPEX_CLOSE_TIMEOUT+1);

return 0;
}

 cut end

This diff fix pipex_ioctl(PIPEXDSESSION) crash issue

 cut begin
diff --git sys/net/pipex.c sys/net/pipex.c
index 3da8ed8..22edce3 100644
--- sys/net/pipex.c
+++ sys/net/pipex.c
@@ -230,7 +230,7 @@ pipex_ioctl(struct pipex_iface_context *pipex_iface, u_long 
cmd, caddr_t data)
 
case PIPEXDSESSION:
ret = pipex_close_session(
-   (struct pipex_session_close_req *)data);
+   (struct pipex_session_close_req *)data, pipex_iface);
break;
 
case PIPEXCSESSION:
@@ -489,7 +489,8 @@ pipex_notify_close_session_all(void)
 }
 
 Static int
-pipex_close_session(struct pipex_session_close_req *req)
+pipex_close_session(struct pipex_session_close_req *req,
+struct pipex_iface_context *iface)
 {
struct pipex_session *session;
 
@@ -498,6 +499,8 @@ pipex_close_session(struct pipex_session_close_req *req)
req->pcr_session_id);
if (session == NULL)
return (EINVAL);
+   if (session->pipex_iface != iface)
+   return (EINVAL);
 
/* remove from close_wait list */
if (session->state == PIPEX_STATE_CLOSE_WAIT)
diff --git sys/net/pipex_local.h sys/net/pipex_local.h
index cf02c8e..ad3c3d3 100644
--- sys/net/pipex_local.h
+++ sys/net/pipex_local.h
@@ -369,7 +369,8 @@ extern struct pipex_hash_head   pipex_id_hashtable[];
 void  pipex_iface_start (struct pipex_iface_context *);
 void  pipex_iface_stop (struct pipex_iface_context *);
 int   pipex_add_session (struct pipex_session_req *, struct 
pipex_iface_context *);
-int   pipex_close_session (struct pipex_session_close_req *);
+int   pipex_close_session (struct pipex_session_close_req *,
+  struct pipex_iface_context *);
 int   pipex_config_session (struct pipex_session_config_req *);
 int   pipex_get_stat (struct pipex_session_stat_req *);
 int   pipex_get_closed (struct pipex_session_list_req *);
 cut end

This diff add ownership checks to the rest pipex_ioctl() commands. A few
words about pppx_get_closed(): since in-kernel timeout feature was
disabled for pppx(4) related pipex_sessions, closed pipex_sessions can't
exist in system, so this function is dummy. I have an idea how to
reenable this disabled timeout, but some reafactoring requited, and fair
pipex_ioctl(PIPEXGCLOSED) call will be restored.

 cut begin
diff --git sys/net/if_pppx.c sys/net/if_pppx.c
index 37a6af0..6c4977d 100644
--- sys/net/if_pppx.c
+++ sys/net/if_pppx.c
@@ -175,6 +175,12 @@ intpppx_add_session(struct pppx_dev *,
struct pipex_session_req *);
 intpppx_del_session(struct pppx_dev *,
struct pipex_session_close_req *);
+intpppx_config_session(struct pppx_dev *,
+   struct pipex_session_config_req *);
+intpppx_get_stat(struct pppx_dev *,
+

Re: pipex(4) man page fix

2020-04-02 Thread Vitaliy Makkoveev
On Thu, Apr 02, 2020 at 09:07:23AM +0200, Martin Pieuchot wrote:
> On 29/03/20(Sun) 00:16, Vitaliy Makkoveev wrote:
> > pipex not used with tun(4)
> 
> It seems an oversight from the addition of the new pppac(4) driver.  See
> net/if_tun.c commits from January this year.
> 
> So the right fix would be to replace tun(4) with pppac(4) and add a pppac.4
> manpage.  Do you feel like tackling that?

Sure. Also PIPEXDSESSION describes pipex_session_stat_req instead of
pipex_session_close_req. I fixed it too.

Index: share/man/man4/pipex.4
===
RCS file: /cvs/src/share/man/man4/pipex.4,v
retrieving revision 1.11
diff -u -p -r1.11 pipex.4
--- share/man/man4/pipex.4  18 Apr 2017 03:21:48 -  1.11
+++ share/man/man4/pipex.4  2 Apr 2020 11:45:40 -
@@ -32,7 +32,7 @@
 .Sh DESCRIPTION
 .Nm
 is used with
-.Xr tun 4
+.Xr pppac 4
 and
 .Xr pppx 4 ,
 and handles PPP frames and forwards IP packets in-kernel.
@@ -51,7 +51,7 @@ using
 adds some extensions to the
 .Xr ioctl 2
 requests to
-.Xr tun 4
+.Xr pppac 4
 or
 .Xr pppx 4
 devices.
@@ -104,8 +104,7 @@ struct pipex_session_req {
 uint16_tpr_peer_mru; /* peer's mru */
 uint16_tpr_timeout_sec;  /* idle timer */
 
-struct in_addr  pr_ip_srcaddr;/* local IP address.
-not used by tun(4) */
+struct in_addr  pr_ip_srcaddr;/* local IP address */
 struct in_addr  pr_ip_address;/* framed IP address */
 struct in_addr  pr_ip_netmask;/* framed IP netmask */
 struct sockaddr_in6 pr_ip6_address;   /* framed IPv6 address */
@@ -171,10 +170,10 @@ struct pipex_mppe_req {
 .It Dv PIPEXDSESSION Fa "struct pipex_session_close_req *"
 Delete the specified session from the kernel.
 Specify the session using a
-.Vt pipex_session_stat_req
+.Vt pipex_session_close_req
 structure, which has the following definition:
 .Bd -literal
-struct pipex_session_stat_req {
+struct pipex_session_close_req {
 int  psr_protocol;   /* tunnel protocol */
 uint16_t psr_session_id; /* session-id */
 struct pipex_statistics  psr_stat;   /* statistics */
@@ -265,7 +264,7 @@ Set the
 .Xr pppx 4
 interface's description of the session.
 This command doesn't work on
-.Xr tun 4
+.Xr pppac 4
 devices.
 Specify the session and its description using a
 .Vt pipex_session_descr_req
@@ -280,8 +279,8 @@ struct pipex_session_descr_req {
 .El
 .Sh SEE ALSO
 .Xr ioctl 2 ,
+.Xr pppax 4 ,
 .Xr pppx 4 ,
-.Xr tun 4 ,
 .Xr npppd 8 ,
 .Xr sysctl 8
 .Sh AUTHORS



Re: usb(4): use cacheable buffers for data transfers (massive speedup)

2020-04-02 Thread Patrick Wildt
On Wed, Apr 01, 2020 at 12:23:53PM +0200, Patrick Wildt wrote:
> On Wed, Apr 01, 2020 at 12:04:25PM +0200, Patrick Wildt wrote:
> > On Wed, Apr 01, 2020 at 09:40:06AM +0200, Patrick Wildt wrote:
> > > On Wed, Apr 01, 2020 at 09:22:07AM +0200, Patrick Wildt wrote:
> > > > On Wed, Apr 01, 2020 at 04:47:10PM +1100, Jonathan Gray wrote:
> > > > > On Wed, Apr 01, 2020 at 12:58:23PM +1100, Jonathan Gray wrote:
> > > > > > On Wed, Mar 18, 2020 at 01:41:06PM +0100, Patrick Wildt wrote:
> > > > > > > On Wed, Mar 18, 2020 at 11:22:40AM +0100, Patrick Wildt wrote:
> > > > > > > > Hi,
> > > > > > > > 
> > > > > > > > I've spent a few days investigating why USB ethernet adapters 
> > > > > > > > are so
> > > > > > > > horribly slow on my ARMs.  Using dt(4) I realized that it was 
> > > > > > > > spending
> > > > > > > > most of its time in memcpy.  But, why?  As it turns out, all 
> > > > > > > > USB data
> > > > > > > > buffers are mapped COHERENT, which on some/most ARMs means 
> > > > > > > > uncached.
> > > > > > > > Using cached data buffers makes the performance rise from 20 
> > > > > > > > mbit/s to
> > > > > > > > 200 mbit/s.  Quite a difference.
> > > > > > > > 
> > > > > > > > sys/dev/usb/usb_mem.c:
> > > > > > > > error = bus_dmamem_map(tag, p->segs, p->nsegs, p->size,
> > > > > > > >>kaddr, 
> > > > > > > > BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
> > > > > > > > 
> > > > > > > > On x86, COHERENT is essentially a no-op.  On ARM, it depends on 
> > > > > > > > the SoC.
> > > > > > > > Some SoCs have cache-coherent USB controllers, some don't.  
> > > > > > > > Mine does
> > > > > > > > not, so mapping it COHERENT means uncached and thus slow.
> > > > > > > > 
> > > > > > > > Why do we do that?  Well, when the code was imported in 99, it 
> > > > > > > > was
> > > > > > > > already there.  Since then we have gained infrastructure for DMA
> > > > > > > > syncs in the USB stack, which I think are proper.
> > > > > > > > 
> > > > > > > > sys/dev/usb/usbdi.c - usbd_transfer() (before transfer)
> > > > > > > > 
> > > > > > > > if (!usbd_xfer_isread(xfer)) {
> > > > > > > > if ((xfer->flags & USBD_NO_COPY) == 0)
> > > > > > > > memcpy(KERNADDR(>dmabuf, 0), 
> > > > > > > > xfer->buffer,
> > > > > > > > xfer->length);
> > > > > > > > usb_syncmem(>dmabuf, 0, xfer->length,
> > > > > > > > BUS_DMASYNC_PREWRITE);
> > > > > > > > } else
> > > > > > > > usb_syncmem(>dmabuf, 0, xfer->length,
> > > > > > > > BUS_DMASYNC_PREREAD);
> > > > > > > > err = pipe->methods->transfer(xfer);
> > > > > > > > 
> > > > > > > > sys/dev/usb/usbdi.c - usb_transfer_complete() (after transfer)
> > > > > > > > 
> > > > > > > > if (xfer->actlen != 0) {
> > > > > > > > if (usbd_xfer_isread(xfer)) {
> > > > > > > > usb_syncmem(>dmabuf, 0, 
> > > > > > > > xfer->actlen,
> > > > > > > > BUS_DMASYNC_POSTREAD);
> > > > > > > > if (!(xfer->flags & USBD_NO_COPY))
> > > > > > > > memcpy(xfer->buffer, 
> > > > > > > > KERNADDR(>dmabuf, 0),
> > > > > > > > xfer->actlen);
> > > > > > > > } else
> > > > > > > > usb_syncmem(>dmabuf, 0, 
> > > > > > > > xfer->actlen,
> > > > > > > > BUS_DMASYNC_POSTWRITE);
> > > > > > > > }
> > > > > > > > 
> > > > > > > > We cannot just remove COHERENT, since some drivers, like 
> > > > > > > > ehci(4), use
> > > > > > > > the same backend to allocate their rings.  And I can't vouch 
> > > > > > > > for those
> > > > > > > > drivers' sanity.
> > > > > > > > 
> > > > > > > > As a first step, I would like to go ahead with another 
> > > > > > > > solution, which
> > > > > > > > is based on a diff from Marius Strobl, who added those syncs in 
> > > > > > > > the
> > > > > > > > first place.  Essentially it splits the memory handling into 
> > > > > > > > cacheable
> > > > > > > > and non-cacheable blocks.  The USB data transfers and everyone 
> > > > > > > > who uses
> > > > > > > > usbd_alloc_buffer() then use cacheable buffers, while code like 
> > > > > > > > ehci(4)
> > > > > > > > still don't.  This is a bit of a safer approach imho, since we 
> > > > > > > > don't
> > > > > > > > hurt the controller drivers, but speed up the data buffers.
> > > > > > > > 
> > > > > > > > Once we have verified that there are no regressions, we can 
> > > > > > > > adjust
> > > > > > > > ehci(4) and the like, add proper syncs, make sure they still 
> > > > > > > > work as
> > > > > > > > well as before, and maybe then back this out again.
> > > > > > > > 
> > > > > > > > Keep note that this is all a no-op on X86, but all the other 
> > > > > > > > archs will
> > > > > > > > profit from this.
> > > > > > > 

[patch] mandoc: Remove argument names from function prototypes

2020-04-02 Thread Martin
Hi there!

I think these are superfluous.

Best,

Martin

Index: cgi.c
===
RCS file: /cvs/src/usr.bin/mandoc/cgi.c,v
retrieving revision 1.109
diff -u -p -r1.109 cgi.c
--- cgi.c   10 Jan 2020 15:20:49 -  1.109
+++ cgi.c   2 Apr 2020 08:54:45 -
@@ -66,9 +66,9 @@ enum  focus {
 static void html_print(const char *);
 static void html_putchar(char);
 static int  http_decode(char *);
-static void http_encode(const char *p);
+static void http_encode(const char *);
 static void parse_manpath_conf(struct req *);
-static void parse_path_info(struct req *req, const char *path);
+static void parse_path_info(struct req *, const char *);
 static void parse_query_string(struct req *, const char *);
 static void pg_error_badrequest(const char *);
 static void pg_error_internal(void);
Index: libmandoc.h
===
RCS file: /cvs/src/usr.bin/mandoc/libmandoc.h,v
retrieving revision 1.63
diff -u -p -r1.63 libmandoc.h
--- libmandoc.h 19 Jan 2020 16:16:32 -  1.63
+++ libmandoc.h 2 Apr 2020 08:54:45 -
@@ -73,7 +73,7 @@ void   roff_man_reset(struct roff_man *)
 int roff_parseln(struct roff *, int, struct buf *, int *);
 voidroff_userret(struct roff *);
 voidroff_endparse(struct roff *);
-voidroff_setreg(struct roff *, const char *, int, char sign);
+voidroff_setreg(struct roff *, const char *, int, char);
 int roff_getreg(struct roff *, const char *);
 char   *roff_strdup(const struct roff *, const char *);
 char   *roff_getarg(struct roff *, char **, int, int *);
Index: mandoc.h
===
RCS file: /cvs/src/usr.bin/mandoc/mandoc.h,v
retrieving revision 1.208
diff -u -p -r1.208 mandoc.h
--- mandoc.h19 Jan 2020 17:59:01 -  1.208
+++ mandoc.h2 Apr 2020 08:54:45 -
@@ -299,7 +299,7 @@ enummandoc_esc {
 };
 
 
-enum mandoc_esc  mandoc_font(const char *, int sz);
+enum mandoc_esc  mandoc_font(const char *, int);
 enum mandoc_esc  mandoc_escape(const char **, const char **, int *);
 void mandoc_msg_setoutfile(FILE *);
 const char  *mandoc_msg_getinfilename(void);
Index: mandocdb.c
===
RCS file: /cvs/src/usr.bin/mandoc/mandocdb.c,v
retrieving revision 1.215
diff -u -p -r1.215 mandocdb.c
--- mandocdb.c  26 Jan 2020 21:24:58 -  1.215
+++ mandocdb.c  2 Apr 2020 08:54:45 -
@@ -107,7 +107,7 @@ struct  mdoc_handler {
 int mandocdb(int, char *[]);
 
 static void dbadd(struct dba *, struct mpage *);
-static void dbadd_mlink(const struct mlink *mlink);
+static void dbadd_mlink(const struct mlink *);
 static void dbprune(struct dba *);
 static void dbwrite(struct dba *);
 static void filescan(const char *);
Index: mdoc_markdown.c
===
RCS file: /cvs/src/usr.bin/mandoc/mdoc_markdown.c,v
retrieving revision 1.34
diff -u -p -r1.34 mdoc_markdown.c
--- mdoc_markdown.c 27 Feb 2020 01:25:57 -  1.34
+++ mdoc_markdown.c 2 Apr 2020 08:54:45 -
@@ -29,16 +29,16 @@
 #include "main.h"
 
 struct md_act {
-   int (*cond)(struct roff_node *n);
-   int (*pre)(struct roff_node *n);
-   void(*post)(struct roff_node *n);
+   int (*cond)(struct roff_node *);
+   int (*pre)(struct roff_node *);
+   void(*post)(struct roff_node *);
const char   *prefix; /* pre-node string constant */
const char   *suffix; /* post-node string constant */
 };
 
 static void md_nodelist(struct roff_node *);
 static void md_node(struct roff_node *);
-static const char *md_stack(char c);
+static const char *md_stack(char);
 static void md_preword(void);
 static void md_rawword(const char *);
 static void md_word(const char *);
Index: out.h
===
RCS file: /cvs/src/usr.bin/mandoc/out.h,v
retrieving revision 1.24
diff -u -p -r1.24 out.h
--- out.h   18 Aug 2018 20:17:58 -  1.24
+++ out.h   2 Apr 2020 08:54:45 -
@@ -64,5 +64,5 @@ structrofftbl {
 struct tbl_span;
 
 const char  *a2roffsu(const char *, struct roffsu *, enum roffscale);
-void tblcalc(struct rofftbl *tbl,
+void tblcalc(struct rofftbl *,
const struct tbl_span *, size_t, size_t);
Index: roff.c
===
RCS file: /cvs/src/usr.bin/mandoc/roff.c,v
retrieving revision 1.243
diff -u -p -r1.243 roff.c
--- 

Re: Dedulpicate pipex(4) and pppx(4) code

2020-04-02 Thread Vitaliy Makkoveev
On Thu, Apr 02, 2020 at 09:26:23AM +0200, Martin Pieuchot wrote:
> Hello Vitaliy,
> 
> On 01/04/20(Wed) 12:59, Vitaliy Makkoveev wrote:
> > Updated diff. The idea is to use already existing pipex API for
> > pipex_session creation and destruction. pppx_if now holds a reference
> > to pipex_session.
> 
> This is great!
> 
> There are many things in this diff which makes it complicated to review,
> at least to me.  Note that I'm not really familiar with this code.
> 
> For example the panic() after the RBT_REMOVE() is now questionable since
> the lock is released then retaken.  Which brings a question for later:
> what is the lock really protecting?  That can be documented in the header
> like it is done for other data structures.
> 
> So the changes includes:
> 
> - pool_get() with PR_WAITOK should never fail.  This could be the first
>   step and also move the allocation at the beginning to make a pattern
>   appear.
> 
> - Allocation of `pxi_session' separately from `pxi', this creates quite
>   some noise because of the line changing indirection.
> 
> - Change in the error paths, which aren't correct and IMHO should be
>   left out for the moment.
> 
> - Use of pipex_add_session(), isn't that independent from the allocation
>   of `session'?
> 
> Could you help me review this by submitting smaller diffs?  Thanks a
> lot!
Let's take a break, another pipex(4) issue found. I'll send diff for it
it today later with new thread.

> 
> > 
> > Index: sys/net/if_pppx.c
> > ===
> > RCS file: /cvs/src/sys/net/if_pppx.c,v
> > retrieving revision 1.78
> > diff -u -p -r1.78 if_pppx.c
> > --- sys/net/if_pppx.c   1 Apr 2020 07:15:59 -   1.78
> > +++ sys/net/if_pppx.c   1 Apr 2020 09:50:19 -
> > @@ -155,7 +155,7 @@ struct pppx_if {
> > int pxi_unit;
> > struct ifnetpxi_if;
> > struct pppx_dev *pxi_dev;
> > -   struct pipex_sessionpxi_session;
> > +   struct pipex_session*pxi_session;
> > struct pipex_iface_context  pxi_ifcontext;
> >  };
> >  
> > @@ -655,15 +655,10 @@ int
> >  pppx_add_session(struct pppx_dev *pxd, struct pipex_session_req *req)
> >  {
> > struct pppx_if *pxi;
> > -   struct pipex_session *session;
> > -   struct pipex_hash_head *chain;
> > struct ifnet *ifp;
> > int unit, error = 0;
> > struct in_ifaddr *ia;
> > struct sockaddr_in ifaddr;
> > -#ifdef PIPEX_PPPOE
> > -   struct ifnet *over_ifp = NULL;
> > -#endif
> >  
> > /*
> >  * XXX: As long as `session' is allocated as part of a `pxi'
> > @@ -673,157 +668,16 @@ pppx_add_session(struct pppx_dev *pxd, s
> > if (req->pr_timeout_sec != 0)
> > return (EINVAL);
> >  
> > -   switch (req->pr_protocol) {
> > -#ifdef PIPEX_PPPOE
> > -   case PIPEX_PROTO_PPPOE:
> > -   over_ifp = ifunit(req->pr_proto.pppoe.over_ifname);
> > -   if (over_ifp == NULL)
> > -   return (EINVAL);
> > -   if (req->pr_peer_address.ss_family != AF_UNSPEC)
> > -   return (EINVAL);
> > -   break;
> > -#endif
> > -#if defined(PIPEX_PPTP) || defined(PIPEX_L2TP)
> > -   case PIPEX_PROTO_PPTP:
> > -   case PIPEX_PROTO_L2TP:
> > -   switch (req->pr_peer_address.ss_family) {
> > -   case AF_INET:
> > -   if (req->pr_peer_address.ss_len != sizeof(struct 
> > sockaddr_in))
> > -   return (EINVAL);
> > -   break;
> > -#ifdef INET6
> > -   case AF_INET6:
> > -   if (req->pr_peer_address.ss_len != sizeof(struct 
> > sockaddr_in6))
> > -   return (EINVAL);
> > -   break;
> > -#endif
> > -   default:
> > -   return (EPROTONOSUPPORT);
> > -   }
> > -   if (req->pr_peer_address.ss_family !=
> > -   req->pr_local_address.ss_family ||
> > -   req->pr_peer_address.ss_len !=
> > -   req->pr_local_address.ss_len)
> > -   return (EINVAL);
> > -   break;
> > -#endif /* defined(PIPEX_PPTP) || defined(PIPEX_L2TP) */
> > -   default:
> > -   return (EPROTONOSUPPORT);
> > -   }
> > -
> > pxi = pool_get(pppx_if_pl, PR_WAITOK | PR_ZERO);
> > -   if (pxi == NULL)
> > -   return (ENOMEM);
> > -
> > -   session = >pxi_session;
> > ifp = >pxi_if;
> >  
> > -   /* fake a pipex interface context */
> > -   session->pipex_iface = >pxi_ifcontext;
> > -   session->pipex_iface->ifnet_this = ifp;
> > -   session->pipex_iface->pipexmode = PIPEX_ENABLED;
> > -
> > -   /* setup session */
> > -   session->state = PIPEX_STATE_OPENED;
> > -   session->protocol = req->pr_protocol;
> > -   session->session_id = req->pr_session_id;
> > -   session->peer_session_id = req->pr_peer_session_id;
> > -   session->peer_mru = req->pr_peer_mru;
> > -   session->timeout_sec = req->pr_timeout_sec;
> > -   session->ppp_flags = 

Fix occasional signify regression test fail

2020-04-02 Thread Christian Ludwig
The signify regression test creates a tar archive from the test's
directory. Without a symlink to the obj directory, the output tarball is
part of the input file list. This makes tar complain that archive.tgz
was modified during copy to archive.

Avoid including the output archive by reducing the input file list to
text files only.

While there, tweak the list of files to clean.
---
 regress/usr.bin/signify/Makefile   | 3 ++-
 regress/usr.bin/signify/signify.sh | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/regress/usr.bin/signify/Makefile b/regress/usr.bin/signify/Makefile
index 208bc5eff38..6fff3450e11 100644
--- a/regress/usr.bin/signify/Makefile
+++ b/regress/usr.bin/signify/Makefile
@@ -1,6 +1,7 @@
 #  $OpenBSD: Makefile,v 1.4 2014/03/17 02:49:02 tedu Exp $
 
-CLEANFILES += test.sig confirmorders confirmorders.sig HASH.sig
+CLEANFILES += test.sig confirmorders confirmorders.sig HASH HASH.sig \
+ archive.tgz signed.tgz
 REGRESS_TARGETS = t1
 
 t1:
diff --git a/regress/usr.bin/signify/signify.sh 
b/regress/usr.bin/signify/signify.sh
index d83dff79b19..5c2d86dec98 100644
--- a/regress/usr.bin/signify/signify.sh
+++ b/regress/usr.bin/signify/signify.sh
@@ -28,7 +28,7 @@ signify -S -e -s $seckey -m HASH
 rm HASH
 signify -C -q -p $pubkey -x HASH.sig
 
-tar zcPf archive.tgz $srcdir 
+tar zcPf archive.tgz $srcdir/*.txt
 signify -zS -s $seckey -m archive.tgz -x signed.tgz
 # check it's still valid gzip
 gunzip -t signed.tgz
-- 
2.26.0



Re: Dedulpicate pipex(4) and pppx(4) code

2020-04-02 Thread Martin Pieuchot
Hello Vitaliy,

On 01/04/20(Wed) 12:59, Vitaliy Makkoveev wrote:
> Updated diff. The idea is to use already existing pipex API for
> pipex_session creation and destruction. pppx_if now holds a reference
> to pipex_session.

This is great!

There are many things in this diff which makes it complicated to review,
at least to me.  Note that I'm not really familiar with this code.

For example the panic() after the RBT_REMOVE() is now questionable since
the lock is released then retaken.  Which brings a question for later:
what is the lock really protecting?  That can be documented in the header
like it is done for other data structures.

So the changes includes:

- pool_get() with PR_WAITOK should never fail.  This could be the first
  step and also move the allocation at the beginning to make a pattern
  appear.

- Allocation of `pxi_session' separately from `pxi', this creates quite
  some noise because of the line changing indirection.

- Change in the error paths, which aren't correct and IMHO should be
  left out for the moment.

- Use of pipex_add_session(), isn't that independent from the allocation
  of `session'?

Could you help me review this by submitting smaller diffs?  Thanks a
lot!

> 
> Index: sys/net/if_pppx.c
> ===
> RCS file: /cvs/src/sys/net/if_pppx.c,v
> retrieving revision 1.78
> diff -u -p -r1.78 if_pppx.c
> --- sys/net/if_pppx.c 1 Apr 2020 07:15:59 -   1.78
> +++ sys/net/if_pppx.c 1 Apr 2020 09:50:19 -
> @@ -155,7 +155,7 @@ struct pppx_if {
>   int pxi_unit;
>   struct ifnetpxi_if;
>   struct pppx_dev *pxi_dev;
> - struct pipex_sessionpxi_session;
> + struct pipex_session*pxi_session;
>   struct pipex_iface_context  pxi_ifcontext;
>  };
>  
> @@ -655,15 +655,10 @@ int
>  pppx_add_session(struct pppx_dev *pxd, struct pipex_session_req *req)
>  {
>   struct pppx_if *pxi;
> - struct pipex_session *session;
> - struct pipex_hash_head *chain;
>   struct ifnet *ifp;
>   int unit, error = 0;
>   struct in_ifaddr *ia;
>   struct sockaddr_in ifaddr;
> -#ifdef PIPEX_PPPOE
> - struct ifnet *over_ifp = NULL;
> -#endif
>  
>   /*
>* XXX: As long as `session' is allocated as part of a `pxi'
> @@ -673,157 +668,16 @@ pppx_add_session(struct pppx_dev *pxd, s
>   if (req->pr_timeout_sec != 0)
>   return (EINVAL);
>  
> - switch (req->pr_protocol) {
> -#ifdef PIPEX_PPPOE
> - case PIPEX_PROTO_PPPOE:
> - over_ifp = ifunit(req->pr_proto.pppoe.over_ifname);
> - if (over_ifp == NULL)
> - return (EINVAL);
> - if (req->pr_peer_address.ss_family != AF_UNSPEC)
> - return (EINVAL);
> - break;
> -#endif
> -#if defined(PIPEX_PPTP) || defined(PIPEX_L2TP)
> - case PIPEX_PROTO_PPTP:
> - case PIPEX_PROTO_L2TP:
> - switch (req->pr_peer_address.ss_family) {
> - case AF_INET:
> - if (req->pr_peer_address.ss_len != sizeof(struct 
> sockaddr_in))
> - return (EINVAL);
> - break;
> -#ifdef INET6
> - case AF_INET6:
> - if (req->pr_peer_address.ss_len != sizeof(struct 
> sockaddr_in6))
> - return (EINVAL);
> - break;
> -#endif
> - default:
> - return (EPROTONOSUPPORT);
> - }
> - if (req->pr_peer_address.ss_family !=
> - req->pr_local_address.ss_family ||
> - req->pr_peer_address.ss_len !=
> - req->pr_local_address.ss_len)
> - return (EINVAL);
> - break;
> -#endif /* defined(PIPEX_PPTP) || defined(PIPEX_L2TP) */
> - default:
> - return (EPROTONOSUPPORT);
> - }
> -
>   pxi = pool_get(pppx_if_pl, PR_WAITOK | PR_ZERO);
> - if (pxi == NULL)
> - return (ENOMEM);
> -
> - session = >pxi_session;
>   ifp = >pxi_if;
>  
> - /* fake a pipex interface context */
> - session->pipex_iface = >pxi_ifcontext;
> - session->pipex_iface->ifnet_this = ifp;
> - session->pipex_iface->pipexmode = PIPEX_ENABLED;
> -
> - /* setup session */
> - session->state = PIPEX_STATE_OPENED;
> - session->protocol = req->pr_protocol;
> - session->session_id = req->pr_session_id;
> - session->peer_session_id = req->pr_peer_session_id;
> - session->peer_mru = req->pr_peer_mru;
> - session->timeout_sec = req->pr_timeout_sec;
> - session->ppp_flags = req->pr_ppp_flags;
> - session->ppp_id = req->pr_ppp_id;
> -
> - session->ip_forward = 1;
> -
> - session->ip_address.sin_family = AF_INET;
> - session->ip_address.sin_len = sizeof(struct sockaddr_in);
> - session->ip_address.sin_addr = req->pr_ip_address;
> -
> - session->ip_netmask.sin_family 

Re: pipex(4) man page fix

2020-04-02 Thread Martin Pieuchot
On 29/03/20(Sun) 00:16, Vitaliy Makkoveev wrote:
> pipex not used with tun(4)

It seems an oversight from the addition of the new pppac(4) driver.  See
net/if_tun.c commits from January this year.

So the right fix would be to replace tun(4) with pppac(4) and add a pppac.4
manpage.  Do you feel like tackling that?

> Index: share/man/man4/pipex.4
> ===
> RCS file: /cvs/src/share/man/man4/pipex.4,v
> retrieving revision 1.11
> diff -u -p -r1.11 pipex.4
> --- share/man/man4/pipex.418 Apr 2017 03:21:48 -  1.11
> +++ share/man/man4/pipex.428 Mar 2020 21:13:57 -
> @@ -32,9 +32,7 @@
>  .Sh DESCRIPTION
>  .Nm
>  is used with
> -.Xr tun 4
> -and
> -.Xr pppx 4 ,
> +.Xr pppx 4
>  and handles PPP frames and forwards IP packets in-kernel.
>  It accelerates the performance of packet forwarding, because it reduces
>  copying of packets between kernel and userland.
> @@ -51,10 +49,8 @@ using
>  adds some extensions to the
>  .Xr ioctl 2
>  requests to
> -.Xr tun 4
> -or
>  .Xr pppx 4
> -devices.
> +device.
>  The added requests are as follows:
>  .Bl -tag -width Ds
>  .It Dv PIPEXGMODEFa "int *"
> @@ -104,8 +100,7 @@ struct pipex_session_req {
>  uint16_tpr_peer_mru; /* peer's mru */
>  uint16_tpr_timeout_sec;  /* idle timer */
>  
> -struct in_addr  pr_ip_srcaddr;/* local IP address.
> -  not used by tun(4) */
> +struct in_addr  pr_ip_srcaddr;/* local IP address */
>  struct in_addr  pr_ip_address;/* framed IP address */
>  struct in_addr  pr_ip_netmask;/* framed IP netmask */
>  struct sockaddr_in6 pr_ip6_address;   /* framed IPv6 address */
> @@ -264,9 +259,6 @@ struct pipex_session_list_req {
>  Set the
>  .Xr pppx 4
>  interface's description of the session.
> -This command doesn't work on
> -.Xr tun 4
> -devices.
>  Specify the session and its description using a
>  .Vt pipex_session_descr_req
>  structure, which has the following definition:
> @@ -281,7 +273,6 @@ struct pipex_session_descr_req {
>  .Sh SEE ALSO
>  .Xr ioctl 2 ,
>  .Xr pppx 4 ,
> -.Xr tun 4 ,
>  .Xr npppd 8 ,
>  .Xr sysctl 8
>  .Sh AUTHORS
>