Re: Add "-c command" option to script(1)

2017-12-13 Thread Paul de Weerd
Hi Jason,

Thank you for your quick feedback!  I've incorporated yours and
off-list feedback from ian@ into a new diff included below.  The diff
now also includes the removal of /* ARGSUSED */ lint comments.

On Wed, Dec 13, 2017 at 09:34:03PM +, Jason McIntyre wrote:
| > +To run a
| 
| i'd remove "a", but it's preference only - your choice.
| 
| > +.Ar command
| > +with its own arguments, enclose it in quotes.
| 
| and s/its own//

Rewrote this sentence a bit, it now reads:

-c command
Run command instead of an interactive shell.  To run a command
with arguments, enclose both in quotes.

Still not 100% happy with it, but the best I could come up with.
Better suggestions wanted :)

Paul

Index: script.1
===
RCS file: /cvs/src/usr.bin/script/script.1,v
retrieving revision 1.14
diff -u -p -r1.14 script.1
--- script.115 Jan 2012 20:06:40 -  1.14
+++ script.114 Dec 2017 07:36:11 -
@@ -39,6 +39,7 @@
 .Sh SYNOPSIS
 .Nm script
 .Op Fl a
+.Op Fl c Ar command
 .Op Ar file
 .Sh DESCRIPTION
 .Nm
@@ -65,9 +66,14 @@ Append the output to
 or
 .Pa typescript ,
 retaining the prior contents.
+.It Fl c Ar command
+Run
+.Ar command
+instead of an interactive shell.
+To run a command with arguments, enclose both in quotes.
 .El
 .Pp
-The script ends when the forked shell exits (a control-D
+The script ends when the forked program exits (a control-D
 .Pq Ql ^D
 to exit
 the Bourne shell
Index: script.c
===
RCS file: /cvs/src/usr.bin/script/script.c,v
retrieving revision 1.33
diff -u -p -r1.33 script.c
--- script.c12 Apr 2017 14:49:05 -  1.33
+++ script.c14 Dec 2017 07:34:10 -
@@ -89,7 +89,7 @@ int   istty;
 
 __dead void done(int);
 void dooutput(void);
-void doshell(void);
+void doshell(char *);
 void fail(void);
 void finish(int);
 void scriptflush(int);
@@ -102,17 +102,23 @@ main(int argc, char *argv[])
struct sigaction sa;
struct winsize win;
char ibuf[BUFSIZ];
+   char *cmd;
ssize_t cc, off;
int aflg, ch;
 
+   cmd = NULL;
aflg = 0;
-   while ((ch = getopt(argc, argv, "a")) != -1)
+   while ((ch = getopt(argc, argv, "ac:")) != -1)
switch(ch) {
case 'a':
aflg = 1;
break;
+   case 'c':
+   cmd = optarg;
+   break;
default:
-   fprintf(stderr, "usage: %s [-a] [file]\n", __progname);
+   fprintf(stderr, "usage: %s [-a] [-c command] [file]\n",
+   __progname);
exit(1);
}
argc -= optind;
@@ -163,7 +169,7 @@ main(int argc, char *argv[])
if (child)
dooutput();
else
-   doshell();
+   doshell(cmd);
}
 
bzero(&sa, sizeof sa);
@@ -196,7 +202,6 @@ main(int argc, char *argv[])
done(sigdeadstatus);
 }
 
-/* ARGSUSED */
 void
 finish(int signo)
 {
@@ -215,7 +220,6 @@ finish(int signo)
errno = save_errno;
 }
 
-/* ARGSUSED */
 void
 handlesigwinch(int signo)
 {
@@ -294,7 +298,6 @@ dooutput(void)
done(0);
 }
 
-/* ARGSUSED */
 void
 scriptflush(int signo)
 {
@@ -302,9 +305,10 @@ scriptflush(int signo)
 }
 
 void
-doshell(void)
+doshell(char *cmd)
 {
char *shell;
+   char *argp[] = {"sh", "-c", NULL, NULL};
 
shell = getenv("SHELL");
if (shell == NULL)
@@ -313,8 +317,15 @@ doshell(void)
(void)close(master);
(void)fclose(fscript);
login_tty(slave);
-   execl(shell, shell, "-i", (char *)NULL);
-   warn("%s", shell);
+
+   if (cmd != NULL) {
+   argp[2] = cmd;
+   execv(_PATH_BSHELL, argp);
+   warn("unable to execute %s", _PATH_BSHELL);
+   } else {
+   execl(shell, shell, "-i", (char *)NULL);
+   warn("%s", shell);
+   }
fail();
 }

 
-- 
>[<++>-]<+++.>+++[<-->-]<.>+++[<+
+++>-]<.>++[<>-]<+.--.[-]
 http://www.weirdnet.nl/ 



Re: Add reset option to boot command of ddb(4)

2017-12-13 Thread Florian Riehm

I will prepare a new diff including the other architecures and
try to find people who can test it.
I have had such a diff already but then I decided to remove
the untested parts because I didn't want to submit untested
code.

friehm

On 12/13/17 21:59, Theo de Raadt wrote:

As it is, this diff will not go in.

Your 2nd attempt is not architecture aware either.  There are more
than 2 architectures.  If you add a MI feature, you must attempt to
add support for it to all the MD versions.  And the process of mailing
it out to the community gives people an opportunity to help test
those.

Seeing as this is only a goto and a label: on each architecture, what
is the purpose of not even trying to write such a diff??  You are
leaving the work, hoping someone eventually does it??

That isn't the way we work.


This patch follows bluhm's attempt for a ddb command 'boot reset'.
My first attempt was not architecture aware.

Tested on i386 by bluhm@ and on amd64 by me.

ok?

friehm

Index: share/man/man4/ddb.4
===
RCS file: /openbsd/src/share/man/man4/ddb.4,v
retrieving revision 1.92
diff -u -p -r1.92 ddb.4
--- share/man/man4/ddb.429 Nov 2017 07:28:21 -  1.92
+++ share/man/man4/ddb.412 Dec 2017 06:35:44 -
@@ -381,6 +381,15 @@ Just halt.
  Just reboot.
  .It Ic boot poweroff
  Power down the machine whenever possible; if it fails, just halt.
+.It Ic boot reset
+Restart the machine by resetting the CPU on i386 and amd64
+architectures.
+Useful in situations were
+.Ic boot reboot
+does not work anymore, i.e. due to locking issues.
+On other platforms it is equivalent to the
+.Ic boot reboot
+command.
  .El
  .\" 
  .It Xo
Index: sys/arch/amd64/amd64/machdep.c
===
RCS file: /openbsd/src/sys/arch/amd64/amd64/machdep.c,v
retrieving revision 1.236
diff -u -p -r1.236 machdep.c
--- sys/arch/amd64/amd64/machdep.c  11 Dec 2017 05:27:40 -  1.236
+++ sys/arch/amd64/amd64/machdep.c  12 Dec 2017 06:35:44 -
@@ -713,6 +713,9 @@ struct pcb dumppcb;
  __dead void
  boot(int howto)
  {
+   if ((howto & RB_RESET) != 0)
+   goto reset;
+
if ((howto & RB_POWERDOWN) != 0)
lid_action = 0;
  
@@ -770,6 +773,7 @@ haltsys:

printf("rebooting...\n");
if (cpureset_delay > 0)
delay(cpureset_delay * 1000);
+reset:
cpu_reset();
for (;;)
continue;
Index: sys/arch/i386/i386/machdep.c
===
RCS file: /openbsd/src/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.607
diff -u -p -r1.607 machdep.c
--- sys/arch/i386/i386/machdep.c11 Dec 2017 05:27:40 -  1.607
+++ sys/arch/i386/i386/machdep.c12 Dec 2017 06:35:44 -
@@ -2629,6 +2629,9 @@ struct pcb dumppcb;
  __dead void
  boot(int howto)
  {
+   if ((howto & RB_RESET) != 0)
+   goto reset;
+
if ((howto & RB_POWERDOWN) != 0)
lid_action = 0;
  
@@ -2709,6 +2712,7 @@ haltsys:

}
  
  	printf("rebooting...\n");

+reset:
cpu_reset();
for (;;)
continue;
Index: sys/ddb/db_command.c
===
RCS file: /openbsd/src/sys/ddb/db_command.c,v
retrieving revision 1.81
diff -u -p -r1.81 db_command.c
--- sys/ddb/db_command.c11 Dec 2017 05:27:40 -  1.81
+++ sys/ddb/db_command.c12 Dec 2017 06:35:44 -
@@ -105,6 +105,7 @@ voiddb_boot_dump_cmd(db_expr_t, int, db
  void  db_boot_halt_cmd(db_expr_t, int, db_expr_t, char *);
  void  db_boot_reboot_cmd(db_expr_t, int, db_expr_t, char *);
  void  db_boot_poweroff_cmd(db_expr_t, int, db_expr_t, char *);
+void   db_boot_reset_cmd(db_expr_t, int, db_expr_t, char *);
  void  db_stack_trace_cmd(db_expr_t, int, db_expr_t, char *);
  void  db_dmesg_cmd(db_expr_t, int, db_expr_t, char *);
  void  db_show_panic_cmd(db_expr_t, int, db_expr_t, char *);
@@ -597,6 +598,7 @@ struct db_command db_boot_cmds[] = {
{ "halt", db_boot_halt_cmd,   0,  0 },
{ "reboot",   db_boot_reboot_cmd, 0,  0 },
{ "poweroff", db_boot_poweroff_cmd,   0,  0 },
+   { "reset",db_boot_reset_cmd,  0,  0 },
{ NULL, }
  };
  
@@ -812,6 +814,12 @@ void

  db_boot_poweroff_cmd(db_expr_t addr, int haddr, db_expr_t count, char *modif)
  {
db_reboot(RB_NOSYNC | RB_HALT | RB_POWERDOWN | RB_TIMEBAD | RB_USERREQ);
+}
+
+void
+db_boot_reset_cmd(db_expr_t addr, int haddr, db_expr_t count, char *modif)
+{
+   db_reboot(RB_RESET | RB_AUTOBOOT | RB_NOSYNC | RB_TIMEBAD | RB_USERREQ);
  }
  
  void

Index: sys/sys/reboot.h
===
RCS file: /openbsd/src/sys/sys/reboot.h,v
retrieving revision 1.17
diff -u -p -r1.17 reboot.h
--- sys/sys/reboot.h  

Re: ntpd: mark packet used for settime as bad

2017-12-13 Thread Patrik Dahlström
Sorry, I seem to have messed up the whitespace. Updated patch:

diff --git usr.sbin/ntpd/client.c usr.sbin/ntpd/client.c
index 3de5268..5ee7ea8 100644
--- usr.sbin/ntpd/client.c
+++ usr.sbin/ntpd/client.c
@@ -402,8 +402,10 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
(long long)interval);

client_update(p);
-   if (settime)
+   if (settime) {
priv_settime(p->reply[p->shift].offset);
+   p->reply[p->shift].good = 0;
+   }

if (++p->shift >= OFFSET_ARRAY_SIZE)
p->shift = 0;

Best regards
// Patrik

On 12/13/2017 05:01 PM, Patrik Dahlström wrote:
> Hello,
> 
> We recently discovered a bug in ntpd:
> When the '-s' flag is used for ntpd, the first reply received will be
> used to set the current time. If this reply also has the shortest round
> trip, it will be used to adjust the time later. Since openntpd uses a
> circular buffer of 8 replies, this leads to the following behavior:
> 
> 1. first reply arrives -> settime(2017)
> 2. 8:t reply arrives -> adjtime(+47 years), offsets in previous replies
> gets adjusted by -47 years.
> 3. 9:t reply arrives and overwrites the first packet -> adjtime(-47
> years). Time is now being adjusted towards 1970 again.
> 4. X replies with worse round trip time arrives -> adjtime(0). X is 1-7.
> 5. reply X+1 -> adjtime(+47 years). Time is now being adjusted towards
> 2017 again. All subsequent updates are correct.
> 
> This patch will ignore the initial packet used to set the time:
> 
> diff --git usr.sbin/ntpd/client.c usr.sbin/ntpd/client.c
> index 3de5268..6ac0c77 100644
> --- usr.sbin/ntpd/client.c
> +++ usr.sbin/ntpd/client.c
> @@ -402,8 +402,10 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
> (long long)interval);
> 
> client_update(p);
> -   if (settime)
> +   if (settime) {
> priv_settime(p->reply[p->shift].offset);
> +p->reply[p->shift].good = 0;
> +}
> 
> if (++p->shift >= OFFSET_ARRAY_SIZE)
> p->shift = 0;
> 
> Best regards
> // Patrik
> 



ntpd: mark packet used for settime as bad

2017-12-13 Thread Patrik Dahlström
Hello,

We recently discovered a bug in ntpd:
When the '-s' flag is used for ntpd, the first reply received will be
used to set the current time. If this reply also has the shortest round
trip, it will be used to adjust the time later. Since openntpd uses a
circular buffer of 8 replies, this leads to the following behavior:

1. first reply arrives -> settime(2017)
2. 8:t reply arrives -> adjtime(+47 years), offsets in previous replies
gets adjusted by -47 years.
3. 9:t reply arrives and overwrites the first packet -> adjtime(-47
years). Time is now being adjusted towards 1970 again.
4. X replies with worse round trip time arrives -> adjtime(0). X is 1-7.
5. reply X+1 -> adjtime(+47 years). Time is now being adjusted towards
2017 again. All subsequent updates are correct.

This patch will ignore the initial packet used to set the time:

diff --git usr.sbin/ntpd/client.c usr.sbin/ntpd/client.c
index 3de5268..6ac0c77 100644
--- usr.sbin/ntpd/client.c
+++ usr.sbin/ntpd/client.c
@@ -402,8 +402,10 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
(long long)interval);

client_update(p);
-   if (settime)
+   if (settime) {
priv_settime(p->reply[p->shift].offset);
+p->reply[p->shift].good = 0;
+}

if (++p->shift >= OFFSET_ARRAY_SIZE)
p->shift = 0;

Best regards
// Patrik



Symbols.map for libkvm

2017-12-13 Thread Philip Guenther

Inspired by kettenis@'s diff for libutil, here's a diff to do the 
(simpler) work for libkvm,

The symbols this hides are just the linker defined ones; we've already 
declared the internal C symbols static or at least hidden.  However, while 
here I've added the dance to have the three internally referenced symbols 
be called direct, eliminating the PLT entries.  Here's the check_syms 
output:

: corwin; ../check_sym
/usr/lib/libkvm.so.16.2 --> obj/libkvm.so.17.0
Dynamic export changes:
removed:
__bss_start
__data_start
_edata
_end
_fini
_init

PLT removed:
kvm_close
kvm_nlist
kvm_read

: corwin;

ok?

Philip Guenther


Index: lib/libkvm/Makefile
===
RCS file: /cvs/src/lib/libkvm/Makefile,v
retrieving revision 1.18
diff -u -p -r1.18 Makefile
--- lib/libkvm/Makefile 30 Mar 2016 06:38:42 -  1.18
+++ lib/libkvm/Makefile 14 Dec 2017 07:02:18 -
@@ -18,6 +18,8 @@ SRCS= kvm_${MACHINE_CPU}.c
 .endif
 .endif
 
+VERSION_SCRIPT=${.CURDIR}/Symbols.map
+
 CFLAGS+= -D_LIBKVM
 SRCS+= kvm.c kvm_file2.c kvm_getloadavg.c kvm_proc.c kvm_proc2.c \
kvm_cd9660.c kvm_udf.c kvm_ntfs.c
Index: lib/libkvm/Symbols.map
===
RCS file: lib/libkvm/Symbols.map
diff -N lib/libkvm/Symbols.map
--- /dev/null   1 Jan 1970 00:00:00 -
+++ lib/libkvm/Symbols.map  14 Dec 2017 07:02:18 -
@@ -0,0 +1,21 @@
+{
+   global:
+   kvm_close;
+   kvm_dump_inval;
+   kvm_dump_mkheader;
+   kvm_dump_wrtheader;
+   kvm_getargv;
+   kvm_getenvv;
+   kvm_geterr;
+   kvm_getfiles;
+   kvm_getloadavg;
+   kvm_getprocs;
+   kvm_nlist;
+   kvm_open;
+   kvm_openfiles;
+   kvm_read;
+   kvm_write;
+
+   local:
+   *;
+};
Index: lib/libkvm/kvm.c
===
RCS file: /cvs/src/lib/libkvm/kvm.c,v
retrieving revision 1.62
diff -u -p -r1.62 kvm.c
--- lib/libkvm/kvm.c10 Jul 2016 23:06:48 -  1.62
+++ lib/libkvm/kvm.c14 Dec 2017 07:02:18 -
@@ -664,6 +664,7 @@ kvm_close(kvm_t *kd)
 
return (error);
 }
+DEF(kvm_close);
 
 /*
  * Set up state necessary to do queries on the kernel namelist
@@ -802,6 +803,7 @@ kvm_nlist(kvm_t *kd, struct nlist *nl)
 */
return ((p - nl) - nvalid);
 }
+DEF(kvm_nlist);
 
 int
 kvm_dump_inval(kvm_t *kd)
@@ -894,6 +896,7 @@ kvm_read(kvm_t *kd, u_long kva, void *bu
}
/* NOTREACHED */
 }
+DEF(kvm_read);
 
 ssize_t
 kvm_write(kvm_t *kd, u_long kva, const void *buf, size_t len)
Index: lib/libkvm/kvm_private.h
===
RCS file: /cvs/src/lib/libkvm/kvm_private.h,v
retrieving revision 1.24
diff -u -p -r1.24 kvm_private.h
--- lib/libkvm/kvm_private.h4 Sep 2015 02:55:09 -   1.24
+++ lib/libkvm/kvm_private.h14 Dec 2017 07:02:18 -
@@ -106,3 +106,11 @@ void_kvm_syserr(kvm_t *kd, const char 
 ssize_t _kvm_pread(kvm_t *, int, void *, size_t, off_t);
 ssize_t _kvm_pwrite(kvm_t *, int, const void *, size_t, off_t);
 __END_HIDDEN_DECLS
+
+
+#definePROTO(x)__dso_hidden typeof(x) x asm("__"#x)
+#defineDEF(x)  __strong_alias(x, __##x)
+
+PROTO(kvm_close);
+PROTO(kvm_nlist);
+PROTO(kvm_read);
Index: lib/libkvm/shlib_version
===
RCS file: /data/src/openbsd/src/lib/libkvm/shlib_version,v
retrieving revision 1.19
diff -u -p -r1.19 shlib_version
--- lib/libkvm/shlib_version2 Oct 2016 23:11:55 -   1.19
+++ lib/libkvm/shlib_version14 Dec 2017 07:00:46 -
@@ -1,2 +1,2 @@
-major=16
-minor=2
+major=17
+minor=0



Re: background scan for iwn(4)

2017-12-13 Thread Mike Larkin
On Wed, Dec 13, 2017 at 05:17:41PM +0100, Stefan Sperling wrote:
> Since nobody is reporting problems with iwm(4), I took some time to write the
> corresponding diff for iwn(4) as well. I hope this increases test coverage :)
> 
> Works for me on:
> iwn0 at pci3 dev 0 function 0 "Intel Centrino Advanced-N 6200" rev 0x35: msi, 
> MIMO 2T2R, MoW
> 

