remove useless knob and always to neighbor unreachable detection

2017-08-08 Thread Florian Obser
As a bonus this reduces the ndp option parsing insanity.

OK?

diff --git sys/netinet6/nd6.c sys/netinet6/nd6.c
index 7fd647c115a..f4af6632b4b 100644
--- sys/netinet6/nd6.c
+++ sys/netinet6/nd6.c
@@ -139,7 +139,6 @@ nd6_ifattach(struct ifnet *ifp)
nd->reachable = ND_COMPUTE_RTIME(nd->basereachable);
nd->retrans = RETRANS_TIMER;
/* per-interface IFXF_AUTOCONF6 needs to be set too to accept RAs */
-   nd->flags = ND6_IFF_PERFORMNUD;
 
return nd;
 }
@@ -388,16 +387,13 @@ nd6_llinfo_timer(void *arg)
break;
 
case ND6_LLINFO_DELAY:
-   if (ndi && (ndi->flags & ND6_IFF_PERFORMNUD) != 0) {
+   if (ndi) {
/* We need NUD */
ln->ln_asked = 1;
ln->ln_state = ND6_LLINFO_PROBE;
nd6_llinfo_settimer(ln, ndi->retrans / 1000);
nd6_ns_output(ifp, &dst->sin6_addr,
&dst->sin6_addr, ln, 0);
-   } else {
-   ln->ln_state = ND6_LLINFO_STALE; /* XXX */
-   nd6_llinfo_settimer(ln, nd6_gctimer);
}
break;
case ND6_LLINFO_PROBE:
@@ -971,7 +967,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
ndi->ndi = *ND_IFINFO(ifp);
break;
case SIOCSIFINFO_FLAGS:
-   ND_IFINFO(ifp)->flags = ndi->ndi.flags;
+   error = ENOTSUP;
break;
case SIOCSNDFLUSH_IN6:  /* XXX: the ioctl name is confusing... */
/* sync kernel routing table with the default router list */
diff --git sys/netinet6/nd6.h sys/netinet6/nd6.h
index a3b9746e73d..ddaaac3425c 100644
--- sys/netinet6/nd6.h
+++ sys/netinet6/nd6.h
@@ -47,13 +47,10 @@ struct nd_ifinfo {
u_int32_t basereachable;/* BaseReachableTime */
u_int32_t reachable;/* Reachable Time */
u_int32_t retrans;  /* Retrans Timer */
-   u_int32_t flags;/* Flags */
int recalctm;   /* BaseReacable re-calculation timer */
u_int8_t initialized; /* Flag to see the entry is initialized */
 };
 
-#define ND6_IFF_PERFORMNUD 0x1
-
 struct in6_nbrinfo {
char ifname[IFNAMSIZ];  /* if name, e.g. "en0" */
struct in6_addr addr;   /* IPv6 address of the neighbor */
diff --git usr.sbin/ndp/ndp.8 usr.sbin/ndp/ndp.8
index a2e863fbb97..c2a27164fb6 100644
--- usr.sbin/ndp/ndp.8
+++ usr.sbin/ndp/ndp.8
@@ -40,7 +40,7 @@
 .Op Fl A Ar wait
 .Op Fl d Ar hostname
 .Op Fl f Ar filename
-.Op Fl i Ar interface Op Ar flag ...
+.Op Fl i Ar interface
 .Op Fl s Ar nodename ether_addr Oo Cm temp Oc Op Cm proxy
 .Op Fl V Ar rdomain
 .Op Ar hostname
@@ -119,28 +119,8 @@ to be inserted in the neighbor cache.
 See the
 .Fl s
 option for a description of the file format.
-.It Fl i Ar interface Op Ar flag ...
+.It Fl i Ar interface
 View ND information for the specified interface.
-If additional arguments are given,
-.Nm
-sets or clears the specified flags for the interface.
-Each flag should be separated by whitespace or tab characters.
-Possible flags are as follows.
-All of the flags can begin with the
-special character
-.Ql - ,
-which means the flag should be cleared.
-Note that
-.Fl -
-would be needed before
-.Fl foo
-in this case.
-.Bl -tag -width Ds
-.It Ic nud
-Turn on or off NUD (Neighbor Unreachability Detection) on the
-interface.
-NUD is usually turned on by default.
-.El
 .It Fl n
 Do not try to resolve numeric addresses to hostnames.
 .It Xo
diff --git usr.sbin/ndp/ndp.c usr.sbin/ndp/ndp.c
index 800385d7779..2163322e1d6 100644
--- usr.sbin/ndp/ndp.c
+++ usr.sbin/ndp/ndp.c
@@ -134,7 +134,7 @@ int ndp_ether_aton(char *, u_char *);
 void usage(void);
 int rtmsg(int);
 int rtget(struct sockaddr_in6 **, struct sockaddr_dl **);
-void ifinfo(char *, int, char **);
+void ifinfo(char *);
 void harmonize_rtr(void);
 static char *sec2str(time_t);
 static void ts_print(const struct timeval *);
@@ -238,7 +238,9 @@ main(int argc, char *argv[])
file(arg);
break;
case 'i':
-   ifinfo(arg, argc, argv);
+   if (argc != 0)
+   usage();
+   ifinfo(arg);
break;
case 's':
if (argc < 2 || argc > 4)
@@ -761,7 +763,7 @@ usage(void)
 {
printf("usage: ndp [-acnt] ");
printf("[-A wait] [-d hostname] [-f filename]\n");
-   printf("\t[-i interface [flag ...]] ");
+   printf("\t[-i interface] ");
printf("[-s nodename ether_addr [temp] [proxy]]\n");
printf("\t[-V rdomain] [hostname]\n");
exit(1);
@@ -881,11 +883,10 @@ rtget(struct sockaddr_in6 **sinp, struct sockaddr_dl 
**sdlp)
 }
 
 void
-ifinfo(char *ifname, int argc, char **argv)
+ifinfo(char *ifname)
 {
struct in6_ndireq nd;
int i, s;
-   u_int32_t newflags;
 
if 

Re: fix arm64 format strings

2017-08-08 Thread Mark Kettenis
> Date: Wed, 9 Aug 2017 14:01:25 +1000
> From: Jonathan Gray 
> 
> Make the kernel build on arm64 again after the recent kprintf changes
> in clang.

ok kettenis@

> Index: arm64/cpu.c
> ===
> RCS file: /cvs/src/sys/arch/arm64/arm64/cpu.c,v
> retrieving revision 1.5
> diff -u -p -r1.5 cpu.c
> --- arm64/cpu.c   6 May 2017 11:27:34 -   1.5
> +++ arm64/cpu.c   9 Aug 2017 03:44:52 -
> @@ -124,12 +124,13 @@ cpu_identify(struct cpu_info *ci)
>   }
>  
>   if (impl_name && part_name) {
> - printf(" %s %s r%dp%d", impl_name, part_name, CPU_VAR(midr),
> + printf(" %s %s r%llup%llu", impl_name, part_name, CPU_VAR(midr),
>   CPU_REV(midr));
>  
>   if (CPU_IS_PRIMARY(ci))
> - snprintf(cpu_model, sizeof(cpu_model), "%s %s r%dp%d",
> - impl_name, part_name, CPU_VAR(midr), CPU_REV(midr));
> + snprintf(cpu_model, sizeof(cpu_model),
> + "%s %s r%llup%llu", impl_name, part_name,
> + CPU_VAR(midr), CPU_REV(midr));
>   } else {
>   printf(" Unknown, MIDR 0x%llx", midr);
>  
> Index: arm64/pmap.c
> ===
> RCS file: /cvs/src/sys/arch/arm64/arm64/pmap.c,v
> retrieving revision 1.36
> diff -u -p -r1.36 pmap.c
> --- arm64/pmap.c  21 May 2017 19:14:36 -  1.36
> +++ arm64/pmap.c  9 Aug 2017 03:44:53 -
> @@ -1063,9 +1063,9 @@ pmap_bootstrap(long kvo, paddr_t lpt1,  
>* bootstrap vm table, which we may need to preserve until
>* later.
>*/
> - printf("removing %llx-%llx\n", ram_start, kernelstart+kvo);
> + printf("removing %lx-%lx\n", ram_start, kernelstart+kvo);
>   pmap_remove_avail(ram_start, kernelstart+kvo);
> - printf("removing %llx-%llx\n", kernelstart+kvo, kernelend+kvo);
> + printf("removing %lx-%lx\n", kernelstart+kvo, kernelend+kvo);
>   pmap_remove_avail(kernelstart+kvo, kernelend+kvo);
>  
>   /*
> @@ -1452,8 +1452,8 @@ pmap_pte_insert(struct pte_desc *pted)
>   uint64_t *pl3;
>  
>   if (pmap_vp_lookup(pm, pted->pted_va, &pl3) == NULL) {
> - panic("pmap_pte_insert: have a pted, but missing a vp"
> - " for %x va pmap %x", __func__, pted->pted_va, pm);
> + panic("%s: have a pted, but missing a vp"
> + " for %lx va pmap %p", __func__, pted->pted_va, pm);
>   }
>  
>   pmap_pte_update(pted, pl3);
> @@ -1515,17 +1515,17 @@ pmap_pte_remove(struct pte_desc *pted, i
>   else
>   vp1 = pm->pm_vp.l1;
>   if (vp1->vp[VP_IDX1(pted->pted_va)] == NULL) {
> - panic("have a pted, but missing the l2 for %x va pmap %x",
> + panic("have a pted, but missing the l2 for %lx va pmap %p",
>   pted->pted_va, pm);
>   }
>   vp2 = vp1->vp[VP_IDX1(pted->pted_va)];
>   if (vp2 == NULL) {
> - panic("have a pted, but missing the l2 for %x va pmap %x",
> + panic("have a pted, but missing the l2 for %lx va pmap %p",
>   pted->pted_va, pm);
>   }
>   vp3 = vp2->vp[VP_IDX2(pted->pted_va)];
>   if (vp3 == NULL) {
> - panic("have a pted, but missing the l2 for %x va pmap %x",
> + panic("have a pted, but missing the l2 for %lx va pmap %p",
>   pted->pted_va, pm);
>   }
>   vp3->l3[VP_IDX3(pted->pted_va)] = 0;
> @@ -1907,7 +1907,7 @@ pmap_steal_avail(size_t size, int align,
>   }
>   }
>   }
> - panic ("unable to allocate region with size %x align %x",
> + panic ("unable to allocate region with size %lx align %x",
>   size, align);
>  }
>  
> @@ -1987,7 +1987,7 @@ pmap_show_mapping(uint64_t va)
>   pm = curproc->p_vmspace->vm_map.pmap;
>  
>   if (pm->have_4_level_pt) {
> - printf("  vp0 = %llx off %x\n",  pm->pm_vp.l0, VP_IDX0(va)*8);
> + printf("  vp0 = %p off %x\n",  pm->pm_vp.l0, VP_IDX0(va)*8);
>   vp1 = pm->pm_vp.l0->vp[VP_IDX0(va)];
>   if (vp1 == NULL)
>   return;
> @@ -1998,16 +1998,16 @@ pmap_show_mapping(uint64_t va)
>   __asm volatile ("mrs %x0, ttbr0_el1" : "=r"(ttbr0));
>   __asm volatile ("mrs %x0, tcr_el1" : "=r"(tcr));
>   printf("  ttbr0 %llx %llx tcr %llx\n", ttbr0, pm->pm_pt0pa, tcr);
> - printf("  vp1 = %llx\n", vp1);
> + printf("  vp1 = %p\n", vp1);
>  
>   vp2 = vp1->vp[VP_IDX1(va)];
> - printf("  vp2 = %llx lp2 = %llx idx1 off %x\n",
> + printf("  vp2 = %p lp2 = %llx idx1 off %x\n",
>   vp2, vp1->l1[VP_IDX1(va)], VP_IDX1(va)*8);
>   if (vp2 == NULL)
>   return;
>  
>   vp3 = vp2->vp[VP_IDX2(va)];
> - printf("  vp3 = %llx lp3 = %llx idx2 off %x\n",
> + printf("  vp3 = %p lp3 = %llx idx2

fix arm64 format strings

2017-08-08 Thread Jonathan Gray
Make the kernel build on arm64 again after the recent kprintf changes
in clang.

Index: arm64/cpu.c
===
RCS file: /cvs/src/sys/arch/arm64/arm64/cpu.c,v
retrieving revision 1.5
diff -u -p -r1.5 cpu.c
--- arm64/cpu.c 6 May 2017 11:27:34 -   1.5
+++ arm64/cpu.c 9 Aug 2017 03:44:52 -
@@ -124,12 +124,13 @@ cpu_identify(struct cpu_info *ci)
}
 
if (impl_name && part_name) {
-   printf(" %s %s r%dp%d", impl_name, part_name, CPU_VAR(midr),
+   printf(" %s %s r%llup%llu", impl_name, part_name, CPU_VAR(midr),
CPU_REV(midr));
 
if (CPU_IS_PRIMARY(ci))
-   snprintf(cpu_model, sizeof(cpu_model), "%s %s r%dp%d",
-   impl_name, part_name, CPU_VAR(midr), CPU_REV(midr));
+   snprintf(cpu_model, sizeof(cpu_model),
+   "%s %s r%llup%llu", impl_name, part_name,
+   CPU_VAR(midr), CPU_REV(midr));
} else {
printf(" Unknown, MIDR 0x%llx", midr);
 
Index: arm64/pmap.c
===
RCS file: /cvs/src/sys/arch/arm64/arm64/pmap.c,v
retrieving revision 1.36
diff -u -p -r1.36 pmap.c
--- arm64/pmap.c21 May 2017 19:14:36 -  1.36
+++ arm64/pmap.c9 Aug 2017 03:44:53 -
@@ -1063,9 +1063,9 @@ pmap_bootstrap(long kvo, paddr_t lpt1,  
 * bootstrap vm table, which we may need to preserve until
 * later.
 */
-   printf("removing %llx-%llx\n", ram_start, kernelstart+kvo);
+   printf("removing %lx-%lx\n", ram_start, kernelstart+kvo);
pmap_remove_avail(ram_start, kernelstart+kvo);
-   printf("removing %llx-%llx\n", kernelstart+kvo, kernelend+kvo);
+   printf("removing %lx-%lx\n", kernelstart+kvo, kernelend+kvo);
pmap_remove_avail(kernelstart+kvo, kernelend+kvo);
 
/*
@@ -1452,8 +1452,8 @@ pmap_pte_insert(struct pte_desc *pted)
uint64_t *pl3;
 
if (pmap_vp_lookup(pm, pted->pted_va, &pl3) == NULL) {
-   panic("pmap_pte_insert: have a pted, but missing a vp"
-   " for %x va pmap %x", __func__, pted->pted_va, pm);
+   panic("%s: have a pted, but missing a vp"
+   " for %lx va pmap %p", __func__, pted->pted_va, pm);
}
 
pmap_pte_update(pted, pl3);
@@ -1515,17 +1515,17 @@ pmap_pte_remove(struct pte_desc *pted, i
else
vp1 = pm->pm_vp.l1;
if (vp1->vp[VP_IDX1(pted->pted_va)] == NULL) {
-   panic("have a pted, but missing the l2 for %x va pmap %x",
+   panic("have a pted, but missing the l2 for %lx va pmap %p",
pted->pted_va, pm);
}
vp2 = vp1->vp[VP_IDX1(pted->pted_va)];
if (vp2 == NULL) {
-   panic("have a pted, but missing the l2 for %x va pmap %x",
+   panic("have a pted, but missing the l2 for %lx va pmap %p",
pted->pted_va, pm);
}
vp3 = vp2->vp[VP_IDX2(pted->pted_va)];
if (vp3 == NULL) {
-   panic("have a pted, but missing the l2 for %x va pmap %x",
+   panic("have a pted, but missing the l2 for %lx va pmap %p",
pted->pted_va, pm);
}
vp3->l3[VP_IDX3(pted->pted_va)] = 0;
@@ -1907,7 +1907,7 @@ pmap_steal_avail(size_t size, int align,
}
}
}
-   panic ("unable to allocate region with size %x align %x",
+   panic ("unable to allocate region with size %lx align %x",
size, align);
 }
 
@@ -1987,7 +1987,7 @@ pmap_show_mapping(uint64_t va)
pm = curproc->p_vmspace->vm_map.pmap;
 
if (pm->have_4_level_pt) {
-   printf("  vp0 = %llx off %x\n",  pm->pm_vp.l0, VP_IDX0(va)*8);
+   printf("  vp0 = %p off %x\n",  pm->pm_vp.l0, VP_IDX0(va)*8);
vp1 = pm->pm_vp.l0->vp[VP_IDX0(va)];
if (vp1 == NULL)
return;
@@ -1998,16 +1998,16 @@ pmap_show_mapping(uint64_t va)
__asm volatile ("mrs %x0, ttbr0_el1" : "=r"(ttbr0));
__asm volatile ("mrs %x0, tcr_el1" : "=r"(tcr));
printf("  ttbr0 %llx %llx tcr %llx\n", ttbr0, pm->pm_pt0pa, tcr);
-   printf("  vp1 = %llx\n", vp1);
+   printf("  vp1 = %p\n", vp1);
 
vp2 = vp1->vp[VP_IDX1(va)];
-   printf("  vp2 = %llx lp2 = %llx idx1 off %x\n",
+   printf("  vp2 = %p lp2 = %llx idx1 off %x\n",
vp2, vp1->l1[VP_IDX1(va)], VP_IDX1(va)*8);
if (vp2 == NULL)
return;
 
vp3 = vp2->vp[VP_IDX2(va)];
-   printf("  vp3 = %llx lp3 = %llx idx2 off %x\n",
+   printf("  vp3 = %p lp3 = %llx idx2 off %x\n",
vp3, vp2->l2[VP_IDX2(va)], VP_IDX2(va)*8);
if (vp3 == NULL)
return;
Index: arm64/trap.c
===

Re: ifstated: add handing of departed interfaces

2017-08-08 Thread Rob Pierce
On Tue, Aug 08, 2017 at 12:12:43AM +0200, Jeremie Courreges-Anglas wrote:
> On Sun, Aug 06 2017, Rob Pierce  wrote:
> > The following diff adds support for detecting the state change of a departed
> > interface. ifstated is not a very verbose daemon, so this diff quietly does
> > the right thing (i.e. there is no exttra warning about a departing 
> > interface).
> 
> But maybe there should be at least a big scary message.  This is not
> exactly a normal situation.

Yes, I agree. This is a special case.

> > The re-arrival of a departed interface involves re-indexing the interface 
> > and
> > possibly other complexities that require more consideration, but for now at
> > least this obvious condition is handled in what I believe is a more
> > appropriate manner.
> 
> I wonder what's the most useful behavior here: complain loudly and fail
> hard (exit) or just consider the link down and monitor the rest of the
> remaining interfaces, as in your diff.

I do like the idea of complaining loudly and failing hard. I had originally
considered a fatal (after forcing a demote of course).

> Destroying then reconfiguring a carp(4) interface won't give you a very
> user-friendly behavior.  Same thing with disconnecting/reconnecting
> interfaces like urtwn(4) or urndis(4).  ifstated(8) won't do anything
> about your new interface, even if you checked that said interface was
> in good shape.
> 
> Also if we keep running, the link is now considered down and we're
> likely to execute commands that refer to an interface that has left;
> that might be good or bad, I don't know what people put in their
> ifstated.conf.
> 
> > Updated regression tests pass, and the corresponding regression diff is also
> > attached.
> >
> > Ok?
> 
> I'm not sure yet which path we should follow.  Let's discuss this in
> Toronto, shal we?  In the meantime, please see the nits below.

Sounds like a plan. Looking forward to it!

Rob

> > Index: regress/usr.sbin/ifstated/ifstated
> > ===
> > RCS file: /cvs/src/regress/usr.sbin/ifstated/ifstated,v
> > retrieving revision 1.3
> > diff -u -p -r1.3 ifstated
> > --- regress/usr.sbin/ifstated/ifstated  31 Jul 2017 18:41:21 -  
> > 1.3
> > +++ regress/usr.sbin/ifstated/ifstated  6 Aug 2017 23:29:11 -
> > @@ -124,6 +124,7 @@ changing state to primary
> >  changing state to demoted
> >  changing state to primary
> >  changing state to primary
> > +changing state to demoted
> >  EOF
> >  
> >  (cd working && nohup ifstated -dvf ./ifstated.conf > ifstated.log 2>&1) &
> > @@ -148,6 +149,8 @@ ifconfig carp${VHIDB} inet ${PREFIX}.${V
> > ${PREFIX}.255 vhid ${VHIDB} carpdev ${NIC}
> >  sleep ${SLEEP}
> >  kill -HUP $(pgrep ifstated) >/dev/null 2>&1
> > +sleep ${SLEEP}
> > +ifconfig carp${VHIDA} destroy
> >  sleep ${SLEEP}
> >  
> >  grep ^changing working/ifstated.log > working/output.new
> > Index: usr.sbin/ifstated/ifstated.c
> > ===
> > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.c,v
> > retrieving revision 1.57
> > diff -u -p -r1.57 ifstated.c
> > --- usr.sbin/ifstated/ifstated.c6 Aug 2017 19:27:54 -   1.57
> > +++ usr.sbin/ifstated/ifstated.c6 Aug 2017 23:29:12 -
> > @@ -1,4 +1,4 @@
> > -/* $OpenBSD: ifstated.c,v 1.57 2017/08/06 19:27:54 rob Exp $   */
> > +/* $OpenBSD: ifstated.c,v 1.56 2017/07/24 12:33:59 jca Exp $   */
> >  
> >  /*
> >   * Copyright (c) 2004 Marco Pfatschbacher 
> > @@ -61,6 +61,7 @@ void  rt_msg_handler(int, short, void *)
> >  void   external_handler(int, short, void *);
> >  void   external_exec(struct ifsd_external *, int);
> >  void   check_external_status(struct ifsd_state *);
> > +void   check_for_ifdeparture(void);
> 
> check_ifdeparture() would be shorter and just as descriptive.
> 
> >  void   external_evtimer_setup(struct ifsd_state *, int);
> >  void   scan_ifstate(int, int, int);
> >  intscan_ifstate_single(int, int, struct ifsd_state *);
> > @@ -150,7 +151,7 @@ main(int argc, char *argv[])
> > if ((rt_fd = socket(PF_ROUTE, SOCK_RAW, 0)) < 0)
> > err(1, "no routing socket");
> >  
> > -   rtfilter = ROUTE_FILTER(RTM_IFINFO);
> > +   rtfilter = ROUTE_FILTER(RTM_IFINFO) | ROUTE_FILTER(RTM_IFANNOUNCE);
> > if (setsockopt(rt_fd, PF_ROUTE, ROUTE_MSGFILTER,
> > &rtfilter, sizeof(rtfilter)) == -1) /* not fatal */
> > log_warn("%s: setsockopt msgfilter", __func__);
> > @@ -234,6 +235,7 @@ rt_msg_handler(int fd, short event, void
> > char msg[2048];
> > struct rt_msghdr *rtm = (struct rt_msghdr *)&msg;
> > struct if_msghdr ifm;
> > +   struct if_announcemsghdr ifan;
> > ssize_t len;
> >  
> > if ((len = read(fd, msg, sizeof(msg))) == -1) {
> > @@ -253,8 +255,19 @@ rt_msg_handler(int fd, short event, void
> > memcpy(&ifm, rtm, sizeof(if

faq/ports/guide: Remove stray comment

2017-08-08 Thread Klemens Nanni
Index: guide.html
===
RCS file: /cvs/www/faq/ports/guide.html,v
retrieving revision 1.73
diff -u -p -r1.73 guide.html
--- guide.html  8 Aug 2017 15:48:56 -   1.73
+++ guide.html  9 Aug 2017 00:13:22 -
@@ -808,7 +808,7 @@ to fiddle with MULTI_PACKAGES a
 Once you've separated the files properly, you will need to check dependencies:
 LIB_DEPENDS, WANTLIB, and RUN_DEPENDS will be split
 for each subpackage.
-It is usually time to check that your multi-packaging "works," and that
+It is usually time to check that your multi-packaging "works" and that
 those nasty dependencies you don't want to force on the user are indeed
 relegated to a specific subpackage.
 



reach dwc2_debug via usb.c

2017-08-08 Thread Artturi Alm
Hi,

small diff below for what the subject suggests.
Now i'm unsure if arm64 does really ever use the uhci it has on pci*,
but something like this would work for atleast octeon && armv7 i think?

-Artturi

diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c
index 8139db6a4ae..f4462fe71fe 100644
--- a/sys/dev/usb/usb.c
+++ b/sys/dev/usb/usb.c
@@ -40,6 +40,7 @@
 #include "ohci.h"
 #include "uhci.h"
 #include "ehci.h"
+#include "dwctwo.h"
 
 #include 
 #include 
@@ -70,6 +71,8 @@
 intusbdebug = 0;
 #if defined(UHCI_DEBUG) && NUHCI > 0
 extern int uhcidebug;
+#elif defined(DWC2_DEBUG) && NDWCTWO > 0
+extern int dwc2debug;
 #endif
 #if defined(OHCI_DEBUG) && NOHCI > 0
 extern int ohcidebug;
@@ -598,6 +601,8 @@ usbioctl(dev_t devt, u_long cmd, caddr_t data, int flag, 
struct proc *p)
usbdebug  = ((*(unsigned int *)data) & 0x00ff);
 #if defined(UHCI_DEBUG) && NUHCI > 0
uhcidebug = ((*(unsigned int *)data) & 0xff00) >> 8;
+#elif defined(DWC2_DEBUG) && NDWCTWO > 0
+   dwc2debug = ((*(unsigned int *)data) & 0xff00) >> 8;
 #endif
 #if defined(OHCI_DEBUG) && NOHCI > 0
ohcidebug = ((*(unsigned int *)data) & 0x00ff) >> 16;



Re: install.sub: ieee80211_{scan,config}: Allow quoted SSIDs

2017-08-08 Thread Klemens Nanni
On Tue, Jul 04, 2017 at 10:44:57PM +0200, Klemens Nanni wrote:
> On Mon, Jul 03, 2017 at 12:45:32AM +0200, Klemens Nanni wrote:
> > Thanks for looking into it.
> > 
> > On Sun, Jul 02, 2017 at 04:32:43PM +, Robert Peichaer wrote:
> > > ieee80211_scan()
> > > - Extract the needed information (nwid, bssid) using a very specific
> > >   sed expression. Any line, not matching this expr is ignored.
> > > 
> > > - Remove leading and trailing double-quotes in case of nwids with
> > >   spaces.
> > I had the ugly case of an empty SSID in reach while testing this so I
> > intentionally left double quotes in place within WLANLIST so that
> > the list presented to the user wouldn't look broken, e.g.
> > "my wifi" chan 1 bssid ...
> > "" chan 2 bssid ...
> > as opposed to
> > my wifi chan 1 bssid ...
> >  chan 2 bssid ...
> > 
> > I'd also leave unqouting to the routine that actually requires it
> > instead of the function that just provides the list.
> > 
> > > - Write nwid and bssid into WLANLIST as '()'.
> > Writing the simple format directly to cache seems like a good idea
> > instead of just cutting ^nwid first here and .*$ somewhere else.
> > 
> > > ieee80211_config()
> > > - just print WLANLIST using ieee80211_scan() if the user chooses
> > >   '?' which has the right format already
> > > 
> > > - in case the user selects an entry from WLANLIST using a number,
> > >   remove the '()' part from the line, resulting in
> > >   the nwid (without double-quotes)
> > > 
> > > - using the quote() function with the ifconfig command ensures,
> > >   that the nwid is quoted properly with single-quotes in case it
> > >   contains spaces
> > This is not needed as "$_nwid" will even work if _nwid='my "wifi'.
> > 
> > > - using the quote() function when writing the nwid to the hostname.if
> > >   files ensures that the nwid is quoted properly with single-quotes
> > >   in case it contains spaces
> > > 
> > > The parse_hn_line() function in netstart does handle quoted nwids
> > > properly when processing the hostname.if config lines as far as I
> > > can see.
> > Yes, it does. But it chokes on SSIDs containing a literal " for example.
> > 
> > 
> > Here is an updated diff taking above considerations into account.
> > 
> > Note how ([[:xdigit:]:]*)$ when picking the answer must not be
> > simplified to (.*)$ as this would fail on SSIDs like "my (hidden) wifi".
> > 
> > Feedback/OK?
> That patch was mangled, sorry. Here it goes again.
> 
> Index: install.sub
> ===
> RCS file: /cvs/src/distrib/miniroot/install.sub,v
> retrieving revision 1.1019
> diff -u -p -r1.1019 install.sub
> --- install.sub   2 Jul 2017 12:45:43 -   1.1019
> +++ install.sub   4 Jul 2017 20:43:56 -
> @@ -1060,10 +1060,9 @@ v6_config() {
> # Perform an 802.11 network scan on interface $1.
> # The result is cached in $WLANLIST.
> ieee80211_scan() {
> - # N.B. Skipping quoted nwid's for now.
>   [[ -f $WLANLIST ]] ||
>   ifconfig $1 scan |
> - sed -n 's/^ nwid \([^"]\)/\1/p' >$WLANLIST
> + sed -n 's/^[[:space:]]*nwid \(.*\) chan [0-9]* bssid 
> \([[:xdigit:]:]*\).*/\1 (\2)/p' >$WLANLIST
>   cat $WLANLIST
> }
> 
> @@ -1082,12 +1081,12 @@ ieee80211_config() {
>   ask_until "Access point? (ESSID, 'any', list# or '?')" "any"
>   case "$resp" in
>   +([0-9]))
> - _nwid=$(ieee80211_scan $_if | sed -n "${resp}s/ .*//p")
> + _nwid=$(ieee80211_scan $_if |
> + sed -n ${resp}'{s/ ([[:xdigit:]:]*)$//p;q;}')
>   [[ -z $_nwid ]] && echo "There is no line $resp."
> + [[ $_nwid = \"*\" ]] && _nwid=${_nwid#\"} 
> _nwid=${_nwid%\"}
>   ;;
> - \?) ieee80211_scan $_if |
> - sed -n 's/^\([^ ]*\) chan .* bssid \([^ ]*\) 
> .*$/   \1 (\2)/p' |
> - cat -n | more -c
> + \?) ieee80211_scan $_if | cat -n | more -c
>   ;;
>   *)  _nwid=$resp
>   ;;
> 
Bump. Any progress on this? It still applies to the latest revision.



accept_rtadv doesn't do anything

2017-08-08 Thread Florian Obser
OK?

diff --git sys/netinet6/nd6.c sys/netinet6/nd6.c
index 77bcd1c5fda..7fd647c115a 100644
--- sys/netinet6/nd6.c
+++ sys/netinet6/nd6.c
@@ -139,7 +139,7 @@ nd6_ifattach(struct ifnet *ifp)
nd->reachable = ND_COMPUTE_RTIME(nd->basereachable);
nd->retrans = RETRANS_TIMER;
/* per-interface IFXF_AUTOCONF6 needs to be set too to accept RAs */
-   nd->flags = (ND6_IFF_PERFORMNUD | ND6_IFF_ACCEPT_RTADV);
+   nd->flags = ND6_IFF_PERFORMNUD;
 
return nd;
 }
diff --git sys/netinet6/nd6.h sys/netinet6/nd6.h
index 04885bc9c3e..a3b9746e73d 100644
--- sys/netinet6/nd6.h
+++ sys/netinet6/nd6.h
@@ -53,7 +53,6 @@ struct nd_ifinfo {
 };
 
 #define ND6_IFF_PERFORMNUD 0x1
-#define ND6_IFF_ACCEPT_RTADV   0x2
 
 struct in6_nbrinfo {
char ifname[IFNAMSIZ];  /* if name, e.g. "en0" */
diff --git usr.sbin/ndp/ndp.8 usr.sbin/ndp/ndp.8
index 23f7aceb697..a2e863fbb97 100644
--- usr.sbin/ndp/ndp.8
+++ usr.sbin/ndp/ndp.8
@@ -140,12 +140,6 @@ in this case.
 Turn on or off NUD (Neighbor Unreachability Detection) on the
 interface.
 NUD is usually turned on by default.
-.It Ic accept_rtadv
-Specify whether or not to accept Router Advertisement messages
-received on the
-.Ar interface .
-Note that the kernel does not accept Router Advertisement messages
-unless the interface is configured for inet6 autoconfiguration.
 .El
 .It Fl n
 Do not try to resolve numeric addresses to hostnames.
diff --git usr.sbin/ndp/ndp.c usr.sbin/ndp/ndp.c
index 75ff6f6168d..800385d7779 100644
--- usr.sbin/ndp/ndp.c
+++ usr.sbin/ndp/ndp.c
@@ -917,7 +917,6 @@ ifinfo(char *ifname, int argc, char **argv)
}\
} while (0)
SETFLAG("nud", ND6_IFF_PERFORMNUD);
-   SETFLAG("accept_rtadv", ND6_IFF_ACCEPT_RTADV);
 
nd.ndi.flags = newflags;
if (ioctl(s, SIOCSIFINFO_FLAGS, (caddr_t)&nd) < 0) {
@@ -940,9 +939,7 @@ ifinfo(char *ifname, int argc, char **argv)
if (nd.ndi.flags) {
printf("\nFlags: ");
if ((nd.ndi.flags & ND6_IFF_PERFORMNUD))
-   printf("nud ");
-   if ((nd.ndi.flags & ND6_IFF_ACCEPT_RTADV))
-   printf("accept_rtadv ");
+   printf("nud");
}
putc('\n', stdout);
 
-- 
I'm not entirely sure you are real.



we are no longer generating privacy addresses in the kernel

2017-08-08 Thread Florian Obser
OK?

diff --git sys/netinet6/nd6.c sys/netinet6/nd6.c
index 245b64c6155..77bcd1c5fda 100644
--- sys/netinet6/nd6.c
+++ sys/netinet6/nd6.c
@@ -969,9 +969,6 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
switch (cmd) {
case SIOCGIFINFO_IN6:
ndi->ndi = *ND_IFINFO(ifp);
-   memset(&ndi->ndi.randomseed0, 0, sizeof ndi->ndi.randomseed0);
-   memset(&ndi->ndi.randomseed1, 0, sizeof ndi->ndi.randomseed1);
-   memset(&ndi->ndi.randomid, 0, sizeof ndi->ndi.randomid);
break;
case SIOCSIFINFO_FLAGS:
ND_IFINFO(ifp)->flags = ndi->ndi.flags;
diff --git sys/netinet6/nd6.h sys/netinet6/nd6.h
index 3b08e2c5dfe..04885bc9c3e 100644
--- sys/netinet6/nd6.h
+++ sys/netinet6/nd6.h
@@ -50,10 +50,6 @@ struct nd_ifinfo {
u_int32_t flags;/* Flags */
int recalctm;   /* BaseReacable re-calculation timer */
u_int8_t initialized; /* Flag to see the entry is initialized */
-   /* the following 3 members are for privacy extension for addrconf */
-   u_int8_t randomseed0[8]; /* upper 64 bits of MD5 digest */
-   u_int8_t randomseed1[8]; /* lower 64 bits (usually the EUI64 IFID) */
-   u_int8_t randomid[8];   /* current random ID */
 };
 
 #define ND6_IFF_PERFORMNUD 0x1

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



nd6_rtr.c no longer needs nd6_recalc_reachtm_interval

2017-08-08 Thread Florian Obser
OK?

diff --git sys/netinet6/nd6_rtr.c sys/netinet6/nd6_rtr.c
index 886436ae863..3542964215d 100644
--- sys/netinet6/nd6_rtr.c
+++ sys/netinet6/nd6_rtr.c
@@ -59,8 +59,6 @@
 
 int rt6_deleteroute(struct rtentry *, void *, unsigned int);
 
-extern int nd6_recalc_reachtm_interval;
-
 /*
  * Receive Router Solicitation Message - just for routers.
  * Router solicitation/advertisement is mostly managed by userland program

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



Re: fstat output

2017-08-08 Thread Theo de Raadt
> $ fstat -f /tmp
> USER CMDPID   FD  MOUNTINUM   MODE  R/W
> SZ|DV
> mpi  fstat571461  /tmp  23  -rw-r--r--w   
> 16

Well that won't work.  Try it a standard 80-wide console.  Every line wraps,
reducing the visible context to 50%, and even using less doesn't help.
Sorry, that's worse. 79 is the limit.





faq/ports/guide: Improve wording

2017-08-08 Thread Klemens Nanni
This way it's feels much more natural to say.

Feedback?

Index: guide.html
===
RCS file: /cvs/www/faq/ports/guide.html,v
retrieving revision 1.72
diff -u -p -r1.72 guide.html
--- guide.html  7 Aug 2017 22:27:51 -   1.72
+++ guide.html  8 Aug 2017 15:29:54 -
@@ -795,8 +795,8 @@ in two variants:
 COMMENT-s2 for the second package,
 PLIST-s1, PLIST-s2, DESCR-s1, DESCR-s2.
 You need to write those COMMENT-s1 and COMMENT-s2 in the
-Makefile, and to split your PLIST into two parts, and to
-create DESCR-s1/DESCR-s2.
+Makefile, split your PLIST into two parts, and create
+DESCR-s1/DESCR-s2.
 You will also need to specify separate PKGNAMEs for all subpackages.
 
 



Re: fstat output

2017-08-08 Thread Martin Pieuchot
On 02/08/17(Wed) 09:34, Todd C. Miller wrote:
> On Wed, 02 Aug 2017 11:01:38 +0200, Alexander Bluhm wrote:
> 
> > On Wed, Aug 02, 2017 at 09:56:50AM +0200, Martin Pieuchot wrote:
> > > Simple diff to improved readability.  Before:
> > 
> > There are situations where you want a full match on the command.
> > For testing and scripting with long program names this is necessary.
> > With a -v switch that shows the long name I would accept the patch.
> > netstat has that, too.  And it would help in my use case.
> 
> Which long name do you mean?  ps_comm is limited to 16 characters.
> You won't really get the full process name without fetching argv
> and even then the program is free to modify argv[0].

New diff that uses 16 characters for ps_comm.

Before:

$ fstat -f /tmp
USER CMD  PID   FD MOUNTINUM MODE R/WSZ|DV
mpi  fstat  260251 /tmp   22  -rw-r--r-- w   16
mpi  ksh561601 /tmp   22  -rw-r--r-- w   16
mpi  python3.6  729313 /tmp   19* -rw---   rwe 4096
mpi  seahorse-sharing 14788   wd /tmp2  drwxrwxrwt r 
1024
mpi  gnome-shell 59193   19 /tmp   14* -rw---   rwe12288
$ fstat -nf /tmp
USER CMD  PID   FD  DEV  INUM   MODE   R/WSZ|DV
mpi  fstat  394821  4,19   22   100644w  495
mpi  ksh561601  4,19   22   100644w  495
mpi  python3.6  729313  4,19   19*  100600  rwe 4096
mpi  seahorse-sharing 14788   wd  4,19241777r 1024
mpi  gnome-shell 59193   19  4,19   14*  100600  rwe12288


After:

$ fstat -f /tmp
USER CMDPID   FD  MOUNTINUM   MODE  R/WSZ|DV
mpi  fstat571461  /tmp  23  -rw-r--r--w   16
mpi  ksh  344661  /tmp  23  -rw-r--r--w   16
mpi  python3.6729313  /tmp  19* -rw---  rwe 4096
mpi  seahorse-sharing 14788   wd  /tmp   2  drwxrwxrwtr 1024
mpi  gnome-shell  59193   19  /tmp  14* -rw---  rwe12288
$ fstat -nf /tmp
USER CMDPID   FD  DEV  INUM   MODE  R/WSZ|DV
mpi  fstat584861  4,19  23  100644w  519
mpi  ksh  344661  4,19  23  100644w  519
mpi  python3.6729313  4,19  19* 100600  rwe 4096
mpi  seahorse-sharing 14788   wd  4,19   2   41777r 1024
mpi  gnome-shell  59193   19  4,19  14* 100600  rwe12288


ok?

Index: fstat.c
===
RCS file: /cvs/src/usr.bin/fstat/fstat.c,v
retrieving revision 1.90
diff -u -p -r1.90 fstat.c
--- fstat.c 21 Jan 2017 12:21:57 -  1.90
+++ fstat.c 8 Aug 2017 15:24:04 -
@@ -316,12 +316,8 @@ main(int argc, char *argv[])
 void
 fstat_header(void)
 {
-   if (nflg)
-   printf("%s",
-"USER CMD  PID   FD  DEV  INUM   MODE   R/WSZ|DV");
-   else
-   printf("%s",
-"USER CMD  PID   FD MOUNTINUM MODE R/WSZ|DV");
+   printf("USER CMDPID   FD  %5sINUM"
+   "   MODE  R/WSZ|DV", (nflg) ? "DEV  " : "MOUNT");
if (oflg)
printf("%s", ":OFFSET  ");
if (checkfile && fsflg == 0)
@@ -336,7 +332,7 @@ uid_t   *procuid;
 pid_t  Pid;
 
 #define PREFIX(i) do { \
-   printf("%-8.8s %-10s %5ld", Uname, Comm, (long)Pid); \
+   printf("%-8.8s %-16.16s %5ld", Uname, Comm, (long)Pid); \
switch (i) { \
case KERN_FILE_TEXT: \
printf(" text"); \
@@ -432,14 +428,14 @@ vtrans(struct kinfo_file *kf)
}
 
if (nflg)
-   (void)printf(" %2ld,%-2ld", (long)major(kf->va_fsid),
+   (void)printf(" %2ld,%-2ld   ", (long)major(kf->va_fsid),
(long)minor(kf->va_fsid));
else if (!(kf->v_flag & VCLONE))
-   (void)printf(" %-8s", kf->f_mntonname);
+   (void)printf("  %-7s", kf->f_mntonname);
else
-   (void)printf(" clone   ");
+   (void)printf("  clone   ");
if (nflg)
-   (void)snprintf(mode, sizeof(mode), "%o", kf->va_mode);
+   (void)snprintf(mode, sizeof(mode), "%o ", kf->va_mode);
else
strmode(kf->va_mode, mode);
printf(" %8llu%s %11s", kf->va_fileid,
@@ -452,7 +448,7 @@ vtrans(struct kinfo_file *kf)
strlcat(rwep, "w", sizeof rwep);
if (kf->fd_ofileflags & UF_EXCLOSE)
strlcat(rwep, "e", sizeof rwep);
-   printf(" %4s", rwep);
+   printf(" %3s", rwep);
switch (kf->v_type) {
case VBLK:
case VCHR: {



Re: Improve the accuracy of the TSC frequency calibration (Was: Calculate the frequency of the tsc timecounter)

2017-08-08 Thread Mike Belopuhov
On Tue, Aug 08, 2017 at 08:18 +0800, Adam Steen wrote:
> On Mon, Jul 31, 2017 at 3:58 PM, Mike Belopuhov  wrote:
> > On Mon, Jul 31, 2017 at 09:48 +0800, Adam Steen wrote:
> >> Ted Unangst  wrote:
> >> > we don't currently export this info, but we could add some sysctls. 
> >> > there's
> >> > some cpufeatures stuff there, but generally stuff isn't exported until
> >> > somebody finds a use for it... it shouldn't be too hard to add something 
> >> > to
> >> > amd64/machdep.c sysctl if you're interested.
> >>
> >> I am interested, as i need the info, i will look into it and hopefully
> >> come back with a patch.
> >
> > This is a bad idea because TSC as the time source is only usable
> > by OpenBSD on Skylake and Kaby Lake CPUs since they encode the TSC
> > frequency in the CPUID. All older CPUs have their TSCs measured
> > against the PIT. Currently the measurement done by the kernel isn't
> > very precise and if TSC is selected as a timecounter, the machine
> > would be gaining time on a pace that cannot be corrected by our NTP
> > daemon. (IIRC, about an hour a day on my Haswell running with NTP).
> >
> > To be able to use TSC as a timecounter source on OpenBSD or Solo5
> > you'd have to improve the in-kernel measurement of the TSC frequency
> > first. I've tried to perform 10 measurements and take an average and
> > it does improve accuracy, however I believe we need to poach another
> > bit from Linux and re-calibrate TSC via HPET:
> >
> >  
> > http://elixir.free-electrons.com/linux/v4.12.4/source/arch/x86/kernel/tsc.c#L409
> >
> > I think this is the most sane thing we can do. Here's a complete
> > procedure that Linux kernel undertakes:
> >
> >  
> > http://elixir.free-electrons.com/linux/v4.12.4/source/arch/x86/kernel/tsc.c#L751
> >
> > Regards,
> > Mike
> 
> Hi Mike/All
> 
> I would like to improve the accuracy of TSC frequency calibration as
> Mike B. describes above.
> 
> I initially thought the calibration would take place at line 470 of
> amd64/identcpu.c
> (https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/arch/amd64/amd64/identcpu.c?annotate=1.87)
>

Indeed, it cannot happen there simply because you don't know at
that point whether or not HPET actually exists.

> But I looked into using the acpihpet directly but it is never exposed
> outside of acpihpet.c.
>

And it shouldn't be.

> Could someone point me to were if would be appropriate to complete
> this calibration and how to use the acpihpet?

The way I envision this is a multi-step approach:

1) TSC frequency is approximated with the PIT (possibly performing
multiple measurements and averaging them out; also keep in mind that
doing it 8 times means you can shift the sum right by 3 instead of
using actual integer division).  This is what should happen around
the line 470 of identcpu.c

2) A function can be provided by identcpu.c to further adjust the
TSC frequency once acpitimer(4) (this is a PM timer) and acpihpet(4)
(or any other timer for that matter) are attached.

3) Once acpitimer(4) or acpihpet(4) or any other timecounter source
are attached and are verified to be operating correctly, they can
perform TSC re-calibration and update the TSC frequency with their
measurements.  The idea here is that the function (or functions) that
facilitate this must abstract enough logic so that you don't have to
duplicate it in the acpitimer or acpihpet themselves.

> (Will it need to be
> exposed like i8254_delay/delay_func/delay in machdep.c and cpu.h)
>

No it won't.

> Lastly should the calibration be done using both delay(i8254 pit) and
> hpet timers similar to Linux described above or just using the hpet?
>

Well, that's what I was arguing for.  As I said in my initial mail
on misc (not quoted here), the TSC must be calibrated using separate
known clocks sources.



Re: [diff] httpd: tls client cert & CRL checks

2017-08-08 Thread Jack Burton
On Tue, 8 Aug 2017 15:10:36 +0930
Jack Burton  wrote:
> On Tue, 08 Aug 2017 14:23:02 +1000
> Joel Sing  wrote:
> > On Saturday 29 July 2017 20:49:18 Jan Klemkow wrote:
> > > In the End, I found and fixed the real bug here:
> > > 
> > > @@ -430,7 +438,11 @@ config_getserver_config(struct httpd *en
> > > }
> > > 
> > > f = SRVFLAG_TLS;
> > > -   srv_conf->flags |= parent->flags & f;
> > > +   if ((srv_conf->flags & f) == 0) {
> > > +   srv_conf->flags |= parent->flags & f;
> > > +   srv_conf->tls_ca = parent->tls_ca;
> > > +   srv_conf->tls_crl = parent->tls_crl;
> > 
> > I'd have to double check, however I'm pretty sure that this will
> > result in a double-free since you're copying the pointer (without a
> > reference count) across server config structs. Both will likely be
> > passed to serverconfig_free(), which means free() will then be
> > passed the same pointer twice.  
> 
> You're absolutely right. That happens when purging config on reload,
> if the old config for a server doing tls client verify has two or more
> location blocks...
> 
> ...and my 30 July diff suffers from the same problem.
<...>
> Perhaps a better alternative would be to free the CA & CRL mem at the
> end of server_tls_init() -- like we do already for the key pair --
> then add flags for CA & CRL use instead of just checking for null
> pointers everywhere (as both my & Jan's diffs have been doing so far).
> 
> It seems I have a couple of other changes to make too, so will roll
> something like that in with them & post a revised diff later today or
> tomorrow.

Okay, here's a further revised diff that takes the approach I proposed
above to fixing the bug that Joel pointed out and also makes a few
other small changes that were suggested to me off list:
* the tls client ca directive now has an "optional" option (to request
  a client cert but not require it);
* the extra bit string I got rid off a diff or two ago is back again,
  now passed through to fcgi as TLS_PEER_VERIFY (since there are now
  multiple possible modes of operation for tls client certs, so fcgi
  responders should have some way of knowing which are in use);
* reworded the descriptions of the TLS_PEER_* fcgi vars in
  httpd.conf(5); and
* fixed a minor typo in httpd.conf(5) that my earlier diff
  had introduced.

Thoughts?

Index: usr.sbin/httpd/config.c
===
RCS file: /cvs/src/usr.sbin/httpd/config.c,v
retrieving revision 1.53
diff -u -p -r1.53 config.c
--- usr.sbin/httpd/config.c 19 Jul 2017 17:36:25 -  1.53
+++ usr.sbin/httpd/config.c 8 Aug 2017 12:36:19 -
@@ -304,10 +304,18 @@ config_setserver_tls(struct httpd *env, 
 
log_debug("%s: configuring tls for %s", __func__, srv_conf->name);
 
+   if (config_settls(env, srv, TLS_CFG_CA, "ca", srv_conf->tls_ca,
+   srv_conf->tls_ca_len) != 0)
+   return (-1);
+
if (config_settls(env, srv, TLS_CFG_CERT, "cert", srv_conf->tls_cert,
srv_conf->tls_cert_len) != 0)
return (-1);
 
+   if (config_settls(env, srv, TLS_CFG_CRL, "crl", srv_conf->tls_crl,
+   srv_conf->tls_crl_len) != 0)
+   return (-1);
+
if (config_settls(env, srv, TLS_CFG_KEY, "key", srv_conf->tls_key,
srv_conf->tls_key_len) != 0)
return (-1);
@@ -431,6 +439,7 @@ config_getserver_config(struct httpd *en
 
f = SRVFLAG_TLS;
srv_conf->flags |= parent->flags & f;
+   srv_conf->tlsflags = parent->tlsflags;
 
f = SRVFLAG_ACCESS_LOG;
if ((srv_conf->flags & f) == 0) {
@@ -655,9 +664,21 @@ config_getserver_tls(struct httpd *env, 
}
 
switch (tls_conf.tls_type) {
+   case TLS_CFG_CA:
+   if (config_gettls(env, srv_conf, &tls_conf, "ca", p, len,
+   &srv_conf->tls_ca, &srv_conf->tls_ca_len) != 0)
+   goto fail;
+   break;
+
case TLS_CFG_CERT:
if (config_gettls(env, srv_conf, &tls_conf, "cert", p, len,
&srv_conf->tls_cert, &srv_conf->tls_cert_len) != 0)
+   goto fail;
+   break;
+
+   case TLS_CFG_CRL:
+   if (config_gettls(env, srv_conf, &tls_conf, "crl", p, len,
+   &srv_conf->tls_crl, &srv_conf->tls_crl_len) != 0)
goto fail;
break;
 
Index: usr.sbin/httpd/httpd.conf.5
===
RCS file: /cvs/src/usr.sbin/httpd/httpd.conf.5,v
retrieving revision 1.82
diff -u -p -r1.82 httpd.conf.5
--- usr.sbin/httpd/httpd.conf.5 9 Apr 2017 09:13:28 -   1.82
+++ usr.sbin/httpd/httpd.conf.5 8 Aug 2017 12:36:19 -
@@ -342,7 +342,37 @@ The revision of the HTTP specification u
 .It Ic SERVER_SOFTWARE
 

Re: ip local input queue length

2017-08-08 Thread Claudio Jeker
On Tue, Aug 08, 2017 at 01:27:27PM +0200, Alexander Bluhm wrote:
> On Tue, Aug 08, 2017 at 12:00:58AM +0200, Alexander Bluhm wrote:
> > By increasing this value from 256 to 2048 I get much better results.
> 
> Now with a define instead of a magic value.
> 
> I think the if_congestion algorithm is not compatible with the way
> the network stack works now.  But to make progress with performance
> tuning, I think we should increase the limit here, so that it is
> not hit.  Then we can see real bottlenecks, learn and revisit the
> congestion algorithm later.
> 
> ok?

I run with 4k or 8k there because the limit on the mbuf queues is 8k.
Actually this double queuing makes things worse at the moment and that's
why we need to bump the number so much. If not the softnet thread will
dequeue packets and drop them in the ip input queue becaue the limit was
hit. Long run the ip input queues should be removed. Didn't mpi have a
diff for that or did some work on this.

OK claudio@ on the diff (people can still fine tune via sysctl).

 
> bluhm
> 
> Index: netinet/ip.h
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip.h,v
> retrieving revision 1.16
> diff -u -p -r1.16 ip.h
> --- netinet/ip.h  13 Jul 2014 13:57:56 -  1.16
> +++ netinet/ip.h  8 Aug 2017 11:19:30 -
> @@ -209,6 +209,10 @@ struct   ip_timestamp {
>  #define  IP_MSS  576 /* default maximum segment size 
> */
>  
>  #ifdef _KERNEL
> +
> +/* Maximum lenght for IP protocol queues */
> +#define IPQ_MAXLEN   2048
> +
>  /*
>   * This is the real IPv4 pseudo header, used for computing the TCP and UDP
>   * checksums. For the Internet checksum, struct ipovly can be used instead.
> Index: netinet/ip_input.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_input.c,v
> retrieving revision 1.316
> diff -u -p -r1.316 ip_input.c
> --- netinet/ip_input.c4 Aug 2017 14:24:05 -   1.316
> +++ netinet/ip_input.c8 Aug 2017 11:19:23 -
> @@ -120,7 +120,7 @@ int   ip_frags = 0;
>  
>  int *ipctl_vars[IPCTL_MAXID] = IPCTL_VARS;
>  
> -struct niqueue ipintrq = NIQUEUE_INITIALIZER(IFQ_MAXLEN, NETISR_IP);
> +struct niqueue ipintrq = NIQUEUE_INITIALIZER(IPQ_MAXLEN, NETISR_IP);
>  
>  struct pool ipqent_pool;
>  struct pool ipq_pool;
> Index: netinet6/ip6_input.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6_input.c,v
> retrieving revision 1.199
> diff -u -p -r1.199 ip6_input.c
> --- netinet6/ip6_input.c  4 Aug 2017 14:24:05 -   1.199
> +++ netinet6/ip6_input.c  8 Aug 2017 11:19:43 -
> @@ -114,7 +114,7 @@
>  #include 
>  #endif
>  
> -struct niqueue ip6intrq = NIQUEUE_INITIALIZER(IFQ_MAXLEN, NETISR_IPV6);
> +struct niqueue ip6intrq = NIQUEUE_INITIALIZER(IPQ_MAXLEN, NETISR_IPV6);
>  
>  struct cpumem *ip6counters;
>  
> 

-- 
:wq Claudio



Re: ip local input queue length

2017-08-08 Thread Alexander Bluhm
On Tue, Aug 08, 2017 at 12:00:58AM +0200, Alexander Bluhm wrote:
> By increasing this value from 256 to 2048 I get much better results.

Now with a define instead of a magic value.

I think the if_congestion algorithm is not compatible with the way
the network stack works now.  But to make progress with performance
tuning, I think we should increase the limit here, so that it is
not hit.  Then we can see real bottlenecks, learn and revisit the
congestion algorithm later.

ok?

bluhm

Index: netinet/ip.h
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip.h,v
retrieving revision 1.16
diff -u -p -r1.16 ip.h
--- netinet/ip.h13 Jul 2014 13:57:56 -  1.16
+++ netinet/ip.h8 Aug 2017 11:19:30 -
@@ -209,6 +209,10 @@ struct ip_timestamp {
 #defineIP_MSS  576 /* default maximum segment size 
*/
 
 #ifdef _KERNEL
+
+/* Maximum lenght for IP protocol queues */
+#define IPQ_MAXLEN 2048
+
 /*
  * This is the real IPv4 pseudo header, used for computing the TCP and UDP
  * checksums. For the Internet checksum, struct ipovly can be used instead.
Index: netinet/ip_input.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.316
diff -u -p -r1.316 ip_input.c
--- netinet/ip_input.c  4 Aug 2017 14:24:05 -   1.316
+++ netinet/ip_input.c  8 Aug 2017 11:19:23 -
@@ -120,7 +120,7 @@ int ip_frags = 0;
 
 int *ipctl_vars[IPCTL_MAXID] = IPCTL_VARS;
 
-struct niqueue ipintrq = NIQUEUE_INITIALIZER(IFQ_MAXLEN, NETISR_IP);
+struct niqueue ipintrq = NIQUEUE_INITIALIZER(IPQ_MAXLEN, NETISR_IP);
 
 struct pool ipqent_pool;
 struct pool ipq_pool;
Index: netinet6/ip6_input.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.199
diff -u -p -r1.199 ip6_input.c
--- netinet6/ip6_input.c4 Aug 2017 14:24:05 -   1.199
+++ netinet6/ip6_input.c8 Aug 2017 11:19:43 -
@@ -114,7 +114,7 @@
 #include 
 #endif
 
-struct niqueue ip6intrq = NIQUEUE_INITIALIZER(IFQ_MAXLEN, NETISR_IPV6);
+struct niqueue ip6intrq = NIQUEUE_INITIALIZER(IPQ_MAXLEN, NETISR_IPV6);
 
 struct cpumem *ip6counters;
 



rtadvd: simplify route message handling

2017-08-08 Thread Jeremie Courreges-Anglas

So rtadvd has this complex code that tries to parse multiple routing
messages, when it actually reads only one message at a time from the
routing socket.  The diff below attempts to acknowledge this and tries
to be as mechanical as possible, variable renaming/gc'ing can happen
later.  Better use cvs diff -b to review this diff.

Thoughts?  ok?


Index: if.c
===
RCS file: /d/cvs/src/usr.sbin/rtadvd/if.c,v
retrieving revision 1.44
diff -u -p -r1.44 if.c
--- if.c12 Jul 2017 06:11:45 -  1.44
+++ if.c8 Aug 2017 07:45:27 -
@@ -186,80 +186,70 @@ lladdropt_fill(struct sockaddr_dl *sdl, 
 }
 
 #define SIN6(s) ((struct sockaddr_in6 *)(s))
-char *
-get_next_msg(char *buf, char *lim, size_t *lenp)
+int
+validate_msg(char *buf)
 {
-   struct rt_msghdr *rtm;
+   struct rt_msghdr *rtm = (struct rt_msghdr *)buf;
struct ifa_msghdr *ifam;
struct sockaddr *sa, *dst, *ifa, *rti_info[RTAX_MAX];
 
-   *lenp = 0;
-   for (rtm = (struct rt_msghdr *)buf;
-rtm < (struct rt_msghdr *)lim;
-rtm = (struct rt_msghdr *)((char *)rtm + rtm->rtm_msglen)) {
-   /* just for safety */
-   if (!rtm->rtm_msglen) {
-   log_warnx("rtm_msglen is 0 (buf=%p lim=%p rtm=%p)",
-   buf, lim, rtm);
-   break;
-   }
-   if (rtm->rtm_version != RTM_VERSION)
-   continue;
-
-   switch (rtm->rtm_type) {
-   case RTM_ADD:
-   case RTM_DELETE:
-   if (rtm->rtm_tableid != 0)
-   continue;
-
-   /* address related checks */
-   sa = (struct sockaddr *)((char *)rtm + rtm->rtm_hdrlen);
-   get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
-   if ((dst = rti_info[RTAX_DST]) == NULL ||
-   dst->sa_family != AF_INET6)
-   continue;
-
-   if (IN6_IS_ADDR_LINKLOCAL(&SIN6(dst)->sin6_addr) ||
-   IN6_IS_ADDR_MULTICAST(&SIN6(dst)->sin6_addr))
-   continue;
-
-   if (rti_info[RTAX_NETMASK] == NULL)
-   continue;
-
-   /* found */
-   *lenp = rtm->rtm_msglen;
-   return (char *)rtm;
-   /* NOTREACHED */
-   case RTM_NEWADDR:
-   case RTM_DELADDR:
-   ifam = (struct ifa_msghdr *)rtm;
-
-   /* address related checks */
-   sa = (struct sockaddr *)((char *)rtm + rtm->rtm_hdrlen);
-   get_rtaddrs(ifam->ifam_addrs, sa, rti_info);
-   if ((ifa = rti_info[RTAX_IFA]) == NULL ||
-   (ifa->sa_family != AF_INET &&
-ifa->sa_family != AF_INET6))
-   continue;
-
-   if (ifa->sa_family == AF_INET6 &&
-   (IN6_IS_ADDR_LINKLOCAL(&SIN6(ifa)->sin6_addr) ||
-IN6_IS_ADDR_MULTICAST(&SIN6(ifa)->sin6_addr)))
-   continue;
-
-   /* found */
-   *lenp = rtm->rtm_msglen;
-   return (char *)rtm;
-   /* NOTREACHED */
-   case RTM_IFINFO:
-   /* found */
-   *lenp = rtm->rtm_msglen;
-   return (char *)rtm;
-   /* NOTREACHED */
-   }
+   /* just for safety */
+   if (!rtm->rtm_msglen) {
+   log_warnx("rtm_msglen is 0 (rtm=%p)", rtm);
+   return -1;
}
+   if (rtm->rtm_version != RTM_VERSION)
+   return -1;
 
-   return (char *)rtm;
+   switch (rtm->rtm_type) {
+   case RTM_ADD:
+   case RTM_DELETE:
+   if (rtm->rtm_tableid != 0)
+   return -1;
+
+   /* address related checks */
+   sa = (struct sockaddr *)((char *)rtm + rtm->rtm_hdrlen);
+   get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
+   if ((dst = rti_info[RTAX_DST]) == NULL ||
+   dst->sa_family != AF_INET6)
+   return -1;
+
+   if (IN6_IS_ADDR_LINKLOCAL(&SIN6(dst)->sin6_addr) ||
+   IN6_IS_ADDR_MULTICAST(&SIN6(dst)->sin6_addr))
+   return -1;
+
+   if (rti_info[RTAX_NETMASK] == NULL)
+   return -1;
+
+   /* found */
+   return 0;
+   /* NOTREACHED */
+   case RTM_NEWADDR:
+   case RTM_DELADDR:
+   ifam = (struct ifa_msghdr *)rtm;
+
+   /* address related checks */
+   

Re: Dynamic interfaces broken in 1.1028 of distrib/miniroot/install.sub

2017-08-08 Thread Robert Peichaer
On Tue, Aug 08, 2017 at 03:40:03AM +0200, Pontus Lundkvist wrote:
> Hi,
> 
> This change introduced in version 1.1028 of distrib/miniroot/install.sub seems
> wrong or incomplete. (Pardon the lack of tabs):
> 
> for _hn in $_trunks $_svlans $_vlans; do
> -   ifstart $_hn
> +   ifstart $_if
> done
> 
> Either _hn should be changed to _if as well, or just leave the change out, no?
> 
> As it is now, it'll only ifstart the last $_if from the for-loop above.
> Noticed when auto upgrade stopped working, depending on internet via vlan.
> 
> s/_if/_hn/ on that line and rerunning the autoinstaller worked.
> 
> Regards,
> Pontus

I just committed a fix for this.

Thanks!

-- 
-=[rpe]=-