better implementation of malloc option C: canaries

2016-10-02 Thread Otto Moerbeek
Hi,

I have been working on a diff to do canaries in a better way.

Canaries (enabled by the C malloc option) are values stored after the
requested size that are checked for being overwritten on calling
free(3). At the moment we only do this for chunks (sub-page sized
allocations). 

To be able to do that we need to store the requested size somewehere.
The current code does that in the chunks itself by increassing the
requested allocation size. It uses a size_t field and an extra pointer
sized field per chunk. It has the drawback that the canary itself is
not stored adjecent to the requested size, but at the end of the chunk.

Mu diff changes this to NOT allocate a potentially larger chunk, but
store the length (as a short) in the chunk metadata struct. The
remainder of the power-of-2 sized chunk is filled with a fixed byte
value. There is room to use other methods involving secrets here. But
firts let's get this right.

Only tested so far on sparc64. This is where you come in! 

Please test to make sure this doesn't break things. Run tests both
with C and without and use other flags combinations.

-Otto

Index: malloc.c
===
RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v
retrieving revision 1.197
diff -u -p -r1.197 malloc.c
--- malloc.c21 Sep 2016 04:38:56 -  1.197
+++ malloc.c3 Oct 2016 05:38:04 -
@@ -178,14 +178,13 @@ struct malloc_readonly {
int malloc_move;/* move allocations to end of page? */
int malloc_realloc; /* always realloc? */
int malloc_xmalloc; /* xmalloc behaviour? */
-   size_t  malloc_canaries;/* use canaries after chunks? */
+   int chunk_canaries; /* use canaries after chunks? */
size_t  malloc_guard;   /* use guard pages after allocations? */
u_int   malloc_cache;   /* free pages we cache */
 #ifdef MALLOC_STATS
int malloc_stats;   /* dump statistics at end */
 #endif
u_int32_t malloc_canary;/* Matched against ones in malloc_pool 
*/
-   uintptr_t malloc_chunk_canary;
 };
 
 /* This object is mapped PROT_READ after initialisation to prevent tampering */
@@ -512,10 +511,10 @@ omalloc_parseopt(char opt)
/* ignored */
break;
case 'c':
-   mopts.malloc_canaries = 0;
+   mopts.chunk_canaries = 0;
break;
case 'C':
-   mopts.malloc_canaries = sizeof(void *);
+   mopts.chunk_canaries = 1;
break;
 #ifdef MALLOC_STATS
case 'd':
@@ -653,9 +652,6 @@ omalloc_init(void)
 
while ((mopts.malloc_canary = arc4random()) == 0)
;
-
-   arc4random_buf(&mopts.malloc_chunk_canary,
-   sizeof(mopts.malloc_chunk_canary));
 }
 
 /*
@@ -763,6 +759,8 @@ alloc_chunk_info(struct dir_info *d, int
 
size = howmany(count, MALLOC_BITS);
size = sizeof(struct chunk_info) + (size - 1) * sizeof(u_short);
+   if (mopts.chunk_canaries)
+   size += count * sizeof(u_short);
size = ALIGN(size);
 
if (LIST_EMPTY(&d->chunk_info_list[bits])) {
@@ -946,16 +944,19 @@ omalloc_make_chunks(struct dir_info *d, 
  * Allocate a chunk
  */
 static void *
