Re: syslogd suppress message repeated

2017-04-16 Thread Stuart Henderson
On 2017/04/17 00:57, Alexander Bluhm wrote:
> Hi,
> 
> I have received complaints from a customer that the "last message
> repeated" feature of syslogd(8) makes their log auditing difficult.
> FreeBSD has -c and -cc to disable it, but our -c is already taken.
> 
> Add -r to suppress the summary line for pipe and remote loghost,
> as they are most commonly used for automated log processing.  With
> -rr the "last message repeated" can be disabled completely.
> 
> ok?
> 
> bluhm
> 
> Index: usr.sbin/syslogd/syslogd.8
> ===
> RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.8,v
> retrieving revision 1.53
> diff -u -p -r1.53 syslogd.8
> --- usr.sbin/syslogd/syslogd.82 Jan 2017 15:58:02 -   1.53
> +++ usr.sbin/syslogd/syslogd.816 Apr 2017 20:01:04 -
> @@ -39,7 +39,7 @@
>  .Sh SYNOPSIS
>  .Nm syslogd
>  .Bk -words
> -.Op Fl 46dFhnuVZ
> +.Op Fl 46dFhnruVZ
>  .Op Fl a Ar path
>  .Op Fl C Ar CAfile
>  .Op Fl c Ar cert_file
> @@ -129,6 +129,10 @@ the symbolic local host name.
>  Specify the pathname of an alternate log socket to be used instead;
>  the default is
>  .Pa /dev/log .
> +.It Fl r
> +Suppress the message repeated summary and print every line immediately.

Would it be clearer if "message repeated" were in quotes?

> +If given once, only message piped to another program or forwarded
> +to a remote loghost are affected.

s/message/messages/

Doesn't this need something like "If given twice, all messages are
affected" or similar?

>  Create a TLS listen socket for receiving encrypted messages and
>  bind it to the specified address.
> Index: usr.sbin/syslogd/syslogd.c

I'm ok with the general idea and code diff.