Ok on iwn0 at pci2 dev 0 function 0 "Intel Centrino Wireless-N 2200" rev 0xc4: 
msi, MIMO 2T2R, BGN, 
no regressions noted.

-ml

> Index: if_iwn.c
> ===
> RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v
> retrieving revision 1.194
> diff -u -p -r1.194 if_iwn.c
> --- if_iwn.c  26 Oct 2017 15:00:28 -  1.194
> +++ if_iwn.c  13 Dec 2017 16:07:07 -
> @@ -222,7 +222,9 @@ int   iwn_config(struct iwn_softc *);
>  uint16_t iwn_get_active_dwell_time(struct iwn_softc *, uint16_t, 
> uint8_t);
>  uint16_t iwn_limit_dwell(struct iwn_softc *, uint16_t);
>  uint16_t iwn_get_passive_dwell_time(struct iwn_softc *, uint16_t);
> -int  iwn_scan(struct iwn_softc *, uint16_t);
> +int  iwn_scan(struct iwn_softc *, uint16_t, int);
> +void iwn_scan_abort(struct iwn_softc *);
> +int  iwn_bgscan(struct ieee80211com *);
>  int  iwn_auth(struct iwn_softc *, int);
>  int  iwn_run(struct iwn_softc *);
>  int  iwn_set_key(struct ieee80211com *, struct ieee80211_node *,
> @@ -516,6 +518,7 @@ iwn_attach(struct device *parent, struct
>   if_attach(ifp);
>   ieee80211_ifattach(ifp);
>   ic->ic_node_alloc = iwn_node_alloc;
> + ic->ic_bgscan_start = iwn_bgscan;
>   ic->ic_newassoc = iwn_newassoc;
>   ic->ic_updateedca = iwn_updateedca;
>   ic->ic_set_key = iwn_set_key;
> @@ -1761,18 +1764,20 @@ iwn_newstate(struct ieee80211com *ic, en
>   struct iwn_node *wn = (void *)ni;
>   int error;
>  
> - timeout_del(&sc->calib_to);
> -
> - if (ic->ic_state == IEEE80211_S_RUN &&
> - (ni->ni_flags & IEEE80211_NODE_HT))
> + if (ic->ic_state == IEEE80211_S_RUN) {
>   ieee80211_mira_cancel_timeouts(&wn->mn);
> + timeout_del(&sc->calib_to);
> + sc->calib.state = IWN_CALIB_STATE_INIT;
> + if (sc->sc_flags & IWN_FLAG_BGSCAN)
> + iwn_scan_abort(sc);
> + }
>  
>   switch (nstate) {
>   case IEEE80211_S_SCAN:
>   /* Make the link LED blink while we're scanning. */
>   iwn_set_led(sc, IWN_LED_LINK, 10, 10);
>  
> - if ((error = iwn_scan(sc, IEEE80211_CHAN_2GHZ)) != 0) {
> + if ((error = iwn_scan(sc, IEEE80211_CHAN_2GHZ, 0)) != 0) {
>   printf("%s: could not initiate scan\n",
>   sc->sc_dev.dv_xname);
>   return error;
> @@ -1971,11 +1976,13 @@ iwn_rx_done(struct iwn_softc *sc, struct
>   struct ieee80211_frame *wh;
>   struct ieee80211_rxinfo rxi;
>   struct ieee80211_node *ni;
> + struct ieee80211_channel *bss_chan = NULL;
>   struct mbuf *m, *m1;
>   struct iwn_rx_stat *stat;
>   caddr_t head;
>   uint32_t flags;
>   int error, len, rssi;
> + uint8_t chan;
>  
>   if (desc->type == IWN_MPDU_RX_DONE) {
>   /* Check for prior RX_PHY notification. */
> @@ -2131,6 +2138,16 @@ iwn_rx_done(struct iwn_softc *sc, struct
>  
>   rssi = ops->get_rssi(stat);
>  
> + chan = stat->chan;
> + if (chan > IEEE80211_CHAN_MAX)
> + chan = IEEE80211_CHAN_MAX;
> +
> + if (ni == ic->ic_bss) {
> + bss_chan = ni->ni_chan;
> + /* Fix current channel. */
> + ni->ni_chan = &ic->ic_channels[chan];
> + }
> +
>  #if NBPFILTER > 0
>   if (sc->sc_drvbpf != NULL) {
>   struct mbuf mb;
> @@ -2140,9 +2157,8 @@ iwn_rx_done(struct iwn_softc *sc, struct
>   tap->wr_flags = 0;
>   if (stat->flags & htole16(IWN_STAT_FLAG_SHPREAMBLE))
>   tap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
> - tap->wr_chan_freq =
> - htole16(ic->ic_channels[stat->chan].ic_freq);
> - chan_flags = ic->ic_channels[stat->chan].ic_flags;
> + tap->wr_chan_freq = htole16(ic->ic_channels[chan].ic_freq);
> + chan_flags = ic->ic_channels[chan].ic_flags;
>   if (ic->ic_curmode != IEEE80211_MODE_11N)
>   chan_flags &= ~IEEE80211_CHAN_HT;
>   tap->wr_chan_flags = htole16(chan_flags);
> @@ -2187,6 +2203,10 @@ iwn_rx_done(struct iwn_softc *sc, struct
>   rxi.rxi_tstamp = 0; /* unused */
>   ieee80211_input(ifp, m, ni, &rxi);
>  
> + /* Restore BSS channel. */
> + if (ni == ic->ic_bss)
> + ni->ni_chan = bss_chan;
> +
>   /* Node is no longer needed. */
>   ieee80211_release_node(ic, ni);
>  }
> @@ -2586,6 +2606,9 @@ iwn_notif_intr(struct iwn_softc *sc)
>   DPRIN

Re: Symbols.map for libutil

2017-12-13 Thread Philip Guenther
On Thu, 14 Dec 2017, Mark Kettenis wrote:
> Diff below makes sure libutil doesn't export any unwanted symbols. The 
> immediate motivation here is to prevent exportong certain libgcc symbols 
> on armv7 that cause issues when switching from gcc to clang.
> 
> With this diff, only symbols present in man pages and public header 
> files are exported.  A few helper functions are made static.  The one 
> exception is imsg_fd_overhead which according to the relevant commit 
> message is intended as a public API.  Note that this API isn't actually 
> used in our tree.  Also note that global variables like this are bad API 
> design.
> 
> The check_syms script gives the following output:
> 
> /usr/lib/libutil.so.12.2 --> obj/libutil.so.13.0
> Dynamic export changes:
> removed:
> __bss_start
> __data_start
> _edata
> _end
> _fini
> _init
> ibuf_dequeue
> ibuf_enqueue
> ibuf_realloc
> imsg_get_fd
> 
> ok?

Nice.  ok guenther@



simplify sched_barrier with a wait condition on the stack

2017-12-13 Thread David Gwynne
this started as just using struct cond to handle the sleep and
wakeups for sched_barrier, but it got a bit bigger.

the biggest semantic change is that it gets rid of the sbar taskq
and uses systqmp instead. a whole thread (which is what is underneath
a taskq) is a very big hammer for solving this problem. the task
the sched barrier wants to run is short, so it wont be a burden for
systqmp.

the other big change is the use of a variable on the stack as the
wait channel for sleeping in the caller and waking up in the task,
instead of a variable in struct schedstate_percpu. the latter is
effectively a shared global. if (and this is a big if) two different
threads are running sched_barrier, this could lead to unwanted
races. putting this on the stack (via struct cond) means each thread
gets its own condition to sleep on and use as a wait channel.

ok?

Index: sys/sched.h
===
RCS file: /cvs/src/sys/sys/sched.h,v
retrieving revision 1.43
diff -u -p -r1.43 sched.h
--- sys/sched.h 4 Dec 2017 09:51:03 -   1.43
+++ sys/sched.h 14 Dec 2017 01:14:47 -
@@ -114,8 +114,6 @@ struct schedstate_percpu {
struct proc *spc_reaper;/* dead proc reaper */
 #endif
LIST_HEAD(,proc) spc_deadproc;
-
-   volatile int spc_barrier;   /* for sched_barrier() */
 };
 
 #ifdef _KERNEL
Index: kern/kern_sched.c
===
RCS file: /cvs/src/sys/kern/kern_sched.c,v
retrieving revision 1.46
diff -u -p -r1.46 kern_sched.c
--- kern/kern_sched.c   28 Nov 2017 16:22:27 -  1.46
+++ kern/kern_sched.c   14 Dec 2017 01:14:48 -
@@ -227,12 +227,6 @@ sched_exit(struct proc *p)
 void
 sched_init_runqueues(void)
 {
-#ifdef MULTIPROCESSOR
-   sbartq = taskq_create("sbar", 1, IPL_VM,
-   TASKQ_MPSAFE | TASKQ_CANTSLEEP);
-   if (sbartq == NULL)
-   panic("unable to create sbar taskq");
-#endif
 }
 
 void
@@ -658,24 +652,28 @@ sched_stop_secondary_cpus(void)
}
 }
 
+struct sched_barrier_state {
+   struct cpu_info *ci;
+   struct cond cond;
+};
+
 void
 sched_barrier_task(void *arg)
 {
-   struct cpu_info *ci = arg;
+   struct sched_barrier_state *sb = arg;
+   struct cpu_info *ci = sb->ci;
 
sched_peg_curproc(ci);
-   ci->ci_schedstate.spc_barrier = 1;
-   wakeup(&ci->ci_schedstate.spc_barrier);
+   cond_signal(&sb->cond);
atomic_clearbits_int(&curproc->p_flag, P_CPUPEG);
 }
 
 void
 sched_barrier(struct cpu_info *ci)
 {
-   struct sleep_state sls;
+   struct sched_barrier_state sb;
struct task task;
CPU_INFO_ITERATOR cii;
-   struct schedstate_percpu *spc;
 
if (ci == NULL) {
CPU_INFO_FOREACH(cii, ci) {
@@ -688,14 +686,12 @@ sched_barrier(struct cpu_info *ci)
if (ci == curcpu())
return;
 
-   task_set(&task, sched_barrier_task, ci);
-   spc = &ci->ci_schedstate;
-   spc->spc_barrier = 0;
-   task_add(sbartq, &task);
-   while (!spc->spc_barrier) {
-   sleep_setup(&sls, &spc->spc_barrier, PWAIT, "sbar");
-   sleep_finish(&sls, !spc->spc_barrier);
-   }
+   sb.ci = ci;
+   cond_init(&sb.cond);
+   task_set(&task, sched_barrier_task, &sb);
+
+   task_add(systqmp, &task);
+   cond_wait(&sb.cond, "sbar");
 }
 
 #else



Re: background scan for iwn(4)

2017-12-13 Thread Mike Burns
On 2017-12-13 17.17.41 +0100, Stefan Sperling wrote:
> Since nobody is reporting problems with iwm(4), I took some time to write the
> corresponding diff for iwn(4) as well. I hope this increases test coverage :)
> 
> Works for me on:
> iwn0 at pci3 dev 0 function 0 "Intel Centrino Advanced-N 6200" rev 0x35: msi, 
> MIMO 2T2R, MoW

Nothing is broken on:

iwn0 at pci2 dev 0 function 0 "Intel Centrino Advanced-N 6205" rev 0x96:
msi, MIMO 2T2R, MoW, address 84:3a:4b:0a:ae:8

I only have the one AP. I tried to figure out how to make my phone into
an AP but my laptop didn't want to connect to it.

-Mike

> 
> Index: if_iwn.c
> ===
> RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v
> retrieving revision 1.194
> diff -u -p -r1.194 if_iwn.c
> --- if_iwn.c  26 Oct 2017 15:00:28 -  1.194
> +++ if_iwn.c  13 Dec 2017 16:07:07 -
> @@ -222,7 +222,9 @@ int   iwn_config(struct iwn_softc *);
>  uint16_t iwn_get_active_dwell_time(struct iwn_softc *, uint16_t, 
> uint8_t);
>  uint16_t iwn_limit_dwell(struct iwn_softc *, uint16_t);
>  uint16_t iwn_get_passive_dwell_time(struct iwn_softc *, uint16_t);
> -int  iwn_scan(struct iwn_softc *, uint16_t);
> +int  iwn_scan(struct iwn_softc *, uint16_t, int);
> +void iwn_scan_abort(struct iwn_softc *);
> +int  iwn_bgscan(struct ieee80211com *);
>  int  iwn_auth(struct iwn_softc *, int);
>  int  iwn_run(struct iwn_softc *);
>  int  iwn_set_key(struct ieee80211com *, struct ieee80211_node *,
> @@ -516,6 +518,7 @@ iwn_attach(struct device *parent, struct
>   if_attach(ifp);
>   ieee80211_ifattach(ifp);
>   ic->ic_node_alloc = iwn_node_alloc;
> + ic->ic_bgscan_start = iwn_bgscan;
>   ic->ic_newassoc = iwn_newassoc;
>   ic->ic_updateedca = iwn_updateedca;
>   ic->ic_set_key = iwn_set_key;
> @@ -1761,18 +1764,20 @@ iwn_newstate(struct ieee80211com *ic, en
>   struct iwn_node *wn = (void *)ni;
>   int error;
>  
> - timeout_del(&sc->calib_to);
> -
> - if (ic->ic_state == IEEE80211_S_RUN &&
> - (ni->ni_flags & IEEE80211_NODE_HT))
> + if (ic->ic_state == IEEE80211_S_RUN) {
>   ieee80211_mira_cancel_timeouts(&wn->mn);
> + timeout_del(&sc->calib_to);
> + sc->calib.state = IWN_CALIB_STATE_INIT;
> + if (sc->sc_flags & IWN_FLAG_BGSCAN)
> + iwn_scan_abort(sc);
> + }
>  
>   switch (nstate) {
>   case IEEE80211_S_SCAN:
>   /* Make the link LED blink while we're scanning. */
>   iwn_set_led(sc, IWN_LED_LINK, 10, 10);
>  
> - if ((error = iwn_scan(sc, IEEE80211_CHAN_2GHZ)) != 0) {
> + if ((error = iwn_scan(sc, IEEE80211_CHAN_2GHZ, 0)) != 0) {
>   printf("%s: could not initiate scan\n",
>   sc->sc_dev.dv_xname);
>   return error;
> @@ -1971,11 +1976,13 @@ iwn_rx_done(struct iwn_softc *sc, struct
>   struct ieee80211_frame *wh;
>   struct ieee80211_rxinfo rxi;
>   struct ieee80211_node *ni;
> + struct ieee80211_channel *bss_chan = NULL;
>   struct mbuf *m, *m1;
>   struct iwn_rx_stat *stat;
>   caddr_t head;
>   uint32_t flags;
>   int error, len, rssi;
> + uint8_t chan;
>  
>   if (desc->type == IWN_MPDU_RX_DONE) {
>   /* Check for prior RX_PHY notification. */
> @@ -2131,6 +2138,16 @@ iwn_rx_done(struct iwn_softc *sc, struct
>  
>   rssi = ops->get_rssi(stat);
>  
> + chan = stat->chan;
> + if (chan > IEEE80211_CHAN_MAX)
> + chan = IEEE80211_CHAN_MAX;
> +
> + if (ni == ic->ic_bss) {
> + bss_chan = ni->ni_chan;
> + /* Fix current channel. */
> + ni->ni_chan = &ic->ic_channels[chan];
> + }
> +
>  #if NBPFILTER > 0
>   if (sc->sc_drvbpf != NULL) {
>   struct mbuf mb;
> @@ -2140,9 +2157,8 @@ iwn_rx_done(struct iwn_softc *sc, struct
>   tap->wr_flags = 0;
>   if (stat->flags & htole16(IWN_STAT_FLAG_SHPREAMBLE))
>   tap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
> - tap->wr_chan_freq =
> - htole16(ic->ic_channels[stat->chan].ic_freq);
> - chan_flags = ic->ic_channels[stat->chan].ic_flags;
> + tap->wr_chan_freq = htole16(ic->ic_channels[chan].ic_freq);
> + chan_flags = ic->ic_channels[chan].ic_flags;
>   if (ic->ic_curmode != IEEE80211_MODE_11N)
>   chan_flags &= ~IEEE80211_CHAN_HT;
>   tap->wr_chan_flags = htole16(chan_flags);
> @@ -2187,6 +2203,10 @@ iwn_rx_done(struct iwn_softc *sc, struct
>   rxi.rxi_tstamp = 0; /* unused */
>   ieee80211_input(ifp, m, ni, &rxi);
>  
> + /* Restore BSS channel. */
> + if (ni == ic->ic_bss)
> + ni->ni_chan = bss_chan;
> +
>   /* Node is no longer needed. */
>   

Re: Symbols.map for libutil

2017-12-13 Thread Theo de Raadt
Lovely.

> Diff below makes sure libutil doesn't export any unwanted symbols.
> The immediate motivation here is to prevent exportong certain libgcc
> symbols on armv7 that cause issues when switching from gcc to clang.
> 
> With this diff, only symbols present in man pages and public header
> files are exported.  A few helper functions are made static.  The one
> exception is imsg_fd_overhead which according to the relevant commit
> message is intended as a public API.  Note that this API isn't
> actually used in our tree.  Also note that global variables like this
> are bad API design.
> 
> The check_syms script gives the following output:
> 
> /usr/lib/libutil.so.12.2 --> obj/libutil.so.13.0
> Dynamic export changes:
> removed:
> __bss_start
> __data_start
> _edata
> _end
> _fini
> _init
> ibuf_dequeue
> ibuf_enqueue
> ibuf_realloc
> imsg_get_fd
> 
> ok?
> 
> 
> Index: lib/libutil/Makefile
> ===
> RCS file: /cvs/src/lib/libutil/Makefile,v
> retrieving revision 1.39
> diff -u -p -r1.39 Makefile
> --- lib/libutil/Makefile  30 Mar 2016 06:38:43 -  1.39
> +++ lib/libutil/Makefile  13 Dec 2017 23:03:05 -
> @@ -3,6 +3,8 @@
>  
>  LIB= util
>  
> +VERSION_SCRIPT=  ${.CURDIR}/Symbols.map
> +
>  HDRS=util.h imsg.h
>  SRCS=bcrypt_pbkdf.c check_expire.c duid.c getmaxpartitions.c \
>   getrawpartition.c login.c \
> Index: lib/libutil/Symbols.map
> ===
> RCS file: lib/libutil/Symbols.map
> diff -N lib/libutil/Symbols.map
> --- /dev/null 1 Jan 1970 00:00:00 -
> +++ lib/libutil/Symbols.map   13 Dec 2017 23:03:05 -
> @@ -0,0 +1,94 @@
> +/*
> + * In order to guarantee that static and shared archs see the same "public"
> + * symbols, this file should always include all the non-static symbols that
> + * are in the application namespace.  So, if a symbol starts with a letter,
> + * don't delete it from here without either making it static or renaming it
> + * to have a leading underbar.
> + */
> +
> +{
> + global:
> + bcrypt_pbkdf;
> + fdforkpty;
> + fdopenpty;
> + fmt_scaled;
> + forkpty;
> + fparseln;
> + getmaxpartitions;
> + getptmfd;
> + getrawpartition;
> + ibuf_add;
> + ibuf_close;
> + ibuf_dynamic;
> + ibuf_free;
> + ibuf_left;
> + ibuf_open;
> + ibuf_reserve;
> + ibuf_seek;
> + ibuf_size;
> + ibuf_write;
> + imsg_add;
> + imsg_clear;
> + imsg_close;
> + imsg_compose;
> + imsg_composev;
> + imsg_create;
> + imsg_fd_overhead;
> + imsg_flush;
> + imsg_free;
> + imsg_get;
> + #imsg_get_fd
> + imsg_init;
> + imsg_read;
> + isduid;
> + login;
> + login_check_expire;
> + login_fbtab;
> + login_tty;
> + logout;
> + logwtmp;
> + msgbuf_clear;
> + msgbuf_drain;
> + msgbuf_init;
> + msgbuf_write;
> + ohash_create_entry;
> + ohash_delete;
> + ohash_entries;
> + ohash_find;
> + ohash_first;
> + ohash_init;
> + ohash_insert;
> + ohash_interval;
> + ohash_lookup_interval;
> + ohash_lookup_memory;
> + ohash_next;
> + ohash_qlookup;
> + ohash_qlookupi;
> + ohash_remove;
> + opendev;
> + opendisk;
> + openpty;
> + pidfile;
> + pkcs5_pbkdf2;
> + pw_abort;
> + #pw_cont;
> + pw_copy;
> + pw_edit;
> + pw_error;
> + pw_file;
> + pw_init;
> + pw_lock;
> + pw_mkdb;
> + pw_prompt;
> + pw_scan;
> + pw_setdir;
> + readlabelfs;
> + scan_scaled;
> + uu_lock;
> + uu_lock_txfr;
> + uu_lockerr;
> + uu_unlock;
> +
> + local:
> + *;
> +};
> Index: lib/libutil/imsg-buffer.c
> ===
> RCS file: /cvs/src/lib/libutil/imsg-buffer.c,v
> retrieving revision 1.10
> diff -u -p -r1.10 imsg-buffer.c
> --- lib/libutil/imsg-buffer.c 11 Apr 2017 09:57:19 -  1.10
> +++ lib/libutil/imsg-buffer.c 13 Dec 2017 23:03:05 -
> @@ -29,9 +29,9 @@
>  
>  #include "imsg.h"
>  
> -int  ibuf_realloc(struct ibuf *, size_t);
> -void ibuf_enqueue(struct msgbuf *, struct ibuf *);
> -void ibuf

Re: TL-WN722N usb ids and attach as urtwn(4)

2017-12-13 Thread Mark Kettenis
> Date: Thu, 14 Dec 2017 00:06:35 +0100
> From: Sebastian Benoit 
> 
> Dec 13 23:49:08 blap /bsd: urtwn0 at uhub0 port 1 configuration 1 interface 0 
> "Realtek 802.11n NIC" rev 2.00/0.00 addr 4
> Dec 13 23:49:08 blap /bsd: urtwn0: MAC/BB RTL8188EU, RF 6052 1T1R, address 
> 
> and i am writing this mail using this device.
> 
> ok?

ok kettenis@

> diff --git share/man/man4/urtwn.4 share/man/man4/urtwn.4
> index 729c6ac1e55..95d0b796fc9 100644
> --- share/man/man4/urtwn.4
> +++ share/man/man4/urtwn.4
> @@ -126,6 +126,7 @@ The following adapters should work:
>  .It Sitecom WL-365
>  .It Sitecom WLA-2100 v2
>  .It Solwise NET-WL-UMD-606N
> +.It TP-LINK TL-WN722N v2
>  .It TP-LINK TL-WN723N v3
>  .It TP-LINK TL-WN725N v2
>  .It TP-Link TL-WN821N v4
> diff --git sys/dev/usb/if_urtwn.c sys/dev/usb/if_urtwn.c
> index e841da1c284..369daaade16 100644
> --- sys/dev/usb/if_urtwn.c
> +++ sys/dev/usb/if_urtwn.c
> @@ -310,7 +310,8 @@ static const struct urtwn_type {
>   URTWN_DEV_8188EU(DLINK, DWA125D1),
>   URTWN_DEV_8188EU(ELECOM,WDC150SU2M),
>   URTWN_DEV_8188EU(REALTEK,   RTL8188ETV),
> - URTWN_DEV_8188EU(REALTEK,   RTL8188EU)
> + URTWN_DEV_8188EU(REALTEK,   RTL8188EU),
> + URTWN_DEV_8188EU(TPLINK,RTL8188EUS)
>  };
>  
>  #define urtwn_lookup(v, p)   \
> diff --git sys/dev/usb/usbdevs sys/dev/usb/usbdevs
> index 8a8a4706c4d..b9c431d5354 100644
> --- sys/dev/usb/usbdevs
> +++ sys/dev/usb/usbdevs
> @@ -4247,6 +4247,7 @@ product TOSHIBA HSDPA   0x1302  HSDPA
>  /* TP-Link products */
>  product TPLINK RTL8192CU 0x0100  RTL8192CU
>  product TPLINK RTL8812AU 0x0101  RTL8812AU
> +product TPLINK RTL8188EUS0x010C  RTL8188EUS
>  
>  /* Trek Technology products */
>  product TREK THUMBDRIVE  0x  ThumbDrive
> diff --git sys/dev/usb/usbdevs.h sys/dev/usb/usbdevs.h
> index 97d2fe771d5..7e313a6f95b 100644
> --- sys/dev/usb/usbdevs.h
> +++ sys/dev/usb/usbdevs.h
> @@ -1,4 +1,4 @@
> -/*   $OpenBSD: usbdevs.h,v 1.690 2017/10/11 17:20:36 patrick Exp $   */
> +/*   $OpenBSD$   */
>  
>  /*
>   * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
> @@ -4254,6 +4254,7 @@
>  /* TP-Link products */
>  #define  USB_PRODUCT_TPLINK_RTL8192CU0x0100  /* RTL8192CU */
>  #define  USB_PRODUCT_TPLINK_RTL8812AU0x0101  /* RTL8812AU */
> +#define  USB_PRODUCT_TPLINK_RTL8188EUS   0x010C  /* RTL8188EUS */
>  
>  /* Trek Technology products */
>  #define  USB_PRODUCT_TREK_THUMBDRIVE 0x  /* ThumbDrive */
> diff --git sys/dev/usb/usbdevs_data.h sys/dev/usb/usbdevs_data.h
> index 6217cd2e0fc..2267b2445bc 100644
> --- sys/dev/usb/usbdevs_data.h
> +++ sys/dev/usb/usbdevs_data.h
> @@ -1,4 +1,4 @@
> -/*   $OpenBSD: usbdevs_data.h,v 1.684 2017/10/11 17:20:36 patrick Exp $  
> */
> +/*   $OpenBSD$   */
>  
>  /*
>   * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
> @@ -10873,6 +10873,10 @@ const struct usb_known_product usb_known_products[] 
> = {
>   USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_RTL8812AU,
>   "RTL8812AU",
>   },
> + {
> + USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_RTL8188EUS,
> + "RTL8188EUS",
> + },
>   {
>   USB_VENDOR_TREK, USB_PRODUCT_TREK_THUMBDRIVE,
>   "ThumbDrive",
> 
> 



Re: Change bcopy to memcpy (i386 VIA PadLock driver)

2017-12-13 Thread David Gwynne

> On 14 Dec 2017, at 07:23, Frederic Cambus  wrote:
> 
> Hi tech@,
> 
> This diff changes bcopy to memcpy in the i386 version of the VIA PadLock
> driver. It was done a while ago in the amd64 version of the driver.
> 
> Comments? OK?

ok

> 
> Index: sys/arch/i386/i386/via.c
> ===
> RCS file: /cvs/src/sys/arch/i386/i386/via.c,v
> retrieving revision 1.37
> diff -u -p -r1.37 via.c
> --- sys/arch/i386/i386/via.c  2 May 2017 11:47:49 -   1.37
> +++ sys/arch/i386/i386/via.c  10 Dec 2017 14:01:21 -
> @@ -161,7 +161,7 @@ viac3_crypto_newsession(u_int32_t *sidp,
>   M_NOWAIT);
>   if (ses == NULL)
>   return (ENOMEM);
> - bcopy(sc->sc_sessions, ses, sesn * sizeof(*ses));
> + memcpy(ses, sc->sc_sessions, sesn * sizeof(*ses));
>   explicit_bzero(sc->sc_sessions, sesn * sizeof(*ses));
>   free(sc->sc_sessions, M_DEVBUF, sesn * sizeof(*ses));
>   sc->sc_sessions = ses;
> @@ -370,7 +370,7 @@ viac3_crypto_encdec(struct cryptop *crp,
>   sc->op_cw[0] = ses->ses_cw0 | C3_CRYPT_CWLO_ENCRYPT;
>   key = ses->ses_ekey;
>   if (crd->crd_flags & CRD_F_IV_EXPLICIT)
> - bcopy(crd->crd_iv, sc->op_iv, 16);
> + memcpy(sc->op_iv, crd->crd_iv, 16);
>   else
>   arc4random_buf(sc->op_iv, 16);
> 
> @@ -382,8 +382,8 @@ viac3_crypto_encdec(struct cryptop *crp,
>   cuio_copyback((struct uio *)crp->crp_buf,
>   crd->crd_inject, 16, sc->op_iv);
>   else
> - bcopy(sc->op_iv,
> - crp->crp_buf + crd->crd_inject, 16);
> + memcpy(crp->crp_buf + crd->crd_inject,
> + sc->op_iv, 16);
>   if (err)
>   return (err);
>   }
> @@ -391,7 +391,7 @@ viac3_crypto_encdec(struct cryptop *crp,
>   sc->op_cw[0] = ses->ses_cw0 | C3_CRYPT_CWLO_DECRYPT;
>   key = ses->ses_dkey;
>   if (crd->crd_flags & CRD_F_IV_EXPLICIT)
> - bcopy(crd->crd_iv, sc->op_iv, 16);
> + memcpy(sc->op_iv, crd->crd_iv, 16);
>   else {
>   if (crp->crp_flags & CRYPTO_F_IMBUF)
>   m_copydata((struct mbuf *)crp->crp_buf,
> @@ -400,8 +400,8 @@ viac3_crypto_encdec(struct cryptop *crp,
>   cuio_copydata((struct uio *)crp->crp_buf,
>   crd->crd_inject, 16, sc->op_iv);
>   else
> - bcopy(crp->crp_buf + crd->crd_inject,
> - sc->op_iv, 16);
> + memcpy(sc->op_iv,
> + crp->crp_buf + crd->crd_inject, 16);
>   }
>   }
> 
> @@ -412,7 +412,7 @@ viac3_crypto_encdec(struct cryptop *crp,
>   cuio_copydata((struct uio *)crp->crp_buf,
>   crd->crd_skip, crd->crd_len, sc->op_buf);
>   else
> - bcopy(crp->crp_buf + crd->crd_skip, sc->op_buf, crd->crd_len);
> + memcpy(sc->op_buf, crp->crp_buf + crd->crd_skip, crd->crd_len);
> 
>   sc->op_cw[1] = sc->op_cw[2] = sc->op_cw[3] = 0;
>   viac3_cbc(&sc->op_cw, sc->op_buf, sc->op_buf, key,
> @@ -425,7 +425,7 @@ viac3_crypto_encdec(struct cryptop *crp,
>   cuio_copyback((struct uio *)crp->crp_buf,
>   crd->crd_skip, crd->crd_len, sc->op_buf);
>   else
> - bcopy(sc->op_buf, crp->crp_buf + crd->crd_skip,
> + memcpy(crp->crp_buf + crd->crd_skip, sc->op_buf,
>   crd->crd_len);
> 
>   if (sc->op_buf != NULL) {
> 



Symbols.map for libutil

2017-12-13 Thread Mark Kettenis
Diff below makes sure libutil doesn't export any unwanted symbols.
The immediate motivation here is to prevent exportong certain libgcc
symbols on armv7 that cause issues when switching from gcc to clang.

With this diff, only symbols present in man pages and public header
files are exported.  A few helper functions are made static.  The one
exception is imsg_fd_overhead which according to the relevant commit
message is intended as a public API.  Note that this API isn't
actually used in our tree.  Also note that global variables like this
are bad API design.

The check_syms script gives the following output:

/usr/lib/libutil.so.12.2 --> obj/libutil.so.13.0
Dynamic export changes:
removed:
__bss_start
__data_start
_edata
_end
_fini
_init
ibuf_dequeue
ibuf_enqueue
ibuf_realloc
imsg_get_fd

ok?


Index: lib/libutil/Makefile
===
RCS file: /cvs/src/lib/libutil/Makefile,v
retrieving revision 1.39
diff -u -p -r1.39 Makefile
--- lib/libutil/Makefile30 Mar 2016 06:38:43 -  1.39
+++ lib/libutil/Makefile13 Dec 2017 23:03:05 -
@@ -3,6 +3,8 @@
 
 LIB=   util
 
+VERSION_SCRIPT=${.CURDIR}/Symbols.map
+
 HDRS=  util.h imsg.h
 SRCS=  bcrypt_pbkdf.c check_expire.c duid.c getmaxpartitions.c \
getrawpartition.c login.c \
Index: lib/libutil/Symbols.map
===
RCS file: lib/libutil/Symbols.map
diff -N lib/libutil/Symbols.map
--- /dev/null   1 Jan 1970 00:00:00 -
+++ lib/libutil/Symbols.map 13 Dec 2017 23:03:05 -
@@ -0,0 +1,94 @@
+/*
+ * In order to guarantee that static and shared archs see the same "public"
+ * symbols, this file should always include all the non-static symbols that
+ * are in the application namespace.  So, if a symbol starts with a letter,
+ * don't delete it from here without either making it static or renaming it
+ * to have a leading underbar.
+ */
+
+{
+   global:
+   bcrypt_pbkdf;
+   fdforkpty;
+   fdopenpty;
+   fmt_scaled;
+   forkpty;
+   fparseln;
+   getmaxpartitions;
+   getptmfd;
+   getrawpartition;
+   ibuf_add;
+   ibuf_close;
+   ibuf_dynamic;
+   ibuf_free;
+   ibuf_left;
+   ibuf_open;
+   ibuf_reserve;
+   ibuf_seek;
+   ibuf_size;
+   ibuf_write;
+   imsg_add;
+   imsg_clear;
+   imsg_close;
+   imsg_compose;
+   imsg_composev;
+   imsg_create;
+   imsg_fd_overhead;
+   imsg_flush;
+   imsg_free;
+   imsg_get;
+   #imsg_get_fd
+   imsg_init;
+   imsg_read;
+   isduid;
+   login;
+   login_check_expire;
+   login_fbtab;
+   login_tty;
+   logout;
+   logwtmp;
+   msgbuf_clear;
+   msgbuf_drain;
+   msgbuf_init;
+   msgbuf_write;
+   ohash_create_entry;
+   ohash_delete;
+   ohash_entries;
+   ohash_find;
+   ohash_first;
+   ohash_init;
+   ohash_insert;
+   ohash_interval;
+   ohash_lookup_interval;
+   ohash_lookup_memory;
+   ohash_next;
+   ohash_qlookup;
+   ohash_qlookupi;
+   ohash_remove;
+   opendev;
+   opendisk;
+   openpty;
+   pidfile;
+   pkcs5_pbkdf2;
+   pw_abort;
+   #pw_cont;
+   pw_copy;
+   pw_edit;
+   pw_error;
+   pw_file;
+   pw_init;
+   pw_lock;
+   pw_mkdb;
+   pw_prompt;
+   pw_scan;
+   pw_setdir;
+   readlabelfs;
+   scan_scaled;
+   uu_lock;
+   uu_lock_txfr;
+   uu_lockerr;
+   uu_unlock;
+
+   local:
+   *;
+};
Index: lib/libutil/imsg-buffer.c
===
RCS file: /cvs/src/lib/libutil/imsg-buffer.c,v
retrieving revision 1.10
diff -u -p -r1.10 imsg-buffer.c
--- lib/libutil/imsg-buffer.c   11 Apr 2017 09:57:19 -  1.10
+++ lib/libutil/imsg-buffer.c   13 Dec 2017 23:03:05 -
@@ -29,9 +29,9 @@
 
 #include "imsg.h"
 
-intibuf_realloc(struct ibuf *, size_t);
-void   ibuf_enqueue(struct msgbuf *, struct ibuf *);
-void   ibuf_dequeue(struct msgbuf *, struct ibuf *);
+static int ibuf_realloc(struct ibuf *, size_t);
+static voidibuf_enqueue(struct msgbuf *, struct ibuf 

TL-WN722N usb ids and attach as urtwn(4)

2017-12-13 Thread Sebastian Benoit

Dec 13 23:49:08 blap /bsd: urtwn0 at uhub0 port 1 configuration 1 interface 0 
"Realtek 802.11n NIC" rev 2.00/0.00 addr 4
Dec 13 23:49:08 blap /bsd: urtwn0: MAC/BB RTL8188EU, RF 6052 1T1R, address 

and i am writing this mail using this device.

ok?

(benno_urtwn_tl-wn722n.diff)

diff --git share/man/man4/urtwn.4 share/man/man4/urtwn.4
index 729c6ac1e55..95d0b796fc9 100644
--- share/man/man4/urtwn.4
+++ share/man/man4/urtwn.4
@@ -126,6 +126,7 @@ The following adapters should work:
 .It Sitecom WL-365
 .It Sitecom WLA-2100 v2
 .It Solwise NET-WL-UMD-606N
+.It TP-LINK TL-WN722N v2
 .It TP-LINK TL-WN723N v3
 .It TP-LINK TL-WN725N v2
 .It TP-Link TL-WN821N v4
diff --git sys/dev/usb/if_urtwn.c sys/dev/usb/if_urtwn.c
index e841da1c284..369daaade16 100644
--- sys/dev/usb/if_urtwn.c
+++ sys/dev/usb/if_urtwn.c
@@ -310,7 +310,8 @@ static const struct urtwn_type {
URTWN_DEV_8188EU(DLINK, DWA125D1),
URTWN_DEV_8188EU(ELECOM,WDC150SU2M),
URTWN_DEV_8188EU(REALTEK,   RTL8188ETV),
-   URTWN_DEV_8188EU(REALTEK,   RTL8188EU)
+   URTWN_DEV_8188EU(REALTEK,   RTL8188EU),
+   URTWN_DEV_8188EU(TPLINK,RTL8188EUS)
 };
 
 #define urtwn_lookup(v, p) \
diff --git sys/dev/usb/usbdevs sys/dev/usb/usbdevs
index 8a8a4706c4d..b9c431d5354 100644
--- sys/dev/usb/usbdevs
+++ sys/dev/usb/usbdevs
@@ -4247,6 +4247,7 @@ product TOSHIBA HSDPA 0x1302  HSDPA
 /* TP-Link products */
 product TPLINK RTL8192CU   0x0100  RTL8192CU
 product TPLINK RTL8812AU   0x0101  RTL8812AU
+product TPLINK RTL8188EUS  0x010C  RTL8188EUS
 
 /* Trek Technology products */
 product TREK THUMBDRIVE0x  ThumbDrive
diff --git sys/dev/usb/usbdevs.h sys/dev/usb/usbdevs.h
index 97d2fe771d5..7e313a6f95b 100644
--- sys/dev/usb/usbdevs.h
+++ sys/dev/usb/usbdevs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdevs.h,v 1.690 2017/10/11 17:20:36 patrick Exp $   */
+/* $OpenBSD$   */
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -4254,6 +4254,7 @@
 /* TP-Link products */
 #defineUSB_PRODUCT_TPLINK_RTL8192CU0x0100  /* RTL8192CU */
 #defineUSB_PRODUCT_TPLINK_RTL8812AU0x0101  /* RTL8812AU */
+#defineUSB_PRODUCT_TPLINK_RTL8188EUS   0x010C  /* RTL8188EUS */
 
 /* Trek Technology products */
 #defineUSB_PRODUCT_TREK_THUMBDRIVE 0x  /* ThumbDrive */
diff --git sys/dev/usb/usbdevs_data.h sys/dev/usb/usbdevs_data.h
index 6217cd2e0fc..2267b2445bc 100644
--- sys/dev/usb/usbdevs_data.h
+++ sys/dev/usb/usbdevs_data.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdevs_data.h,v 1.684 2017/10/11 17:20:36 patrick Exp $  
*/
+/* $OpenBSD$   */
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -10873,6 +10873,10 @@ const struct usb_known_product usb_known_products[] = {
USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_RTL8812AU,
"RTL8812AU",
},
+   {
+   USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_RTL8188EUS,
+   "RTL8188EUS",
+   },
{
USB_VENDOR_TREK, USB_PRODUCT_TREK_THUMBDRIVE,
"ThumbDrive",



Re: mess with regression tests

2017-12-13 Thread Alexander Bluhm
On Wed, Dec 06, 2017 at 11:19:18PM +0300, Sergey Bronnikov wrote:
> Patch below adds similar scripts for ed, perl, gdb, libkeynote, ctags,
> m4 and sed. Patch looks huge but it is actually simple. Anyway if you
> want splitted patch I will resend.

It is not the patch that is too big but the task.  Try to start
with one test, get it integrated, learn, and then do the next.

I have only looked at ed as it is the first in your list.

It generates a lot of errors:
*** The script =.red exited abnormally  ***
*** The script a1.red exited abnormally  ***
*** The script i1.red exited abnormally  ***
*** The script i3.red exited abnormally  ***
*** The script k1.red exited abnormally  ***
*** The script nl.red exited abnormally  ***
*** The script r1.red exited abnormally  ***
*** The script s2.red exited abnormally  ***
*** The script =.red exited abnormally  ***
*** The script a1.red exited abnormally  ***
*** The script i1.red exited abnormally  ***
*** The script i3.red exited abnormally  ***
*** The script k1.red exited abnormally  ***
*** The script nl.red exited abnormally  ***
*** The script r1.red exited abnormally  ***
*** The script s2.red exited abnormally  ***

I think they have to be fixed, before I will run them.  Importing
failing tests is not a good idea.

Although the tests fail, the regress framework does not recognize
it.  Running tests and not caring about the result is pointless.

Then it creates temparary files in /usr/src/bin/ed/test.  Ideally
they should be in /usr/src/regress/bin/ed/obj and removed by make
clean.  If this is too complicated, we could leave it as it is.
But we should at least try it.

So please select one regress to start with, make it nicely pass and
fail, fix the bugs and get your work commited.  I will help you
there.

bluhm



Re: Add "-c command" option to script(1)

2017-12-13 Thread Jason McIntyre
On Wed, Dec 13, 2017 at 05:45:25PM +0100, Paul de Weerd wrote:
> 
> Index: script.1
> ===
> RCS file: /cvs/src/usr.bin/script/script.1,v
> retrieving revision 1.14
> diff -u -p -r1.14 script.1
> --- script.1  15 Jan 2012 20:06:40 -  1.14
> +++ script.1  13 Dec 2017 12:27:32 -
> @@ -39,6 +39,7 @@
>  .Sh SYNOPSIS
>  .Nm script
>  .Op Fl a
> +.Op Fl c Ar command
>  .Op Ar file
>  .Sh DESCRIPTION
>  .Nm
> @@ -65,6 +66,13 @@ Append the output to
>  or
>  .Pa typescript ,
>  retaining the prior contents.
> +.It Fl c Ar command
> +Run
> +.Ar command
> +instead of an interactive shell.
> +To run a

i'd remove "a", but it's preference only - your choice.

> +.Ar command
> +with its own arguments, enclose it in quotes.

and s/its own//

>  .El
>  .Pp
>  The script ends when the forked shell exits (a control-D
> Index: script.c
> ===

you want to update usage() too.

jmc

> RCS file: /cvs/src/usr.bin/script/script.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 script.c
> --- script.c  12 Apr 2017 14:49:05 -  1.33
> +++ script.c  13 Dec 2017 12:15:20 -
> @@ -89,7 +89,7 @@ int istty;
>  
>  __dead void done(int);
>  void dooutput(void);
> -void doshell(void);
> +void doshell(char *);
>  void fail(void);
>  void finish(int);
>  void scriptflush(int);
> @@ -102,15 +102,20 @@ main(int argc, char *argv[])
>   struct sigaction sa;
>   struct winsize win;
>   char ibuf[BUFSIZ];
> + char *cmd;
>   ssize_t cc, off;
>   int aflg, ch;
>  
> + cmd = NULL;
>   aflg = 0;
> - while ((ch = getopt(argc, argv, "a")) != -1)
> + while ((ch = getopt(argc, argv, "ac:")) != -1)
>   switch(ch) {
>   case 'a':
>   aflg = 1;
>   break;
> + case 'c':
> + cmd = optarg;
> + break;
>   default:
>   fprintf(stderr, "usage: %s [-a] [file]\n", __progname);
>   exit(1);
> @@ -163,7 +168,7 @@ main(int argc, char *argv[])
>   if (child)
>   dooutput();
>   else
> - doshell();
> + doshell(cmd);
>   }
>  
>   bzero(&sa, sizeof sa);
> @@ -302,9 +307,10 @@ scriptflush(int signo)
>  }
>  
>  void
> -doshell(void)
> +doshell(char *cmd)
>  {
>   char *shell;
> + char *argp[] = {"sh", "-c", NULL, NULL};
>  
>   shell = getenv("SHELL");
>   if (shell == NULL)
> @@ -313,8 +319,15 @@ doshell(void)
>   (void)close(master);
>   (void)fclose(fscript);
>   login_tty(slave);
> - execl(shell, shell, "-i", (char *)NULL);
> - warn("%s", shell);
> +
> + if (cmd != NULL) {
> + argp[2] = cmd;
> + execv(_PATH_BSHELL, argp);
> + warn("unable to execute %s", _PATH_BSHELL);
> + } else {
> + execl(shell, shell, "-i", (char *)NULL);
> + warn("%s", shell);
> + }
>   fail();
>  }
>  
> 
> -- 
> >[<++>-]<+++.>+++[<-->-]<.>+++[<+
> +++>-]<.>++[<>-]<+.--.[-]
>  http://www.weirdnet.nl/ 
> 



Re: background scan for iwn(4)

2017-12-13 Thread Sebastian Benoit
Stefan Sperling(s...@stsp.name) on 2017.12.13 17:17:41 +0100:
> Since nobody is reporting problems with iwm(4), I took some time to write the
> corresponding diff for iwn(4) as well. I hope this increases test coverage :)
> 
> Works for me on:
> iwn0 at pci3 dev 0 function 0 "Intel Centrino Advanced-N 6200" rev 0x35: msi, 
> MIMO 2T2R, MoW

works on my 

iwn0 at pci2 dev 0 function 0 "Intel Centrino Advanced-N 6205" rev 0x34: msi, 
MIMO 2T2R, MoW

/Benno


> 
> Index: if_iwn.c
> ===
> RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v
> retrieving revision 1.194
> diff -u -p -r1.194 if_iwn.c
> --- if_iwn.c  26 Oct 2017 15:00:28 -  1.194
> +++ if_iwn.c  13 Dec 2017 16:07:07 -
> @@ -222,7 +222,9 @@ int   iwn_config(struct iwn_softc *);
>  uint16_t iwn_get_active_dwell_time(struct iwn_softc *, uint16_t, 
> uint8_t);
>  uint16_t iwn_limit_dwell(struct iwn_softc *, uint16_t);
>  uint16_t iwn_get_passive_dwell_time(struct iwn_softc *, uint16_t);
> -int  iwn_scan(struct iwn_softc *, uint16_t);
> +int  iwn_scan(struct iwn_softc *, uint16_t, int);
> +void iwn_scan_abort(struct iwn_softc *);
> +int  iwn_bgscan(struct ieee80211com *);
>  int  iwn_auth(struct iwn_softc *, int);
>  int  iwn_run(struct iwn_softc *);
>  int  iwn_set_key(struct ieee80211com *, struct ieee80211_node *,
> @@ -516,6 +518,7 @@ iwn_attach(struct device *parent, struct
>   if_attach(ifp);
>   ieee80211_ifattach(ifp);
>   ic->ic_node_alloc = iwn_node_alloc;
> + ic->ic_bgscan_start = iwn_bgscan;
>   ic->ic_newassoc = iwn_newassoc;
>   ic->ic_updateedca = iwn_updateedca;
>   ic->ic_set_key = iwn_set_key;
> @@ -1761,18 +1764,20 @@ iwn_newstate(struct ieee80211com *ic, en
>   struct iwn_node *wn = (void *)ni;
>   int error;
>  
> - timeout_del(&sc->calib_to);
> -
> - if (ic->ic_state == IEEE80211_S_RUN &&
> - (ni->ni_flags & IEEE80211_NODE_HT))
> + if (ic->ic_state == IEEE80211_S_RUN) {
>   ieee80211_mira_cancel_timeouts(&wn->mn);
> + timeout_del(&sc->calib_to);
> + sc->calib.state = IWN_CALIB_STATE_INIT;
> + if (sc->sc_flags & IWN_FLAG_BGSCAN)
> + iwn_scan_abort(sc);
> + }
>  
>   switch (nstate) {
>   case IEEE80211_S_SCAN:
>   /* Make the link LED blink while we're scanning. */
>   iwn_set_led(sc, IWN_LED_LINK, 10, 10);
>  
> - if ((error = iwn_scan(sc, IEEE80211_CHAN_2GHZ)) != 0) {
> + if ((error = iwn_scan(sc, IEEE80211_CHAN_2GHZ, 0)) != 0) {
>   printf("%s: could not initiate scan\n",
>   sc->sc_dev.dv_xname);
>   return error;
> @@ -1971,11 +1976,13 @@ iwn_rx_done(struct iwn_softc *sc, struct
>   struct ieee80211_frame *wh;
>   struct ieee80211_rxinfo rxi;
>   struct ieee80211_node *ni;
> + struct ieee80211_channel *bss_chan = NULL;
>   struct mbuf *m, *m1;
>   struct iwn_rx_stat *stat;
>   caddr_t head;
>   uint32_t flags;
>   int error, len, rssi;
> + uint8_t chan;
>  
>   if (desc->type == IWN_MPDU_RX_DONE) {
>   /* Check for prior RX_PHY notification. */
> @@ -2131,6 +2138,16 @@ iwn_rx_done(struct iwn_softc *sc, struct
>  
>   rssi = ops->get_rssi(stat);
>  
> + chan = stat->chan;
> + if (chan > IEEE80211_CHAN_MAX)
> + chan = IEEE80211_CHAN_MAX;
> +
> + if (ni == ic->ic_bss) {
> + bss_chan = ni->ni_chan;
> + /* Fix current channel. */
> + ni->ni_chan = &ic->ic_channels[chan];
> + }
> +
>  #if NBPFILTER > 0
>   if (sc->sc_drvbpf != NULL) {
>   struct mbuf mb;
> @@ -2140,9 +2157,8 @@ iwn_rx_done(struct iwn_softc *sc, struct
>   tap->wr_flags = 0;
>   if (stat->flags & htole16(IWN_STAT_FLAG_SHPREAMBLE))
>   tap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
> - tap->wr_chan_freq =
> - htole16(ic->ic_channels[stat->chan].ic_freq);
> - chan_flags = ic->ic_channels[stat->chan].ic_flags;
> + tap->wr_chan_freq = htole16(ic->ic_channels[chan].ic_freq);
> + chan_flags = ic->ic_channels[chan].ic_flags;
>   if (ic->ic_curmode != IEEE80211_MODE_11N)
>   chan_flags &= ~IEEE80211_CHAN_HT;
>   tap->wr_chan_flags = htole16(chan_flags);
> @@ -2187,6 +2203,10 @@ iwn_rx_done(struct iwn_softc *sc, struct
>   rxi.rxi_tstamp = 0; /* unused */
>   ieee80211_input(ifp, m, ni, &rxi);
>  
> + /* Restore BSS channel. */
> + if (ni == ic->ic_bss)
> + ni->ni_chan = bss_chan;
> +
>   /* Node is no longer needed. */
>   ieee80211_release_node(ic, ni);
>  }
> @@ -2586,6 +2606,9 @@ iwn_notif_intr(struct iwn_softc *sc)
>   DPRINTFN(2, ("scanni

Re: Change bcopy to memcpy (i386 VIA PadLock driver)

2017-12-13 Thread Mike Larkin
On Wed, Dec 13, 2017 at 10:23:46PM +0100, Frederic Cambus wrote:
> Hi tech@,
> 
> This diff changes bcopy to memcpy in the i386 version of the VIA PadLock
> driver. It was done a while ago in the amd64 version of the driver.
> 
> Comments? OK?
> 

ok mlarkin

> Index: sys/arch/i386/i386/via.c
> ===
> RCS file: /cvs/src/sys/arch/i386/i386/via.c,v
> retrieving revision 1.37
> diff -u -p -r1.37 via.c
> --- sys/arch/i386/i386/via.c  2 May 2017 11:47:49 -   1.37
> +++ sys/arch/i386/i386/via.c  10 Dec 2017 14:01:21 -
> @@ -161,7 +161,7 @@ viac3_crypto_newsession(u_int32_t *sidp,
>   M_NOWAIT);
>   if (ses == NULL)
>   return (ENOMEM);
> - bcopy(sc->sc_sessions, ses, sesn * sizeof(*ses));
> + memcpy(ses, sc->sc_sessions, sesn * sizeof(*ses));
>   explicit_bzero(sc->sc_sessions, sesn * sizeof(*ses));
>   free(sc->sc_sessions, M_DEVBUF, sesn * sizeof(*ses));
>   sc->sc_sessions = ses;
> @@ -370,7 +370,7 @@ viac3_crypto_encdec(struct cryptop *crp,
>   sc->op_cw[0] = ses->ses_cw0 | C3_CRYPT_CWLO_ENCRYPT;
>   key = ses->ses_ekey;
>   if (crd->crd_flags & CRD_F_IV_EXPLICIT)
> - bcopy(crd->crd_iv, sc->op_iv, 16);
> + memcpy(sc->op_iv, crd->crd_iv, 16);
>   else
>   arc4random_buf(sc->op_iv, 16);
>  
> @@ -382,8 +382,8 @@ viac3_crypto_encdec(struct cryptop *crp,
>   cuio_copyback((struct uio *)crp->crp_buf,
>   crd->crd_inject, 16, sc->op_iv);
>   else
> - bcopy(sc->op_iv,
> - crp->crp_buf + crd->crd_inject, 16);
> + memcpy(crp->crp_buf + crd->crd_inject,
> + sc->op_iv, 16);
>   if (err)
>   return (err);
>   }
> @@ -391,7 +391,7 @@ viac3_crypto_encdec(struct cryptop *crp,
>   sc->op_cw[0] = ses->ses_cw0 | C3_CRYPT_CWLO_DECRYPT;
>   key = ses->ses_dkey;
>   if (crd->crd_flags & CRD_F_IV_EXPLICIT)
> - bcopy(crd->crd_iv, sc->op_iv, 16);
> + memcpy(sc->op_iv, crd->crd_iv, 16);
>   else {
>   if (crp->crp_flags & CRYPTO_F_IMBUF)
>   m_copydata((struct mbuf *)crp->crp_buf,
> @@ -400,8 +400,8 @@ viac3_crypto_encdec(struct cryptop *crp,
>   cuio_copydata((struct uio *)crp->crp_buf,
>   crd->crd_inject, 16, sc->op_iv);
>   else
> - bcopy(crp->crp_buf + crd->crd_inject,
> - sc->op_iv, 16);
> + memcpy(sc->op_iv,
> + crp->crp_buf + crd->crd_inject, 16);
>   }
>   }
>  
> @@ -412,7 +412,7 @@ viac3_crypto_encdec(struct cryptop *crp,
>   cuio_copydata((struct uio *)crp->crp_buf,
>   crd->crd_skip, crd->crd_len, sc->op_buf);
>   else
> - bcopy(crp->crp_buf + crd->crd_skip, sc->op_buf, crd->crd_len);
> + memcpy(sc->op_buf, crp->crp_buf + crd->crd_skip, crd->crd_len);
>  
>   sc->op_cw[1] = sc->op_cw[2] = sc->op_cw[3] = 0;
>   viac3_cbc(&sc->op_cw, sc->op_buf, sc->op_buf, key,
> @@ -425,7 +425,7 @@ viac3_crypto_encdec(struct cryptop *crp,
>   cuio_copyback((struct uio *)crp->crp_buf,
>   crd->crd_skip, crd->crd_len, sc->op_buf);
>   else
> - bcopy(sc->op_buf, crp->crp_buf + crd->crd_skip,
> + memcpy(crp->crp_buf + crd->crd_skip, sc->op_buf,
>   crd->crd_len);
>  
>   if (sc->op_buf != NULL) {
> 



Change bcopy to memcpy (i386 VIA PadLock driver)

2017-12-13 Thread Frederic Cambus
Hi tech@,

This diff changes bcopy to memcpy in the i386 version of the VIA PadLock
driver. It was done a while ago in the amd64 version of the driver.

Comments? OK?

Index: sys/arch/i386/i386/via.c
===
RCS file: /cvs/src/sys/arch/i386/i386/via.c,v
retrieving revision 1.37
diff -u -p -r1.37 via.c
--- sys/arch/i386/i386/via.c2 May 2017 11:47:49 -   1.37
+++ sys/arch/i386/i386/via.c10 Dec 2017 14:01:21 -
@@ -161,7 +161,7 @@ viac3_crypto_newsession(u_int32_t *sidp,
M_NOWAIT);
if (ses == NULL)
return (ENOMEM);
-   bcopy(sc->sc_sessions, ses, sesn * sizeof(*ses));
+   memcpy(ses, sc->sc_sessions, sesn * sizeof(*ses));
explicit_bzero(sc->sc_sessions, sesn * sizeof(*ses));
free(sc->sc_sessions, M_DEVBUF, sesn * sizeof(*ses));
sc->sc_sessions = ses;
@@ -370,7 +370,7 @@ viac3_crypto_encdec(struct cryptop *crp,
sc->op_cw[0] = ses->ses_cw0 | C3_CRYPT_CWLO_ENCRYPT;
key = ses->ses_ekey;
if (crd->crd_flags & CRD_F_IV_EXPLICIT)
-   bcopy(crd->crd_iv, sc->op_iv, 16);
+   memcpy(sc->op_iv, crd->crd_iv, 16);
else
arc4random_buf(sc->op_iv, 16);
 
@@ -382,8 +382,8 @@ viac3_crypto_encdec(struct cryptop *crp,
cuio_copyback((struct uio *)crp->crp_buf,
crd->crd_inject, 16, sc->op_iv);
else
-   bcopy(sc->op_iv,
-   crp->crp_buf + crd->crd_inject, 16);
+   memcpy(crp->crp_buf + crd->crd_inject,
+   sc->op_iv, 16);
if (err)
return (err);
}
@@ -391,7 +391,7 @@ viac3_crypto_encdec(struct cryptop *crp,
sc->op_cw[0] = ses->ses_cw0 | C3_CRYPT_CWLO_DECRYPT;
key = ses->ses_dkey;
if (crd->crd_flags & CRD_F_IV_EXPLICIT)
-   bcopy(crd->crd_iv, sc->op_iv, 16);
+   memcpy(sc->op_iv, crd->crd_iv, 16);
else {
if (crp->crp_flags & CRYPTO_F_IMBUF)
m_copydata((struct mbuf *)crp->crp_buf,
@@ -400,8 +400,8 @@ viac3_crypto_encdec(struct cryptop *crp,
cuio_copydata((struct uio *)crp->crp_buf,
crd->crd_inject, 16, sc->op_iv);
else
-   bcopy(crp->crp_buf + crd->crd_inject,
-   sc->op_iv, 16);
+   memcpy(sc->op_iv,
+   crp->crp_buf + crd->crd_inject, 16);
}
}
 
@@ -412,7 +412,7 @@ viac3_crypto_encdec(struct cryptop *crp,
cuio_copydata((struct uio *)crp->crp_buf,
crd->crd_skip, crd->crd_len, sc->op_buf);
else
-   bcopy(crp->crp_buf + crd->crd_skip, sc->op_buf, crd->crd_len);
+   memcpy(sc->op_buf, crp->crp_buf + crd->crd_skip, crd->crd_len);
 
sc->op_cw[1] = sc->op_cw[2] = sc->op_cw[3] = 0;
viac3_cbc(&sc->op_cw, sc->op_buf, sc->op_buf, key,
@@ -425,7 +425,7 @@ viac3_crypto_encdec(struct cryptop *crp,
cuio_copyback((struct uio *)crp->crp_buf,
crd->crd_skip, crd->crd_len, sc->op_buf);
else
-   bcopy(sc->op_buf, crp->crp_buf + crd->crd_skip,
+   memcpy(crp->crp_buf + crd->crd_skip, sc->op_buf,
crd->crd_len);
 
if (sc->op_buf != NULL) {



Re: update Mesa to 17.2.6

2017-12-13 Thread Bryan Steele
On Wed, Dec 13, 2017 at 04:19:03PM -0500, Bryan Steele wrote:
> On Wed, Dec 13, 2017 at 09:56:32PM +0100, Matthieu Herrb wrote:
> > On Mon, Nov 27, 2017 at 08:22:30PM +1100, Jonathan Gray wrote:
> > > cd /usr/xenocara/lib
> > > ftp https://mesa.freedesktop.org/archive/mesa-17.2.6.tar.gz
> > > ftp http://jsg.id.au/mesa-update/mesa.diff.gz
> > > tar zxf mesa-17.2.6.tar.gz
> > > gunzip mesa.diff.gz
> > > patch -p0 < mesa.diff
> > > 
> > > sed -i 's/mesa$/mesa-17.2.6/' Makefile
> > > 
> > > build xenocara as normal
> > > 
> > > Builds on at least amd64, i386, sparc64, armv7 and arm64.
> > > 
> > > I'm interested in reports from people who saw corruption on Intel
> > > graphics during the brief period when Mesa 17.1.6 was in the tree.
> > 
> > Hi,
> > 
> > Works for me on my various intel and radeon based machines, including
> > macppc (with r300). I wasn't seeing the corruption with 17.1.6 though.
> > 
> > I've also checked the it builds and that glxgears works (slowly as
> > expected) on loongson.
> > -- 
> > Matthieu Herrb
> >
> 
> Hi,
> 
> The last time the Mesa 17 update came up there was also an issue with
> the newly introduced GLSL shader cache with pledge(2), which broke 3d
> Accel/WebGL in chromium, at least on radeondrm(4).
> 
> Is this still an issue?

Note; this is similar to the issue we had with ~/.drirc configurations.

https://marc.info/?l=openbsd-cvs&m=145221017502166&w=2
https://marc.info/?l=openbsd-ports-cvs&m=145211683609002&w=2



Re: update Mesa to 17.2.6

2017-12-13 Thread Bryan Steele
On Wed, Dec 13, 2017 at 09:56:32PM +0100, Matthieu Herrb wrote:
> On Mon, Nov 27, 2017 at 08:22:30PM +1100, Jonathan Gray wrote:
> > cd /usr/xenocara/lib
> > ftp https://mesa.freedesktop.org/archive/mesa-17.2.6.tar.gz
> > ftp http://jsg.id.au/mesa-update/mesa.diff.gz
> > tar zxf mesa-17.2.6.tar.gz
> > gunzip mesa.diff.gz
> > patch -p0 < mesa.diff
> > 
> > sed -i 's/mesa$/mesa-17.2.6/' Makefile
> > 
> > build xenocara as normal
> > 
> > Builds on at least amd64, i386, sparc64, armv7 and arm64.
> > 
> > I'm interested in reports from people who saw corruption on Intel
> > graphics during the brief period when Mesa 17.1.6 was in the tree.
> 
> Hi,
> 
> Works for me on my various intel and radeon based machines, including
> macppc (with r300). I wasn't seeing the corruption with 17.1.6 though.
> 
> I've also checked the it builds and that glxgears works (slowly as
> expected) on loongson.
> -- 
> Matthieu Herrb
>

Hi,

The last time the Mesa 17 update came up there was also an issue with
the newly introduced GLSL shader cache with pledge(2), which broke 3d
Accel/WebGL in chromium, at least on radeondrm(4).

Is this still an issue?

On Thu, Aug 24, 2017 at 09:14:53PM -0400, Bryan Steele wrote:
> It's the GPU Process that crashses, not chrome totally, so stuff
> doesn't feel as fast but otherwise works.. except WebGL.
> 
> With MESA_GLSL_CACHE_DISABLE
>
> Canvas: Hardware accelerated
> CheckerImaging: Disabled
> Flash: Hardware accelerated
> Flash Stage3D: Hardware accelerated
> Flash Stage3D Baseline profile: Hardware accelerated
> Compositing: Hardware accelerated
> Multiple Raster Threads: Enabled
> Native GpuMemoryBuffers: Software only. Hardware acceleration disabled
> Rasterization: Software only. Hardware acceleration disabled
> Video Decode: Hardware accelerated
> WebGL: Hardware accelerated
> WebGL2: Hardware accelerated
> 
> Without MESA_GLSL_CACHE_DISABLE
> 
> Canvas: Software only, hardware acceleration unavailable
> CheckerImaging: Disabled
> Flash: Software only, hardware acceleration unavailable
> Flash Stage3D: Software only, hardware acceleration unavailable
> Flash Stage3D Baseline profile: Software only, hardware acceleration
unavailable
> Compositing: Software only, hardware acceleration unavailable
> Multiple Raster Threads: Enabled
> Native GpuMemoryBuffers: Software only. Hardware acceleration disabled
> Rasterization: Software only, hardware acceleration unavailable
> Video Decode: Software only, hardware acceleration unavailable
> WebGL: Hardware accelerated but at reduced performance
> WebGL2: Unavailable
> 
> $ ktrace -di
>  73674 chrome   CALL  open(0x178f67579a80,0x1)
>  73674 chrome   NAMI
> "/home/brynet/.cache/mesa/de/4387ec406a27454794d3b16d24e\
>  73674 chrome   PLDG  open, "rpath", errno 1 Operation not permitted
>  98110 chrome   CALL  kill(73674,SIGKILL)
> 
> -Bryan.



Re: Add reset option to boot command of ddb(4)

2017-12-13 Thread Raf Czlonka
On Wed, Dec 13, 2017 at 06:09:14PM GMT, Florian Riehm wrote:
> Hi,
> 
> This patch follows bluhm's attempt for a ddb command 'boot reset'.
> My first attempt was not architecture aware.
> 
> Tested on i386 by bluhm@ and on amd64 by me.
> 
> ok?
> 
> friehm
> 
> Index: share/man/man4/ddb.4
> ===
> RCS file: /openbsd/src/share/man/man4/ddb.4,v
> retrieving revision 1.92
> diff -u -p -r1.92 ddb.4
> --- share/man/man4/ddb.4  29 Nov 2017 07:28:21 -  1.92
> +++ share/man/man4/ddb.4  12 Dec 2017 06:35:44 -
> @@ -381,6 +381,15 @@ Just halt.
>  Just reboot.
>  .It Ic boot poweroff
>  Power down the machine whenever possible; if it fails, just halt.
> +.It Ic boot reset
> +Restart the machine by resetting the CPU on i386 and amd64
> +architectures.
> +Useful in situations were

Shouldn't this read "where"?

Raf

> +.Ic boot reboot
> +does not work anymore, i.e. due to locking issues.
> +On other platforms it is equivalent to the
> +.Ic boot reboot
> +command.
>  .El
>  .\" 
>  .It Xo
> Index: sys/arch/amd64/amd64/machdep.c
> ===
> RCS file: /openbsd/src/sys/arch/amd64/amd64/machdep.c,v
> retrieving revision 1.236
> diff -u -p -r1.236 machdep.c
> --- sys/arch/amd64/amd64/machdep.c11 Dec 2017 05:27:40 -  1.236
> +++ sys/arch/amd64/amd64/machdep.c12 Dec 2017 06:35:44 -
> @@ -713,6 +713,9 @@ struct pcb dumppcb;
>  __dead void
>  boot(int howto)
>  {
> + if ((howto & RB_RESET) != 0)
> + goto reset;
> +
>   if ((howto & RB_POWERDOWN) != 0)
>   lid_action = 0;
>  
> @@ -770,6 +773,7 @@ haltsys:
>   printf("rebooting...\n");
>   if (cpureset_delay > 0)
>   delay(cpureset_delay * 1000);
> +reset:
>   cpu_reset();
>   for (;;)
>   continue;
> Index: sys/arch/i386/i386/machdep.c
> ===
> RCS file: /openbsd/src/sys/arch/i386/i386/machdep.c,v
> retrieving revision 1.607
> diff -u -p -r1.607 machdep.c
> --- sys/arch/i386/i386/machdep.c  11 Dec 2017 05:27:40 -  1.607
> +++ sys/arch/i386/i386/machdep.c  12 Dec 2017 06:35:44 -
> @@ -2629,6 +2629,9 @@ struct pcb dumppcb;
>  __dead void
>  boot(int howto)
>  {
> + if ((howto & RB_RESET) != 0)
> + goto reset;
> +
>   if ((howto & RB_POWERDOWN) != 0)
>   lid_action = 0;
>  
> @@ -2709,6 +2712,7 @@ haltsys:
>   }
>  
>   printf("rebooting...\n");
> +reset:
>   cpu_reset();
>   for (;;)
>   continue;
> Index: sys/ddb/db_command.c
> ===
> RCS file: /openbsd/src/sys/ddb/db_command.c,v
> retrieving revision 1.81
> diff -u -p -r1.81 db_command.c
> --- sys/ddb/db_command.c  11 Dec 2017 05:27:40 -  1.81
> +++ sys/ddb/db_command.c  12 Dec 2017 06:35:44 -
> @@ -105,6 +105,7 @@ void  db_boot_dump_cmd(db_expr_t, int, db
>  void db_boot_halt_cmd(db_expr_t, int, db_expr_t, char *);
>  void db_boot_reboot_cmd(db_expr_t, int, db_expr_t, char *);
>  void db_boot_poweroff_cmd(db_expr_t, int, db_expr_t, char *);
> +void db_boot_reset_cmd(db_expr_t, int, db_expr_t, char *);
>  void db_stack_trace_cmd(db_expr_t, int, db_expr_t, char *);
>  void db_dmesg_cmd(db_expr_t, int, db_expr_t, char *);
>  void db_show_panic_cmd(db_expr_t, int, db_expr_t, char *);
> @@ -597,6 +598,7 @@ struct db_command db_boot_cmds[] = {
>   { "halt",   db_boot_halt_cmd,   0,  0 },
>   { "reboot", db_boot_reboot_cmd, 0,  0 },
>   { "poweroff",   db_boot_poweroff_cmd,   0,  0 },
> + { "reset",  db_boot_reset_cmd,  0,  0 },
>   { NULL, }
>  };
>  
> @@ -812,6 +814,12 @@ void
>  db_boot_poweroff_cmd(db_expr_t addr, int haddr, db_expr_t count, char *modif)
>  {
>   db_reboot(RB_NOSYNC | RB_HALT | RB_POWERDOWN | RB_TIMEBAD | RB_USERREQ);
> +}
> +
> +void
> +db_boot_reset_cmd(db_expr_t addr, int haddr, db_expr_t count, char *modif)
> +{
> + db_reboot(RB_RESET | RB_AUTOBOOT | RB_NOSYNC | RB_TIMEBAD | RB_USERREQ);
>  }
>  
>  void
> Index: sys/sys/reboot.h
> ===
> RCS file: /openbsd/src/sys/sys/reboot.h,v
> retrieving revision 1.17
> diff -u -p -r1.17 reboot.h
> --- sys/sys/reboot.h  11 Jul 2014 14:36:44 -  1.17
> +++ sys/sys/reboot.h  12 Dec 2017 06:35:45 -
> @@ -56,6 +56,7 @@
>  #define  RB_POWERDOWN0x1000  /* attempt to power down machine */
>  #define  RB_SERCONS  0x2000  /* use serial console if available */
>  #define  RB_USERREQ  0x4000  /* boot() called at user request (e.g. 
> ddb) */
> +#define  RB_RESET0x8000  /* do not try to cleanup, only for ddb 
> */
>  
>  /*
>   * Constants for converting boot-style device number to type,
> 



Re: Add reset option to boot command of ddb(4)

2017-12-13 Thread Theo de Raadt
As it is, this diff will not go in.

Your 2nd attempt is not architecture aware either.  There are more
than 2 architectures.  If you add a MI feature, you must attempt to
add support for it to all the MD versions.  And the process of mailing
it out to the community gives people an opportunity to help test
those.

Seeing as this is only a goto and a label: on each architecture, what
is the purpose of not even trying to write such a diff??  You are
leaving the work, hoping someone eventually does it??

That isn't the way we work.

> This patch follows bluhm's attempt for a ddb command 'boot reset'.
> My first attempt was not architecture aware.
> 
> Tested on i386 by bluhm@ and on amd64 by me.
> 
> ok?
> 
> friehm
> 
> Index: share/man/man4/ddb.4
> ===
> RCS file: /openbsd/src/share/man/man4/ddb.4,v
> retrieving revision 1.92
> diff -u -p -r1.92 ddb.4
> --- share/man/man4/ddb.4  29 Nov 2017 07:28:21 -  1.92
> +++ share/man/man4/ddb.4  12 Dec 2017 06:35:44 -
> @@ -381,6 +381,15 @@ Just halt.
>  Just reboot.
>  .It Ic boot poweroff
>  Power down the machine whenever possible; if it fails, just halt.
> +.It Ic boot reset
> +Restart the machine by resetting the CPU on i386 and amd64
> +architectures.
> +Useful in situations were
> +.Ic boot reboot
> +does not work anymore, i.e. due to locking issues.
> +On other platforms it is equivalent to the
> +.Ic boot reboot
> +command.
>  .El
>  .\" 
>  .It Xo
> Index: sys/arch/amd64/amd64/machdep.c
> ===
> RCS file: /openbsd/src/sys/arch/amd64/amd64/machdep.c,v
> retrieving revision 1.236
> diff -u -p -r1.236 machdep.c
> --- sys/arch/amd64/amd64/machdep.c11 Dec 2017 05:27:40 -  1.236
> +++ sys/arch/amd64/amd64/machdep.c12 Dec 2017 06:35:44 -
> @@ -713,6 +713,9 @@ struct pcb dumppcb;
>  __dead void
>  boot(int howto)
>  {
> + if ((howto & RB_RESET) != 0)
> + goto reset;
> +
>   if ((howto & RB_POWERDOWN) != 0)
>   lid_action = 0;
>  
> @@ -770,6 +773,7 @@ haltsys:
>   printf("rebooting...\n");
>   if (cpureset_delay > 0)
>   delay(cpureset_delay * 1000);
> +reset:
>   cpu_reset();
>   for (;;)
>   continue;
> Index: sys/arch/i386/i386/machdep.c
> ===
> RCS file: /openbsd/src/sys/arch/i386/i386/machdep.c,v
> retrieving revision 1.607
> diff -u -p -r1.607 machdep.c
> --- sys/arch/i386/i386/machdep.c  11 Dec 2017 05:27:40 -  1.607
> +++ sys/arch/i386/i386/machdep.c  12 Dec 2017 06:35:44 -
> @@ -2629,6 +2629,9 @@ struct pcb dumppcb;
>  __dead void
>  boot(int howto)
>  {
> + if ((howto & RB_RESET) != 0)
> + goto reset;
> +
>   if ((howto & RB_POWERDOWN) != 0)
>   lid_action = 0;
>  
> @@ -2709,6 +2712,7 @@ haltsys:
>   }
>  
>   printf("rebooting...\n");
> +reset:
>   cpu_reset();
>   for (;;)
>   continue;
> Index: sys/ddb/db_command.c
> ===
> RCS file: /openbsd/src/sys/ddb/db_command.c,v
> retrieving revision 1.81
> diff -u -p -r1.81 db_command.c
> --- sys/ddb/db_command.c  11 Dec 2017 05:27:40 -  1.81
> +++ sys/ddb/db_command.c  12 Dec 2017 06:35:44 -
> @@ -105,6 +105,7 @@ void  db_boot_dump_cmd(db_expr_t, int, db
>  void db_boot_halt_cmd(db_expr_t, int, db_expr_t, char *);
>  void db_boot_reboot_cmd(db_expr_t, int, db_expr_t, char *);
>  void db_boot_poweroff_cmd(db_expr_t, int, db_expr_t, char *);
> +void db_boot_reset_cmd(db_expr_t, int, db_expr_t, char *);
>  void db_stack_trace_cmd(db_expr_t, int, db_expr_t, char *);
>  void db_dmesg_cmd(db_expr_t, int, db_expr_t, char *);
>  void db_show_panic_cmd(db_expr_t, int, db_expr_t, char *);
> @@ -597,6 +598,7 @@ struct db_command db_boot_cmds[] = {
>   { "halt",   db_boot_halt_cmd,   0,  0 },
>   { "reboot", db_boot_reboot_cmd, 0,  0 },
>   { "poweroff",   db_boot_poweroff_cmd,   0,  0 },
> + { "reset",  db_boot_reset_cmd,  0,  0 },
>   { NULL, }
>  };
>  
> @@ -812,6 +814,12 @@ void
>  db_boot_poweroff_cmd(db_expr_t addr, int haddr, db_expr_t count, char *modif)
>  {
>   db_reboot(RB_NOSYNC | RB_HALT | RB_POWERDOWN | RB_TIMEBAD | RB_USERREQ);
> +}
> +
> +void
> +db_boot_reset_cmd(db_expr_t addr, int haddr, db_expr_t count, char *modif)
> +{
> + db_reboot(RB_RESET | RB_AUTOBOOT | RB_NOSYNC | RB_TIMEBAD | RB_USERREQ);
>  }
>  
>  void
> Index: sys/sys/reboot.h
> ===
> RCS file: /openbsd/src/sys/sys/reboot.h,v
> retrieving revision 1.17
> diff -u -p -r1.17 reboot.h
> --- sys/sys/reboot.h  11 Jul 2014 14:36:44 -  1.17
> +++ sys/sys/reboot.h  12 Dec 2017 06:35:45 -
> @@ -56,6 +56,7 @@
>  #define  RB_

Re: update Mesa to 17.2.6

2017-12-13 Thread Matthieu Herrb
On Mon, Nov 27, 2017 at 08:22:30PM +1100, Jonathan Gray wrote:
> cd /usr/xenocara/lib
> ftp https://mesa.freedesktop.org/archive/mesa-17.2.6.tar.gz
> ftp http://jsg.id.au/mesa-update/mesa.diff.gz
> tar zxf mesa-17.2.6.tar.gz
> gunzip mesa.diff.gz
> patch -p0 < mesa.diff
> 
> sed -i 's/mesa$/mesa-17.2.6/' Makefile
> 
> build xenocara as normal
> 
> Builds on at least amd64, i386, sparc64, armv7 and arm64.
> 
> I'm interested in reports from people who saw corruption on Intel
> graphics during the brief period when Mesa 17.1.6 was in the tree.

Hi,

Works for me on my various intel and radeon based machines, including
macppc (with r300). I wasn't seeing the corruption with 17.1.6 though.

I've also checked the it builds and that glxgears works (slowly as
expected) on loongson.
-- 
Matthieu Herrb



Add reset option to boot command of ddb(4)

2017-12-13 Thread Florian Riehm
Hi,

This patch follows bluhm's attempt for a ddb command 'boot reset'.
My first attempt was not architecture aware.

Tested on i386 by bluhm@ and on amd64 by me.

ok?

friehm

Index: share/man/man4/ddb.4
===
RCS file: /openbsd/src/share/man/man4/ddb.4,v
retrieving revision 1.92
diff -u -p -r1.92 ddb.4
--- share/man/man4/ddb.429 Nov 2017 07:28:21 -  1.92
+++ share/man/man4/ddb.412 Dec 2017 06:35:44 -
@@ -381,6 +381,15 @@ Just halt.
 Just reboot.
 .It Ic boot poweroff
 Power down the machine whenever possible; if it fails, just halt.
+.It Ic boot reset
+Restart the machine by resetting the CPU on i386 and amd64
+architectures.
+Useful in situations were
+.Ic boot reboot
+does not work anymore, i.e. due to locking issues.
+On other platforms it is equivalent to the
+.Ic boot reboot
+command.
 .El
 .\" 
 .It Xo
Index: sys/arch/amd64/amd64/machdep.c
===
RCS file: /openbsd/src/sys/arch/amd64/amd64/machdep.c,v
retrieving revision 1.236
diff -u -p -r1.236 machdep.c
--- sys/arch/amd64/amd64/machdep.c  11 Dec 2017 05:27:40 -  1.236
+++ sys/arch/amd64/amd64/machdep.c  12 Dec 2017 06:35:44 -
@@ -713,6 +713,9 @@ struct pcb dumppcb;
 __dead void
 boot(int howto)
 {
+   if ((howto & RB_RESET) != 0)
+   goto reset;
+
if ((howto & RB_POWERDOWN) != 0)
lid_action = 0;
 
@@ -770,6 +773,7 @@ haltsys:
printf("rebooting...\n");
if (cpureset_delay > 0)
delay(cpureset_delay * 1000);
+reset:
cpu_reset();
for (;;)
continue;
Index: sys/arch/i386/i386/machdep.c
===
RCS file: /openbsd/src/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.607
diff -u -p -r1.607 machdep.c
--- sys/arch/i386/i386/machdep.c11 Dec 2017 05:27:40 -  1.607
+++ sys/arch/i386/i386/machdep.c12 Dec 2017 06:35:44 -
@@ -2629,6 +2629,9 @@ struct pcb dumppcb;
 __dead void
 boot(int howto)
 {
+   if ((howto & RB_RESET) != 0)
+   goto reset;
+
if ((howto & RB_POWERDOWN) != 0)
lid_action = 0;
 
@@ -2709,6 +2712,7 @@ haltsys:
}
 
printf("rebooting...\n");
+reset:
cpu_reset();
for (;;)
continue;
Index: sys/ddb/db_command.c
===
RCS file: /openbsd/src/sys/ddb/db_command.c,v
retrieving revision 1.81
diff -u -p -r1.81 db_command.c
--- sys/ddb/db_command.c11 Dec 2017 05:27:40 -  1.81
+++ sys/ddb/db_command.c12 Dec 2017 06:35:44 -
@@ -105,6 +105,7 @@ voiddb_boot_dump_cmd(db_expr_t, int, db
 void   db_boot_halt_cmd(db_expr_t, int, db_expr_t, char *);
 void   db_boot_reboot_cmd(db_expr_t, int, db_expr_t, char *);
 void   db_boot_poweroff_cmd(db_expr_t, int, db_expr_t, char *);
+void   db_boot_reset_cmd(db_expr_t, int, db_expr_t, char *);
 void   db_stack_trace_cmd(db_expr_t, int, db_expr_t, char *);
 void   db_dmesg_cmd(db_expr_t, int, db_expr_t, char *);
 void   db_show_panic_cmd(db_expr_t, int, db_expr_t, char *);
@@ -597,6 +598,7 @@ struct db_command db_boot_cmds[] = {
{ "halt",   db_boot_halt_cmd,   0,  0 },
{ "reboot", db_boot_reboot_cmd, 0,  0 },
{ "poweroff",   db_boot_poweroff_cmd,   0,  0 },
+   { "reset",  db_boot_reset_cmd,  0,  0 },
{ NULL, }
 };
 
@@ -812,6 +814,12 @@ void
 db_boot_poweroff_cmd(db_expr_t addr, int haddr, db_expr_t count, char *modif)
 {
db_reboot(RB_NOSYNC | RB_HALT | RB_POWERDOWN | RB_TIMEBAD | RB_USERREQ);
+}
+
+void
+db_boot_reset_cmd(db_expr_t addr, int haddr, db_expr_t count, char *modif)
+{
+   db_reboot(RB_RESET | RB_AUTOBOOT | RB_NOSYNC | RB_TIMEBAD | RB_USERREQ);
 }
 
 void
Index: sys/sys/reboot.h
===
RCS file: /openbsd/src/sys/sys/reboot.h,v
retrieving revision 1.17
diff -u -p -r1.17 reboot.h
--- sys/sys/reboot.h11 Jul 2014 14:36:44 -  1.17
+++ sys/sys/reboot.h12 Dec 2017 06:35:45 -
@@ -56,6 +56,7 @@
 #defineRB_POWERDOWN0x1000  /* attempt to power down machine */
 #defineRB_SERCONS  0x2000  /* use serial console if available */
 #defineRB_USERREQ  0x4000  /* boot() called at user request (e.g. 
ddb) */
+#defineRB_RESET0x8000  /* do not try to cleanup, only for ddb 
*/
 
 /*
  * Constants for converting boot-style device number to type,



Re: rpc: use monotime for timeouts

2017-12-13 Thread Jeremie Courreges-Anglas
On Tue, Dec 12 2017, Jeremie Courreges-Anglas  wrote:
> On Sun, Dec 10 2017, Scott Cheloha  wrote:
>> Hi,
>>
>> These timeouts in sunrpc need to be based on the monotonic
>> clock to avoid a race with adjtime(2), settimeofday(2), etc.
>>
>> There are obvious possible improvements here and elsewhere
>> in sunrpc.  Here especially the time-related variable names
>> could be made more descriptive, the various BSD time macros
>> could be more effectively employed, and ppoll(2) can (now) be
>> leveraged to ignore EINTR and simplify those loops.  But that
>> all belongs in a separate diff.
>>
>> Likewise, there are dead timevals elsewhere in RPC
>> that I can remove in a separate diff.
>>
>> Then again, this is ancient upstream code.  Does cleanup here
>> put too much burden on the project?  Like, I imagine that the
>> sort of cleanup I'm seeing here could make merging changes
>> from elsewhere painful.
>
> Well, afaik upstream can be considered dead, and looking at cvs log
> people have implemented a bunch of changes and improvements to these
> files, so I think that further improvements are welcome.
>
>> I have also included here my sys/time.h diff from like two
>> seconds ago, which enables the use of TIMEVAL_TO_TIMESPEC
>> in the body of the if statement in clnt_udp.c.  Its use makes
>> the diff simpler.
>
> (The sys/time.h change has since been committed.)
>
>> This is probably not adequately tested, though it compiles
>> and I'm not seeing any issues in my (small) NFS setup.
>>
>> Thoughts and feedback?
>
> I'll schedule some time for a review tomorrow, more eyes would be
> welcome.

Looks fine to me and works fine here.  Here's a refreshed diff to be
applied from libc/.


Index: rpc/clnt_tcp.c
===
RCS file: /d/cvs/src/lib/libc/rpc/clnt_tcp.c,v
retrieving revision 1.29
diff -u -p -r1.29 clnt_tcp.c
--- rpc/clnt_tcp.c  1 Nov 2015 03:45:29 -   1.29
+++ rpc/clnt_tcp.c  13 Dec 2017 15:39:07 -
@@ -385,25 +385,26 @@ static int
 readtcp(struct ct_data *ct, caddr_t buf, int len)
 {
struct pollfd pfd[1];
-   struct timeval start, after, duration, tmp;
-   int delta, r, save_errno;
+   struct timespec start, after, duration, tmp, delta, wait;
+   int r, save_errno;
 
if (len == 0)
return (0);
 
pfd[0].fd = ct->ct_sock;
pfd[0].events = POLLIN;
-   delta = ct->ct_wait.tv_sec * 1000 + ct->ct_wait.tv_usec / 1000;
-   gettimeofday(&start, NULL);
+   TIMEVAL_TO_TIMESPEC(&ct->ct_wait, &wait);
+   delta = wait;
+   clock_gettime(CLOCK_MONOTONIC, &start);
for (;;) {
-   r = poll(pfd, 1, delta);
+   r = ppoll(pfd, 1, &delta, NULL);
save_errno = errno;
 
-   gettimeofday(&after, NULL);
-   timersub(&start, &after, &duration);
-   timersub(&ct->ct_wait, &duration, &tmp);
-   delta = tmp.tv_sec * 1000 + tmp.tv_usec / 1000;
-   if (delta <= 0)
+   clock_gettime(CLOCK_MONOTONIC, &after);
+   timespecsub(&start, &after, &duration);
+   timespecsub(&wait, &duration, &tmp);
+   delta = tmp;
+   if (delta.tv_sec < 0 || !timespecisset(&delta))
r = 0;
 
switch (r) {
Index: rpc/clnt_udp.c
===
RCS file: /d/cvs/src/lib/libc/rpc/clnt_udp.c,v
retrieving revision 1.32
diff -u -p -r1.32 clnt_udp.c
--- rpc/clnt_udp.c  1 Nov 2015 03:45:29 -   1.32
+++ rpc/clnt_udp.c  13 Dec 2017 15:39:07 -
@@ -216,19 +216,20 @@ clntudp_call(CLIENT *cl,  /* client handl
struct sockaddr_in from;
struct rpc_msg reply_msg;
XDR reply_xdrs;
-   struct timeval time_waited, start, after, tmp1, tmp2;
+   struct timespec time_waited, start, after, tmp1, tmp2, wait;
bool_t ok;
int nrefreshes = 2; /* number of times to refresh cred */
-   struct timeval timeout;
+   struct timespec timeout;
 
if (cu->cu_total.tv_usec == -1)
-   timeout = utimeout; /* use supplied timeout */
+   TIMEVAL_TO_TIMESPEC(&utimeout, &timeout); /* use supplied 
timeout */
else
-   timeout = cu->cu_total; /* use default timeout */
+   TIMEVAL_TO_TIMESPEC(&cu->cu_total, &timeout); /* use default 
timeout */
 
pfd[0].fd = cu->cu_sock;
pfd[0].events = POLLIN;
-   timerclear(&time_waited);
+   timespecclear(&time_waited);
+   TIMEVAL_TO_TIMESPEC(&cu->cu_wait, &wait);
 call_again:
xdrs = &(cu->cu_outxdrs);
xdrs->x_op = XDR_ENCODE;
@@ -254,7 +255,7 @@ send_again:
/*
 * Hack to provide rpc-based message passing
 */
-   if (!timerisset(&timeout))
+   if (!timespecisset(&timeout))
return (cu->cu_error.re_status = RPC_TIMEDOUT);
 
/

Add "-c command" option to script(1)

2017-12-13 Thread Paul de Weerd
Hi all,

As seen in NetBSD, FreeBSD and Linux, script(1) could do with a way to
tell it what command to run instead of your $SHELL.  This implements
the "-c command" option.  I've taken the logic to start the command
(and its arguments, if any) from crontab(1), execv'ing `sh -c
`.

I wrote this because I got fed up with typing `cu -l cuaU3 -s 19200`
right after starting script every time: it annoys my command line
editing fingers that I can't just recall what I did before.

There's a roundabout way of achieving something similar by setting
SHELL to some script that runs your command with its arguments, but
that's just silly (and nasty).

NetBSD: uses "-c command", executes the command using system(3)
Linux: uses "-c command", didn't look at the implementation
FreeBSD: uses arguments after the filename, wields execvp(3)

(these three have a bunch more extra options, all of which mostly look
like bullshit - specifying an alternative command seems the only
useful thing to me)

Illumos: feature parity with current OpenBSD, no -c command


My implementation worked from the get go, so there must be something
wrong with it.  All comments and feedback appreciated; asbestos
underwear at the ready.

Sample output:
[weerd@pom] $ obj/script -c "ls -l" output.`date +%s`
Script started, output file is output.1513183391
total 36
drwxr-xr-x  2 weerd  wsrc   512 May  9  2017 CVS
-rw-r--r--  1 weerd  wsrc   131 Sep 21  1997 Makefile
lrwxrwx---  1 weerd  wsrc23 Dec 13 17:42 obj -> /usr/obj/usr.bin/script
-rw-r--r--  1 weerd  wsrc 0 Dec 13 17:43 output.1513183391
-rw-r--r--  1 weerd  wsrc  3642 Dec 13 17:42 script.1
-rw-r--r--  1 weerd  wsrc  8464 Dec 13 17:41 script.c
Script done, output file is output.1513183391


Paul 'WEiRD' de Weerd

Index: script.1
===
RCS file: /cvs/src/usr.bin/script/script.1,v
retrieving revision 1.14
diff -u -p -r1.14 script.1
--- script.115 Jan 2012 20:06:40 -  1.14
+++ script.113 Dec 2017 12:27:32 -
@@ -39,6 +39,7 @@
 .Sh SYNOPSIS
 .Nm script
 .Op Fl a
+.Op Fl c Ar command
 .Op Ar file
 .Sh DESCRIPTION
 .Nm
@@ -65,6 +66,13 @@ Append the output to
 or
 .Pa typescript ,
 retaining the prior contents.
+.It Fl c Ar command
+Run
+.Ar command
+instead of an interactive shell.
+To run a
+.Ar command
+with its own arguments, enclose it in quotes.
 .El
 .Pp
 The script ends when the forked shell exits (a control-D
Index: script.c
===
RCS file: /cvs/src/usr.bin/script/script.c,v
retrieving revision 1.33
diff -u -p -r1.33 script.c
--- script.c12 Apr 2017 14:49:05 -  1.33
+++ script.c13 Dec 2017 12:15:20 -
@@ -89,7 +89,7 @@ int   istty;
 
 __dead void done(int);
 void dooutput(void);
-void doshell(void);
+void doshell(char *);
 void fail(void);
 void finish(int);
 void scriptflush(int);
@@ -102,15 +102,20 @@ main(int argc, char *argv[])
struct sigaction sa;
struct winsize win;
char ibuf[BUFSIZ];
+   char *cmd;
ssize_t cc, off;
int aflg, ch;
 
+   cmd = NULL;
aflg = 0;
-   while ((ch = getopt(argc, argv, "a")) != -1)
+   while ((ch = getopt(argc, argv, "ac:")) != -1)
switch(ch) {
case 'a':
aflg = 1;
break;
+   case 'c':
+   cmd = optarg;
+   break;
default:
fprintf(stderr, "usage: %s [-a] [file]\n", __progname);
exit(1);
@@ -163,7 +168,7 @@ main(int argc, char *argv[])
if (child)
dooutput();
else
-   doshell();
+   doshell(cmd);
}
 
bzero(&sa, sizeof sa);
@@ -302,9 +307,10 @@ scriptflush(int signo)
 }
 
 void
-doshell(void)
+doshell(char *cmd)
 {
char *shell;
+   char *argp[] = {"sh", "-c", NULL, NULL};
 
shell = getenv("SHELL");
if (shell == NULL)
@@ -313,8 +319,15 @@ doshell(void)
(void)close(master);
(void)fclose(fscript);
login_tty(slave);
-   execl(shell, shell, "-i", (char *)NULL);
-   warn("%s", shell);
+
+   if (cmd != NULL) {
+   argp[2] = cmd;
+   execv(_PATH_BSHELL, argp);
+   warn("unable to execute %s", _PATH_BSHELL);
+   } else {
+   execl(shell, shell, "-i", (char *)NULL);
+   warn("%s", shell);
+   }
fail();
 }
 

-- 
>[<++>-]<+++.>+++[<-->-]<.>+++[<+
+++>-]<.>++[<>-]<+.--.[-]
 http://www.weirdnet.nl/ 



background scan for iwn(4)

2017-12-13 Thread Stefan Sperling
Since nobody is reporting problems with iwm(4), I took some time to write the
corresponding diff for iwn(4) as well. I hope this increases test coverage :)

Works for me on:
iwn0 at pci3 dev 0 function 0 "Intel Centrino Advanced-N 6200" rev 0x35: msi, 
MIMO 2T2R, MoW

Index: if_iwn.c
===
RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v
retrieving revision 1.194
diff -u -p -r1.194 if_iwn.c
--- if_iwn.c26 Oct 2017 15:00:28 -  1.194
+++ if_iwn.c13 Dec 2017 16:07:07 -
@@ -222,7 +222,9 @@ int iwn_config(struct iwn_softc *);
 uint16_t   iwn_get_active_dwell_time(struct iwn_softc *, uint16_t, 
uint8_t);
 uint16_t   iwn_limit_dwell(struct iwn_softc *, uint16_t);
 uint16_t   iwn_get_passive_dwell_time(struct iwn_softc *, uint16_t);
-intiwn_scan(struct iwn_softc *, uint16_t);
+intiwn_scan(struct iwn_softc *, uint16_t, int);
+void   iwn_scan_abort(struct iwn_softc *);
+intiwn_bgscan(struct ieee80211com *);
 intiwn_auth(struct iwn_softc *, int);
 intiwn_run(struct iwn_softc *);
 intiwn_set_key(struct ieee80211com *, struct ieee80211_node *,
@@ -516,6 +518,7 @@ iwn_attach(struct device *parent, struct
if_attach(ifp);
ieee80211_ifattach(ifp);
ic->ic_node_alloc = iwn_node_alloc;
+   ic->ic_bgscan_start = iwn_bgscan;
ic->ic_newassoc = iwn_newassoc;
ic->ic_updateedca = iwn_updateedca;
ic->ic_set_key = iwn_set_key;
@@ -1761,18 +1764,20 @@ iwn_newstate(struct ieee80211com *ic, en
struct iwn_node *wn = (void *)ni;
int error;
 
-   timeout_del(&sc->calib_to);
-
-   if (ic->ic_state == IEEE80211_S_RUN &&
-   (ni->ni_flags & IEEE80211_NODE_HT))
+   if (ic->ic_state == IEEE80211_S_RUN) {
ieee80211_mira_cancel_timeouts(&wn->mn);
+   timeout_del(&sc->calib_to);
+   sc->calib.state = IWN_CALIB_STATE_INIT;
+   if (sc->sc_flags & IWN_FLAG_BGSCAN)
+   iwn_scan_abort(sc);
+   }
 
switch (nstate) {
case IEEE80211_S_SCAN:
/* Make the link LED blink while we're scanning. */
iwn_set_led(sc, IWN_LED_LINK, 10, 10);
 
-   if ((error = iwn_scan(sc, IEEE80211_CHAN_2GHZ)) != 0) {
+   if ((error = iwn_scan(sc, IEEE80211_CHAN_2GHZ, 0)) != 0) {
printf("%s: could not initiate scan\n",
sc->sc_dev.dv_xname);
return error;
@@ -1971,11 +1976,13 @@ iwn_rx_done(struct iwn_softc *sc, struct
struct ieee80211_frame *wh;
struct ieee80211_rxinfo rxi;
struct ieee80211_node *ni;
+   struct ieee80211_channel *bss_chan = NULL;
struct mbuf *m, *m1;
struct iwn_rx_stat *stat;
caddr_t head;
uint32_t flags;
int error, len, rssi;
+   uint8_t chan;
 
if (desc->type == IWN_MPDU_RX_DONE) {
/* Check for prior RX_PHY notification. */
@@ -2131,6 +2138,16 @@ iwn_rx_done(struct iwn_softc *sc, struct
 
rssi = ops->get_rssi(stat);
 
+   chan = stat->chan;
+   if (chan > IEEE80211_CHAN_MAX)
+   chan = IEEE80211_CHAN_MAX;
+
+   if (ni == ic->ic_bss) {
+   bss_chan = ni->ni_chan;
+   /* Fix current channel. */
+   ni->ni_chan = &ic->ic_channels[chan];
+   }
+
 #if NBPFILTER > 0
if (sc->sc_drvbpf != NULL) {
struct mbuf mb;
@@ -2140,9 +2157,8 @@ iwn_rx_done(struct iwn_softc *sc, struct
tap->wr_flags = 0;
if (stat->flags & htole16(IWN_STAT_FLAG_SHPREAMBLE))
tap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
-   tap->wr_chan_freq =
-   htole16(ic->ic_channels[stat->chan].ic_freq);
-   chan_flags = ic->ic_channels[stat->chan].ic_flags;
+   tap->wr_chan_freq = htole16(ic->ic_channels[chan].ic_freq);
+   chan_flags = ic->ic_channels[chan].ic_flags;
if (ic->ic_curmode != IEEE80211_MODE_11N)
chan_flags &= ~IEEE80211_CHAN_HT;
tap->wr_chan_flags = htole16(chan_flags);
@@ -2187,6 +2203,10 @@ iwn_rx_done(struct iwn_softc *sc, struct
rxi.rxi_tstamp = 0; /* unused */
ieee80211_input(ifp, m, ni, &rxi);
 
+   /* Restore BSS channel. */
+   if (ni == ic->ic_bss)
+   ni->ni_chan = bss_chan;
+
/* Node is no longer needed. */
ieee80211_release_node(ic, ni);
 }
@@ -2586,6 +2606,9 @@ iwn_notif_intr(struct iwn_softc *sc)
DPRINTFN(2, ("scanning channel %d status %x\n",
scan->chan, letoh32(scan->status)));
 
+   if (sc->sc_flags & IWN_FLAG_BGSCAN)
+   break;
+
/* Fix current channel. */

Re: libressl: crash in DES_fcrypt

2017-12-13 Thread Bob Beck
why AA?  why not just choose two random ascii salt chars at that point?  or
since this is effectively a failure case encrypt a random ascii salt and
random string?

using AA will produce a usable result based on the original string.
 encrypting a random string with a random salt means the failure return
wont be accidentally used

On Wed, Dec 13, 2017 at 06:51 Theo de Raadt  wrote:

> I still don't understand.
>
> This feels like fail-open.
>
> > I would like to commit this fix.  I tried to avoid the crash in
> > libcrypto with least possible impact for the DES_fcrypt() API.
> >
> > ok?
> >
> > bluhm
> >
> > On Tue, Dec 05, 2017 at 05:20:49PM +0100, Alexander Bluhm wrote:
> > > On Fri, Oct 27, 2017 at 01:50:26AM +0200, Jan Engelhardt wrote:
> > > > #include 
> > > > int main(void) {
> > > > char salt[3] = {0xf8, 0xd0, 0x00};
> > > > char out[32];
> > > > DES_fcrypt("foo", salt, out);
> > > > }
> > >
> > > This program produces a Segmentation fault in OpenBSD current.
> > >
> > > > openssl 1.1.x has it fixed (but 1.0.2l does not!) - their commit
> > > > seems to be 6493e4801e9edbe1ad1e256d4ce9cd55c8aa2242 in
> > > > https://github.com/openssl/openssl .
> > >
> > > Their fix changes the semantics of DES_crypt() and DES_fcrypt().
> > > They may fail and return NULL now.  This was never the case before
> > > so we may expect that programs do not check it.  With DES_fcrypt()
> > > it is very likely that some uninitilaized content of the return
> > > string is used.
> > >
> > > So I have extended the workaround that was there already.  Read the
> > > comment above the fix.  If the salt does not consist of two ascii
> > > characters, replace it with "AA".  This gives a safe result in all
> > > cases.
> > >
> > > ok?
> > >
> > > bluhm
> > >
> > > Index: lib/libcrypto/des/fcrypt.c
> > > ===
> > > RCS file: /data/mirror/openbsd/cvs/src/lib/libcrypto/des/fcrypt.c,v
> > > retrieving revision 1.12
> > > diff -u -p -r1.12 fcrypt.c
> > > --- lib/libcrypto/des/fcrypt.c  26 Dec 2016 21:30:10 -
> 1.12
> > > +++ lib/libcrypto/des/fcrypt.c  5 Dec 2017 16:03:57 -
> > > @@ -78,9 +78,15 @@ char *DES_fcrypt(const char *buf, const
> > >  * crypt to "*".  This was found when replacing the crypt in
> > >  * our shared libraries.  People found that the disabled
> > >  * accounts effectively had no passwd :-(. */
> > > -   x=ret[0]=((salt[0] == '\0')?'A':salt[0]);
> > > +   x = salt[0];
> > > +   if (x == 0 || x >= sizeof(con_salt))
> > > +   x = 'A';
> > > +   ret[0] = x;
> > > Eswap0=con_salt[x]<<2;
> > > -   x=ret[1]=((salt[1] == '\0')?'A':salt[1]);
> > > +   x = (salt[0] == '\0') ? 'A' : salt[1];
> > > +   if (x == 0 || x >= sizeof(con_salt))
> > > +   x = 'A';
> > > +   ret[1] = x;
> > > Eswap1=con_salt[x]<<6;
> > >  /* EAY
> > >  r=strlen(buf);
> > > Index: regress/lib/libcrypto/des/destest.c
> > > ===
> > > RCS file:
> /data/mirror/openbsd/cvs/src/regress/lib/libcrypto/des/destest.c,v
> > > retrieving revision 1.3
> > > diff -u -p -r1.3 destest.c
> > > --- regress/lib/libcrypto/des/destest.c 30 Oct 2015 15:58:40
> -  1.3
> > > +++ regress/lib/libcrypto/des/destest.c 5 Dec 2017 16:02:18 -
> > > @@ -749,18 +749,38 @@ plain[8+4], plain[8+5], plain[8+6], plai
> > > }
> > > printf("\n");
> > > printf("fast crypt test ");
> > > -   str=crypt("testing","ef");
> > > +   str=DES_crypt("testing","ef");
> > > if (strcmp("efGnQx2725bI2",str) != 0)
> > > {
> > > printf("fast crypt error, %s should be
> efGnQx2725bI2\n",str);
> > > err=1;
> > > }
> > > -   str=crypt("bca76;23","yA");
> > > +   str=DES_crypt("bca76;23","yA");
> > > if (strcmp("yA1Rp/1hZXIJk",str) != 0)
> > > {
> > > printf("fast crypt error, %s should be
> yA1Rp/1hZXIJk\n",str);
> > > err=1;
> > > }
> > > +   str = DES_crypt("testing", "\202B");
> > > +   if (strncmp("AB",str,2) != 0) {
> > > +   printf("salt %s first non ascii not replaced with A\n",
> str);
> > > +   err = 1;
> > > +   }
> > > +   str = DES_crypt("testing", "B\202");
> > > +   if (strncmp("BA",str,2) != 0) {
> > > +   printf("salt %s second non ascii not replaced with A\n",
> str);
> > > +   err = 1;
> > > +   }
> > > +   str = DES_crypt("testing", "\0B");
> > > +   if (strncmp("AA",str,2) != 0) {
> > > +   printf("salt %s first NUL not replaced with AA\n", str);
> > > +   err = 1;
> > > +   }
> > > +   str = DES_crypt("testing", "B");
> > > +   if (strncmp("BA",str,2) != 0) {
> > > +   printf("salt %s second NUL not replaced with A\n", str);
> > > +   err = 1;
> > > +   }
> > > printf("\n");
> > > return(err);
> > > }
> >
>
>


Re: libressl: crash in DES_fcrypt

2017-12-13 Thread Theo de Raadt
I still don't understand.

This feels like fail-open.

> I would like to commit this fix.  I tried to avoid the crash in
> libcrypto with least possible impact for the DES_fcrypt() API.
> 
> ok?
> 
> bluhm
> 
> On Tue, Dec 05, 2017 at 05:20:49PM +0100, Alexander Bluhm wrote:
> > On Fri, Oct 27, 2017 at 01:50:26AM +0200, Jan Engelhardt wrote:
> > > #include 
> > > int main(void) {
> > > char salt[3] = {0xf8, 0xd0, 0x00};
> > > char out[32];
> > > DES_fcrypt("foo", salt, out);
> > > }
> > 
> > This program produces a Segmentation fault in OpenBSD current.
> > 
> > > openssl 1.1.x has it fixed (but 1.0.2l does not!) - their commit
> > > seems to be 6493e4801e9edbe1ad1e256d4ce9cd55c8aa2242 in
> > > https://github.com/openssl/openssl .
> > 
> > Their fix changes the semantics of DES_crypt() and DES_fcrypt().
> > They may fail and return NULL now.  This was never the case before
> > so we may expect that programs do not check it.  With DES_fcrypt()
> > it is very likely that some uninitilaized content of the return
> > string is used.
> > 
> > So I have extended the workaround that was there already.  Read the
> > comment above the fix.  If the salt does not consist of two ascii
> > characters, replace it with "AA".  This gives a safe result in all
> > cases.
> > 
> > ok?
> > 
> > bluhm
> > 
> > Index: lib/libcrypto/des/fcrypt.c
> > ===
> > RCS file: /data/mirror/openbsd/cvs/src/lib/libcrypto/des/fcrypt.c,v
> > retrieving revision 1.12
> > diff -u -p -r1.12 fcrypt.c
> > --- lib/libcrypto/des/fcrypt.c  26 Dec 2016 21:30:10 -  1.12
> > +++ lib/libcrypto/des/fcrypt.c  5 Dec 2017 16:03:57 -
> > @@ -78,9 +78,15 @@ char *DES_fcrypt(const char *buf, const 
> >  * crypt to "*".  This was found when replacing the crypt in
> >  * our shared libraries.  People found that the disabled
> >  * accounts effectively had no passwd :-(. */
> > -   x=ret[0]=((salt[0] == '\0')?'A':salt[0]);
> > +   x = salt[0];
> > +   if (x == 0 || x >= sizeof(con_salt))
> > +   x = 'A';
> > +   ret[0] = x;
> > Eswap0=con_salt[x]<<2;
> > -   x=ret[1]=((salt[1] == '\0')?'A':salt[1]);
> > +   x = (salt[0] == '\0') ? 'A' : salt[1];
> > +   if (x == 0 || x >= sizeof(con_salt))
> > +   x = 'A';
> > +   ret[1] = x;
> > Eswap1=con_salt[x]<<6;
> >  /* EAY
> >  r=strlen(buf);
> > Index: regress/lib/libcrypto/des/destest.c
> > ===
> > RCS file: /data/mirror/openbsd/cvs/src/regress/lib/libcrypto/des/destest.c,v
> > retrieving revision 1.3
> > diff -u -p -r1.3 destest.c
> > --- regress/lib/libcrypto/des/destest.c 30 Oct 2015 15:58:40 -  
> > 1.3
> > +++ regress/lib/libcrypto/des/destest.c 5 Dec 2017 16:02:18 -
> > @@ -749,18 +749,38 @@ plain[8+4], plain[8+5], plain[8+6], plai
> > }
> > printf("\n");
> > printf("fast crypt test ");
> > -   str=crypt("testing","ef");
> > +   str=DES_crypt("testing","ef");
> > if (strcmp("efGnQx2725bI2",str) != 0)
> > {
> > printf("fast crypt error, %s should be efGnQx2725bI2\n",str);
> > err=1;
> > }
> > -   str=crypt("bca76;23","yA");
> > +   str=DES_crypt("bca76;23","yA");
> > if (strcmp("yA1Rp/1hZXIJk",str) != 0)
> > {
> > printf("fast crypt error, %s should be yA1Rp/1hZXIJk\n",str);
> > err=1;
> > }
> > +   str = DES_crypt("testing", "\202B");
> > +   if (strncmp("AB",str,2) != 0) {
> > +   printf("salt %s first non ascii not replaced with A\n", str);
> > +   err = 1;
> > +   }
> > +   str = DES_crypt("testing", "B\202");
> > +   if (strncmp("BA",str,2) != 0) {
> > +   printf("salt %s second non ascii not replaced with A\n", str);
> > +   err = 1;
> > +   }
> > +   str = DES_crypt("testing", "\0B");
> > +   if (strncmp("AA",str,2) != 0) {
> > +   printf("salt %s first NUL not replaced with AA\n", str);
> > +   err = 1;
> > +   }
> > +   str = DES_crypt("testing", "B");
> > +   if (strncmp("BA",str,2) != 0) {
> > +   printf("salt %s second NUL not replaced with A\n", str);
> > +   err = 1;
> > +   }
> > printf("\n");
> > return(err);
> > }
> 



Re: libressl: crash in DES_fcrypt

2017-12-13 Thread Alexander Bluhm
Hi,

I would like to commit this fix.  I tried to avoid the crash in
libcrypto with least possible impact for the DES_fcrypt() API.

ok?

bluhm

On Tue, Dec 05, 2017 at 05:20:49PM +0100, Alexander Bluhm wrote:
> On Fri, Oct 27, 2017 at 01:50:26AM +0200, Jan Engelhardt wrote:
> > #include 
> > int main(void) {
> > char salt[3] = {0xf8, 0xd0, 0x00};
> > char out[32];
> > DES_fcrypt("foo", salt, out);
> > }
> 
> This program produces a Segmentation fault in OpenBSD current.
> 
> > openssl 1.1.x has it fixed (but 1.0.2l does not!) - their commit
> > seems to be 6493e4801e9edbe1ad1e256d4ce9cd55c8aa2242 in
> > https://github.com/openssl/openssl .
> 
> Their fix changes the semantics of DES_crypt() and DES_fcrypt().
> They may fail and return NULL now.  This was never the case before
> so we may expect that programs do not check it.  With DES_fcrypt()
> it is very likely that some uninitilaized content of the return
> string is used.
> 
> So I have extended the workaround that was there already.  Read the
> comment above the fix.  If the salt does not consist of two ascii
> characters, replace it with "AA".  This gives a safe result in all
> cases.
> 
> ok?
> 
> bluhm
> 
> Index: lib/libcrypto/des/fcrypt.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/lib/libcrypto/des/fcrypt.c,v
> retrieving revision 1.12
> diff -u -p -r1.12 fcrypt.c
> --- lib/libcrypto/des/fcrypt.c26 Dec 2016 21:30:10 -  1.12
> +++ lib/libcrypto/des/fcrypt.c5 Dec 2017 16:03:57 -
> @@ -78,9 +78,15 @@ char *DES_fcrypt(const char *buf, const 
>* crypt to "*".  This was found when replacing the crypt in
>* our shared libraries.  People found that the disabled
>* accounts effectively had no passwd :-(. */
> - x=ret[0]=((salt[0] == '\0')?'A':salt[0]);
> + x = salt[0];
> + if (x == 0 || x >= sizeof(con_salt))
> + x = 'A';
> + ret[0] = x;
>   Eswap0=con_salt[x]<<2;
> - x=ret[1]=((salt[1] == '\0')?'A':salt[1]);
> + x = (salt[0] == '\0') ? 'A' : salt[1];
> + if (x == 0 || x >= sizeof(con_salt))
> + x = 'A';
> + ret[1] = x;
>   Eswap1=con_salt[x]<<6;
>  /* EAY
>  r=strlen(buf);
> Index: regress/lib/libcrypto/des/destest.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/regress/lib/libcrypto/des/destest.c,v
> retrieving revision 1.3
> diff -u -p -r1.3 destest.c
> --- regress/lib/libcrypto/des/destest.c   30 Oct 2015 15:58:40 -  
> 1.3
> +++ regress/lib/libcrypto/des/destest.c   5 Dec 2017 16:02:18 -
> @@ -749,18 +749,38 @@ plain[8+4], plain[8+5], plain[8+6], plai
>   }
>   printf("\n");
>   printf("fast crypt test ");
> - str=crypt("testing","ef");
> + str=DES_crypt("testing","ef");
>   if (strcmp("efGnQx2725bI2",str) != 0)
>   {
>   printf("fast crypt error, %s should be efGnQx2725bI2\n",str);
>   err=1;
>   }
> - str=crypt("bca76;23","yA");
> + str=DES_crypt("bca76;23","yA");
>   if (strcmp("yA1Rp/1hZXIJk",str) != 0)
>   {
>   printf("fast crypt error, %s should be yA1Rp/1hZXIJk\n",str);
>   err=1;
>   }
> + str = DES_crypt("testing", "\202B");
> + if (strncmp("AB",str,2) != 0) {
> + printf("salt %s first non ascii not replaced with A\n", str);
> + err = 1;
> + }
> + str = DES_crypt("testing", "B\202");
> + if (strncmp("BA",str,2) != 0) {
> + printf("salt %s second non ascii not replaced with A\n", str);
> + err = 1;
> + }
> + str = DES_crypt("testing", "\0B");
> + if (strncmp("AA",str,2) != 0) {
> + printf("salt %s first NUL not replaced with AA\n", str);
> + err = 1;
> + }
> + str = DES_crypt("testing", "B");
> + if (strncmp("BA",str,2) != 0) {
> + printf("salt %s second NUL not replaced with A\n", str);
> + err = 1;
> + }
>   printf("\n");
>   return(err);
>   }



Re: OpenBSD OpenCL 2.x support perspective

2017-12-13 Thread Paul Irofti
There is no OpenCL support in OpenBSD.



Re: disable hw vlan tagging support in ix(4)

2017-12-13 Thread Kapetanakis Giannis
On 13/12/17 10:29, Martin Pieuchot wrote:
> On 13/12/17(Wed) 09:54, David Gwynne wrote:
>> im still looking at vlan performance problems, as discussed by mpi@
>> at http://www.grenadille.net/post/2017/02/13/What-happened-to-my-vlan.
>>
>> recently it occurred to me that we're making an implicit assumption
>> that having the chip handle the injection of vlan tags has zero
>> cost, and that all the loss in performance is purely a software
>> problem. to test this assumption i knocked up the diff below to
>> disable hw vlan tagging in ix(4), which was used in the tests mpi
>> and hrvoje did.
>>
>> hrvoje tested this diff for me and noted a 10% improvement in pps
>> when forwarding between vlan interfaces on ix(4). to quote hrvoje:
>>
>> without diff
>> send - receive
>> vlan - vlan = 830Kpps
>>
>> with diff
>> send - receive
>> vlan - vlan = 995Kpps
>>
>> my conclusion is that assumption that nics are fast at offloads is
>> wrong. therefore id like to put this in. unfortunately 10% doesnt
>> account for the entire loss in forwarding over vlan, but it does
>> help a bit.
>>
>> would anyone else like to test? or ok it?
> 
> I don't have hardware to test but I'd like to add that in bridge(4)
> scenario hardware tagging also decrease performance.
> 
> From my point of view removing this per-chip option makes the stack
> simpler, so I'm all for it.  However I'd like to hear more test reports
> on different ix(4) models.

Sorry to jump in but it looks to me that apart from different ix(4) models
this should also be checked with different CPUs as well.

I mean that with a recent fast CPU like E5-26xx it seems you get an improvement.
This might not be the case with an older CPU. 
Also what happens with L2 performance (not only L3 routing).

best,

G



Re: net/rtsock.c: size to free(9)

2017-12-13 Thread Martin Pieuchot
On 11/12/17(Mon) 15:46, kshe wrote:
> On Sun, 10 Dec 2017 11:25:50 +, Martin Pieuchot wrote:
> > On 08/12/17(Fri) 12:58, kshe wrote:
> > > I noticed one instance where the size given to free(9) can easily be
> > > determined.
> >
> > What about the other free(9)s in the same function?
> 
> Somehow I did not immediately realize that rtm_report() would simply
> store the allocated length in rtm->rtm_msglen.  Now that I do, here is
> an updated diff dealing with the remaining calls (along with some more
> unrelated whitespace fixes).

Thanks.  I'd suggest you for the next time to not to mix withespace or
style changes with a functional change.

That said it'd be great if you could look at other free(9) calls missing
the size argument.

Cheers,
Martin



Re: disable hw vlan tagging support in ix(4)

2017-12-13 Thread Martin Pieuchot
On 13/12/17(Wed) 09:54, David Gwynne wrote:
> im still looking at vlan performance problems, as discussed by mpi@
> at http://www.grenadille.net/post/2017/02/13/What-happened-to-my-vlan.
> 
> recently it occurred to me that we're making an implicit assumption
> that having the chip handle the injection of vlan tags has zero
> cost, and that all the loss in performance is purely a software
> problem. to test this assumption i knocked up the diff below to
> disable hw vlan tagging in ix(4), which was used in the tests mpi
> and hrvoje did.
> 
> hrvoje tested this diff for me and noted a 10% improvement in pps
> when forwarding between vlan interfaces on ix(4). to quote hrvoje:
> 
> without diff
> send - receive
> vlan - vlan = 830Kpps
> 
> with diff
> send - receive
> vlan - vlan = 995Kpps
> 
> my conclusion is that assumption that nics are fast at offloads is
> wrong. therefore id like to put this in. unfortunately 10% doesnt
> account for the entire loss in forwarding over vlan, but it does
> help a bit.
> 
> would anyone else like to test? or ok it?

I don't have hardware to test but I'd like to add that in bridge(4)
scenario hardware tagging also decrease performance.

>From my point of view removing this per-chip option makes the stack
simpler, so I'm all for it.  However I'd like to hear more test reports
on different ix(4) models.

> Index: if_ix.c
> ===
> RCS file: /cvs/src/sys/dev/pci/if_ix.c,v
> retrieving revision 1.152
> diff -u -p -r1.152 if_ix.c
> --- if_ix.c   22 Jun 2017 02:44:37 -  1.152
> +++ if_ix.c   12 Dec 2017 23:39:41 -
> @@ -154,8 +154,6 @@ void  ixgbe_set_ivar(struct ix_softc *, u
>  void ixgbe_configure_ivars(struct ix_softc *);
>  uint8_t  *ixgbe_mc_array_itr(struct ixgbe_hw *, uint8_t **, uint32_t *);
>  
> -void ixgbe_setup_vlan_hw_support(struct ix_softc *);
> -
>  /* Support for pluggable optic modules */
>  void ixgbe_setup_optics(struct ix_softc *);
>  void ixgbe_handle_mod(struct ix_softc *);
> @@ -702,9 +700,6 @@ ixgbe_init(void *arg)
>   IXGBE_WRITE_REG(&sc->hw, IXGBE_RDT(i), rxr->last_desc_filled);
>   }
>  
> - /* Set up VLAN support and filter */
> - ixgbe_setup_vlan_hw_support(sc);
> -
>   /* Enable Receive engine */
>   rxctrl = IXGBE_READ_REG(&sc->hw, IXGBE_RXCTRL);
>   if (sc->hw.mac.type == ixgbe_mac_82598EB)
> @@ -1621,10 +1616,6 @@ ixgbe_setup_interface(struct ix_softc *s
>  
>   ifp->if_capabilities = IFCAP_VLAN_MTU;
>  
> -#if NVLAN > 0
> - ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING;
> -#endif
> -
>  #ifdef IX_CSUM_OFFLOAD
>   ifp->if_capabilities |= IFCAP_CSUM_TCPv4 | IFCAP_CSUM_UDPv4;
>  #endif
> @@ -2922,12 +2913,6 @@ ixgbe_rxeof(struct ix_queue *que)
>   /* first desc of a non-ps chain */
>   sendmp = mp;
>   sendmp->m_pkthdr.len = mp->m_len;
> -#if NVLAN > 0
> - if (staterr & IXGBE_RXD_STAT_VP) {
> - sendmp->m_pkthdr.ether_vtag = vtag;
> - sendmp->m_flags |= M_VLANTAG;
> - }
> -#endif
>   }
>  
>   /* Pass the head pointer on */
> @@ -2989,44 +2974,6 @@ ixgbe_rx_checksum(uint32_t staterr, stru
>   if (!(errors & IXGBE_RXD_ERR_TCPE))
>   mp->m_pkthdr.csum_flags |=
>   M_TCP_CSUM_IN_OK | M_UDP_CSUM_IN_OK;
> - }
> -}
> -
> -void
> -ixgbe_setup_vlan_hw_support(struct ix_softc *sc)
> -{
> - uint32_tctrl;
> - int i;
> -
> - /*
> -  * A soft reset zero's out the VFTA, so
> -  * we need to repopulate it now.
> -  */
> - for (i = 0; i < IXGBE_VFTA_SIZE; i++) {
> - if (sc->shadow_vfta[i] != 0)
> - IXGBE_WRITE_REG(&sc->hw, IXGBE_VFTA(i),
> - sc->shadow_vfta[i]);
> - }
> -
> - ctrl = IXGBE_READ_REG(&sc->hw, IXGBE_VLNCTRL);
> -#if 0
> - /* Enable the Filter Table if enabled */
> - if (ifp->if_capenable & IFCAP_VLAN_HWFILTER) {
> - ctrl &= ~IXGBE_VLNCTRL_CFIEN;
> - ctrl |= IXGBE_VLNCTRL_VFE;
> - }
> -#endif
> - if (sc->hw.mac.type == ixgbe_mac_82598EB)
> - ctrl |= IXGBE_VLNCTRL_VME;
> - IXGBE_WRITE_REG(&sc->hw, IXGBE_VLNCTRL, ctrl);
> -
> - /* On 82599 the VLAN enable is per/queue in RXDCTL */
> - if (sc->hw.mac.type != ixgbe_mac_82598EB) {
> - for (i = 0; i < sc->num_queues; i++) {
> - ctrl = IXGBE_READ_REG(&sc->hw, IXGBE_RXDCTL(i));
> - ctrl |= IXGBE_RXDCTL_VME;
> - IXGBE_WRITE_REG(&sc->hw, IXGBE_RXDCTL(i), ctrl);
> - }
>   }
>  }
>  
> 



Re: relayd and PUT

2017-12-13 Thread Rivo Nurges
Hi!

Thanks for enlightening me, I’ll try to fix the real problem.

Rivo

> On 13 Dec 2017, at 08:42, Claudio Jeker  wrote:
> 
>> On Wed, Dec 13, 2017 at 12:25:39AM +, Rivo Nurges wrote:
>> Hi!
>> 
>> If you http PUT a "big" file through relayd, server<>relay read side
>> will eventually get a EVBUFFER_TIMEOUT. Nothing comes back from the
>> server until the PUT is done. I disabled server read timeouts for PUT
>> requests.
>> 
>> While trying to fix the issue I managed to trigger another problem. For
>> HTTP relays we open relay<>server connection only after the first
>> request is completely read from the client. If http PUT is the the
>> first request and is big enough we will run out of memory and
>> eventually out of swap. To avoid the issue I will open relay<>server
>> connection earlyer and let relayd to start sending the stuff to the
>> server.
>> 
>> And another one I don't know how to fix. If relayd fills all memory and
>> swap with buffers kernel enters infinite loop. relayd is in flt_noram
>> state and pagedaemon constantly tries to free something without any
>> luck. userland scheduling halts. bgp looses its peers but carp still
>> happily sends its hellos...
>> 
> 
> I have seen something similar and came to the conclusion that the timeout
> handling of relayd is not correct. As long as traffic is flowing the
> timeout should be reset (at least that is what every other implementation
> does). This is not really happening in relayd. I have seen this on GET
> requests that are huge (timeout hits in the middle of the transimit and
> kills the session).
> 
> Because of this I think the diff is a workaround and does not solve the
> real underlying problem.
> 
>> Rivo
>> 
>> Index: usr.sbin/relayd/relay.c
>> ===
>> RCS file: /cvs/src/usr.sbin/relayd/relay.c,v
>> retrieving revision 1.236
>> diff -u -p -r1.236 relay.c
>> --- usr.sbin/relayd/relay.c28 Nov 2017 01:51:47 -1.
>> 236
>> +++ usr.sbin/relayd/relay.c13 Dec 2017 00:05:33 -
>> @@ -723,7 +723,8 @@ relay_connected(int fd, short sig, void 
>>relay_tls_connected(out);
>> 
>>bufferevent_settimeout(bev,
>> -rlay->rl_conf.timeout.tv_sec, rlay-
>>> rl_conf.timeout.tv_sec);
>> +con->se_out.writeonly ? 0 : rlay->rl_conf.timeout.tv_sec,
>> +rlay->rl_conf.timeout.tv_sec);
>>bufferevent_setwatermark(bev, EV_WRITE,
>>RELAY_MIN_PREFETCHED * proto->tcpbufsiz, 0);
>>bufferevent_enable(bev, EV_READ|EV_WRITE);
>> Index: usr.sbin/relayd/relay_http.c
>> ===
>> RCS file: /cvs/src/usr.sbin/relayd/relay_http.c,v
>> retrieving revision 1.70
>> diff -u -p -r1.70 relay_http.c
>> --- usr.sbin/relayd/relay_http.c27 Nov 2017 16:25:50 -
>> 1.70
>> +++ usr.sbin/relayd/relay_http.c13 Dec 2017 00:05:33 -
>> @@ -439,6 +439,10 @@ relay_read_http(struct bufferevent *bev,
>>case HTTP_METHOD_OPTIONS:
>>case HTTP_METHOD_POST:
>>case HTTP_METHOD_PUT:
>> +con->se_out.writeonly = 1;
>> +if(cre->dst->state == STATE_CONNECTED)
>> +bufferevent_settimeout(bev,
>> +0, rlay->rl_conf.timeout.tv_sec); 
>>case HTTP_METHOD_RESPONSE:
>>/* WebDAV methods */
>>case HTTP_METHOD_PROPFIND:
>> @@ -569,6 +573,9 @@ relay_read_httpcontent(struct buffereven
>>goto fail;
>>cre->toread -= size;
>>}
>> +if (cre->dst->writeonly && cre->dst->state !=
>> STATE_CONNECTED)
>> +if (relay_connect(con) == -1)
>> +goto fail;
>>DPRINTF("%s: done, size %lu, to read %lld", __func__,
>>size, cre->toread);
>>}
>> Index: usr.sbin/relayd/relayd.h
>> ===
>> RCS file: /cvs/src/usr.sbin/relayd/relayd.h,v
>> retrieving revision 1.248
>> diff -u -p -r1.248 relayd.h
>> --- usr.sbin/relayd/relayd.h28 Nov 2017 18:25:53 -1
>> .248
>> +++ usr.sbin/relayd/relayd.h13 Dec 2017 00:05:33 -
>> @@ -218,6 +218,7 @@ struct ctl_relay_event {
>>int line;
>>int done;
>>int timedout;
>> +int writeonly;
>>enum relay_state state;
>>enum direction dir;
>> 
> 
> -- 
> :wq Claudio
>