-malloc_bytes(struct dir_info *d, size_t size, void *f)
+malloc_bytes(struct dir_info *d, size_t argsize, void *f)
 {
int i, j, listnum;
-   size_t  k;
+   size_t  k, size;
u_short u, *lp;
struct chunk_info *bp;
 
if (mopts.malloc_canary != (d->canary1 ^ (u_int32_t)(uintptr_t)d) ||
d->canary1 != ~d->canary2)
wrterror(d, "internal struct corrupt", NULL);
+
+   size = argsize;
+
/* Don't bother with anything less than this */
/* unless we have a malloc(0) requests */
if (size != 0 && size < MALLOC_MINSIZE)
@@ -1021,22 +1022,24 @@ malloc_bytes(struct dir_info *d, size_t 
 
/* Adjust to the real offset of that chunk */
k += (lp - bp->bits) * MALLOC_BITS;
+   
+   if (mopts.chunk_canaries)
+   bp->bits[howmany(bp->total, MALLOC_BITS) + k] = argsize;
+
k <<= bp->shift;
 
-   if (mopts.malloc_canaries && bp->size > 0) {
-   char *end = (char *)bp->page + k + bp->size;
-   uintptr_t *canary = (uintptr_t *)(end - mopts.malloc_canaries);
-   *canary = mopts.malloc_chunk_canary ^ hash(canary);
+   if (bp->size > 0) {
+   if (mopts.malloc_junk == 2)
+   memset((char *)bp->page + k, SOME_JUNK, bp->size);
+   else if (mopts.chunk_canaries)
+   memset((char *)bp->page + k + argsize, SOME_JUNK,
+   bp->size - argsize);
}
-
-   if (mopts.malloc_junk == 2 && bp->size > 0)
-   memset((char *)bp->page + k, SOME_JUNK,
-

Re: Explicitly cast the return variable in tls_load_file()

2016-10-02 Thread kinichiro inoguchi
Thanks, that is apparently better than I suggested and reasonable.
And I confirmed it can also avoid the issue.
I appreciate if this is applied.

And, yes I believe compilation error is bug of compiler, not source code.
I posted this compilation error to Intel C++ compiler forum on Sunday.
https://software.intel.com/en-us/forums/intel-c-compiler
My post is not showed up yet since it is not approved on weekend, though, I
would like to confirm the thoughts of compiler side.


Re: Explicitly cast the return variable in tls_load_file()

2016-10-02 Thread Ted Unangst
Brent Cook wrote:
> ​Why not just make the variable type match the return type to begin with?

sure, that's reasonable.

> 
> ​--- a/src/lib/libtls/tls_util.c
> +++ b/src/lib/libtls/tls_util.c
> @@ -105,7 +105,8 @@ tls_load_file(const char *name, size_t *len, char
> *password)
> FILE *fp;
> EVP_PKEY *key = NULL;
> BIO *bio = NULL;
> -   char *data, *buf = NULL;
> +   char *data;
> +   uint8_t *buf = NULL;
> struct stat st;
> size_t size;
> int fd = -1;



Re: ntpd(8): use safer dup3() instead of dup2()

2016-10-02 Thread Rafael Zalamena
On Sun, Oct 02, 2016 at 02:30:11PM -0700, Philip Guenther wrote:
> On Sun, 2 Oct 2016, Rafael Zalamena wrote:
> > This diff is an improvement and an attempt to fix the bug where the 
> > ntpd(8) not always stays running.
> > 
> > During the review of syslogd fork+exec diff I noticed the use of dup3() 
> > and went to read its man page: dup2() doesn't always remove the CLOEXEC 
> > flag from the descriptor, so using dup3() is a better idea because it 
> > does check the flag and if the oldd == newd then it retuns an useful 
> > error.
> > 
> > So if dup3() returns us an error it means oldd == newd and we should 
> > remove the CLOEXEC flag ourself.
> 
> IMO, it's better to just check for oldd==newd ourselves instead of making 
> a call that we can tell will fail and then inferring the condition from 
> the errno.
> 

Thank you for the input, it does indeed look better, but I changed the
fatal() messages a little.

ok?


Index: util.c
===
RCS file: /home/obsdcvs/src/usr.sbin/ntpd/util.c,v
retrieving revision 1.22
diff -u -p -r1.22 util.c
--- util.c  14 Sep 2016 13:20:16 -  1.22
+++ util.c  2 Oct 2016 21:39:15 -
@@ -16,6 +16,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -184,7 +185,11 @@ start_child(char *pname, int cfd, int ar
break;
case 0:
/* Prepare the parent socket and execute. */
-   dup2(cfd, PARENT_SOCK_FILENO);
+   if (cfd != PARENT_SOCK_FILENO) {
+   if (dup2(cfd, PARENT_SOCK_FILENO) == -1)
+   fatal("%s: dup2", __func__);
+   } else if (fcntl(cfd, F_SETFD, 0) == -1)
+   fatal("%s: fcntl", __func__);
 
execvp(argv[0], nargv);
fatal("%s: execvp", __func__);



Re: ntpd(8): use safer dup3() instead of dup2()

2016-10-02 Thread Philip Guenther
On Sun, 2 Oct 2016, Rafael Zalamena wrote:
> This diff is an improvement and an attempt to fix the bug where the 
> ntpd(8) not always stays running.
> 
> During the review of syslogd fork+exec diff I noticed the use of dup3() 
> and went to read its man page: dup2() doesn't always remove the CLOEXEC 
> flag from the descriptor, so using dup3() is a better idea because it 
> does check the flag and if the oldd == newd then it retuns an useful 
> error.
> 
> So if dup3() returns us an error it means oldd == newd and we should 
> remove the CLOEXEC flag ourself.

IMO, it's better to just check for oldd==newd ourselves instead of making 
a call that we can tell will fail and then inferring the condition from 
the errno.

I.e., something more like:

--- util.c  14 Sep 2016 13:20:16 -  1.22
+++ util.c  2 Oct 2016 21:27:33 -
@@ -16,6 +16,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -184,7 +185,11 @@ start_child(char *pname, int cfd, int ar
break;
case 0:
/* Prepare the parent socket and execute. */
-   dup2(cfd, PARENT_SOCK_FILENO);
+   if (cfd != PARENT_SOCK_FILENO) {
+   if (dup2(cfd, PARENT_SOCK_FILENO) == -1)
+   fatal("dup3");
+   } else if (fcntl(cfd, F_SETFD, 0) == -1)
+   fatal("fcntl");
 
execvp(argv[0], nargv);
fatal("%s: execvp", __func__);



Re: syslogd fork+exec

2016-10-02 Thread Alexander Bluhm
On Sat, Oct 01, 2016 at 07:41:13PM +0200, Rafael Zalamena wrote:
> This could be replaced with "closefrom(4);".

Updated diff:
- use closefrom(2)
- use execvp(3) to allow starting syslogd(8) without full path
- add a debug message to make testing easier

ok?

bluhm

Index: usr.sbin/syslogd/privsep.c
===
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/privsep.c,v
retrieving revision 1.61
diff -u -p -u -p -r1.61 privsep.c
--- usr.sbin/syslogd/privsep.c  28 Jun 2016 18:22:50 -  1.61
+++ usr.sbin/syslogd/privsep.c  2 Oct 2016 20:57:10 -
@@ -2,6 +2,7 @@
 
 /*
  * Copyright (c) 2003 Anil Madhavapeddy 
+ * Copyright (c) 2016 Alexander Bluhm 
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -71,9 +72,6 @@ enum cmd_types {
 
 static int priv_fd = -1;
 static volatile pid_t child_pid = -1;
-static char config_file[PATH_MAX];
-static struct stat cf_info;
-static int allow_getnameinfo = 0;
 static volatile sig_atomic_t cur_state = STATE_INIT;
 
 /* Queue for the allowed logfiles */
@@ -94,25 +92,12 @@ static void must_read(int, void *, size_
 static void must_write(int, void *, size_t);
 static int  may_read(int, void *, size_t);
 
-int
-priv_init(char *conf, int numeric, int lockfd, int nullfd, char *argv[])
+void
+priv_init(int lockfd, int nullfd, int argc, char *argv[])
 {
-   int i, fd, socks[2], cmd, addr_len, result, restart;
-   size_t path_len, protoname_len, hostname_len, servname_len;
-   char path[PATH_MAX], protoname[5];
-   char hostname[NI_MAXHOST], servname[NI_MAXSERV];
-   struct sockaddr_storage addr;
-   struct stat cf_stat;
+   int i, socks[2];
struct passwd *pw;
-   struct addrinfo hints, *res0;
-   struct sigaction sa;
-
-   memset(&sa, 0, sizeof(sa));
-   sigemptyset(&sa.sa_mask);
-   sa.sa_flags = SA_RESTART;
-   sa.sa_handler = SIG_DFL;
-   for (i = 1; i < _NSIG; i++)
-   sigaction(i, &sa, NULL);
+   char childnum[11], **privargv;
 
/* Create sockets */
if (socketpair(AF_LOCAL, SOCK_STREAM, PF_UNSPEC, socks) == -1)
@@ -141,12 +126,9 @@ priv_init(char *conf, int numeric, int l
err(1, "setresuid() failed");
close(socks[0]);
priv_fd = socks[1];
-   return 0;
+   return;
}
-
-   if (pledge("stdio rpath wpath cpath dns getpw sendfd id proc exec",
-   NULL) == -1)
-   err(1, "pledge priv");
+   close(socks[1]);
 
if (!Debug) {
close(lockfd);
@@ -157,20 +139,6 @@ priv_init(char *conf, int numeric, int l
if (nullfd > 2)
close(nullfd);
 
-   /* Father */
-   /* Pass TERM/HUP/INT/QUIT through to child, and accept CHLD */
-   sa.sa_handler = sig_pass_to_chld;
-   sigaction(SIGTERM, &sa, NULL);
-   sigaction(SIGHUP, &sa, NULL);
-   sigaction(SIGINT, &sa, NULL);
-   sigaction(SIGQUIT, &sa, NULL);
-   sa.sa_handler = sig_got_chld;
-   sa.sa_flags |= SA_NOCLDSTOP;
-   sigaction(SIGCHLD, &sa, NULL);
-
-   setproctitle("[priv]");
-   close(socks[1]);
-
/* Close descriptors that only the unpriv child needs */
if (fd_ctlconn != -1)
close(fd_ctlconn);
@@ -194,38 +162,87 @@ priv_init(char *conf, int numeric, int l
if (fd_unix[i] != -1)
close(fd_unix[i]);
 
-   /* Save the config file specified by the child process */
-   if (strlcpy(config_file, conf, sizeof config_file) >= 
sizeof(config_file))
-   errx(1, "config_file truncation");
+   if (dup3(socks[0], 3, 0) == -1)
+   err(1, "dup3 priv sock failed");
+   snprintf(childnum, sizeof(childnum), "%d", child_pid);
+   if ((privargv = reallocarray(NULL, argc + 3, sizeof(char *))) == NULL)
+   err(1, "alloc priv argv failed");
+   for (i = 0; i < argc; i++)
+   privargv[i] = argv[i];
+   privargv[i++] = "-P";
+   privargv[i++] = childnum;
+   privargv[i++] = NULL;
+   execvp(privargv[0], privargv);
+   err(1, "exec priv '%s' failed", privargv[0]);
+}
 
-   if (stat(config_file, &cf_info) < 0)
-   err(1, "stat config file failed");
+__dead void
+priv_exec(char *conf, int numeric, int child, int argc, char *argv[])
+{
+   int i, fd, sock, cmd, addr_len, result, restart;
+   size_t path_len, protoname_len, hostname_len, servname_len;
+   char path[PATH_MAX], protoname[5];
+   char hostname[NI_MAXHOST], servname[NI_MAXSERV];
+   struct sockaddr_storage addr;
+   struct stat cf_info, cf_stat;
+   struct addrinfo hints, *res0;
+   struct sigaction sa;
+
+   if (pledge("stdio rpath wpath cpath dns getpw sendfd id proc exec",
+   NULL) == -1)
+   err(1, "

ntpd(8): use safer dup3() instead of dup2()

2016-10-02 Thread Rafael Zalamena
This diff is an improvement and an attempt to fix the bug where the ntpd(8)
not always stays running.

During the review of syslogd fork+exec diff I noticed the use of dup3()
and went to read its man page: dup2() doesn't always remove the CLOEXEC
flag from the descriptor, so using dup3() is a better idea because it does
check the flag and if the oldd == newd then it retuns an useful error.

So if dup3() returns us an error it means oldd == newd and we should
remove the CLOEXEC flag ourself.

ok?


Index: util.c
===
RCS file: /home/obsdcvs/src/usr.sbin/ntpd/util.c,v
retrieving revision 1.22
diff -u -p -r1.22 util.c
--- util.c  14 Sep 2016 13:20:16 -  1.22
+++ util.c  2 Oct 2016 18:31:41 -
@@ -16,6 +16,8 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -184,7 +186,12 @@ start_child(char *pname, int cfd, int ar
break;
case 0:
/* Prepare the parent socket and execute. */
-   dup2(cfd, PARENT_SOCK_FILENO);
+   if (dup3(cfd, PARENT_SOCK_FILENO, 0) == -1) {
+   if (errno != EINVAL)
+   fatal("%s: dup3", __func__);
+   if (fcntl(cfd, F_SETFD, 0) == -1)
+   fatal("%s: fcntl", __func__);
+   }
 
execvp(argv[0], nargv);
fatal("%s: execvp", __func__);



bridge(4): use hook to notify interface detach

2016-10-02 Thread Rafael Zalamena
Just like the switch(4) diff, this one does the same thing for the
bridge(4).

This diff removes bridge(4) code from if.c and uses the detach hook to
be notified about interface removals.

ok?


Index: net/if.c
===
RCS file: /home/obsdcvs/src/sys/net/if.c,v
retrieving revision 1.451
diff -u -p -r1.451 if.c
--- net/if.c28 Sep 2016 08:31:42 -  1.451
+++ net/if.c2 Oct 2016 20:40:30 -
@@ -895,12 +895,6 @@ if_deactivate(struct ifnet *ifp)
 */
dohooks(ifp->if_detachhooks, HOOK_REMOVE | HOOK_FREE);
 
-#if NBRIDGE > 0
-   /* Remove the interface from any bridge it is part of.  */
-   if (ifp->if_bridgeport)
-   bridge_ifdetach(ifp);
-#endif
-
 #if NSWITCH > 0
if (ifp->if_switchport)
switch_port_detach(ifp);
Index: net/if_bridge.c
===
RCS file: /home/obsdcvs/src/sys/net/if_bridge.c,v
retrieving revision 1.285
diff -u -p -r1.285 if_bridge.c
--- net/if_bridge.c 29 Sep 2016 11:37:44 -  1.285
+++ net/if_bridge.c 2 Oct 2016 20:39:56 -
@@ -106,6 +106,7 @@
 
 void   bridgeattach(int);
 intbridge_ioctl(struct ifnet *, u_long, caddr_t);
+void   bridge_ifdetach(void *);
 intbridge_input(struct ifnet *, struct mbuf *, void *);
 void   bridge_process(struct ifnet *, struct mbuf *);
 void   bridgeintr_frame(struct bridge_softc *, struct ifnet *, struct mbuf *);
@@ -244,6 +245,7 @@ bridge_delete(struct bridge_softc *sc, s
 
p->ifp->if_bridgeport = NULL;
error = ifpromisc(p->ifp, 0);
+   hook_disestablish(p->ifp->if_detachhooks, p->bif_dhcookie);
 
if_ih_remove(p->ifp, bridge_input, NULL);
TAILQ_REMOVE(&sc->sc_iflist, p, next);
@@ -356,6 +358,8 @@ bridge_ioctl(struct ifnet *ifp, u_long c
SIMPLEQ_INIT(&p->bif_brlin);
SIMPLEQ_INIT(&p->bif_brlout);
ifs->if_bridgeport = (caddr_t)p;
+   p->bif_dhcookie = hook_establish(ifs->if_detachhooks, 0,
+   bridge_ifdetach, ifs);
if_ih_insert(p->ifp, bridge_input, NULL);
TAILQ_INSERT_TAIL(&sc->sc_iflist, p, next);
break;
@@ -567,8 +571,9 @@ bridge_ioctl(struct ifnet *ifp, u_long c
 
 /* Detach an interface from a bridge.  */
 void
-bridge_ifdetach(struct ifnet *ifp)
+bridge_ifdetach(void *arg)
 {
+   struct ifnet *ifp = (struct ifnet *)arg;
struct bridge_softc *sc;
struct bridge_iflist *bif;
 
Index: net/if_bridge.h
===
RCS file: /home/obsdcvs/src/sys/net/if_bridge.h,v
retrieving revision 1.52
diff -u -p -r1.52 if_bridge.h
--- net/if_bridge.h 29 Sep 2016 11:37:44 -  1.52
+++ net/if_bridge.h 2 Oct 2016 20:35:26 -
@@ -398,6 +398,7 @@ struct bridge_iflist {
struct brl_head bif_brlout; /* output rules */
struct  ifnet *ifp; /* member interface */
u_int32_t   bif_flags;  /* member flags */
+   void*bif_dhcookie;
 };
 #define bif_state  bif_stp->bp_state
 
@@ -450,7 +451,6 @@ struct bridge_softc {
 extern const u_int8_t bstp_etheraddr[];
 struct llc;
 
-void   bridge_ifdetach(struct ifnet *);
 intbridge_output(struct ifnet *, struct mbuf *, struct sockaddr *,
 struct rtentry *);
 void   bridge_update(struct ifnet *, struct ether_addr *, int);



switch(4): use hook to notify interface detach

2016-10-02 Thread Rafael Zalamena
mpi@ suggested that it would be possible to use if_detachhooks to handle
the interface teardown instead of adding code to if.c, so this diff does
exactly that.

Not only we get to remove switch(4) code from if.c, we also get less lines
of code by removing some duplicated teardown procedure in
switch_clone_destroy().

ok?


Index: net/if_switch.c
===
RCS file: /home/obsdcvs/src/sys/net/if_switch.c,v
retrieving revision 1.7
diff -u -p -r1.7 if_switch.c
--- net/if_switch.c 29 Sep 2016 11:37:44 -  1.7
+++ net/if_switch.c 2 Oct 2016 20:03:33 -
@@ -74,6 +74,7 @@ intswitch_port_set_local(struct switch
 int switch_port_unset_local(struct switch_softc *, struct switch_port *);
 int switch_ioctl(struct ifnet *, unsigned long, caddr_t);
 int switch_port_add(struct switch_softc *, struct ifbreq *);
+voidswitch_port_detach(void *);
 int switch_port_del(struct switch_softc *, struct ifbreq *);
 int switch_port_list(struct switch_softc *, struct ifbifconf *);
 int switch_output(struct ifnet *, struct mbuf *, struct sockaddr *,
@@ -215,16 +216,9 @@ switch_clone_destroy(struct ifnet *ifp)
struct ifnet*ifs;
 
TAILQ_FOREACH_SAFE(swpo, &sc->sc_swpo_list, swpo_list_next, tp) {
-   if ((ifs = if_get(swpo->swpo_ifindex)) != NULL) {
-   if (swpo->swpo_flags & IFBIF_LOCAL)
-   switch_port_unset_local(sc, swpo);
-   ifs->if_switchport = NULL;
-   ifpromisc(ifs, 0);
-   if_ih_remove(ifs, switch_input, NULL);
-   if_put(ifs);
-   TAILQ_REMOVE(&sc->sc_swpo_list, swpo, swpo_list_next);
-   free(swpo, M_DEVBUF, sizeof(*swpo));
-   } else
+   if ((ifs = if_get(swpo->swpo_ifindex)) != NULL)
+   switch_port_detach(ifs);
+   else
log(LOG_ERR, "failed to cleanup on ifindex(%d)\n",
swpo->swpo_ifindex);
}
@@ -576,6 +570,8 @@ switch_port_add(struct switch_softc *sc,
ifs->if_switchport = (caddr_t)swpo;
if_ih_insert(ifs, switch_input, NULL);
swpo->swpo_port_no = swofp_assign_portno(sc, ifs->if_index);
+   swpo->swpo_dhcookie = hook_establish(ifs->if_detachhooks, 0,
+   switch_port_detach, ifs);
 
nanouptime(&swpo->swpo_appended);
 
@@ -630,8 +626,9 @@ done:
 }
 
 void
-switch_port_detach(struct ifnet *ifp)
+switch_port_detach(void *arg)
 {
+   struct ifnet*ifp = (struct ifnet *)arg;
struct switch_softc *sc = ifp->if_softc;
struct switch_port  *swpo;
 
@@ -640,6 +637,7 @@ switch_port_detach(struct ifnet *ifp)
switch_port_unset_local(sc, swpo);
 
ifp->if_switchport = NULL;
+   hook_disestablish(ifp->if_detachhooks, swpo->swpo_dhcookie);
ifpromisc(ifp, 0);
if_ih_remove(ifp, switch_input, NULL);
TAILQ_REMOVE(&sc->sc_swpo_list, swpo, swpo_list_next);
Index: net/if_switch.h
===
RCS file: /home/obsdcvs/src/sys/net/if_switch.h,v
retrieving revision 1.3
diff -u -p -r1.3 if_switch.h
--- net/if_switch.h 28 Sep 2016 08:31:42 -  1.3
+++ net/if_switch.h 2 Oct 2016 19:47:44 -
@@ -174,6 +174,7 @@ struct switch_port {
struct timespec  swpo_appended;
struct switch_softc *swpo_switch;
uint32_t swpo_flags;
+   void*swpo_dhcookie;
void(*swop_bk_start)(struct ifnet *);
 };
 
@@ -215,7 +216,6 @@ void switch_port_egress(struct switch_s
 int switch_swfcl_dup(struct switch_flow_classify *,
struct switch_flow_classify *);
 voidswitch_swfcl_free(struct switch_flow_classify *);
-voidswitch_port_detach(struct ifnet *);
 
 /* switchctl.c */
 voidswitch_dev_destroy(struct switch_softc *);
Index: net/if.c
===
RCS file: /home/obsdcvs/src/sys/net/if.c,v
retrieving revision 1.451
diff -u -p -r1.451 if.c
--- net/if.c28 Sep 2016 08:31:42 -  1.451
+++ net/if.c2 Oct 2016 19:51:40 -
@@ -130,10 +130,6 @@
 #include 
 #endif
 
-#if NSWITCH > 0
-#include 
-#endif
-
 void   if_attachsetup(struct ifnet *);
 void   if_attachdomain(struct ifnet *);
 void   if_attach_common(struct ifnet *);
@@ -899,11 +895,6 @@ if_deactivate(struct ifnet *ifp)
/* Remove the interface from any bridge it is part of.  */
if (ifp->if_bridgeport)
bridge_ifdetach(ifp);
-#endif
-
-#if NSWITCH > 0
-   if (ifp->if_switchport)
-   switch_port_detach(ifp);
 #endif
 
 #if NCARP > 0



Re: stricter sys_mount() flag handling

2016-10-02 Thread Alexander Bluhm
On Sat, Oct 01, 2016 at 06:01:34PM +0200, Martin Natano wrote:
> After committing the new MNT_NOPERM flag I got some complaints that my
> code doesn't work by people that recompiled mount_ffs, but didn't reboot
> to the new kernel. I don't blame them; in that situation sys_mount()
> silently ignores the unknown flag. IMHO we should check the flags more
> strictly. Ok?

I think we once had a simmilar problem, when someone tried to unmount
with MNT_DOOMED.  So I like to check all flags at the beginning of
the system call.

But I think you should remove these from the mask:

/*
 * Flags set by internal operations.
 */
#define MNT_LOCAL   0x1000  /* filesystem is stored locally */
#define MNT_QUOTA   0x2000  /* quotas are enabled on filesystem */
#define MNT_ROOTFS  0x4000  /* identifies the root filesystem */

And I want this check also for sys_unmount().

bluhm

> Index: sys/mount.h
> ===
> RCS file: /cvs/src/sys/sys/mount.h,v
> retrieving revision 1.127
> diff -u -p -r1.127 mount.h
> --- sys/mount.h   10 Sep 2016 16:53:30 -  1.127
> +++ sys/mount.h   1 Oct 2016 15:36:11 -
> @@ -414,6 +414,11 @@ struct mount {
>  #define MNT_DOOMED   0x0800  /* device behind filesystem is gone */
>  
>  /*
> + * All mount flags.
> + */
> +#define  MNT_FLAGMASK0x0e0f
> +
> +/*
>   * Flags for various system call interfaces.
>   *
>   * waitfor flags to vfs_sync() and getfsstat()
> Index: kern/vfs_syscalls.c
> ===
> RCS file: /cvs/src/sys/kern/vfs_syscalls.c,v
> retrieving revision 1.265
> diff -u -p -r1.265 vfs_syscalls.c
> --- kern/vfs_syscalls.c   10 Sep 2016 16:53:30 -  1.265
> +++ kern/vfs_syscalls.c   1 Oct 2016 15:36:11 -
> @@ -117,6 +117,9 @@ sys_mount(struct proc *p, void *v, regis
>   if ((error = suser(p, 0)))
>   return (error);
>  
> + if (flags & ~MNT_FLAGMASK)
> + return (EINVAL);
> +
>   /*
>* Mount points must fit in MNAMELEN, not MAXPATHLEN.
>*/



Re: clang, stack limit and inlining

2016-10-02 Thread Mark Kettenis
> From: "Theo de Raadt" 
> Date: Fri, 30 Sep 2016 09:38:30 -0600
> 
> > Diff below is a possible way to fix this.  But in a way we're cheating
> > here since we'll still consume more than 2047 bytes of stack space
> > when we descend into wskbd_initmute().  So perhaps we should rewrite
> > this code to dynamically allocate the mixer_devinfo structs?
> 
> yes, it should be dynamically allocated.

Here's a diff that does that.

As far as I can tell (playing "My favourite hacks") this causes bo
regressions on my x1 rev 3.

ok?


Index: dev/audio.c
===
RCS file: /cvs/src/sys/dev/audio.c,v
retrieving revision 1.153
diff -u -p -r1.153 audio.c
--- dev/audio.c 19 Sep 2016 06:46:43 -  1.153
+++ dev/audio.c 2 Oct 2016 17:33:56 -
@@ -1786,45 +1786,57 @@ audiopoll(dev_t dev, int events, struct 
 int
 wskbd_initmute(struct audio_softc *sc, struct mixer_devinfo *vol)
 {
-   struct mixer_devinfo mi;
+   struct mixer_devinfo *mi;
+   int index = -1;
 
-   mi.index = vol->next;
-   for (mi.index = vol->next; mi.index != -1; mi.index = mi.next) {
-   if (sc->ops->query_devinfo(sc->arg, &mi) != 0)
+   mi = malloc(sizeof(struct mixer_devinfo), M_TEMP, M_WAITOK);
+
+   for (mi->index = vol->next; mi->index != -1; mi->index = mi->next) {
+   if (sc->ops->query_devinfo(sc->arg, mi) != 0)
+   break;
+   if (strcmp(mi->label.name, AudioNmute) == 0) {
+   index = mi->index;
break;
-   if (strcmp(mi.label.name, AudioNmute) == 0)
-   return mi.index;
+   }
}
-   return -1;
+
+   free(mi, M_TEMP, sizeof(struct mixer_devinfo));
+   return index;
 }
 
 int
 wskbd_initvol(struct audio_softc *sc, struct wskbd_vol *vol, char *cn, char 
*dn)
 {
-   struct mixer_devinfo dev, cls;
+   struct mixer_devinfo *dev, *cls;
 
-   for (dev.index = 0; ; dev.index++) {
-   if (sc->ops->query_devinfo(sc->arg, &dev) != 0)
+   vol->val = vol->mute = -1;
+   dev = malloc(sizeof(struct mixer_devinfo), M_TEMP, M_WAITOK);
+   cls = malloc(sizeof(struct mixer_devinfo), M_TEMP, M_WAITOK);
+
+   for (dev->index = 0; ; dev->index++) {
+   if (sc->ops->query_devinfo(sc->arg, dev) != 0)
break;
-   if (dev.type != AUDIO_MIXER_VALUE)
+   if (dev->type != AUDIO_MIXER_VALUE)
continue;
-   cls.index = dev.mixer_class;
-   if (sc->ops->query_devinfo(sc->arg, &cls) != 0)
+   cls->index = dev->mixer_class;
+   if (sc->ops->query_devinfo(sc->arg, cls) != 0)
continue;
-   if (strcmp(cls.label.name, cn) == 0 &&
-   strcmp(dev.label.name, dn) == 0) {
-   vol->val = dev.index;
-   vol->nch = dev.un.v.num_channels;
-   vol->step = dev.un.v.delta > 8 ? dev.un.v.delta : 8;
-   vol->mute = wskbd_initmute(sc, &dev);
+   if (strcmp(cls->label.name, cn) == 0 &&
+   strcmp(dev->label.name, dn) == 0) {
+   vol->val = dev->index;
+   vol->nch = dev->un.v.num_channels;
+   vol->step = dev->un.v.delta > 8 ? dev->un.v.delta : 8;
+   vol->mute = wskbd_initmute(sc, dev);
vol->val_pending = vol->mute_pending = 0;
-   DPRINTF("%s: wskbd using %s.%s%s\n",
-   DEVNAME(sc), cn, dn, vol->mute >= 0 ? ", mute 
control" : "");
-   return 1;
+   DPRINTF("%s: wskbd using %s.%s%s\n", DEVNAME(sc),
+   cn, dn, vol->mute >= 0 ? ", mute control" : "");
+   break;
}
}
-   vol->val = vol->mute = -1;
-   return 0;
+
+   free(cls, M_TEMP, sizeof(struct mixer_devinfo));
+   free(dev, M_TEMP, sizeof(struct mixer_devinfo));
+   return (vol->val != -1);
 }
 
 void



v6 time_uptime vs time_second

2016-10-02 Thread Martin Pieuchot
I'm trying to figure out where the regression in IPv6/NDP is and here's
what I found so far.

When the route expiration time got converted from time_second to
time_uptime we forgot to do the same for values inside RAs.  I'm not
sure what's the real impact of this, but it is clearly wrong.  Diff
below should fix that.

ok?

Index: netinet6/in6.c
===
RCS file: /cvs/src/sys/netinet6/in6.c,v
retrieving revision 1.192
diff -u -p -r1.192 in6.c
--- netinet6/in6.c  4 Sep 2016 10:32:01 -   1.192
+++ netinet6/in6.c  2 Oct 2016 17:18:24 -
@@ -353,7 +353,7 @@ in6_ioctl(u_long cmd, caddr_t data, stru
case SIOCGIFALIFETIME_IN6:
ifr->ifr_ifru.ifru_lifetime = ia6->ia6_lifetime;
if (ia6->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
-   time_t maxexpire;
+   time_t expire, maxexpire;
struct in6_addrlifetime *retlt =
&ifr->ifr_ifru.ifru_lifetime;
 
@@ -365,8 +365,13 @@ in6_ioctl(u_long cmd, caddr_t data, stru
(time_t)~(1ULL << ((sizeof(maxexpire) * 8) - 1));
if (ia6->ia6_lifetime.ia6t_vltime <
maxexpire - ia6->ia6_updatetime) {
-   retlt->ia6t_expire = ia6->ia6_updatetime +
+   expire = ia6->ia6_updatetime +
ia6->ia6_lifetime.ia6t_vltime;
+   if (expire != 0) {
+   expire -= time_uptime;
+   expire += time_second;
+   }
+   retlt->ia6t_expire = expire;
} else
retlt->ia6t_expire = maxexpire;
}
@@ -604,7 +609,7 @@ in6_update_ifa(struct ifnet *ifp, struct
ia6->ia_ifa.ifa_addr = sin6tosa(&ia6->ia_addr);
ia6->ia_addr.sin6_family = AF_INET6;
ia6->ia_addr.sin6_len = sizeof(ia6->ia_addr);
-   ia6->ia6_createtime = ia6->ia6_updatetime = time_second;
+   ia6->ia6_createtime = ia6->ia6_updatetime = time_uptime;
if ((ifp->if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK)) != 0) {
/*
 * XXX: some functions expect that ifa_dstaddr is not
@@ -667,12 +672,12 @@ in6_update_ifa(struct ifnet *ifp, struct
ia6->ia6_lifetime = ifra->ifra_lifetime;
if (ia6->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
ia6->ia6_lifetime.ia6t_expire =
-   time_second + ia6->ia6_lifetime.ia6t_vltime;
+   time_uptime + ia6->ia6_lifetime.ia6t_vltime;
} else
ia6->ia6_lifetime.ia6t_expire = 0;
if (ia6->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
ia6->ia6_lifetime.ia6t_preferred =
-   time_second + ia6->ia6_lifetime.ia6t_pltime;
+   time_uptime + ia6->ia6_lifetime.ia6t_pltime;
} else
ia6->ia6_lifetime.ia6t_preferred = 0;
 
Index: netinet6/in6.h
===
RCS file: /cvs/src/sys/netinet6/in6.h,v
retrieving revision 1.90
diff -u -p -r1.90 in6.h
--- netinet6/in6.h  27 Jun 2016 16:33:48 -  1.90
+++ netinet6/in6.h  2 Oct 2016 17:18:24 -
@@ -280,11 +280,11 @@ struct route_in6 {
 
 #define IFA6_IS_DEPRECATED(a) \
((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \
-(u_int32_t)((time_second - (a)->ia6_updatetime)) > \
+(u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
 (a)->ia6_lifetime.ia6t_pltime)
 #define IFA6_IS_INVALID(a) \
((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \
-(u_int32_t)((time_second - (a)->ia6_updatetime)) > \
+(u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
 (a)->ia6_lifetime.ia6t_vltime)
 
 #endif /* _KERNEL */
Index: netinet6/ip6_forward.c
===
RCS file: /cvs/src/sys/netinet6/ip6_forward.c,v
retrieving revision 1.92
diff -u -p -r1.92 ip6_forward.c
--- netinet6/ip6_forward.c  24 Aug 2016 09:41:12 -  1.92
+++ netinet6/ip6_forward.c  2 Oct 2016 17:18:24 -
@@ -104,8 +104,8 @@ ip6_forward(struct mbuf *m, struct rtent
IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) ||
IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) {
ip6stat.ip6s_cantforward++;
-   if (ip6_log_time + ip6_log_interval < time_second) {
-   ip6_log_time = time_second;
+   if (ip6_log_time + ip6_log_interval < time_uptime) {
+   ip6_log_time = time_uptime;
inet_ntop(AF_INET6, &ip6->ip6_src, src6, sizeof(src6));
 

printf("%s", NULL) in make(1)

2016-10-02 Thread Theo Buehler
Found a bunch of these in my /var/log/messages:

Oct  2 18:30:58 idefix make: vfprintf %s NULL in "Applying :%c to "%s" "
Oct  2 18:30:58 idefix make: vfprintf %s NULL in "Result is "%s" "

To reproduce, issue 'make -n -d v' in a simple port, e.g. sysutils/cpuid

Index: usr.bin/make/varmodifiers.c
===
RCS file: /var/cvs/src/usr.bin/make/varmodifiers.c,v
retrieving revision 1.43
diff -u -p -r1.43 varmodifiers.c
--- usr.bin/make/varmodifiers.c 15 Nov 2015 06:19:22 -  1.43
+++ usr.bin/make/varmodifiers.c 2 Oct 2016 16:32:07 -
@@ -1453,7 +1453,8 @@ VarModifiers_Apply(char *str, const stru
 
tstr++;
if (DEBUG(VAR))
-   printf("Applying :%c to \"%s\"\n", *tstr, str);
+   printf("Applying :%c to \"%s\"\n", *tstr, str ? str :
+   "(null)");
 
mod = choose_mod[(unsigned char)*tstr];
arg = NULL;
@@ -1502,7 +1503,7 @@ VarModifiers_Apply(char *str, const stru
break;
}
if (DEBUG(VAR))
-   printf("Result is \"%s\"\n", str);
+   printf("Result is \"%s\"\n", str ? str : "(null)");
}
if (*tstr == '\0')
Parse_Error(PARSE_FATAL, "Unclosed variable specification");



larger bus width for ommmc(4)

2016-10-02 Thread Jonathan Gray
Only set the highspeed bit in bus_clock if highspeed is supported
by the controller.  Needed as the bus_clock callback is called with
SDMMC_TIMING_HIGHSPEED even if the capability is not set.
Required to raise the bus width on pandaboard which doesn't have
the highspeed capability.

As anything other than 1 bit mode results in the emmc on the bbb
timing out waiting for command completion, limit high bus
modes to the first hsmmc controller (by way of dual-volt property).
This at least lets 4 bit modes work with sd cards on bbb.

Index: ommmc.c
===
RCS file: /cvs/src/sys/arch/armv7/omap/ommmc.c,v
retrieving revision 1.29
diff -u -p -r1.29 ommmc.c
--- ommmc.c 12 Aug 2016 03:22:41 -  1.29
+++ ommmc.c 2 Oct 2016 15:15:00 -
@@ -193,6 +193,7 @@ struct ommmc_softc {
bus_space_handle_t  sc_ioh;
void*sc_ih; /* Interrupt handler */
uint32_tsc_flags;
+#define FL_HSS (1 << 0)
 
struct device *sdmmc;   /* generic SD/MMC device */
int clockbit;   /* clock control bit */
@@ -298,7 +299,7 @@ ommmc_attach(struct device *parent, stru
struct ommmc_softc  *sc = (struct ommmc_softc *) self;
struct fdt_attach_args  *faa = aux;
struct sdmmcbus_attach_args  saa;
-   uint32_t caps;
+   uint32_t caps, width;
uint32_t addr, size;
int  len, unit;
char hwmods[128];
@@ -432,8 +433,19 @@ ommmc_attach(struct device *parent, stru
saa.saa_busname = "sdmmc";
saa.sct = &ommmc_functions;
saa.sch = sc;
-   if (caps & MMCHS_CAPA_HSS)
-   saa.caps |= SMC_CAPS_MMC_HIGHSPEED;
+   if (OF_getproplen(faa->fa_node, "ti,needs-special-hs-handling") == 0 &&
+   (caps & MMCHS_CAPA_HSS)) {
+   sc->sc_flags |= FL_HSS;
+   saa.caps |= SMC_CAPS_MMC_HIGHSPEED | SMC_CAPS_SD_HIGHSPEED;
+   }
+   width = OF_getpropint(faa->fa_node, "bus-width", 1);
+   /* with emmc width > 1 ommmc_wait_intr MMCHS_STAT_CC times out */
+   if (OF_getproplen(faa->fa_node, "ti,dual-volt") != 0)
+   width = 1;
+   if (width >= 8)
+   saa.caps |= SMC_CAPS_8BIT_MODE;
+   if (width >= 4)
+   saa.caps |= SMC_CAPS_4BIT_MODE;
 
sc->sdmmc = config_found(&sc->sc_dev, &saa, NULL);
if (sc->sdmmc == NULL) {
@@ -717,10 +729,10 @@ ommmc_bus_clock(sdmmc_chipset_handle_t s
reg |= div << MMCHS_SYSCTL_CLKD_SH;
HWRITE4(sc, MMCHS_SYSCTL, reg);
 
-   if (timing == SDMMC_TIMING_LEGACY)
-   HCLR4(sc, MMCHS_HCTL, MMCHS_HCTL_HSPE);
-   else
+   if ((timing == SDMMC_TIMING_HIGHSPEED) && (sc->sc_flags & FL_HSS))
HSET4(sc, MMCHS_HCTL, MMCHS_HCTL_HSPE);
+   else
+   HCLR4(sc, MMCHS_HCTL, MMCHS_HCTL_HSPE);
 
/*
 * Start internal clock.  Wait 10ms for stabilization.



Re: Explicitly cast the return variable in tls_load_file()

2016-10-02 Thread Brent Cook
On Sun, Oct 02, 2016 at 08:50:39AM -0500, Brent Cook wrote:
> On Sat, Oct 1, 2016 at 7:12 PM, Ted Unangst  wrote:
>
> > Kinichiro Inoguchi wrote:
> > > I would like to cast the return variable explicitly in tls_load_file().
> > > This fix also avoiding Intel C++ compiler "assertion failed" described
> > here.
> > > https://github.com/libressl-portable/portable/issues/209#
> > issuecomment-249587024
> >
> > This is a compiler bug? The code doesn't change, and there's no bug in the
> > library that I see.
> >
>
> ​If the compiler is implying that the code is incorrect, it has a funny way
> of saying it. This looks not-dissimilar to a gcc ICE:
>
> ​
>  1>C:\libressl-2.5.0\tls\tls_util.c(157): error : assertion failed:
> construct_message: not all fill-ins used (shared/cfe/edgcpfe/error.c, line
> 3586)
> 1>
>
> ​Why not just make the variable type match the return type to begin with?
>
> ​--- a/src/lib/libtls/tls_util.c
> +++ b/src/lib/libtls/tls_util.c
> @@ -105,7 +105,8 @@ tls_load_file(const char *name, size_t *len, char
> *password)
> FILE *fp;
> EVP_PKEY *key = NULL;
> BIO *bio = NULL;
> -   char *data, *buf = NULL;
> +   char *data;
> +   uint8_t *buf = NULL;
> struct stat st;
> size_t size;
> int fd = -1;

Here's an un-gmail-munged diff:

diff --git a/src/lib/libtls/tls_util.c b/src/lib/libtls/tls_util.c
index b3035c9..1b8c28a 100644
--- a/src/lib/libtls/tls_util.c
+++ b/src/lib/libtls/tls_util.c
@@ -105,7 +105,8 @@ tls_load_file(const char *name, size_t *len, char *password)
FILE *fp;
EVP_PKEY *key = NULL;
BIO *bio = NULL;
-   char *data, *buf = NULL;
+   char *data;
+   uint8_t *buf = NULL;
struct stat st;
size_t size;
int fd = -1;



Re: Explicitly cast the return variable in tls_load_file()

2016-10-02 Thread Brent Cook
On Sat, Oct 1, 2016 at 7:12 PM, Ted Unangst  wrote:

> Kinichiro Inoguchi wrote:
> > I would like to cast the return variable explicitly in tls_load_file().
> > This fix also avoiding Intel C++ compiler "assertion failed" described
> here.
> > https://github.com/libressl-portable/portable/issues/209#
> issuecomment-249587024
>
> This is a compiler bug? The code doesn't change, and there's no bug in the
> library that I see.
>

​If the compiler is implying that the code is incorrect, it has a funny way
of saying it. This looks not-dissimilar to a gcc ICE:

​
 1>C:\libressl-2.5.0\tls\tls_util.c(157): error : assertion failed:
construct_message: not all fill-ins used (shared/cfe/edgcpfe/error.c, line
3586)
1>

​Why not just make the variable type match the return type to begin with?

​--- a/src/lib/libtls/tls_util.c
+++ b/src/lib/libtls/tls_util.c
@@ -105,7 +105,8 @@ tls_load_file(const char *name, size_t *len, char
*password)
FILE *fp;
EVP_PKEY *key = NULL;
BIO *bio = NULL;
-   char *data, *buf = NULL;
+   char *data;
+   uint8_t *buf = NULL;
struct stat st;
size_t size;
int fd = -1;


Re: EVP_CipherFinal_ex for snmpd

2016-10-02 Thread Brent Cook
ok

On Sun, Oct 2, 2016 at 12:34 AM, David Gwynne  wrote:

> this gets rid of a linker warning.
>
> the impression i get is that EVP_CipherFinal_ex explicitely does
> not do cleanup of the cipher context thing, while EVP_CipherFinal
> could if it wanted to.
>
> ok?
>
> Index: usm.c
> ===
> RCS file: /cvs/src/usr.sbin/snmpd/usm.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 usm.c
> --- usm.c   16 Jan 2015 00:05:13 -  1.9
> +++ usm.c   2 Oct 2016 05:32:03 -
> @@ -605,7 +605,7 @@ usm_crypt(struct snmp_message *msg, u_ch
> EVP_CIPHER_CTX_set_padding(&ctx, 0);
>
> if (EVP_CipherUpdate(&ctx, outbuf, &len, inbuf, inlen) &&
> -   EVP_CipherFinal(&ctx, outbuf + len, &len2))
> +   EVP_CipherFinal_ex(&ctx, outbuf + len, &len2))
> rv = len + len2;
> else
> rv = -1;
>
>


pending timeouts in trpt

2016-10-02 Thread David Gwynne
i think the change to move tcp timers to timeouts got this bit wrong.

we do want to print the timer if it is pending, it doesnt make sense
otherwise.

ok?

Index: trpt.c
===
RCS file: /cvs/src/usr.sbin/trpt/trpt.c,v
retrieving revision 1.33
diff -u -p -r1.33 trpt.c
--- trpt.c  27 Aug 2016 01:50:07 -  1.33
+++ trpt.c  2 Oct 2016 08:51:21 -
@@ -401,7 +401,7 @@ tcp_trace(short act, short ostate, struc
int i;
 
for (i = 0; i < TCPT_NTIMERS; i++) {
-   if (timeout_pending(&tp->t_timer[i]))
+   if (!timeout_pending(&tp->t_timer[i]))
continue;
printf("%s%s=%d", cp, tcptimers[i],
tp->t_timer[i].to_time);



Re: make snmpd explicitely include tree.h

2016-10-02 Thread Philip Guenther
On Sat, Oct 1, 2016 at 11:58 PM, David Gwynne  wrote:
> at the moment its relying on a pf header.
>
> ok?

ok guenther@


...though the set of #includes in that .h file should be reviewed:
lots of the .c file there pull in net/if.h, so why is snmpd.h doing
so, etc.



Re: share/misc: Complete 'airport' and 'inter.phone' for Poland

2016-10-02 Thread Raf Czlonka
On Sat, Oct 01, 2016 at 11:00:07PM BST, Frederic Cambus wrote:
> Hi tech@,
> 
> This diff adds missing airports and area codes for Poland, and fixes
> some erroneous entries.

Hi Frederic,

I've been meaning to do it for a while - thanks! :^)

A couple of comments below.

Cheers,

Raf

> OK?
> 
> Index: share/misc/airport
> ===
> RCS file: /cvs/src/share/misc/airport,v
> retrieving revision 1.56
> diff -u -p -r1.56 airport
> --- share/misc/airport10 Jul 2016 13:52:27 -  1.56
> +++ share/misc/airport1 Oct 2016 20:37:42 -
> @@ -273,6 +273,7 @@ BXU:Butuan, Butuan, Philippines
>  BYO:Bonito, Brazil
>  BYU:Bindlacher Berg, Bayreuth, Germany
>  BZE:Philip S. W. Goldson International, Belize City, Belize
> +BZG:Szwederowo, Bydgoszcz, Poland
>  BZN:Gallatin Field, Bozeman, Montana, USA
>  CAE:Columbia Metropolitan, South Carolina, USA
>  CAG:Elmas, Cagliari, Sardinia, Italy
> @@ -726,6 +727,7 @@ IAS:Iasi, Romania
>  IBZ:Ibiza, Spain
>  ICT:Wichita Mid-Continent, Kansas, USA
>  IDA:Idaho Falls, Idaho, USA
> +IEG:Babimost, Zielona Gora, Poland
>  IEV:Kyiv Zhulyany International, Kyiv, Ukraine
>  IFO:Ivano-Frankivs'k International, Ivano-Frankivs'k, Ukraine
>  IFP:Bullhead City, Arizona, USA
> @@ -936,6 +938,7 @@ LCA:Larnaca International, Cyprus
>  LCE:La Ceiba International, Honduras
>  LCG:La Coruna, Spain
>  LCH:Lake Charles, Louisiana, USA
> +LCJ:Lublinek, Lodz, Poland

Lublinek is an informal name used in the past so if you're not going
to use "Wladyslaw Reymont" as its name, I'd suggest you drop
"Lublinek" altogether as you've done with Poznan below.

>  LCY:London City, England, United Kingdom
>  LDB:Londrina, Parana, Brazil
>  LDE:Tarbes International, Lourdes/Tarbes, France
> @@ -1009,6 +1012,7 @@ LUD:Luderitz, Namibia
>  LUG:Agno, Lugano, Switzerland
>  LUN:Lusaka, Zambia
>  LUX:Findel, Luxembourg
> +LUZ:Swidnik, Lublin, Poland
>  LVI:Livingstone, Zambia
>  LVK:Livermore, California, USA
>  LWB:Greenbrier Valley, West Virginia, USA
> @@ -1345,7 +1349,7 @@ POP:La Union, Puerto Plata, Dominican Re
>  POR:Pori, Finland
>  POS:Port Of Spain, Trinidad
>  POU:Dutchess County, Poughkeepsie, New York, USA
> -POZ:Lawica, Poznan, Poland
> +POZ:Poznan, Poland
>  PPG:Pago Pago International, American Samoa
>  PPS:Puerto Princesa, Philippines
>  PPT:Pape'ete, Tahiti, French Polynesia
> @@ -1406,6 +1410,7 @@ RCB:Richards Bay, South Africa
>  RCE:Roche Harbor, Washington, USA
>  RDD:Redding, California, USA
>  RDG:Reading Municipal / Spaatz Field, Pennsylvania, USA
> +RDO:Sadkow, Radom, Poland
>  RDU:Raleigh-Durham, North Carolina, USA
>  REC:Guararapes International, Recife, Pernambuco, Brazil
>  REG:Tito Menniti, Reggio Calabria, Italy
> @@ -1457,6 +1462,7 @@ RUN:Roland Garros Airport, Reunion Islan
>  RUT:Rutland, Vermont, USA
>  RWI:Wilson, Rocky Mount, North Carolina, USA
>  RWN:Rivne International, Rivne, Ukraine
> +RZE:Jasionka, Rzeszow, Poland
>  SAB:Saba Island, Netherlands Antilles
>  SAF:Santa Fe, New Mexico, USA
>  SAH:Sanaa International, Yemen
> @@ -1620,6 +1626,7 @@ SZG:Salzburg, Austria
>  SZR:Stara Zagora, Bulgaria
>  SZS:Ryan's Creek, Stewart Island, New Zealand
>  SZX:Shenzhen, China
> +SZY:Szymany, Olsztyn, Poland
>  SZZ:Goleniow, Szczecin, Poland
>  TAB:Crown Point, Tobago, Trinidad And Tobago
>  TAC:Dz Romualdez, Tacloban, Philippines
> @@ -1815,6 +1822,7 @@ WIL:Wilson, Nairobi, Kenya
>  WIN:Winton, Queensland, Australia
>  WLG:Wellington International, New Zealand
>  WMH:Mountain Home, Arkansas, USA
> +WMI:Modlin, Warsaw, Poland
>  WNA:Napakiak, Alaska, USA
>  WRL:Worland, Wyoming, USA
>  WRO:Strachowice, Wroclaw, Poland
> Index: share/misc/inter.phone
> ===
> RCS file: /cvs/src/share/misc/inter.phone,v
> retrieving revision 1.42
> diff -u -p -r1.42 inter.phone
> --- share/misc/inter.phone9 Jul 2016 23:32:51 -   1.42
> +++ share/misc/inter.phone1 Oct 2016 20:37:42 -
> @@ -1711,10 +1711,55 @@
>  47:2:Oslo:Norway
>  47:5:Bergen:Norway
>  47:7:Trondheim:Norway
> -48:12:Crakow:Poland
> +48:12:Krakow:Poland
> +48:13:Krosno:Poland
> +48:14:Tarnow:Poland
> +48:15:Tarnobrzeg:Poland
> +48:16:Przemysl:Poland
> +48:17:Rzeszow:Poland
> +48:18:Nowy Sacz:Poland
>  48:22:Warsaw:Poland

You've used Polish spelling for Krakow - to follow suit, Warsaw
should be changed to Warszawa or Krakow to Cracow (with two C's)
as it is know internationally.

> +48:23:Ciechanow:Poland
> +48:24:Plock:Poland
> +48:25:Siedlce:Poland
> +48:29:Ostroleka:Poland
> +48:32:Katowice:Poland
> +48:33:Bielsko-Biala:Poland
> +48:34:Czestochowa:Poland
> +48:41:Kielce:Poland
>  48:42:Lodz:Poland
> +48:43:Sieradz:Poland
> +48:44:Piotrkow Trybunalski:Poland
> +48:46:Skierniewice:Poland
> +48:48:Radom:Poland
> +48:52:Bydgoszcz:Poland
> +48:54:Wloclawek:Poland
> +48:55:Elblag:Poland
> +48:56:Torun:Poland
>  48:58:Gdansk:Poland
> +48:59:Slupsk:Poland
> +48:61:Poznan:Poland
> +