> ===
> RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v
> retrieving revision 1.241
> diff -u -p -r1.241 syslogd.c
> --- usr.sbin/syslogd/syslogd.c7 Apr 2017 15:36:16 -   1.241
> +++ usr.sbin/syslogd/syslogd.c16 Apr 2017 20:14:30 -
> @@ -209,6 +209,7 @@ int   Initialized = 0;/* set when we have
>  int  MarkInterval = 20 * 60; /* interval between marks in seconds */
>  int  MarkSeq = 0;/* mark sequence number */
>  int  PrivChild = 0;  /* Exec the privileged parent process */
> +int  Repeat = 0; /* 0 msg repeated, 1 in files only, 2 never */
>  int  SecureMode = 1; /* when true, speak only unix domain socks */
>  int  NoDNS = 0;  /* when true, refrain from doing DNS lookups */
>  int  ZuluTime = 0;   /* display date and time in UTC ISO format */
> @@ -369,8 +370,8 @@ main(int argc, char *argv[])
>   tls_hostport = tls_host = NULL;
>   nbind = nlisten = 0;
>  
> - while ((ch = getopt(argc, argv, "46a:C:c:dFf:hK:k:m:nP:p:S:s:T:U:uVZ"))
> - != -1)
> + while ((ch = getopt(argc, argv,
> + "46a:C:c:dFf:hK:k:m:nP:p:rS:s:T:U:uVZ")) != -1) {
>   switch (ch) {
>   case '4':   /* disable IPv6 */
>   Family = PF_INET;
> @@ -425,6 +426,9 @@ main(int argc, char *argv[])
>   case 'p':   /* path */
>   path_unix[0] = optarg;
>   break;
> + case 'r':
> + Repeat++;
> + break;
>   case 'S':   /* allow tls and listen on address */
>   tls_hostport = optarg;
>   if ((p = strdup(optarg)) == NULL)
> @@ -455,6 +459,7 @@ main(int argc, char *argv[])
>   default:
>   usage();
>   }
> + }
>   if (argc != optind)
>   usage();
>  
> @@ -1766,7 +1771,10 @@ logline(int pri, int flags, char *from, 
>   /*
>* suppress duplicate lines to this file
>*/
> - if ((flags & MARK) == 0 && msglen == f->f_prevlen &&
> + if ((Repeat == 0 || (Repeat == 1 &&
> + (f->f_type != F_PIPE && f->f_type != F_FORWUDP &&
> + f->f_type != F_FORWTCP && f->f_type != F_FORWTLS))) &&
> + (flags & MARK) == 0 && msglen == f->f_prevlen &&
>   !strcmp(msg, f->f_prevline) &&
>   !strcmp(from, f->f_prevhost)) {
>   strlcpy(f->f_lasttime, timestamp,
> 



retire icmp6_rip6_input

2017-04-16 Thread Alexander Bluhm
Hi,

As the comment says, icmp6_rip6_input() is mostly duplicated code
from rip6_input().  So lets merge these functions together and
retire icmp6_rip6_input().

ok?

bluhm

Index: netinet6/icmp6.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/icmp6.c,v
retrieving revision 1.205
diff -u -p -r1.205 icmp6.c
--- netinet6/icmp6.c14 Apr 2017 20:46:31 -  1.205
+++ netinet6/icmp6.c16 Apr 2017 23:23:45 -
@@ -135,7 +135,6 @@ static struct rttimer_queue *icmp6_redir
 static int icmp6_redirect_lowat = -1;
 
 void   icmp6_errcount(int, int);
-inticmp6_rip6_input(struct mbuf **, int);
 inticmp6_ratelimit(const struct in6_addr *, const int, const int);
 const char *icmp6_redirect_diag(struct in6_addr *, struct in6_addr *,
struct in6_addr *);
@@ -761,9 +760,7 @@ badlen:
 raw:
 #endif
/* deliver the packet to appropriate sockets */
-   icmp6_rip6_input(, *offp);
-
-   return IPPROTO_DONE;
+   return rip6_input(mp, offp, proto, af);
 
  freeit:
m_freem(m);
@@ -1039,104 +1036,6 @@ icmp6_mtudisc_update(struct ip6ctlparam 
 */
LIST_FOREACH(mc, _mtudisc_callbacks, mc_list)
(*mc->mc_func)(, m->m_pkthdr.ph_rtableid);
-}
-
-/*
- * XXX almost dup'ed code with rip6_input.
- */
-int
-icmp6_rip6_input(struct mbuf **mp, int off)
-{
-   struct mbuf *m = *mp;
-   struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
-   struct inpcb *in6p;
-   struct inpcb *last = NULL;
-   struct sockaddr_in6 rip6src;
-   struct icmp6_hdr *icmp6;
-   struct mbuf *opts = NULL;
-
-   IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off, sizeof(*icmp6));
-   if (icmp6 == NULL) {
-   /* m is already reclaimed */
-   return IPPROTO_DONE;
-   }
-
-   bzero(, sizeof(rip6src));
-   rip6src.sin6_len = sizeof(struct sockaddr_in6);
-   rip6src.sin6_family = AF_INET6;
-   /* KAME hack: recover scopeid */
-   in6_recoverscope(, >ip6_src);
-
-   TAILQ_FOREACH(in6p, _queue, inp_queue) {
-   if (!(in6p->inp_flags & INP_IPV6))
-   continue;
-   if (in6p->inp_ipv6.ip6_nxt != IPPROTO_ICMPV6)
-   continue;
-#if NPF > 0
-   if (m->m_pkthdr.pf.flags & PF_TAG_DIVERTED) {
-   struct pf_divert *divert;
-
-   /* XXX rdomain support */
-   if ((divert = pf_find_divert(m)) == NULL)
-   continue;
-   if (IN6_IS_ADDR_UNSPECIFIED(>addr.v6))
-   goto divert_reply;
-   if (!IN6_ARE_ADDR_EQUAL(>inp_laddr6,
-   >addr.v6))
-   continue;
-   } else
- divert_reply:
-#endif
-   if (!IN6_IS_ADDR_UNSPECIFIED(>inp_laddr6) &&
-  !IN6_ARE_ADDR_EQUAL(>inp_laddr6, >ip6_dst))
-   continue;
-   if (!IN6_IS_ADDR_UNSPECIFIED(>inp_faddr6) &&
-  !IN6_ARE_ADDR_EQUAL(>inp_faddr6, >ip6_src))
-   continue;
-   if (in6p->inp_icmp6filt
-   && ICMP6_FILTER_WILLBLOCK(icmp6->icmp6_type,
-in6p->inp_icmp6filt))
-   continue;
-   if (last) {
-   struct  mbuf *n;
-   if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) != NULL) {
-   if (last->inp_flags & IN6P_CONTROLOPTS)
-   ip6_savecontrol(last, n, );
-   /* strip intermediate headers */
-   m_adj(n, off);
-   if (sbappendaddr(>inp_socket->so_rcv,
-   sin6tosa(), n, opts) == 0) {
-   /* should notify about lost packet */
-   m_freem(n);
-   m_freem(opts);
-   } else
-   sorwakeup(last->inp_socket);
-   opts = NULL;
-   }
-   }
-   last = in6p;
-   }
-   if (last) {
-   if (last->inp_flags & IN6P_CONTROLOPTS)
-   ip6_savecontrol(last, m, );
-   /* strip intermediate headers */
-   m_adj(m, off);
-   if (sbappendaddr(>inp_socket->so_rcv,
-   sin6tosa(), m, opts) == 0) {
-   m_freem(m);
-   m_freem(opts);
-   } else
-   sorwakeup(last->inp_socket);
-   } else {
-   struct counters_ref ref;
-   uint64_t *counters;
-
-   m_freem(m);
-   counters = counters_enter(, ip6counters);
-   

syslogd suppress message repeated

2017-04-16 Thread Alexander Bluhm
Hi,

I have received complaints from a customer that the "last message
repeated" feature of syslogd(8) makes their log auditing difficult.
FreeBSD has -c and -cc to disable it, but our -c is already taken.

Add -r to suppress the summary line for pipe and remote loghost,
as they are most commonly used for automated log processing.  With
-rr the "last message repeated" can be disabled completely.

ok?

bluhm

Index: usr.sbin/syslogd/syslogd.8
===
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.8,v
retrieving revision 1.53
diff -u -p -r1.53 syslogd.8
--- usr.sbin/syslogd/syslogd.8  2 Jan 2017 15:58:02 -   1.53
+++ usr.sbin/syslogd/syslogd.8  16 Apr 2017 20:01:04 -
@@ -39,7 +39,7 @@
 .Sh SYNOPSIS
 .Nm syslogd
 .Bk -words
-.Op Fl 46dFhnuVZ
+.Op Fl 46dFhnruVZ
 .Op Fl a Ar path
 .Op Fl C Ar CAfile
 .Op Fl c Ar cert_file
@@ -129,6 +129,10 @@ the symbolic local host name.
 Specify the pathname of an alternate log socket to be used instead;
 the default is
 .Pa /dev/log .
+.It Fl r
+Suppress the message repeated summary and print every line immediately.
+If given once, only message piped to another program or forwarded
+to a remote loghost are affected.
 .It Fl S Ar listen_address
 Create a TLS listen socket for receiving encrypted messages and
 bind it to the specified address.
Index: usr.sbin/syslogd/syslogd.c
===
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.241
diff -u -p -r1.241 syslogd.c
--- usr.sbin/syslogd/syslogd.c  7 Apr 2017 15:36:16 -   1.241
+++ usr.sbin/syslogd/syslogd.c  16 Apr 2017 20:14:30 -
@@ -209,6 +209,7 @@ int Initialized = 0;/* set when we have
 intMarkInterval = 20 * 60; /* interval between marks in seconds */
 intMarkSeq = 0;/* mark sequence number */
 intPrivChild = 0;  /* Exec the privileged parent process */
+intRepeat = 0; /* 0 msg repeated, 1 in files only, 2 never */
 intSecureMode = 1; /* when true, speak only unix domain socks */
 intNoDNS = 0;  /* when true, refrain from doing DNS lookups */
 intZuluTime = 0;   /* display date and time in UTC ISO format */
@@ -369,8 +370,8 @@ main(int argc, char *argv[])
tls_hostport = tls_host = NULL;
nbind = nlisten = 0;
 
-   while ((ch = getopt(argc, argv, "46a:C:c:dFf:hK:k:m:nP:p:S:s:T:U:uVZ"))
-   != -1)
+   while ((ch = getopt(argc, argv,
+   "46a:C:c:dFf:hK:k:m:nP:p:rS:s:T:U:uVZ")) != -1) {
switch (ch) {
case '4':   /* disable IPv6 */
Family = PF_INET;
@@ -425,6 +426,9 @@ main(int argc, char *argv[])
case 'p':   /* path */
path_unix[0] = optarg;
break;
+   case 'r':
+   Repeat++;
+   break;
case 'S':   /* allow tls and listen on address */
tls_hostport = optarg;
if ((p = strdup(optarg)) == NULL)
@@ -455,6 +459,7 @@ main(int argc, char *argv[])
default:
usage();
}
+   }
if (argc != optind)
usage();
 
@@ -1766,7 +1771,10 @@ logline(int pri, int flags, char *from, 
/*
 * suppress duplicate lines to this file
 */
-   if ((flags & MARK) == 0 && msglen == f->f_prevlen &&
+   if ((Repeat == 0 || (Repeat == 1 &&
+   (f->f_type != F_PIPE && f->f_type != F_FORWUDP &&
+   f->f_type != F_FORWTCP && f->f_type != F_FORWTLS))) &&
+   (flags & MARK) == 0 && msglen == f->f_prevlen &&
!strcmp(msg, f->f_prevline) &&
!strcmp(from, f->f_prevhost)) {
strlcpy(f->f_lasttime, timestamp,



Re: ld.lld: disable colors/bold/whatever

2017-04-16 Thread Mark Kettenis
> Date: Sun, 16 Apr 2017 21:21:24 +0200
> From: Patrick Wildt 
> 
> Hi,
> 
> this diff disables the color diagnostics by default so that LLVM's lld
> does not throw any ANSI sequences.
> 
> ok?

Wouldn't it be better to just change
lib/Support/Unix/Process.inc:terminalHasColors() to always return false?

that should take care of the color stuff in all the different llvm tools.

> diff --git a/gnu/llvm/tools/lld/ELF/DriverUtils.cpp 
> b/gnu/llvm/tools/lld/ELF/DriverUtils.cpp
> index 5ba494d791d..36b4052d72a 100644
> --- a/gnu/llvm/tools/lld/ELF/DriverUtils.cpp
> +++ b/gnu/llvm/tools/lld/ELF/DriverUtils.cpp
> @@ -59,7 +59,7 @@ static bool getColorDiagnostics(opt::InputArgList ) {
>auto *Arg = Args.getLastArg(OPT_color_diagnostics, 
> OPT_color_diagnostics_eq,
>OPT_no_color_diagnostics);
>if (!Arg)
> -return Default;
> +return false;
>if (Arg->getOption().getID() == OPT_color_diagnostics)
>  return true;
>if (Arg->getOption().getID() == OPT_no_color_diagnostics)
> 
> 



ld.lld: disable colors/bold/whatever

2017-04-16 Thread Patrick Wildt
Hi,

this diff disables the color diagnostics by default so that LLVM's lld
does not throw any ANSI sequences.

ok?

Patrick

diff --git a/gnu/llvm/tools/lld/ELF/DriverUtils.cpp 
b/gnu/llvm/tools/lld/ELF/DriverUtils.cpp
index 5ba494d791d..36b4052d72a 100644
--- a/gnu/llvm/tools/lld/ELF/DriverUtils.cpp
+++ b/gnu/llvm/tools/lld/ELF/DriverUtils.cpp
@@ -59,7 +59,7 @@ static bool getColorDiagnostics(opt::InputArgList ) {
   auto *Arg = Args.getLastArg(OPT_color_diagnostics, OPT_color_diagnostics_eq,
   OPT_no_color_diagnostics);
   if (!Arg)
-return Default;
+return false;
   if (Arg->getOption().getID() == OPT_color_diagnostics)
 return true;
   if (Arg->getOption().getID() == OPT_no_color_diagnostics)



syslogd multiple tls listen sockets

2017-04-16 Thread Alexander Bluhm
Hi,

This allows syslogd(8) to listen on multiple addresses for incomming
TLS connections.

ok?

bluhm

Index: usr.sbin/syslogd/syslogd.8
===
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.8,v
retrieving revision 1.53
diff -u -p -r1.53 syslogd.8
--- usr.sbin/syslogd/syslogd.8  2 Jan 2017 15:58:02 -   1.53
+++ usr.sbin/syslogd/syslogd.8  16 Apr 2017 18:32:45 -
@@ -135,8 +135,9 @@ bind it to the specified address.
 A port number may be specified using the
 .Ar host : Ns Ar port
 syntax.
-The parameter is also used to find a suitable server key and
-certificate in
+The first
+.Ar listen_address
+is also used to find a suitable server key and certificate in
 .Pa /etc/ssl/ .
 .It Fl s Ar reporting_socket
 Specify path to an
@@ -175,7 +176,7 @@ in UTC.
 .El
 .Pp
 The options
-.Fl a , T ,
+.Fl a , S, T ,
 and
 .Fl U
 can be given more than once to specify multiple input sources.
Index: usr.sbin/syslogd/syslogd.c
===
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.241
diff -u -p -r1.241 syslogd.c
--- usr.sbin/syslogd/syslogd.c  7 Apr 2017 15:36:16 -   1.241
+++ usr.sbin/syslogd/syslogd.c  16 Apr 2017 18:53:53 -
@@ -350,9 +350,9 @@ main(int argc, char *argv[])
int  ch, i;
int  lockpipe[2] = { -1, -1}, pair[2], nullfd, fd;
int  fd_ctlsock, fd_klog, fd_sendsys, *fd_bind, *fd_listen;
-   int  fd_tls, *fd_unix, nbind, nlisten;
+   int *fd_tls, *fd_unix, nbind, nlisten, ntls;
char**bind_host, **bind_port, **listen_host, **listen_port;
-   char*tls_hostport, *tls_host, *tls_port;
+   char*tls_hostport, **tls_host, **tls_port;
 
/* block signal until handler is set up */
sigemptyset();
@@ -365,9 +365,10 @@ main(int argc, char *argv[])
path_unix[0] = _PATH_LOG;
nunix = 1;
 
-   bind_host = bind_port = listen_host = listen_port = NULL;
-   tls_hostport = tls_host = NULL;
-   nbind = nlisten = 0;
+   bind_host = listen_host = tls_host = NULL;
+   bind_port = listen_port = tls_port = NULL;
+   tls_hostport = NULL;
+   nbind = nlisten = ntls = 0;
 
while ((ch = getopt(argc, argv, "46a:C:c:dFf:hK:k:m:nP:p:S:s:T:U:uVZ"))
!= -1)
@@ -426,11 +427,10 @@ main(int argc, char *argv[])
path_unix[0] = optarg;
break;
case 'S':   /* allow tls and listen on address */
-   tls_hostport = optarg;
-   if ((p = strdup(optarg)) == NULL)
-   err(1, "strdup tls address");
-   if (loghost_parse(p, NULL, _host, _port) == -1)
-   errx(1, "bad tls address: %s", optarg);
+   if (tls_hostport == NULL)
+   tls_hostport = optarg;
+   address_alloc("tls", optarg, _host, _port,
+   );
break;
case 's':
path_ctlsock = optarg;
@@ -511,10 +511,13 @@ main(int argc, char *argv[])
_listen[i], _listen[i]) == -1)
log_warnx("socket listen tcp failed");
}
-   fd_tls = -1;
-   if (tls_host && socket_bind("tls", tls_host, tls_port, 0,
-   _tls, _tls) == -1)
-   log_warnx("socket listen tls failed");
+   if ((fd_tls = reallocarray(NULL, ntls, sizeof(*fd_tls))) == NULL)
+   fatal("allocate tls fd");
+   for (i = 0; i < ntls; i++) {
+   if (socket_bind("tls", tls_host[i], tls_port[i], 0,
+   _tls[i], _tls[i]) == -1)
+   log_warnx("socket listen tls failed");
+   }
 
if ((fd_unix = reallocarray(NULL, nunix, sizeof(*fd_unix))) == NULL)
fatal("allocate unix fd");
@@ -570,8 +573,14 @@ main(int argc, char *argv[])
log_warn("tls_config_new server");
if ((server_ctx = tls_server()) == NULL) {
log_warn("tls_server");
-   close(fd_tls);
-   fd_tls = -1;
+   for (i = 0; i < ntls; i++)
+   close(fd_tls[i]);
+   free(fd_tls);
+   fd_tls = NULL;
+   free(tls_host);
+   free(tls_port);
+   tls_host = tls_port = NULL;
+   ntls = 0;
}
}
}
@@ -618,7 +627,7 @@ main(int argc, char *argv[])
const char *names[2];
 
  

Re: arm64 ieee.h

2017-04-16 Thread Patrick Wildt
On Sun, Apr 16, 2017 at 05:52:54PM +0200, Mark Kettenis wrote:
> Like mips64 and sparc64, the 128-bit long double floating point format
> needs the EXT_IMPLICIT_NBIT define.  This fixes the lib/libc/printf
> regress test.
> 
> While there, remove struct ieee_ldouble, which isn't used and doesn't
> exist on other architectures.
> 
> ok?

ok patrick@

> 
> 
> Index: arch/arm64/include/ieee.h
> ===
> RCS file: /cvs/src/sys/arch/arm64/include/ieee.h,v
> retrieving revision 1.2
> diff -u -p -r1.2 ieee.h
> --- arch/arm64/include/ieee.h 11 Jan 2017 00:18:22 -  1.2
> +++ arch/arm64/include/ieee.h 16 Apr 2017 14:26:33 -
> @@ -90,6 +90,8 @@
>  #define  EXT_FRACLBITS   32
>  #define  EXT_FRACBITS112
>  
> +#define  EXT_IMPLICIT_NBIT
> +
>  #define  EXT_TO_ARRAY32(p, a) do {   \
>   (a)[0] = (uint32_t)(p)->ext_fracl;  \
>   (a)[1] = (uint32_t)(p)->ext_fraclm; \
> @@ -108,13 +110,6 @@ struct ieee_double {
>   u_int   dbl_frach:20;
>   u_int   dbl_exp:11;
>   u_int   dbl_sign:1;
> -};
> -
> -struct ieee_ldouble {
> - u_long  ldbl_fracl;
> - u_long  ldbl_frach:20;
> - u_int   ldbl_exp:11;
> - u_int   ldbl_sign:1;
>  };
>  
>  struct ieee_ext {
> 



Re: show correct vltime/pltime when setting with ifconfig(8)

2017-04-16 Thread Alexander Bluhm
On Sat, Apr 08, 2017 at 04:55:23PM +, Florian Obser wrote:
> We need to update the ia6_updatetime when changing the vltime/pltime
> vio ioctl(2). Otherwise ifconfig shows the wrong times since
> vltime/pltime are calculated from this value on export.
> 
> The handling of router advertisements does the right thing.
> 
> OK?

Maybe you don't want to set ia6_updatetime in the "if (ia6 == NULL)
{" block then.

anyway OK bluhm@

> 
> p.s. I don't think this worked ever, but if you want to suggest to
> remove the ioctls, uhm, no. I need them for slaacd...
> 
> diff --git in6.c in6.c
> index 5aaef3b515b..e052adad4c8 100644
> --- in6.c
> +++ in6.c
> @@ -665,6 +665,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq 
> *ifra,
>* to see if the address is deprecated or invalidated, but initialize
>* these members for applications.
>*/
> + ia6->ia6_updatetime = time_uptime;
>   ia6->ia6_lifetime = ifra->ifra_lifetime;
>   if (ia6->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
>   ia6->ia6_lifetime.ia6t_expire =
> 
> 
> -- 
> I'm not entirely sure you are real.



Re: show correct vltime/pltime when setting with ifconfig(8)

2017-04-16 Thread Florian Obser
anyone?

On Sat, Apr 08, 2017 at 04:55:23PM +, Florian Obser wrote:
> 
> We need to update the ia6_updatetime when changing the vltime/pltime
> vio ioctl(2). Otherwise ifconfig shows the wrong times since
> vltime/pltime are calculated from this value on export.
> 
> The handling of router advertisements does the right thing.
> 
> OK?
> 
> p.s. I don't think this worked ever, but if you want to suggest to
> remove the ioctls, uhm, no. I need them for slaacd...
> 
> diff --git in6.c in6.c
> index 5aaef3b515b..e052adad4c8 100644
> --- in6.c
> +++ in6.c
> @@ -665,6 +665,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq 
> *ifra,
>* to see if the address is deprecated or invalidated, but initialize
>* these members for applications.
>*/
> + ia6->ia6_updatetime = time_uptime;
>   ia6->ia6_lifetime = ifra->ifra_lifetime;
>   if (ia6->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
>   ia6->ia6_lifetime.ia6t_expire =
> 
> 
> -- 
> I'm not entirely sure you are real.
> 

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



check af in rip_input

2017-04-16 Thread Alexander Bluhm
Hi,

The raw ip input functions are called from several places, so I
think a check that the address family is correct, is justified.

ok?

bluhm

Index: netinet/raw_ip.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/raw_ip.c,v
retrieving revision 1.98
diff -u -p -r1.98 raw_ip.c
--- netinet/raw_ip.c14 Apr 2017 20:46:31 -  1.98
+++ netinet/raw_ip.c16 Apr 2017 16:13:42 -
@@ -125,6 +125,8 @@ rip_input(struct mbuf **mp, int *offp, i
struct counters_ref ref;
uint64_t *counters;
 
+   KASSERT(af == AF_INET);
+
ripsrc.sin_addr = ip->ip_src;
TAILQ_FOREACH(inp, _queue, inp_queue) {
if (inp->inp_socket->so_state & SS_CANTRCVMORE)
Index: netinet6/raw_ip6.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/raw_ip6.c,v
retrieving revision 1.109
diff -u -p -r1.109 raw_ip6.c
--- netinet6/raw_ip6.c  14 Apr 2017 20:46:31 -  1.109
+++ netinet6/raw_ip6.c  16 Apr 2017 16:15:24 -
@@ -125,6 +125,8 @@ rip6_input(struct mbuf **mp, int *offp, 
struct sockaddr_in6 rip6src;
struct mbuf *opts = NULL;
 
+   KASSERT(af == AF_INET6);
+
rip6stat_inc(rip6s_ipackets);
 
/* Be proactive about malicious use of IPv4 mapped address */



use af in tcp_input

2017-04-16 Thread Alexander Bluhm
Hi,

Simplify tcp_input() by using the address family passed by pr_input.

ok?

bluhm

Index: netinet/tcp_input.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/tcp_input.c,v
retrieving revision 1.339
diff -u -p -r1.339 tcp_input.c
--- netinet/tcp_input.c 14 Apr 2017 20:46:31 -  1.339
+++ netinet/tcp_input.c 16 Apr 2017 15:44:55 -
@@ -359,7 +359,7 @@ tcp_input(struct mbuf **mp, int *offp, i
 {
struct mbuf *m = *mp;
int iphlen = *offp;
-   struct ip *ip;
+   struct ip *ip = NULL;
struct inpcb *inp = NULL;
u_int8_t *optp = NULL;
int optlen = 0;
@@ -399,51 +399,9 @@ tcp_input(struct mbuf **mp, int *offp, i
goto drop;
 
/*
-* Before we do ANYTHING, we have to figure out if it's TCP/IPv6 or
-* TCP/IPv4.
-*/
-   switch (mtod(m, struct ip *)->ip_v) {
-#ifdef INET6
-   case 6:
-   af = AF_INET6;
-   break;
-#endif
-   case 4:
-   af = AF_INET;
-   break;
-   default:
-   m_freem(m);
-   return IPPROTO_DONE;
-   }
-
-   /*
 * Get IP and TCP header together in first mbuf.
 * Note: IP leaves IP header in first mbuf.
 */
-   switch (af) {
-   case AF_INET:
-#ifdef DIAGNOSTIC
-   if (iphlen < sizeof(struct ip)) {
-   m_freem(m);
-   return IPPROTO_DONE;
-   }
-#endif /* DIAGNOSTIC */
-   break;
-#ifdef INET6
-   case AF_INET6:
-#ifdef DIAGNOSTIC
-   if (iphlen < sizeof(struct ip6_hdr)) {
-   m_freem(m);
-   return IPPROTO_DONE;
-   }
-#endif /* DIAGNOSTIC */
-   break;
-#endif
-   default:
-   m_freem(m);
-   return IPPROTO_DONE;
-   }
-
IP6_EXTHDR_GET(th, struct tcphdr *, m, iphlen, sizeof(*th));
if (!th) {
tcpstat_inc(tcps_rcvshort);
@@ -451,10 +409,6 @@ tcp_input(struct mbuf **mp, int *offp, i
}
 
tlen = m->m_pkthdr.len - iphlen;
-   ip = NULL;
-#ifdef INET6
-   ip6 = NULL;
-#endif
switch (af) {
case AF_INET:
ip = mtod(m, struct ip *);
@@ -497,6 +451,8 @@ tcp_input(struct mbuf **mp, int *offp, i
}
break;
 #endif
+   default:
+   unhandled_af(af);
}
 
/*



Re: start building clang alongside gcc on amd64

2017-04-16 Thread Mark Kettenis
> Date: Mon, 17 Apr 2017 01:49:18 +1000
> From: Jonathan Gray 
> 
> On Sun, Apr 16, 2017 at 11:15:55AM +0200, Mark Kettenis wrote:
> > Here is my current diff to build clang alongside gcc.  The idea is
> > that if you add an architecture to both CLANG_ARCH and GCC4_ARCH, both
> > compilers get built, but gcc remains the default compiler.  It forces
> > the clang-related libraries (libcompiler_rt, libc++abi, libc++) to be
> > built with clang.
> > 
> > You'll need to bootstrap clang with the ports gcc before you can do a
> > make build.  This is done using:
> > 
> > # pkg_add g++
> > # cd /usr/src/gnu/usr.bin/clang
> > # make obj
> > # make BOOTSTRAP_CLANG=yes
> > # make install
> > 
> > Thoughts?  ok?  If we don't want to start building clang on amd64 just
> > yet, I can leave GCC4_ARCHS empty for now.
> 
> Having a GCC4_ARCH list without all the gcc4 archs is a bit strange.
> It is more along the lines of ALSO_CLANG.

Well, we could add all gcc4 architectures to GCC4_ARCH if that makes
you happier.  All the architecture list variables end with _ARCH,
that's why I came up with this solution.

> The tests added to the clang directories are for if /usr/bin/c++
> can't do c++11.  Maybe we could define variables in the makefiles
> to indicate this before bsd.own.mk is included and then adjust
> CC and CXX in bsd.own.mk if it is set and COMPILER_VERSION is gcc3
> or gcc4?

Is that worth the trouble?  Eventaully these chacks will disappear
again.

> I don't see the point in keeping the BOOTSTRAP_CLANG parts,
> if CC and CXX are already being overridden isn't just installing
> ports clang going to be enough assuming /usr/local/bin is in PATH?

Bootstrapping with ports clang doesn't work.  It triggers some
incompatibility between clang and the ports libstdc++.

> > Index: gnu/usr.bin/Makefile
> > ===
> > RCS file: /cvs/src/gnu/usr.bin/Makefile,v
> > retrieving revision 1.58
> > diff -u -p -r1.58 Makefile
> > --- gnu/usr.bin/Makefile20 Feb 2017 01:00:26 -  1.58
> > +++ gnu/usr.bin/Makefile15 Apr 2017 12:06:10 -
> > @@ -10,7 +10,8 @@ SUBDIR+=  cc clang gcc
> >  SUBDIR+=   gcc
> >  .  elif ${COMPILER_VERSION:L} == "gcc4"
> >  SUBDIR+=   cc
> > -.  elif ${COMPILER_VERSION:L} == "clang"
> > +.  endif
> > +.  if ${BUILD_CLANG} == "yes"
> >  SUBDIR+=   clang
> >  .  endif
> >  .endif
> > Index: gnu/usr.bin/clang/Makefile.inc
> > ===
> > RCS file: /cvs/src/gnu/usr.bin/clang/Makefile.inc,v
> > retrieving revision 1.4
> > diff -u -p -r1.4 Makefile.inc
> > --- gnu/usr.bin/clang/Makefile.inc  16 Feb 2017 02:08:42 -  1.4
> > +++ gnu/usr.bin/clang/Makefile.inc  27 Mar 2017 15:56:49 -
> > @@ -2,6 +2,11 @@
> >  
> >  LLVM_SRCS?=${.CURDIR}/../../../llvm
> >  
> > +.if ${COMPILER_VERSION:L} != "clang"
> > +CC=clang
> > +CXX=   clang++
> > +.endif
> > +
> >  BOOTSTRAP_CLANG?=no
> >  .if ${BOOTSTRAP_CLANG} == "yes"
> >  CC=egcc
> > Index: lib/libcompiler_rt/Makefile
> > ===
> > RCS file: /cvs/src/lib/libcompiler_rt/Makefile,v
> > retrieving revision 1.6
> > diff -u -p -r1.6 Makefile
> > --- lib/libcompiler_rt/Makefile 9 Apr 2017 21:47:05 -   1.6
> > +++ lib/libcompiler_rt/Makefile 15 Apr 2017 12:14:38 -
> > @@ -2,7 +2,12 @@
> >  
> >  .include 
> >  
> > -.if ${COMPILER_VERSION:L} == "clang"
> > +.if ${COMPILER_VERSION:L} != "clang"
> > +CC=clang
> > +CXX=   clang++
> > +.endif
> > +
> > +.if ${BUILD_CLANG} == "yes"
> >  
> >  LIB=   compiler_rt
> >  NOPIC=
> > Index: lib/libcxx/Makefile
> > ===
> > RCS file: /cvs/src/lib/libcxx/Makefile,v
> > retrieving revision 1.5
> > diff -u -p -r1.5 Makefile
> > --- lib/libcxx/Makefile 16 Feb 2017 02:08:42 -  1.5
> > +++ lib/libcxx/Makefile 15 Apr 2017 12:04:11 -
> > @@ -2,7 +2,12 @@
> >  
> >  .include 
> >  
> > -.if ${COMPILER_VERSION:L} == "clang"
> > +.if ${COMPILER_VERSION:L} != "clang"
> > +CC=clang
> > +CXX=   clang++
> > +.endif
> > +
> > +.if ${BUILD_CLANG} == "yes"
> >  
> >  HDRDIR=${.CURDIR}/include
> >  SRCDIR=${.CURDIR}/src
> > Index: lib/libcxxabi/Makefile
> > ===
> > RCS file: /cvs/src/lib/libcxxabi/Makefile,v
> > retrieving revision 1.7
> > diff -u -p -r1.7 Makefile
> > --- lib/libcxxabi/Makefile  6 Apr 2017 09:28:29 -   1.7
> > +++ lib/libcxxabi/Makefile  15 Apr 2017 12:00:40 -
> > @@ -2,7 +2,12 @@
> >  
> >  .include 
> >  
> > -.if ${COMPILER_VERSION:L} == "clang"
> > +.if ${COMPILER_VERSION:L} != "clang"
> > +CC=clang
> > +CXX=   clang++
> > +.endif
> > +
> > +.if ${BUILD_CLANG} == "yes"
> >  
> >  

arm64 ieee.h

2017-04-16 Thread Mark Kettenis
Like mips64 and sparc64, the 128-bit long double floating point format
needs the EXT_IMPLICIT_NBIT define.  This fixes the lib/libc/printf
regress test.

While there, remove struct ieee_ldouble, which isn't used and doesn't
exist on other architectures.

ok?


Index: arch/arm64/include/ieee.h
===
RCS file: /cvs/src/sys/arch/arm64/include/ieee.h,v
retrieving revision 1.2
diff -u -p -r1.2 ieee.h
--- arch/arm64/include/ieee.h   11 Jan 2017 00:18:22 -  1.2
+++ arch/arm64/include/ieee.h   16 Apr 2017 14:26:33 -
@@ -90,6 +90,8 @@
 #defineEXT_FRACLBITS   32
 #defineEXT_FRACBITS112
 
+#defineEXT_IMPLICIT_NBIT
+
 #defineEXT_TO_ARRAY32(p, a) do {   \
(a)[0] = (uint32_t)(p)->ext_fracl;  \
(a)[1] = (uint32_t)(p)->ext_fraclm; \
@@ -108,13 +110,6 @@ struct ieee_double {
u_int   dbl_frach:20;
u_int   dbl_exp:11;
u_int   dbl_sign:1;
-};
-
-struct ieee_ldouble {
-   u_long  ldbl_fracl;
-   u_long  ldbl_frach:20;
-   u_int   ldbl_exp:11;
-   u_int   ldbl_sign:1;
 };
 
 struct ieee_ext {



Re: start building clang alongside gcc on amd64

2017-04-16 Thread Jonathan Gray
On Sun, Apr 16, 2017 at 11:15:55AM +0200, Mark Kettenis wrote:
> Here is my current diff to build clang alongside gcc.  The idea is
> that if you add an architecture to both CLANG_ARCH and GCC4_ARCH, both
> compilers get built, but gcc remains the default compiler.  It forces
> the clang-related libraries (libcompiler_rt, libc++abi, libc++) to be
> built with clang.
> 
> You'll need to bootstrap clang with the ports gcc before you can do a
> make build.  This is done using:
> 
> # pkg_add g++
> # cd /usr/src/gnu/usr.bin/clang
> # make obj
> # make BOOTSTRAP_CLANG=yes
> # make install
> 
> Thoughts?  ok?  If we don't want to start building clang on amd64 just
> yet, I can leave GCC4_ARCHS empty for now.

Having a GCC4_ARCH list without all the gcc4 archs is a bit strange.
It is more along the lines of ALSO_CLANG.

The tests added to the clang directories are for if /usr/bin/c++
can't do c++11.  Maybe we could define variables in the makefiles
to indicate this before bsd.own.mk is included and then adjust
CC and CXX in bsd.own.mk if it is set and COMPILER_VERSION is gcc3
or gcc4?

I don't see the point in keeping the BOOTSTRAP_CLANG parts,
if CC and CXX are already being overridden isn't just installing
ports clang going to be enough assuming /usr/local/bin is in PATH?

> 
> 
> Index: gnu/usr.bin/Makefile
> ===
> RCS file: /cvs/src/gnu/usr.bin/Makefile,v
> retrieving revision 1.58
> diff -u -p -r1.58 Makefile
> --- gnu/usr.bin/Makefile  20 Feb 2017 01:00:26 -  1.58
> +++ gnu/usr.bin/Makefile  15 Apr 2017 12:06:10 -
> @@ -10,7 +10,8 @@ SUBDIR+=cc clang gcc
>  SUBDIR+= gcc
>  .  elif ${COMPILER_VERSION:L} == "gcc4"
>  SUBDIR+= cc
> -.  elif ${COMPILER_VERSION:L} == "clang"
> +.  endif
> +.  if ${BUILD_CLANG} == "yes"
>  SUBDIR+= clang
>  .  endif
>  .endif
> Index: gnu/usr.bin/clang/Makefile.inc
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/Makefile.inc,v
> retrieving revision 1.4
> diff -u -p -r1.4 Makefile.inc
> --- gnu/usr.bin/clang/Makefile.inc16 Feb 2017 02:08:42 -  1.4
> +++ gnu/usr.bin/clang/Makefile.inc27 Mar 2017 15:56:49 -
> @@ -2,6 +2,11 @@
>  
>  LLVM_SRCS?=  ${.CURDIR}/../../../llvm
>  
> +.if ${COMPILER_VERSION:L} != "clang"
> +CC=  clang
> +CXX= clang++
> +.endif
> +
>  BOOTSTRAP_CLANG?=no
>  .if ${BOOTSTRAP_CLANG} == "yes"
>  CC=  egcc
> Index: lib/libcompiler_rt/Makefile
> ===
> RCS file: /cvs/src/lib/libcompiler_rt/Makefile,v
> retrieving revision 1.6
> diff -u -p -r1.6 Makefile
> --- lib/libcompiler_rt/Makefile   9 Apr 2017 21:47:05 -   1.6
> +++ lib/libcompiler_rt/Makefile   15 Apr 2017 12:14:38 -
> @@ -2,7 +2,12 @@
>  
>  .include 
>  
> -.if ${COMPILER_VERSION:L} == "clang"
> +.if ${COMPILER_VERSION:L} != "clang"
> +CC=  clang
> +CXX= clang++
> +.endif
> +
> +.if ${BUILD_CLANG} == "yes"
>  
>  LIB= compiler_rt
>  NOPIC=
> Index: lib/libcxx/Makefile
> ===
> RCS file: /cvs/src/lib/libcxx/Makefile,v
> retrieving revision 1.5
> diff -u -p -r1.5 Makefile
> --- lib/libcxx/Makefile   16 Feb 2017 02:08:42 -  1.5
> +++ lib/libcxx/Makefile   15 Apr 2017 12:04:11 -
> @@ -2,7 +2,12 @@
>  
>  .include 
>  
> -.if ${COMPILER_VERSION:L} == "clang"
> +.if ${COMPILER_VERSION:L} != "clang"
> +CC=  clang
> +CXX= clang++
> +.endif
> +
> +.if ${BUILD_CLANG} == "yes"
>  
>  HDRDIR=  ${.CURDIR}/include
>  SRCDIR=  ${.CURDIR}/src
> Index: lib/libcxxabi/Makefile
> ===
> RCS file: /cvs/src/lib/libcxxabi/Makefile,v
> retrieving revision 1.7
> diff -u -p -r1.7 Makefile
> --- lib/libcxxabi/Makefile6 Apr 2017 09:28:29 -   1.7
> +++ lib/libcxxabi/Makefile15 Apr 2017 12:00:40 -
> @@ -2,7 +2,12 @@
>  
>  .include 
>  
> -.if ${COMPILER_VERSION:L} == "clang"
> +.if ${COMPILER_VERSION:L} != "clang"
> +CC=  clang
> +CXX= clang++
> +.endif
> +
> +.if ${BUILD_CLANG} == "yes"
>  
>  HDRDIR=  ${.CURDIR}/include
>  SRCDIR=  ${.CURDIR}/src
> Index: share/mk/bsd.own.mk
> ===
> RCS file: /cvs/src/share/mk/bsd.own.mk,v
> retrieving revision 1.182
> diff -u -p -r1.182 bsd.own.mk
> --- share/mk/bsd.own.mk   18 Dec 2016 17:02:21 -  1.182
> +++ share/mk/bsd.own.mk   15 Apr 2017 11:58:41 -
> @@ -15,7 +15,8 @@ SKEY?=  yes
>  # Set `YP' to `yes' to build with support for NIS/YP.
>  YP?= yes
>  
> -CLANG_ARCH=aarch64
> +CLANG_ARCH=aarch64 amd64
> +GCC4_ARCH=amd64
>  GCC3_ARCH=m88k
>  
>  # m88k: ?
> @@ -23,12 +24,20 @@ PIE_ARCH=alpha amd64 arm hppa i386 mips6
>  STATICPIE_ARCH=alpha amd64 arm 

use af in udp_input

2017-04-16 Thread Alexander Bluhm
Hi,

As we have the address family in pr_input now, udp_input can be
simplified.

ok?

bluhm

Index: netinet/udp_usrreq.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/udp_usrreq.c,v
retrieving revision 1.234
diff -u -p -r1.234 udp_usrreq.c
--- netinet/udp_usrreq.c14 Apr 2017 20:46:31 -  1.234
+++ netinet/udp_usrreq.c16 Apr 2017 15:25:43 -
@@ -152,7 +152,7 @@ udp_input(struct mbuf **mp, int *offp, i
 {
struct mbuf *m = *mp;
int iphlen = *offp;
-   struct ip *ip;
+   struct ip *ip = NULL;
struct udphdr *uh;
struct inpcb *inp = NULL;
struct mbuf *opts = NULL;
@@ -167,7 +167,7 @@ udp_input(struct mbuf **mp, int *offp, i
 #endif /* INET6 */
} srcsa, dstsa;
 #ifdef INET6
-   struct ip6_hdr *ip6;
+   struct ip6_hdr *ip6 = NULL;
 #endif /* INET6 */
 #ifdef IPSEC
struct m_tag *mtag;
@@ -181,31 +181,6 @@ udp_input(struct mbuf **mp, int *offp, i
 
udpstat_inc(udps_ipackets);
 
-   switch (mtod(m, struct ip *)->ip_v) {
-   case 4:
-   ip = mtod(m, struct ip *);
-#ifdef INET6
-   ip6 = NULL;
-#endif /* INET6 */
-   srcsa.sa.sa_family = AF_INET;
-#ifdef IPSEC
-   protoff = offsetof(struct ip, ip_p);
-#endif /* IPSEC */
-   break;
-#ifdef INET6
-   case 6:
-   ip = NULL;
-   ip6 = mtod(m, struct ip6_hdr *);
-   srcsa.sa.sa_family = AF_INET6;
-#ifdef IPSEC
-   protoff = offsetof(struct ip6_hdr, ip6_nxt);
-#endif /* IPSEC */
-   break;
-#endif /* INET6 */
-   default:
-   goto bad;
-   }
-
IP6_EXTHDR_GET(uh, struct udphdr *, m, iphlen, sizeof(struct udphdr));
if (!uh) {
udpstat_inc(udps_hdrops);
@@ -223,7 +198,8 @@ udp_input(struct mbuf **mp, int *offp, i
 * If not enough data to reflect UDP length, drop.
 */
len = ntohs((u_int16_t)uh->uh_ulen);
-   if (ip) {
+   switch (af) {
+   case AF_INET:
if (m->m_pkthdr.len - iphlen != len) {
if (len > (m->m_pkthdr.len - iphlen) ||
len < sizeof(struct udphdr)) {
@@ -232,9 +208,15 @@ udp_input(struct mbuf **mp, int *offp, i
}
m_adj(m, len - (m->m_pkthdr.len - iphlen));
}
-   }
+   ip = mtod(m, struct ip *);
+   /*
+* Save a copy of the IP header in case we want restore it
+* for sending an ICMP error message in response.
+*/
+   save_ip = *ip;
+   break;
 #ifdef INET6
-   else if (ip6) {
+   case AF_INET6:
/* jumbograms */
if (len == 0 && m->m_pkthdr.len - iphlen > 0x)
len = m->m_pkthdr.len - iphlen;
@@ -242,28 +224,18 @@ udp_input(struct mbuf **mp, int *offp, i
udpstat_inc(udps_badlen);
goto bad;
}
-   }
-#endif
-   else /* shouldn't happen */
-   goto bad;
-
-   /*
-* Save a copy of the IP header in case we want restore it
-* for sending an ICMP error message in response.
-*/
-   if (ip)
-   save_ip = *ip;
-
-#ifdef INET6
-   if (ip6) {
+   ip6 = mtod(m, struct ip6_hdr *);
/* Be proactive about malicious use of IPv4 mapped address */
if (IN6_IS_ADDR_V4MAPPED(>ip6_src) ||
IN6_IS_ADDR_V4MAPPED(>ip6_dst)) {
/* XXX stat */
goto bad;
}
-   }
+   break;
 #endif /* INET6 */
+   default:
+   unhandled_af(af);
+   }
 
/*
 * Checksum extended UDP header and data.
@@ -335,14 +307,16 @@ udp_input(struct mbuf **mp, int *offp, i
skip -= sizeof(struct udphdr);
 
espstat.esps_udpencin++;
+   protoff = af == AF_INET ? offsetof(struct ip, ip_p) :
+   offsetof(struct ip6_hdr, ip6_nxt);
ipsec_common_input(m, skip, protoff,
-   srcsa.sa.sa_family, IPPROTO_ESP, 1);
+   af, IPPROTO_ESP, 1);
return IPPROTO_DONE;
}
}
 #endif
 
-   switch (srcsa.sa.sa_family) {
+   switch (af) {
case AF_INET:
bzero(, sizeof(struct sockaddr_in));
srcsa.sin.sin_len = sizeof(struct sockaddr_in);
@@ -621,7 +595,7 @@ udp_input(struct mbuf **mp, int *offp, i
>dst, tdbi->proto);
} else
tdb = NULL;
-   ipsp_spd_lookup(m, srcsa.sa.sa_family, iphlen, ,
+   ipsp_spd_lookup(m, af, iphlen, ,
IPSP_DIRECTION_IN, tdb, inp, 0);

Re: Noob looking to work on HDMI audio integration

2017-04-16 Thread Tanel Kriik
On Sun, Apr 16, 2017 at 5:54 PM, Jonathan Gray  wrote:
> The hdmi codecs were disabled in azalia as non working audio devices
> would attach as audio0 with the real audio device attaching as audio1.
> This meant symlinks in /dev had to change or programs had to explicitly
> use /dev/audio1 etc instead of /dev/audio.

I see. Could azalia determine which codecs work and which do not
at the time of attachment? Alternatively, would it be reasonable
to prefer codects in order of: 1. analog, 2. digital and 3. HDMI
during attachment, instead of skipping HDMI altogether?



Re: Noob looking to work on HDMI audio integration

2017-04-16 Thread Jonathan Gray
On Sun, Apr 16, 2017 at 05:04:49PM +0300, Tanel Kriik wrote:
> Hi, total newbie here:
> 
> I have intermediate C experience from work and free time,
> and use OpenBSD more or less often.
> I'm familiar with the OpenBSD coding style and have compiled the
> kernel a few times,
> but I haven't dabbled deeper than that.
> 
> Areas I'm surely lacking in:
> 
> * Audio processing (only know the basics of DSP)
> * Drivers
> * OpenBSD development workflow (modify, compile, test cycle - how do you do 
> it?)
> 
> I guess I'd need to at least get to know the azalia(4) driver and how
> it interfaces with
> lower-level drivers in the system?
> 
> On the other hand, if it was easy, then someone would've already done it?
> 
> I'd like to hear from more experienced people here if this would be at least
> realistically doable by someone at my level.
> Has this been attempted before but stopped due to some inherent obstacles?
> 
> I browsed azalia.c and found that for some reason HDMI codecs are disabled,
> but I don't remember seeing an exact explanation as to why it was done from 
> the
> CVS logs (might have overlooked something though). Does it have something
> to do with the internal mixers in graphics cards or something similar?
> 
> Thanks
> 

The hdmi codecs were disabled in azalia as non working audio devices
would attach as audio0 with the real audio device attaching as audio1.
This meant symlinks in /dev had to change or programs had to explicitly
use /dev/audio1 etc instead of /dev/audio.



Noob looking to work on HDMI audio integration

2017-04-16 Thread Tanel Kriik
Hi, total newbie here:

I have intermediate C experience from work and free time,
and use OpenBSD more or less often.
I'm familiar with the OpenBSD coding style and have compiled the
kernel a few times,
but I haven't dabbled deeper than that.

Areas I'm surely lacking in:

* Audio processing (only know the basics of DSP)
* Drivers
* OpenBSD development workflow (modify, compile, test cycle - how do you do it?)

I guess I'd need to at least get to know the azalia(4) driver and how
it interfaces with
lower-level drivers in the system?

On the other hand, if it was easy, then someone would've already done it?

I'd like to hear from more experienced people here if this would be at least
realistically doable by someone at my level.
Has this been attempted before but stopped due to some inherent obstacles?

I browsed azalia.c and found that for some reason HDMI codecs are disabled,
but I don't remember seeing an exact explanation as to why it was done from the
CVS logs (might have overlooked something though). Does it have something
to do with the internal mixers in graphics cards or something similar?

Thanks



vi NULL check before free()

2017-04-16 Thread Michael W. Bombardieri
Hi,

Remove some checks for NULL around free() in vi.
vi still sees to work when I build it on i386 and amd64.

- Michael


Index: cl/cl_screen.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_screen.c,v
retrieving revision 1.27
diff -u -p -u -r1.27 cl_screen.c
--- cl/cl_screen.c  28 May 2016 18:30:35 -  1.27
+++ cl/cl_screen.c  16 Apr 2017 13:06:45 -
@@ -434,14 +434,10 @@ cl_ex_init(SCR *sp)
 
/* Enter_standout_mode and exit_standout_mode are paired. */
if (clp->smso == NULL || clp->rmso == NULL) {
-   if (clp->smso != NULL) {
-   free(clp->smso);
-   clp->smso = NULL;
-   }
-   if (clp->rmso != NULL) {
-   free(clp->rmso);
-   clp->rmso = NULL;
-   }
+   free(clp->smso);
+   clp->smso = NULL;
+   free(clp->rmso);
+   clp->rmso = NULL;
}
 
/*
@@ -515,26 +511,16 @@ cl_getcap(SCR *sp, char *name, char **el
 static void
 cl_freecap(CL_PRIVATE *clp)
 {
-   if (clp->el != NULL) {
-   free(clp->el);
-   clp->el = NULL;
-   }
-   if (clp->cup != NULL) {
-   free(clp->cup);
-   clp->cup = NULL;
-   }
-   if (clp->cuu1 != NULL) {
-   free(clp->cuu1);
-   clp->cuu1 = NULL;
-   }
-   if (clp->rmso != NULL) {
-   free(clp->rmso);
-   clp->rmso = NULL;
-   }
-   if (clp->smso != NULL) {
-   free(clp->smso);
-   clp->smso = NULL;
-   }
+   free(clp->el);
+   clp->el = NULL;
+   free(clp->cup);
+   clp->cup = NULL;
+   free(clp->cuu1);
+   clp->cuu1 = NULL;
+   free(clp->rmso);
+   clp->rmso = NULL;
+   free(clp->smso);
+   clp->smso = NULL;
 }
 
 /*
Index: common/cut.c
===
RCS file: /cvs/src/usr.bin/vi/common/cut.c,v
retrieving revision 1.16
diff -u -p -u -r1.16 cut.c
--- common/cut.c27 May 2016 09:18:11 -  1.16
+++ common/cut.c16 Apr 2017 13:06:45 -
@@ -343,7 +343,6 @@ text_lfree(TEXTH *headp)
 void
 text_free(TEXT *tp)
 {
-   if (tp->lb != NULL)
-   free(tp->lb);
+   free(tp->lb);
free(tp);
 }
Index: common/exf.c
===
RCS file: /cvs/src/usr.bin/vi/common/exf.c,v
retrieving revision 1.44
diff -u -p -u -r1.44 exf.c
--- common/exf.c1 Aug 2016 18:27:35 -   1.44
+++ common/exf.c16 Apr 2017 13:06:46 -
@@ -76,8 +76,7 @@ file_add(SCR *sp, CHAR_T *name)
TAILQ_FOREACH_SAFE(frp, >frefq, q, tfrp) {
if (frp->name == NULL) {
TAILQ_REMOVE(>frefq, frp, q);
-   if (frp->name != NULL)
-   free(frp->name);
+   free(frp->name);
free(frp);
continue;
}
@@ -197,8 +196,7 @@ file_init(SCR *sp, FREF *frp, char *rcv_
F_SET(frp, FR_TMPFILE);
if ((frp->tname = strdup(tname)) == NULL ||
(frp->name == NULL && (frp->name = strdup(tname)) == NULL)) 
{
-   if (frp->tname != NULL)
-   free(frp->tname);
+   free(frp->tname);
msgq(sp, M_SYSERR, NULL);
(void)unlink(tname);
goto err;
@@ -410,10 +408,9 @@ file_init(SCR *sp, FREF *frp, char *rcv_
 
return (0);
 
-err:   if (frp->name != NULL) {
-   free(frp->name);
-   frp->name = NULL;
-   }
+err:
+   free(frp->name);
+   frp->name = NULL;
if (frp->tname != NULL) {
(void)unlink(frp->tname);
free(frp->tname);
@@ -422,10 +419,8 @@ err:   if (frp->name != NULL) {
 
 oerr:  if (F_ISSET(ep, F_RCV_ON))
(void)unlink(ep->rcv_path);
-   if (ep->rcv_path != NULL) {
-   free(ep->rcv_path);
-   ep->rcv_path = NULL;
-   }
+   free(ep->rcv_path);
+   ep->rcv_path = NULL;
if (ep->db != NULL)
(void)ep->db->close(ep->db);
free(ep);
@@ -659,8 +654,7 @@ file_end(SCR *sp, EXF *ep, int force)
frp->tname = NULL;
if (F_ISSET(frp, FR_TMPFILE)) {
TAILQ_REMOVE(>gp->frefq, frp, q);
-   if (frp->name != NULL)
-   free(frp->name);
+   free(frp->name);
free(frp);
}
sp->frp = NULL;
@@ -704,11 +698,8 @@ file_end(SCR *sp, EXF *ep, int force)

Re: arm64 _longjmp fix

2017-04-16 Thread Jonathan Gray
On Sun, Apr 16, 2017 at 12:27:51PM +0200, Mark Kettenis wrote:
> We fixed longjmp(), but left _longjmp() alone.  In this case the
> return code is still in w1 so the fix is slightly different.  Makes
> the longjmp regress test pass on arm64.
> 
> ok?

ok jsg@

> 
> 
> Index: lib/libc/arch/aarch64/gen/_setjmp.S
> ===
> RCS file: /cvs/src/lib/libc/arch/aarch64/gen/_setjmp.S,v
> retrieving revision 1.1
> diff -u -p -r1.1 _setjmp.S
> --- lib/libc/arch/aarch64/gen/_setjmp.S   11 Jan 2017 18:09:24 -  
> 1.1
> +++ lib/libc/arch/aarch64/gen/_setjmp.S   16 Apr 2017 10:25:24 -
> @@ -91,7 +91,8 @@ ENTRY(_longjmp)
>  #endif
>  
>   /* Load the return value */
> - mov x0, x1
> + cmp w1, #0
> + csinc   w0, w1, wzr, ne
>   ret
>  
>  botch:
> 



Fix regress/lib/libc/db

2017-04-16 Thread Mark Kettenis
The db-3 subtest fails on 64-bit systems (and has been failing for a
long time, maybe forever?).  The problem is that (off_t)SIZE_MAX
becomes -1, so the

if (sb.st_size > (off_t)SIZE_MAX)

condition is always true.  Since we pass (int)sb.st_size to read(2), I
think checking for INT_MAX is the easiest way to fix this test.  If we
ever put a >2G binary in /bin, we're in deep trouble anyway.

ok?


Index: regress/lib/libc/db/dbtest.c
===
RCS file: /cvs/src/regress/lib/libc/db/dbtest.c,v
retrieving revision 1.14
diff -u -p -r1.14 dbtest.c
--- regress/lib/libc/db/dbtest.c23 Oct 2015 18:47:21 -  1.14
+++ regress/lib/libc/db/dbtest.c16 Apr 2017 12:50:41 -
@@ -685,7 +685,7 @@ rfile(name, lenp)
if ((fd = open(name, O_RDONLY, 0)) < 0 ||
fstat(fd, ))
dberr("%s: %s\n", name, strerror(errno));
-   if (sb.st_size > (off_t)SIZE_MAX)
+   if (sb.st_size > (off_t)INT_MAX)
dberr("%s: %s\n", name, strerror(E2BIG));
if ((p = (void *)malloc((u_int)sb.st_size)) == NULL)
dberr("%s", strerror(errno));



dnsmasq/IP_SENDSRCADDR [st...@openbsd.org: CVS: cvs.openbsd.org: ports]

2017-04-16 Thread Stuart Henderson
Anyone have ideas about this?


- Forwarded message from Stuart Henderson  -

From: Stuart Henderson 
Date: Sun, 16 Apr 2017 04:41:10 -0600 (MDT)
To: ports-chan...@openbsd.org
Subject: CVS: cvs.openbsd.org: ports

CVSROOT:/cvs
Module name:ports
Changes by: st...@cvs.openbsd.org   2017/04/16 04:41:10

Modified files:
net/dnsmasq: Tag: OPENBSD_6_1 Makefile 
Added files:
net/dnsmasq/patches: Tag: OPENBSD_6_1 patch-src_dnsmasq_c 
 patch-src_forward_c 

Log message:
MFC: Disable use of IP_SENDSRCADDR in dnsmasq for now, for some
yet-to-be-determined reason it results in no reply being sent to the
client. Problem reported by Harald Dunkel. OK Brad.


- End forwarded message -



arm64 _longjmp fix

2017-04-16 Thread Mark Kettenis
We fixed longjmp(), but left _longjmp() alone.  In this case the
return code is still in w1 so the fix is slightly different.  Makes
the longjmp regress test pass on arm64.

ok?


Index: lib/libc/arch/aarch64/gen/_setjmp.S
===
RCS file: /cvs/src/lib/libc/arch/aarch64/gen/_setjmp.S,v
retrieving revision 1.1
diff -u -p -r1.1 _setjmp.S
--- lib/libc/arch/aarch64/gen/_setjmp.S 11 Jan 2017 18:09:24 -  1.1
+++ lib/libc/arch/aarch64/gen/_setjmp.S 16 Apr 2017 10:25:24 -
@@ -91,7 +91,8 @@ ENTRY(_longjmp)
 #endif
 
/* Load the return value */
-   mov x0, x1
+   cmp w1, #0
+   csinc   w0, w1, wzr, ne
ret
 
 botch:



Fix regex regress for clang

2017-04-16 Thread Mark Kettenis
clang doesn't like the

  DEF_WEAK(regfree)

that's in the libc code that gets recycled for the test.  Diff below
defines it away in the same way as we do in ld.so.

ok?


Index: regress/lib/libc/regex/Makefile
===
RCS file: /cvs/src/regress/lib/libc/regex/Makefile,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile
--- regress/lib/libc/regex/Makefile 10 Dec 2014 03:12:38 -  1.10
+++ regress/lib/libc/regex/Makefile 16 Apr 2017 10:22:43 -
@@ -7,6 +7,7 @@ SRCS=   main.c split.c debug.c regcomp.c r
 CLEANFILES += t_exhaust
 
 CFLAGS+= -I${.CURDIR}/../../../../lib/libc/regex -DREDEBUG -DPOSIX_MISTAKE
+CFLAGS+= -D'DEF_WEAK(x)=asm("")'
 
 TESTS= ${.CURDIR}/tests
 



yacc: y.tab.c remains on error

2017-04-16 Thread Michael W. Bombardieri
Hi,

yacc will produce a y.tab.c file when it is fed input with bad
syntax. Maybe this is expected behaviour but is it better for
yacc to clean up after itself? When I feed the same badsyntax.y
to bison 3.0.4 it doesn't create y.tab.c.

yacc creates y.tab.c very early. Unlink the file in
done() if it's heading for exit with non-zero status?
As a result y.tab.c is removed for other errors, such as 
no_space() which means out of memory.

- Michael


Index: main.c
===
RCS file: /cvs/src/usr.bin/yacc/main.c,v
retrieving revision 1.28
diff -u -p -u -r1.28 main.c
--- main.c  27 Jul 2016 20:53:47 -  1.28
+++ main.c  16 Apr 2017 09:29:03 -
@@ -109,6 +109,8 @@ volatile sig_atomic_t sigdie;
 void
 done(int k)
 {
+   if (k != 0)
+   unlink(output_file_name);
if (action_file)
unlink(action_file_name);
if (text_file)



start building clang alongside gcc on amd64

2017-04-16 Thread Mark Kettenis
Here is my current diff to build clang alongside gcc.  The idea is
that if you add an architecture to both CLANG_ARCH and GCC4_ARCH, both
compilers get built, but gcc remains the default compiler.  It forces
the clang-related libraries (libcompiler_rt, libc++abi, libc++) to be
built with clang.

You'll need to bootstrap clang with the ports gcc before you can do a
make build.  This is done using:

# pkg_add g++
# cd /usr/src/gnu/usr.bin/clang
# make obj
# make BOOTSTRAP_CLANG=yes
# make install

Thoughts?  ok?  If we don't want to start building clang on amd64 just
yet, I can leave GCC4_ARCHS empty for now.


Index: gnu/usr.bin/Makefile
===
RCS file: /cvs/src/gnu/usr.bin/Makefile,v
retrieving revision 1.58
diff -u -p -r1.58 Makefile
--- gnu/usr.bin/Makefile20 Feb 2017 01:00:26 -  1.58
+++ gnu/usr.bin/Makefile15 Apr 2017 12:06:10 -
@@ -10,7 +10,8 @@ SUBDIR+=  cc clang gcc
 SUBDIR+=   gcc
 .  elif ${COMPILER_VERSION:L} == "gcc4"
 SUBDIR+=   cc
-.  elif ${COMPILER_VERSION:L} == "clang"
+.  endif
+.  if ${BUILD_CLANG} == "yes"
 SUBDIR+=   clang
 .  endif
 .endif
Index: gnu/usr.bin/clang/Makefile.inc
===
RCS file: /cvs/src/gnu/usr.bin/clang/Makefile.inc,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile.inc
--- gnu/usr.bin/clang/Makefile.inc  16 Feb 2017 02:08:42 -  1.4
+++ gnu/usr.bin/clang/Makefile.inc  27 Mar 2017 15:56:49 -
@@ -2,6 +2,11 @@
 
 LLVM_SRCS?=${.CURDIR}/../../../llvm
 
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
 BOOTSTRAP_CLANG?=no
 .if ${BOOTSTRAP_CLANG} == "yes"
 CC=egcc
Index: lib/libcompiler_rt/Makefile
===
RCS file: /cvs/src/lib/libcompiler_rt/Makefile,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile
--- lib/libcompiler_rt/Makefile 9 Apr 2017 21:47:05 -   1.6
+++ lib/libcompiler_rt/Makefile 15 Apr 2017 12:14:38 -
@@ -2,7 +2,12 @@
 
 .include 
 
-.if ${COMPILER_VERSION:L} == "clang"
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
+.if ${BUILD_CLANG} == "yes"
 
 LIB=   compiler_rt
 NOPIC=
Index: lib/libcxx/Makefile
===
RCS file: /cvs/src/lib/libcxx/Makefile,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile
--- lib/libcxx/Makefile 16 Feb 2017 02:08:42 -  1.5
+++ lib/libcxx/Makefile 15 Apr 2017 12:04:11 -
@@ -2,7 +2,12 @@
 
 .include 
 
-.if ${COMPILER_VERSION:L} == "clang"
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
+.if ${BUILD_CLANG} == "yes"
 
 HDRDIR=${.CURDIR}/include
 SRCDIR=${.CURDIR}/src
Index: lib/libcxxabi/Makefile
===
RCS file: /cvs/src/lib/libcxxabi/Makefile,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile
--- lib/libcxxabi/Makefile  6 Apr 2017 09:28:29 -   1.7
+++ lib/libcxxabi/Makefile  15 Apr 2017 12:00:40 -
@@ -2,7 +2,12 @@
 
 .include 
 
-.if ${COMPILER_VERSION:L} == "clang"
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
+.if ${BUILD_CLANG} == "yes"
 
 HDRDIR=${.CURDIR}/include
 SRCDIR=${.CURDIR}/src
Index: share/mk/bsd.own.mk
===
RCS file: /cvs/src/share/mk/bsd.own.mk,v
retrieving revision 1.182
diff -u -p -r1.182 bsd.own.mk
--- share/mk/bsd.own.mk 18 Dec 2016 17:02:21 -  1.182
+++ share/mk/bsd.own.mk 15 Apr 2017 11:58:41 -
@@ -15,7 +15,8 @@ SKEY?=yes
 # Set `YP' to `yes' to build with support for NIS/YP.
 YP?=   yes
 
-CLANG_ARCH=aarch64
+CLANG_ARCH=aarch64 amd64
+GCC4_ARCH=amd64
 GCC3_ARCH=m88k
 
 # m88k: ?
@@ -23,12 +24,20 @@ PIE_ARCH=alpha amd64 arm hppa i386 mips6
 STATICPIE_ARCH=alpha amd64 arm hppa i386 mips64 mips64el powerpc sh sparc64
 
 .for _arch in ${MACHINE_ARCH}
-.if !empty(CLANG_ARCH:M${_arch})
-COMPILER_VERSION?=clang
-.elif !empty(GCC3_ARCH:M${_arch})
+.if !empty(GCC3_ARCH:M${_arch})
 COMPILER_VERSION?=gcc3
+.elif !empty(GCC4_ARCH:M${_arch})
+COMPILER_VERSION?=gcc4
+.elif !empty(CLANG_ARCH:M${_arch})
+COMPILER_VERSION?=clang
 .else
 COMPILER_VERSION?=gcc4
+.endif
+
+.if !empty(CLANG_ARCH:M${_arch})
+BUILD_CLANG?=yes
+.else
+BUILD_CLANG?=no
 .endif
 
 .if !empty(STATICPIE_ARCH:M${_arch})



Re: umb: aggregate packets on tx

2017-04-16 Thread Stefan Sperling
On Sat, Apr 15, 2017 at 11:21:41PM +0200, Alexander Bluhm wrote:
> On Mon, Feb 20, 2017 at 04:35:10PM +0100, Gerhard Roth wrote:
> > On Mon, 12 Dec 2016 14:50:50 +0100 Gerhard Roth  
> > wrote:
> > > The current umb(4) implementation needs one USB transfer for every packet
> > > that is sent. With the following patch, we can now aggregate several
> > > packets from the ifq into one single USB transfer.
> > > 
> > > This may speed up the tx path. And even if it doesn't, at least it
> > > reduces the number of transfers required.
> 
> I am running with this for two days now.  Works fine.
> 
> umb0 at uhub0 port 4 configuration 1 interface 6 "Lenovo H5321 gw" rev 
> 2.00/0.00 addr 2
> 
> Diff looks reasonable.  OK bluhm@

Yes, the diff makes sense. OK by me as well.

Sent over 
umb0 at uhub0 port 4 configuration 1 interface 0 "Sierra Wireless Inc. Sierra 
Wireless EM7345 4G LTE" rev 2.00/17.29 addr 7
with patch applied.

Thanks!