Re: Kill sysctl net.inet6.ip6.v6only

2016-05-18 Thread Claudio Jeker
On Thu, May 19, 2016 at 01:15:57AM +0200, Jeremie Courreges-Anglas wrote:
> 
> As noticed by djm it doesn't make much sense to expose this in sysctl(8)
> output.
> 
> ok?

OK, especially since it makes the setsockopt code path actually
understandable.
 
> Index: sbin/sysctl/sysctl.8
> ===
> RCS file: /cvs/src/sbin/sysctl/sysctl.8,v
> retrieving revision 1.193
> diff -u -p -r1.193 sysctl.8
> --- sbin/sysctl/sysctl.8  31 Mar 2016 15:53:25 -  1.193
> +++ sbin/sysctl/sysctl.8  18 May 2016 22:17:40 -
> @@ -295,7 +295,6 @@ and a few require a kernel compiled with
>  .It net.inet6.ip6.defmcasthlim Ta integer Ta yes
>  .It net.inet6.ip6.use_deprecated Ta integer Ta yes
>  .It net.inet6.ip6.rr_prune Ta integer Ta yes
> -.It net.inet6.ip6.v6only Ta integer Ta no
>  .It net.inet6.ip6.maxfrags Ta integer Ta yes
>  .It net.inet6.ip6.mforwarding Ta integer Ta yes
>  .It net.inet6.ip6.multipath Ta integer Ta yes
> Index: sys/netinet6/in6.h
> ===
> RCS file: /cvs/src/sys/netinet6/in6.h,v
> retrieving revision 1.87
> diff -u -p -r1.87 in6.h
> --- sys/netinet6/in6.h3 Dec 2015 10:34:24 -   1.87
> +++ sys/netinet6/in6.h18 May 2016 22:17:40 -
> @@ -577,8 +577,7 @@ ifatoia6(struct ifaddr *ifa)
>  #define IPV6CTL_DEFMCASTHLIM 18
>  #define IPV6CTL_USE_DEPRECATED   21  /* use deprecated addr (RFC2462 
> 5.5.4) */
>  #define IPV6CTL_RR_PRUNE 22  /* walk timer for router renumbering */
> -#define IPV6CTL_V6ONLY   24
> -/* 25 to 40: resrved */
> +/* 24 to 40: reserved */
>  #define IPV6CTL_MAXFRAGS 41  /* max fragments */
>  #define IPV6CTL_MFORWARDING  42
>  #define IPV6CTL_MULTIPATH43
> @@ -622,7 +621,7 @@ ifatoia6(struct ifaddr *ifa)
>   { "use_deprecated", CTLTYPE_INT }, \
>   { "rr_prune", CTLTYPE_INT }, \
>   { 0, 0 }, \
> - { "v6only", CTLTYPE_INT }, \
> + { 0, 0 }, \
>   { 0, 0 }, \
>   { 0, 0 }, \
>   { 0, 0 }, \
> Index: sys/netinet6/in6_proto.c
> ===
> RCS file: /cvs/src/sys/netinet6/in6_proto.c,v
> retrieving revision 1.84
> diff -u -p -r1.84 in6_proto.c
> --- sys/netinet6/in6_proto.c  3 Dec 2015 21:57:59 -   1.84
> +++ sys/netinet6/in6_proto.c  18 May 2016 22:17:40 -
> @@ -282,7 +282,6 @@ int   ip6_use_deprecated = 1; /* allow dep
>  int  ip6_rr_prune = 5;   /* router renumbering prefix
>* walk list every 5 sec.*/
>  int  ip6_mcast_pmtu = 0; /* enable pMTU discovery for multicast? */
> -const int ip6_v6only = 1;
>  int  ip6_neighborgcthresh = 2048; /* Threshold # of NDP entries for GC */
>  int  ip6_maxifprefixes = 16; /* Max acceptable prefixes via RA per IF */
>  int  ip6_maxifdefrouters = 16; /* Max acceptable def routers via RA */
> Index: sys/netinet6/ip6_input.c
> ===
> RCS file: /cvs/src/sys/netinet6/ip6_input.c,v
> retrieving revision 1.159
> diff -u -p -r1.159 ip6_input.c
> --- sys/netinet6/ip6_input.c  7 May 2016 09:58:06 -   1.159
> +++ sys/netinet6/ip6_input.c  18 May 2016 22:17:40 -
> @@ -1369,8 +1369,6 @@ ip6_sysctl(int *name, u_int namelen, voi
>   return (ENOTDIR);
>  
>   switch (name[0]) {
> - case IPV6CTL_V6ONLY:
> - return sysctl_rdint(oldp, oldlenp, newp, ip6_v6only);
>   case IPV6CTL_DAD_PENDING:
>   return sysctl_rdint(oldp, oldlenp, newp, ip6_dad_pending);
>   case IPV6CTL_STATS:
> Index: sys/netinet6/ip6_output.c
> ===
> RCS file: /cvs/src/sys/netinet6/ip6_output.c,v
> retrieving revision 1.206
> diff -u -p -r1.206 ip6_output.c
> --- sys/netinet6/ip6_output.c 29 Apr 2016 11:40:27 -  1.206
> +++ sys/netinet6/ip6_output.c 18 May 2016 22:17:40 -
> @@ -1237,11 +1237,11 @@ do { \
>   error = EINVAL;
>   break;
>   }
> - if ((ip6_v6only && optval) ||
> - (!ip6_v6only && !optval))
> - error = 0;
> - else
> + /* No support for IPv4-mapped 
> addresses. */
> + if (!optval)
>   error = EINVAL;
> + else
> + error = 0;
>   break;
>   case IPV6_RECVTCLASS:
>   OPTSET(IN6P_TCLASS);
> @@ -1493,7 +1493,7 @@ do { \
>   break;
>  
>

msg buf lmin

2016-05-18 Thread Alexander Bluhm
Hi,

All msg buf counters are long, so lmin(9) should be used here.

ok?

bluhm

Index: kern/subr_log.c
===
RCS file: /cvs/src/sys/kern/subr_log.c,v
retrieving revision 1.43
diff -u -p -r1.43 subr_log.c
--- kern/subr_log.c 18 May 2016 23:42:12 -  1.43
+++ kern/subr_log.c 19 May 2016 00:00:23 -
@@ -145,7 +145,7 @@ msgbuf_putchar(struct msgbuf *mbp, const
return;
 
mbp->msg_bufc[mbp->msg_bufx++] = c;
-   mbp->msg_bufl = min(mbp->msg_bufl+1, mbp->msg_bufs);
+   mbp->msg_bufl = lmin(mbp->msg_bufl+1, mbp->msg_bufs);
if (mbp->msg_bufx < 0 || mbp->msg_bufx >= mbp->msg_bufs)
mbp->msg_bufx = 0;
/* If the buffer is full, keep the most recent data. */



Kill sysctl net.inet6.ip6.v6only

2016-05-18 Thread Jeremie Courreges-Anglas

As noticed by djm it doesn't make much sense to expose this in sysctl(8)
output.

ok?

Index: sbin/sysctl/sysctl.8
===
RCS file: /cvs/src/sbin/sysctl/sysctl.8,v
retrieving revision 1.193
diff -u -p -r1.193 sysctl.8
--- sbin/sysctl/sysctl.831 Mar 2016 15:53:25 -  1.193
+++ sbin/sysctl/sysctl.818 May 2016 22:17:40 -
@@ -295,7 +295,6 @@ and a few require a kernel compiled with
 .It net.inet6.ip6.defmcasthlim Ta integer Ta yes
 .It net.inet6.ip6.use_deprecated Ta integer Ta yes
 .It net.inet6.ip6.rr_prune Ta integer Ta yes
-.It net.inet6.ip6.v6only Ta integer Ta no
 .It net.inet6.ip6.maxfrags Ta integer Ta yes
 .It net.inet6.ip6.mforwarding Ta integer Ta yes
 .It net.inet6.ip6.multipath Ta integer Ta yes
Index: sys/netinet6/in6.h
===
RCS file: /cvs/src/sys/netinet6/in6.h,v
retrieving revision 1.87
diff -u -p -r1.87 in6.h
--- sys/netinet6/in6.h  3 Dec 2015 10:34:24 -   1.87
+++ sys/netinet6/in6.h  18 May 2016 22:17:40 -
@@ -577,8 +577,7 @@ ifatoia6(struct ifaddr *ifa)
 #define IPV6CTL_DEFMCASTHLIM   18
 #define IPV6CTL_USE_DEPRECATED 21  /* use deprecated addr (RFC2462 5.5.4) 
*/
 #define IPV6CTL_RR_PRUNE   22  /* walk timer for router renumbering */
-#define IPV6CTL_V6ONLY 24
-/* 25 to 40: resrved */
+/* 24 to 40: reserved */
 #define IPV6CTL_MAXFRAGS   41  /* max fragments */
 #define IPV6CTL_MFORWARDING42
 #define IPV6CTL_MULTIPATH  43
@@ -622,7 +621,7 @@ ifatoia6(struct ifaddr *ifa)
{ "use_deprecated", CTLTYPE_INT }, \
{ "rr_prune", CTLTYPE_INT }, \
{ 0, 0 }, \
-   { "v6only", CTLTYPE_INT }, \
+   { 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
Index: sys/netinet6/in6_proto.c
===
RCS file: /cvs/src/sys/netinet6/in6_proto.c,v
retrieving revision 1.84
diff -u -p -r1.84 in6_proto.c
--- sys/netinet6/in6_proto.c3 Dec 2015 21:57:59 -   1.84
+++ sys/netinet6/in6_proto.c18 May 2016 22:17:40 -
@@ -282,7 +282,6 @@ int ip6_use_deprecated = 1; /* allow dep
 intip6_rr_prune = 5;   /* router renumbering prefix
 * walk list every 5 sec.*/
 intip6_mcast_pmtu = 0; /* enable pMTU discovery for multicast? */
-const int ip6_v6only = 1;
 intip6_neighborgcthresh = 2048; /* Threshold # of NDP entries for GC */
 intip6_maxifprefixes = 16; /* Max acceptable prefixes via RA per IF */
 intip6_maxifdefrouters = 16; /* Max acceptable def routers via RA */
Index: sys/netinet6/ip6_input.c
===
RCS file: /cvs/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.159
diff -u -p -r1.159 ip6_input.c
--- sys/netinet6/ip6_input.c7 May 2016 09:58:06 -   1.159
+++ sys/netinet6/ip6_input.c18 May 2016 22:17:40 -
@@ -1369,8 +1369,6 @@ ip6_sysctl(int *name, u_int namelen, voi
return (ENOTDIR);
 
switch (name[0]) {
-   case IPV6CTL_V6ONLY:
-   return sysctl_rdint(oldp, oldlenp, newp, ip6_v6only);
case IPV6CTL_DAD_PENDING:
return sysctl_rdint(oldp, oldlenp, newp, ip6_dad_pending);
case IPV6CTL_STATS:
Index: sys/netinet6/ip6_output.c
===
RCS file: /cvs/src/sys/netinet6/ip6_output.c,v
retrieving revision 1.206
diff -u -p -r1.206 ip6_output.c
--- sys/netinet6/ip6_output.c   29 Apr 2016 11:40:27 -  1.206
+++ sys/netinet6/ip6_output.c   18 May 2016 22:17:40 -
@@ -1237,11 +1237,11 @@ do { \
error = EINVAL;
break;
}
-   if ((ip6_v6only && optval) ||
-   (!ip6_v6only && !optval))
-   error = 0;
-   else
+   /* No support for IPv4-mapped 
addresses. */
+   if (!optval)
error = EINVAL;
+   else
+   error = 0;
break;
case IPV6_RECVTCLASS:
OPTSET(IN6P_TCLASS);
@@ -1493,7 +1493,7 @@ do { \
break;
 
case IPV6_V6ONLY:
-   optval = (ip6_v6only != 0); /* XXX */
+   optval = 1;
break;
 
case IPV6_PORTRANGE:
Index: sys/netinet6/ip6_var.h

Enforce ether_output() requirements

2016-05-18 Thread Martin Pieuchot
Back in the old cool days you could simply call ether_output() with a
stuffed sockaddr and it will do the L2 resolution for you...  Well as
long as you do not care about IPv6 it's true.

During the last years I tried to reduce the number of places where
ether_output() was called without passing it a "struct rtentry" as
last argument.  The reason for this move is to remove a potential
route insertion in arpresolve(), done in read-only context (hot path).

Diff below convert the last offender explicitly passing NULL to an
if_output() function: pf_route().

I'm interested in tests but keep in mind that it is highly probable
that some code paths still path a NULL pointer as last argument, if
rtalloc(9) fails and its return is not checked.  That's why I added
a KASSERT(), to fix these cases.

Index: net/if_ethersubr.c
===
RCS file: /cvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.236
diff -u -p -r1.236 if_ethersubr.c
--- net/if_ethersubr.c  18 May 2016 20:15:14 -  1.236
+++ net/if_ethersubr.c  18 May 2016 20:45:47 -
@@ -193,8 +193,12 @@ ether_output(struct ifnet *ifp, struct m
struct mbuf *mcopy = NULL;
struct ether_header *eh;
struct arpcom *ac = (struct arpcom *)ifp;
+   sa_family_t af = dst->sa_family;
int error = 0;
 
+   KASSERT(rt != NULL || ISSET(m->m_flags, M_MCAST|M_BCAST) ||
+   af == AF_UNSPEC || af == pseudo_AF_HDRCMPLT);
+
 #ifdef DIAGNOSTIC
if (ifp->if_rdomain != rtable_l2(m->m_pkthdr.ph_rtableid)) {
printf("%s: trying to send packet on wrong domain. "
@@ -208,7 +212,7 @@ ether_output(struct ifnet *ifp, struct m
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
 
-   switch (dst->sa_family) {
+   switch (af) {
case AF_INET:
error = arpresolve(ifp, rt, m, dst, edst);
if (error)
Index: net/pf.c
===
RCS file: /cvs/src/sys/net/pf.c,v
retrieving revision 1.970
diff -u -p -r1.970 pf.c
--- net/pf.c3 May 2016 12:13:38 -   1.970
+++ net/pf.c18 May 2016 20:45:49 -
@@ -5574,6 +5574,12 @@ pf_route(struct mbuf **m, struct pf_rule
s->rt_addr.v4.s_addr;
ifp = s->rt_kif ? s->rt_kif->pfik_ifp : NULL;
}
+
+   rt = rtalloc(sintosa(dst), RT_RESOLVE, rtableid);
+   if (rt == NULL) {
+   ipstat.ips_noroute++;
+   goto bad;
+   }
}
if (ifp == NULL)
goto bad;
@@ -5602,7 +5608,7 @@ pf_route(struct mbuf **m, struct pf_rule
ipstat.ips_outswcsum++;
ip->ip_sum = in_cksum(m0, ip->ip_hl << 2);
}
-   error = ifp->if_output(ifp, m0, sintosa(dst), NULL);
+   error = ifp->if_output(ifp, m0, sintosa(dst), rt);
goto done;
}
 
@@ -5631,7 +5637,7 @@ pf_route(struct mbuf **m, struct pf_rule
m1 = m0->m_nextpkt;
m0->m_nextpkt = 0;
if (error == 0)
-   error = ifp->if_output(ifp, m0, sintosa(dst), NULL);
+   error = ifp->if_output(ifp, m0, sintosa(dst), rt);
else
m_freem(m0);
}
Index: netinet/if_ether.c
===
RCS file: /cvs/src/sys/netinet/if_ether.c,v
retrieving revision 1.207
diff -u -p -r1.207 if_ether.c
--- netinet/if_ether.c  18 May 2016 20:15:14 -  1.207
+++ netinet/if_ether.c  18 May 2016 20:45:50 -
@@ -294,40 +294,28 @@ arpresolve(struct ifnet *ifp, struct rte
return (0);
}
 
-   if (rt0 != NULL) {
-   error = rt_checkgate(rt0, );
-   if (error) {
-   m_freem(m);
-   return (error);
-   }
+   error = rt_checkgate(rt0, );
+   if (error) {
+   m_freem(m);
+   return (error);
+   }
 
-   if ((rt->rt_flags & RTF_LLINFO) == 0) {
-   log(LOG_DEBUG, "%s: %s: route contains no arp"
-   " information\n", __func__, inet_ntop(AF_INET,
-   (rt_key(rt))->sin_addr, addr,
-   sizeof(addr)));
-   m_freem(m);
-   return (EINVAL);
-   }
+   if ((rt->rt_flags & RTF_LLINFO) == 0) {
+   log(LOG_DEBUG, "%s: %s: route contains no arp"
+   " information\n", __func__, inet_ntop(AF_INET,
+   (rt_key(rt))->sin_addr, addr,
+   sizeof(addr)));
+   m_freem(m);
+   return (EINVAL);
+   }
 
-   la = (struct 

Re: usb: cache vendor, product and serial

2016-05-18 Thread Ted Unangst
Patrick Wildt wrote:
> The same issue can be reproduced by calling usbdevs(8) in a loop.  It
> uses the same ioctl and "breaks" this usb mass storage.

As a rule, we should limit the contact users have with hardware. "Safe"
readonly operations are no exception.



Re: usb: cache vendor, product and serial

2016-05-18 Thread Martin Pieuchot
On 18/05/16(Wed) 18:28, Patrick Wildt wrote:
> Hi,
> 
> I had the pleasure of debugging a USB mass storage device that showed
> interesting behaviour when used with our stack and in combination with
> the blink(1) usb device.
> 
> The blink(1)-tool depends on libusb.  Libusb calls ioctl(USB_DEVICEINFO)
> plenty of times to get a map of the USB tree.  Per ioctl, three USB
> requests are created (to read: vendor, product, serial).  This kind of
> floods all connected USB devices.
> 
> I have a hotplugd script that waits for usb mass storage devices, reads
> the disklabel, fscks and tries to mount a partition.  Due to the ioctl,
> one of those calls, which mostly only read from the storage device,
> freeze until they later time out.  The flood of read requests caused
> by the ioctl seem to make the mass storage halt its operation.
> 
> The same issue can be reproduced by calling usbdevs(8) in a loop.  It
> uses the same ioctl and "breaks" this usb mass storage.
>
> An idea is to cache those three strings, so that the ioctl does not
> create any requests.  NetBSD seems to have implemented a caching
> mechanism to fix a similar issue.  Though they have not enabled the
> caching for that specific ioctl.

They did this caching because their stack call the function multiple
times during the attachment of a device.

> The idea of this diff, adapted from NetBSD, is that we read out the
> strings early on when the device is found, store a copy of those per
> device.  Then whenever it's needed it can be used.
> 
> ok? Comments?

ok mpi@

I'd also like to see if we can always use the cache.  Because it is
unlikely that a vendor or product name will change.

> diff --git sys/dev/usb/usb.c sys/dev/usb/usb.c
> index 732ecfd..c198bf0 100644
> --- sys/dev/usb/usb.c
> +++ sys/dev/usb/usb.c
> @@ -520,7 +520,7 @@ usb_fill_di_task(void *arg)
>   if (dev == NULL)
>   return;
>  
> - usbd_fill_deviceinfo(dev, di, 1);
> + usbd_fill_deviceinfo(dev, di, 0);
>  }
>  
>  void
> diff --git sys/dev/usb/usb_subr.c sys/dev/usb/usb_subr.c
> index a255793..fef6d52 100644
> --- sys/dev/usb/usb_subr.c
> +++ sys/dev/usb/usb_subr.c
> @@ -63,6 +63,7 @@ usbd_status usbd_set_config(struct usbd_device *, int);
>  void usbd_devinfo(struct usbd_device *, int, char *, size_t);
>  void usbd_devinfo_vp(struct usbd_device *, char *, size_t,
>   char *, size_t, int);
> +void usbd_get_device_string(struct usbd_device *, uByte, char **);
>  char *usbd_get_string(struct usbd_device *, int, char *, size_t);
>  int  usbd_getnewaddr(struct usbd_bus *);
>  int  usbd_print(void *, const char *);
> @@ -212,6 +213,28 @@ usbd_trim_spaces(char *p)
>  }
>  
>  void
> +usbd_get_device_string(struct usbd_device *dev, uByte index, char **buf)
> +{
> + char *b = malloc(USB_MAX_STRING_LEN, M_USB, M_NOWAIT);
> + if (b != NULL) {
> + usbd_get_string(dev, index, b, USB_MAX_STRING_LEN);
> + usbd_trim_spaces(b);
> + }
> + *buf = b;
> +}
> +
> +void
> +usbd_get_device_strings(struct usbd_device *dev)
> +{
> + usbd_get_device_string(dev, dev->ddesc.iManufacturer,
> + >vendor);
> + usbd_get_device_string(dev, dev->ddesc.iProduct,
> + >product);
> + usbd_get_device_string(dev, dev->ddesc.iSerialNumber,
> + >serial);
> +}
> +
> +void
>  usbd_devinfo_vp(struct usbd_device *dev, char *v, size_t vl,
>  char *p, size_t pl, int usedev)
>  {
> @@ -232,6 +255,11 @@ usbd_devinfo_vp(struct usbd_device *dev, char *v, size_t 
> vl,
>   usbd_trim_spaces(vendor);
>   product = usbd_get_string(dev, udd->iProduct, p, pl);
>   usbd_trim_spaces(product);
> + } else {
> + if (dev->vendor != NULL)
> + vendor = dev->vendor;
> + if (dev->product != NULL)
> + product = dev->product;
>   }
>  #ifdef USBVERBOSE
>   if (vendor == NULL || product == NULL) {
> @@ -294,7 +322,7 @@ usbd_devinfo(struct usbd_device *dev, int showclass, char 
> *base, size_t len)
>   char *cp = base;
>   int bcdDevice, bcdUSB;
>  
> - usbd_devinfo_vp(dev, vendor, sizeof vendor, product, sizeof product, 1);
> + usbd_devinfo_vp(dev, vendor, sizeof vendor, product, sizeof product, 0);
>   snprintf(cp, len, "\"%s %s\"", vendor, product);
>   cp += strlen(cp);
>   if (showclass) {
> @@ -1188,6 +1216,8 @@ usbd_new_device(struct device *parent, struct usbd_bus 
> *bus, int depth,
>   DPRINTF(("usbd_new_device: new dev (addr %d), dev=%p, parent=%p\n",
>addr, dev, parent));
>  
> + usbd_get_device_strings(dev);
> +
>   err = usbd_probe_and_attach(parent, dev, port, addr);
>   if (err) {
>   usb_free_device(dev);
> @@ -1304,8 +1334,13 @@ usbd_fill_deviceinfo(struct usbd_device *dev, struct 
> usb_device_info *di,
>   di->udi_nports = 0;
>  
>   bzero(di->udi_serial, 

Re: New 12" Retina Macbook (Macbook9,1)

2016-05-18 Thread Ted Unangst
Bryan C. Everly wrote:
> I just received my 12" Retina Macbook (the Macbook9,1) which is the
> latest Skylake version.  I would really like to get OpenBSD running on
> this and am happy to trace any code, build patches, stand on my head,
> etc. if I could get someone interested in working with me to figure
> this thing out.

I would get acquainted with vmware. OS X is then a giant hardware abstraction
layer.



Re: libfuse has moved to github

2016-05-18 Thread Ray Lai
Looks good to me

> On May 18, 2016, at 11:14 PM, Jason McIntyre  wrote:
> 
>> On Wed, May 18, 2016 at 12:13:14AM +0800, Ray Lai wrote:
>> Also separate out the specification (does that count as a "standard"?)
>> and the implementation.
> 
> i've tweaked the diff a little to shorten it and keep the links in one
> section. STANDARDS seems the better choice.  i also don;t think the
> HISTORY tweak is neccessary.
> 
> ok with that, ray?
> 
> jmc
> 
> Index: fuse_main.3
> ===
> RCS file: /cvs/src/lib/libfuse/fuse_main.3,v
> retrieving revision 1.1
> diff -u -r1.1 fuse_main.3
> --- fuse_main.38 Aug 2013 06:41:06 -1.1
> +++ fuse_main.318 May 2016 15:13:16 -
> @@ -252,10 +252,12 @@
> }
> .Ed
> .Sh SEE ALSO
> -The FUSE specifications and orignal implementation can be found at:
> -.Lk http://fuse.sourceforge.net/
> -.Pp
> .Xr fuse 4
> +.Sh STANDARDS
> +The original FUSE specification can be found at
> +.Lk http://libfuse.github.io/doxygen/ .
> +The original implementation can be found at
> +.Lk https://github.com/libfuse/libfuse/ .
> .Sh HISTORY
> The FUSE library first appeared in
> .Ox 5.4 .



Re: New 12" Retina Macbook (Macbook9,1)

2016-05-18 Thread Mike Larkin
On Wed, May 18, 2016 at 09:32:55AM -0500, joshua stein wrote:
> On Wed, 18 May 2016 at 09:33:36 -0400, Bryan C. Everly wrote:
> > 2.  The keyboard works at the boot prompt, but does not work once the
> > install/upgrade/shell prompt comes up
> 
> The keyboard and trackpad appear to be connected over SPI:
> 
> https://bugzilla.kernel.org/show_bug.cgi?id=99891
> 
> While there may be some short path to keeping the keyboard in a
> legacy mode, I'm sure the trackpad will require an entirely new
> driver to be usable at all.
> 
> > 5.  The internal solid state hard drive is not recognized. This is one
> > of the NVM Express (or some people call them NVMe) drives.  I think I
> > saw a patch floating around on the list to enable the controller to be
> > recognized.  Once I update sources I'll see if I can build a kernel
> > with that patch applied to see if I can get farther.
> 
> Some commits went into Linux to support it, but it still looks buggy
> there:
> 
> https://bugzilla.kernel.org/show_bug.cgi?id=105621
> 
> So with no easy path to a working keyboard or trackpad, practically
> no chance of wireless support nor even the ability to plug in a
> small USB adapter due to the single USB-C port, I doubt this laptop
> will be usable at all under OpenBSD.  And the keyboard sucks.
> 

you forgot skylake video, too.



usb: cache vendor, product and serial

2016-05-18 Thread Patrick Wildt
Hi,

I had the pleasure of debugging a USB mass storage device that showed
interesting behaviour when used with our stack and in combination with
the blink(1) usb device.

The blink(1)-tool depends on libusb.  Libusb calls ioctl(USB_DEVICEINFO)
plenty of times to get a map of the USB tree.  Per ioctl, three USB
requests are created (to read: vendor, product, serial).  This kind of
floods all connected USB devices.

I have a hotplugd script that waits for usb mass storage devices, reads
the disklabel, fscks and tries to mount a partition.  Due to the ioctl,
one of those calls, which mostly only read from the storage device,
freeze until they later time out.  The flood of read requests caused
by the ioctl seem to make the mass storage halt its operation.

The same issue can be reproduced by calling usbdevs(8) in a loop.  It
uses the same ioctl and "breaks" this usb mass storage.

An idea is to cache those three strings, so that the ioctl does not
create any requests.  NetBSD seems to have implemented a caching
mechanism to fix a similar issue.  Though they have not enabled the
caching for that specific ioctl.

The idea of this diff, adapted from NetBSD, is that we read out the
strings early on when the device is found, store a copy of those per
device.  Then whenever it's needed it can be used.

ok? Comments?

Patrick

diff --git sys/dev/usb/usb.c sys/dev/usb/usb.c
index 732ecfd..c198bf0 100644
--- sys/dev/usb/usb.c
+++ sys/dev/usb/usb.c
@@ -520,7 +520,7 @@ usb_fill_di_task(void *arg)
if (dev == NULL)
return;
 
-   usbd_fill_deviceinfo(dev, di, 1);
+   usbd_fill_deviceinfo(dev, di, 0);
 }
 
 void
diff --git sys/dev/usb/usb_subr.c sys/dev/usb/usb_subr.c
index a255793..fef6d52 100644
--- sys/dev/usb/usb_subr.c
+++ sys/dev/usb/usb_subr.c
@@ -63,6 +63,7 @@ usbd_status   usbd_set_config(struct usbd_device *, int);
 void   usbd_devinfo(struct usbd_device *, int, char *, size_t);
 void   usbd_devinfo_vp(struct usbd_device *, char *, size_t,
char *, size_t, int);
+void   usbd_get_device_string(struct usbd_device *, uByte, char **);
 char   *usbd_get_string(struct usbd_device *, int, char *, size_t);
 intusbd_getnewaddr(struct usbd_bus *);
 intusbd_print(void *, const char *);
@@ -212,6 +213,28 @@ usbd_trim_spaces(char *p)
 }
 
 void
+usbd_get_device_string(struct usbd_device *dev, uByte index, char **buf)
+{
+   char *b = malloc(USB_MAX_STRING_LEN, M_USB, M_NOWAIT);
+   if (b != NULL) {
+   usbd_get_string(dev, index, b, USB_MAX_STRING_LEN);
+   usbd_trim_spaces(b);
+   }
+   *buf = b;
+}
+
+void
+usbd_get_device_strings(struct usbd_device *dev)
+{
+   usbd_get_device_string(dev, dev->ddesc.iManufacturer,
+   >vendor);
+   usbd_get_device_string(dev, dev->ddesc.iProduct,
+   >product);
+   usbd_get_device_string(dev, dev->ddesc.iSerialNumber,
+   >serial);
+}
+
+void
 usbd_devinfo_vp(struct usbd_device *dev, char *v, size_t vl,
 char *p, size_t pl, int usedev)
 {
@@ -232,6 +255,11 @@ usbd_devinfo_vp(struct usbd_device *dev, char *v, size_t 
vl,
usbd_trim_spaces(vendor);
product = usbd_get_string(dev, udd->iProduct, p, pl);
usbd_trim_spaces(product);
+   } else {
+   if (dev->vendor != NULL)
+   vendor = dev->vendor;
+   if (dev->product != NULL)
+   product = dev->product;
}
 #ifdef USBVERBOSE
if (vendor == NULL || product == NULL) {
@@ -294,7 +322,7 @@ usbd_devinfo(struct usbd_device *dev, int showclass, char 
*base, size_t len)
char *cp = base;
int bcdDevice, bcdUSB;
 
-   usbd_devinfo_vp(dev, vendor, sizeof vendor, product, sizeof product, 1);
+   usbd_devinfo_vp(dev, vendor, sizeof vendor, product, sizeof product, 0);
snprintf(cp, len, "\"%s %s\"", vendor, product);
cp += strlen(cp);
if (showclass) {
@@ -1188,6 +1216,8 @@ usbd_new_device(struct device *parent, struct usbd_bus 
*bus, int depth,
DPRINTF(("usbd_new_device: new dev (addr %d), dev=%p, parent=%p\n",
 addr, dev, parent));
 
+   usbd_get_device_strings(dev);
+
err = usbd_probe_and_attach(parent, dev, port, addr);
if (err) {
usb_free_device(dev);
@@ -1304,8 +1334,13 @@ usbd_fill_deviceinfo(struct usbd_device *dev, struct 
usb_device_info *di,
di->udi_nports = 0;
 
bzero(di->udi_serial, sizeof(di->udi_serial));
-   usbd_get_string(dev, dev->ddesc.iSerialNumber, di->udi_serial,
-   sizeof(di->udi_serial));
+   if (!usedev && dev->serial != NULL) {
+   strlcpy(di->udi_serial, dev->serial,
+   sizeof(di->udi_serial));
+   } else {
+   usbd_get_string(dev, dev->ddesc.iSerialNumber,
+   di->udi_serial, sizeof(di->udi_serial));
+   }
 }
 

Re: libfuse has moved to github

2016-05-18 Thread Jason McIntyre
On Wed, May 18, 2016 at 12:13:14AM +0800, Ray Lai wrote:
> Also separate out the specification (does that count as a "standard"?)
> and the implementation.
> 

i've tweaked the diff a little to shorten it and keep the links in one
section. STANDARDS seems the better choice.  i also don;t think the
HISTORY tweak is neccessary.

ok with that, ray?

jmc

Index: fuse_main.3
===
RCS file: /cvs/src/lib/libfuse/fuse_main.3,v
retrieving revision 1.1
diff -u -r1.1 fuse_main.3
--- fuse_main.3 8 Aug 2013 06:41:06 -   1.1
+++ fuse_main.3 18 May 2016 15:13:16 -
@@ -252,10 +252,12 @@
 }
 .Ed
 .Sh SEE ALSO
-The FUSE specifications and orignal implementation can be found at:
-.Lk http://fuse.sourceforge.net/
-.Pp
 .Xr fuse 4
+.Sh STANDARDS
+The original FUSE specification can be found at
+.Lk http://libfuse.github.io/doxygen/ .
+The original implementation can be found at
+.Lk https://github.com/libfuse/libfuse/ .
 .Sh HISTORY
 The FUSE library first appeared in
 .Ox 5.4 .



Re: New 12" Retina Macbook (Macbook9,1)

2016-05-18 Thread joshua stein
On Wed, 18 May 2016 at 09:33:36 -0400, Bryan C. Everly wrote:
> 2.  The keyboard works at the boot prompt, but does not work once the
> install/upgrade/shell prompt comes up

The keyboard and trackpad appear to be connected over SPI:

https://bugzilla.kernel.org/show_bug.cgi?id=99891

While there may be some short path to keeping the keyboard in a
legacy mode, I'm sure the trackpad will require an entirely new
driver to be usable at all.

> 5.  The internal solid state hard drive is not recognized. This is one
> of the NVM Express (or some people call them NVMe) drives.  I think I
> saw a patch floating around on the list to enable the controller to be
> recognized.  Once I update sources I'll see if I can build a kernel
> with that patch applied to see if I can get farther.

Some commits went into Linux to support it, but it still looks buggy
there:

https://bugzilla.kernel.org/show_bug.cgi?id=105621

So with no easy path to a working keyboard or trackpad, practically
no chance of wireless support nor even the ability to plug in a
small USB adapter due to the single USB-C port, I doubt this laptop
will be usable at all under OpenBSD.  And the keyboard sucks.



Re: [ntpd] Simultaneously listen on IPv4 and IPv6

2016-05-18 Thread Jeremie Courreges-Anglas
Stuart Henderson  writes:

> On 2016/05/18 14:01, Jeremie Courreges-Anglas wrote:
>> Stuart Henderson  writes:
>> 
>> > Removing the sysctl should be very pretty safe as far as ports goes (I
>> > did wonder if thing s might read the sysctl and change behaviour but it
>> > seems that's not the case). Looks like only nsh will break from doing
>> > that and it's easily fixed.
>> 
>> I fear that this is only creating a source of make-work for porters.
>> 
>> - What will happen if we remove the sysctl?
>>   Some external software will not compile.
>
> djm is talking about removing the IPV6CTL_V6ONLY sysctl,
> not the ioctl. The sysctl isn't a problem, it will be a tiny
> change in one OpenBSD-specific port and I'm pretty sure not
> more than that.

Oops, sorry for the noise.  *grabs another cup of coffee*

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



New 12" Retina Macbook (Macbook9,1)

2016-05-18 Thread Bryan C. Everly
Hello tech@

I just received my 12" Retina Macbook (the Macbook9,1) which is the
latest Skylake version.  I would really like to get OpenBSD running on
this and am happy to trace any code, build patches, stand on my head,
etc. if I could get someone interested in working with me to figure
this thing out.

Here is where things stand with the latest 6.0 snapshot:

1.  It will boot the install60.fs ramdisk image and successfully get
to the Install/Upgrade/Shell prompt

2.  The keyboard works at the boot prompt, but does not work once the
install/upgrade/shell prompt comes up

3.  My USB-C to USB 3.0 hub that I purchased works just fine to boot
USB thumb drives

4.  A USB keyboard plugged into the hub allows me to have a working
keyboard once the installer hits the prompt

5.  The internal solid state hard drive is not recognized. This is one
of the NVM Express (or some people call them NVMe) drives.  I think I
saw a patch floating around on the list to enable the controller to be
recognized.  Once I update sources I'll see if I can build a kernel
with that patch applied to see if I can get farther.

6.  The Broadcom 0x43a3 (I think it is the Broadcom 4350 chipset) WiFi
adapter is not working.  Not surprising given... well... Broadcom.

I was able to get a dmesg out of the thing by ripping out my boot USB
stick and jamming in a MSDOS formatted USB stick.  I've cut and pasted
it below.

Again, anyone willing to help me see if I can get this farther along?


--- snip ---

OpenBSD 6.0-beta (RAMDISK_CD) #1882: Wed May 18 01:18:09 MDT 2016
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/RAMDISK_CD
RTC BIOS diagnostic error
fe
real mem = 8468639744 (8076MB)
avail mem = 8210128896 (7829MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.0 @ 0x8af1e000 (42 entries)
bios0: vendor Apple Inc. version "MB91.88Z.0154.B00.1603041656" date 03/04/2016
bios0: Apple Inc. MacBook9,1
acpi0 at bios0: rev 2
acpi0: tables DSDT FACP UEFI ECDT HPET APIC MCFG SBST SSDT SSDT SSDT
SSDT SSDT SSDT SSDT SSDT SSDT SSDT DMAR
acpiec0 at acpi0
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) m7-6Y75 CPU @ 1.20GHz, 2894.54 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,SENSOR,ARAT
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: apic clock running at 23MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4.1.1.1, IBE
cpu at mainbus0: not configured
cpu at mainbus0: not configured
cpu at mainbus0: not configured
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 24 pins
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (PEG0)
acpiprt2 at acpi0: bus 1 (RP01)
acpiprt3 at acpi0: bus -1 (RP05)
acpiprt4 at acpi0: bus 2 (RP09)
acpiprt5 at acpi0: bus 3 (RP10)
acpicpu at acpi0 not configured
"APP0001" at acpi0 not configured
"ACPI0008" at acpi0 not configured
"ACPI0002" at acpi0 not configured
"APP000D" at acpi0 not configured
"BCM2E7C" at acpi0 not configured
"PNP0C0A" at acpi0 not configured
"ACPI0003" at acpi0 not configured
"PNP0C0D" at acpi0 not configured
"PNP0C0C" at acpi0 not configured
"APP0002" at acpi0 not configured
"PNP0C0E" at acpi0 not configured
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 vendor "Intel", unknown product 0x190c rev 0x08
vendor "Intel", unknown product 0x191e (class display subclass VGA,
rev 0x07) at pci0 dev 2 function 0 not configured
xhci0 at pci0 dev 20 function 0 "Intel 100 Series xHCI" rev 0x21: msi
usb0 at xhci0: USB revision 3.0
uhub0 at usb0 "Intel xHCI root hub" rev 3.00/1.00 addr 1
vendor "Intel", unknown product 0x9d60 (class DASP subclass
miscellaneous, rev 0x21) at pci0 dev 21 function 0 not configured
vendor "Intel", unknown product 0x9d62 (class DASP subclass
miscellaneous, rev 0x21) at pci0 dev 21 function 2 not configured
"Intel 100 Series MEI" rev 0x21 at pci0 dev 22 function 0 not configured
vendor "Intel", unknown product 0x9d66 (class DASP subclass
miscellaneous, rev 0x21) at pci0 dev 25 function 0 not configured
ppb0 at pci0 dev 28 function 0 "Intel 100 Series PCIE" rev 0xf1: msi
pci1 at ppb0 bus 1
vendor "Apple", unknown product 0x2003 (class mass storage subclass
miscellaneous, rev 0x11) at pci1 dev 0 function 0 not configured
ppb1 at pci0 dev 29 function 0 "Intel 100 Series PCIE" rev 0xf1: msi
pci2 at ppb1 bus 2
vendor "Broadcom", unknown product 0x43a3 (class network subclass
miscellaneous, rev 0x05) at pci2 dev 0 function 0 not configured
ppb2 at pci0 dev 29 function 1 "Intel 100 Series PCIE" rev 0xf1: msi
pci3 at ppb2 bus 3
"Broadcom BCM15700A2" rev 0x00 at pci3 dev 0 

Re: [ntpd] Simultaneously listen on IPv4 and IPv6

2016-05-18 Thread lists
Tue, 17 May 2016 08:27:42 -0500 Brent Cook 
> This patch came by way of the openntpd github. Linux (and possibly others)
> will attempt to bind to 0.0.0.0 when binding to '::' and return an error if
> it can't, unless IPV6_V6ONLY is set. See
> https://github.com/openntpd-portable/openntpd-portable/issues/19
> 
> OK as an in-tree patch? OpenBSD seems to adopt a more liberal
> interpretation and not return a failure in the same scenario. (The patch
> against the 5.7 tree, but you get the idea)
> 
> diff -uNr openntpd-5.7p4/src/server.c new/src/server.c
> --- openntpd-5.7p4/src/server.c 2015-03-25 04:18:56.0 +0300
> +++ new/src/server.c2016-03-05 18:06:07.946888570 +0300
> @@ -40,6 +40,7 @@
> size_t   sa6len = sizeof(struct in6_addr);
> u_intnew_cnt = 0;
> int  tos = IPTOS_LOWDELAY;
> +   int  on = 1;
> int  rdomain, fd;
> @@ -139,6 +140,12 @@
> IPPROTO_IP, IP_TOS, , sizeof(tos)) == -1)
> log_warn("setsockopt IPTOS_LOWDELAY");
> 
> +#ifdef IPV6_V6ONLY
> +   if (la->sa.ss_family == AF_INET6 && setsockopt(la->fd,
> +   IPPROTO_IPV6, IPV6_V6ONLY, , sizeof(on)) == -1)
> +   log_warn("setsockopt IPV6_V6ONLY");
> +#endif
> +
> if (la->rtable != -1 &&
> setsockopt(la->fd, SOL_SOCKET, SO_RTABLE, >rtable,
> 

No way, as system operators dating back as long as there is public
Internet, we all know, explicit declaration of listen sockets is a
must.  No implicit ipv4 on ipv6 declaration, this is the true path.
The same for other cases, no implicit ipv6 on explicit ivp4 et all.



Re: [ntpd] Simultaneously listen on IPv4 and IPv6

2016-05-18 Thread Theo de Raadt
> Yes, the ioctl has to stay for exactly the reasons you give.
> These are all over the tree. It's not 1 ports, but pretty
> much *everything* that talks v6 and listens on dual sockets
> apart from maybe some niche BSD-centric things. These
> programs won't run on Linux without it. (They will run
> on FreeBSD though).

Really good reason to not deploy v6.



Re: [ntpd] Simultaneously listen on IPv4 and IPv6

2016-05-18 Thread Stuart Henderson
On 2016/05/18 14:01, Jeremie Courreges-Anglas wrote:
> Stuart Henderson  writes:
> 
> > Removing the sysctl should be very pretty safe as far as ports goes (I
> > did wonder if thing s might read the sysctl and change behaviour but it
> > seems that's not the case). Looks like only nsh will break from doing
> > that and it's easily fixed.
> 
> I fear that this is only creating a source of make-work for porters.
> 
> - What will happen if we remove the sysctl?
>   Some external software will not compile.

djm is talking about removing the IPV6CTL_V6ONLY sysctl,
not the ioctl. The sysctl isn't a problem, it will be a tiny
change in one OpenBSD-specific port and I'm pretty sure not
more than that.

> - What will happen next?
>   Add #ifdefs around each unguarded use of IPV6_V6ONLY in the ports
>   tree.  Submit that upstream.
> 
> - What is the gain?
>   None, even if the patch gets pushed upstream.

Yes, the ioctl has to stay for exactly the reasons you give.
These are all over the tree. It's not 1 ports, but pretty
much *everything* that talks v6 and listens on dual sockets
apart from maybe some niche BSD-centric things. These
programs won't run on Linux without it. (They will run
on FreeBSD though).



Re: [ntpd] Simultaneously listen on IPv4 and IPv6

2016-05-18 Thread Jeremie Courreges-Anglas
Stuart Henderson  writes:

> Removing the sysctl should be very pretty safe as far as ports goes (I
> did wonder if thing s might read the sysctl and change behaviour but it
> seems that's not the case). Looks like only nsh will break from doing
> that and it's easily fixed.

I fear that this is only creating a source of make-work for porters.

- What will happen if we remove the sysctl?
  Some external software will not compile.

- What will happen next?
  Add #ifdefs around each unguarded use of IPV6_V6ONLY in the ports
  tree.  Submit that upstream.

- What is the gain?
  None, even if the patch gets pushed upstream.

*We will just succeed in adding more #ifdefs in the ecosystem*, to all
software that use IPV6_V6ONLY, for a good (disabling v4-mapped) or bad
(relying on v4-mapped) purpose.

The real problem with IPV6_V6ONLY is that some people write code
assuming they can set IPV6_V6ONLY==0 on their socket, and use a single
socket for both v4 and v6.  Some of them will not listen to our point of
view, and will just ignore the fact that their software doesn't work as
designed on OpenBSD.  Whatever.  Some others may listen, and that's
where we can help, by giving pointers or even patches.  That's something
we can - and should - already do.

As much as I'd like what IPV6_V6ONLY had never existed*, I don't see the
point of removing the sysctl in OpenBSD.

* who wants to take
  http://tools.ietf.org/html/draft-itojun-v6ops-v4mapped-harmful-02 out
  of its "draft" status?

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: [patch] daemon.3

2016-05-18 Thread Remco

Op 05/18/16 om 13:55 schreef Ingo Schwarze:

Hi,

Remco wrote on Wed, May 18, 2016 at 10:29:40AM +0200:

Op 05/18/16 om 01:49 schreef Edgar Pettijohn:



The wording made it hard for me to understand at first.
The "unless" "non-zero" seem like double negatives.


Actually, quadruple negation:

  1. Unless
  2. nochdir   is
  3. non-
  4. zero

Yikes.



Index: daemon.3
===
RCS file: /cvs/src/lib/libc/gen/daemon.3,v
retrieving revision 1.12
diff -u -p -u -r1.12 daemon.3
--- daemon.35 Jun 2013 03:39:22 -1.12
+++ daemon.317 May 2016 23:42:25 -
@@ -43,16 +43,16 @@ The
   function is for programs wishing to detach themselves from the
   controlling terminal and run in the background as system daemons.
   .Pp
-Unless the argument
+If the argument
   .Fa nochdir
-is non-zero,
+is zero,
   .Fn daemon
   changes the current working directory to the root
   .Pq Pa / .
   .Pp
-Unless the argument
+If the argument
   .Fa noclose
-is non-zero,
+is zero,
   .Fn daemon
   will redirect standard input, standard output and standard error to
   .Pa /dev/null .


I quickly committed this correct patch (with two minor tweaks)
in the hope that people stop proposing incorrect versions.


I personally think the cause of confusion is the negated parameters,


Indeed.

Interface designers, *please* design the flags accepted by your
interfaces to have *positive* semantics, even if that means that
some of them are active by default.  That's so much easier to
understand and document.  With flags called NO_FOOBAR, we regularly
end up with double negation in the documentation, and confusion
often ensues.

[...]

Don't use negated parameters by renaming "nochdr" to "cd"


That would have been better, but obviously, it can't be done after
the fact, once the interface if established in practice.  It would
require changing the implementation of the interface and all the
code using it.  That would be extremely error prone and it would
land us in compatibility hell.

Remco's patch is completely wrong.

Yours,
   Ingo




Ingo's right, please ignore my patch, that was kind of a stupid move.

Thanks for setting me straight on this one Ingo.



Re: [patch] daemon.3

2016-05-18 Thread Ingo Schwarze
Hi,

Remco wrote on Wed, May 18, 2016 at 10:29:40AM +0200:
> Op 05/18/16 om 01:49 schreef Edgar Pettijohn:

>> The wording made it hard for me to understand at first.
>> The "unless" "non-zero" seem like double negatives.

Actually, quadruple negation:

 1. Unless
 2. nochdir   is
 3. non-
 4. zero

Yikes.


>> Index: daemon.3
>> ===
>> RCS file: /cvs/src/lib/libc/gen/daemon.3,v
>> retrieving revision 1.12
>> diff -u -p -u -r1.12 daemon.3
>> --- daemon.35 Jun 2013 03:39:22 -1.12
>> +++ daemon.317 May 2016 23:42:25 -
>> @@ -43,16 +43,16 @@ The
>>   function is for programs wishing to detach themselves from the
>>   controlling terminal and run in the background as system daemons.
>>   .Pp
>> -Unless the argument
>> +If the argument
>>   .Fa nochdir
>> -is non-zero,
>> +is zero,
>>   .Fn daemon
>>   changes the current working directory to the root
>>   .Pq Pa / .
>>   .Pp
>> -Unless the argument
>> +If the argument
>>   .Fa noclose
>> -is non-zero,
>> +is zero,
>>   .Fn daemon
>>   will redirect standard input, standard output and standard error to
>>   .Pa /dev/null .

I quickly committed this correct patch (with two minor tweaks)
in the hope that people stop proposing incorrect versions.

> I personally think the cause of confusion is the negated parameters,

Indeed.

Interface designers, *please* design the flags accepted by your
interfaces to have *positive* semantics, even if that means that
some of them are active by default.  That's so much easier to
understand and document.  With flags called NO_FOOBAR, we regularly
end up with double negation in the documentation, and confusion
often ensues.

[...]
> Don't use negated parameters by renaming "nochdr" to "cd"

That would have been better, but obviously, it can't be done after
the fact, once the interface if established in practice.  It would
require changing the implementation of the interface and all the
code using it.  That would be extremely error prone and it would
land us in compatibility hell.

Remco's patch is completely wrong.

Yours,
  Ingo



Re: [PATCH] Allow softraid crypto to work with write-protected keys

2016-05-18 Thread bytevolcano
My apologies for the noise; the previous one was the wrong revision (r1.126 
instead of 1.127) because both patches look similar; here is the most recent 
catch:

Index: sys/dev/softraid_crypto.c
===
RCS file: /cvs/src/sys/dev/softraid_crypto.c,v
retrieving revision 1.127
diff -u -p -r1.127 softraid_crypto.c
--- sys/dev/softraid_crypto.c   17 May 2016 19:28:59 -  1.127
+++ sys/dev/softraid_crypto.c   18 May 2016 10:26:32 -
@@ -795,7 +795,7 @@ sr_crypto_read_key_disk(struct sr_discip
sr_error(sc, "cannot open key disk %s", devname);
goto done;
}
-   if (VOP_OPEN(vn, FREAD | FWRITE, NOCRED, curproc)) {
+   if (VOP_OPEN(vn, FREAD, NOCRED, curproc)) {
DNPRINTF(SR_D_META,"%s: sr_crypto_read_key_disk cannot "
"open %s\n", DEVNAME(sc), devname);
vput(vn);
@@ -809,8 +809,6 @@ sr_crypto_read_key_disk(struct sr_discip
NOCRED, curproc)) {
DNPRINTF(SR_D_META, "%s: sr_crypto_read_key_disk ioctl "
"failed\n", DEVNAME(sc));
-   VOP_CLOSE(vn, FREAD | FWRITE, NOCRED, curproc);
-   vput(vn);
goto done;
}
if (label.d_partitions[part].p_fstype != FS_RAID) {



Re: [PATCH] Allow softraid crypto to work with write-protected keys

2016-05-18 Thread bytevolcano
Ted Unangst wrote:
> i removed these last two lines, since they were incorrect. thanks for spotting
> that. however the vop_close at the end still needs updating.

Thanks Ted,

Also I found another stray VOP_CLOSE() setup.

I have also put in the VOP_OPEN(vn, FREAD, ...) as I am not sure about 100% 
clear on what you mean by "the vop_close at the end still needs updating."

Do you mean it needs to actually be called with VOP_CLOSE(vn, FREAD | FWRITE, 
...)?

I am also confused by the opening of the key disk in read-write mode, when 
there doesn't seem to be any obvious need to write to it; what bit of metadata 
needs to be updated? All I see it doing is preventing the possibility of using 
write-protected key disks.


Index: sys/dev/softraid_crypto.c
===
RCS file: /cvs/src/sys/dev/softraid_crypto.c,v
retrieving revision 1.126
diff -u -p -r1.126 softraid_crypto.c
--- sys/dev/softraid_crypto.c   12 Apr 2016 16:26:54 -  1.126
+++ sys/dev/softraid_crypto.c   17 May 2016 10:13:02 -
@@ -797,7 +797,7 @@ sr_crypto_read_key_disk(struct sr_discip
sr_error(sc, "cannot open key disk %s", devname);
goto done;
}
-   if (VOP_OPEN(vn, FREAD | FWRITE, NOCRED, curproc)) {
+   if (VOP_OPEN(vn, FREAD, NOCRED, curproc)) {
DNPRINTF(SR_D_META,"%s: sr_crypto_read_key_disk cannot "
"open %s\n", DEVNAME(sc), devname);
vput(vn);
@@ -811,8 +811,6 @@ sr_crypto_read_key_disk(struct sr_discip
NOCRED, curproc)) {
DNPRINTF(SR_D_META, "%s: sr_crypto_read_key_disk ioctl "
"failed\n", DEVNAME(sc));
-   VOP_CLOSE(vn, FREAD | FWRITE, NOCRED, curproc);
-   vput(vn);
goto done;
}
if (label.d_partitions[part].p_fstype != FS_RAID) {



Update iwm(4) to newer firmware

2016-05-18 Thread Stefan Sperling
Update iwm(4) to firmware version 16.242414.0 (API 16).
New firmware has been available in fw_update(1) for several weeks already.

Among many API changes this firmware version introduces a wide command header
for some commands because the old API format has run out command number space.

This firmware has a new scan API (LMAC scan -- "lower mac" scan) which can
scan both 2GHz and 5GHz bands in a single run. This allows us to simplify
the hairy scanning logic in the driver significantly.

A couple of new firmware features (Smart FIFO, BT coex, Location Aware
Regulatory, TX backoff for temperature regulation) are unused, but are
nonetheless initialized by the driver because apparently the firmware
generally expects the driver to initialize firmware state.

Many thanks to Emmanuel Grumbach for providing helpful advice, and to
genua gmbh for funding this effort.

This also paves the way for upcoming 8260 device support in iwm(4).

Index: if_iwm.c
===
RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v
retrieving revision 1.81
diff -u -p -r1.81 if_iwm.c
--- if_iwm.c18 May 2016 07:28:01 -  1.81
+++ if_iwm.c18 May 2016 09:42:53 -
@@ -1,7 +1,8 @@
 /* $OpenBSD: if_iwm.c,v 1.81 2016/05/18 07:28:01 stsp Exp $*/
 
 /*
- * Copyright (c) 2014 genua mbh 
+ * Copyright (c) 2014, 2016 genua gmbh 
+ *   Author: Stefan Sperling 
  * Copyright (c) 2014 Fixup Software Ltd.
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -21,9 +22,6 @@
  * Based on BSD-licensed source modules in the Linux iwlwifi driver,
  * which were used as the reference documentation for this implementation.
  *
- * Driver version we are currently based off of is
- * Linux 3.14.3 (tag id a2df521e42b1d9a23f620ac79dbfe8655a8391dd)
- *
  ***
  *
  * This file is provided under a dual BSD/GPLv2 license.  When using or
@@ -32,6 +30,8 @@
  * GPL LICENSE SUMMARY
  *
  * Copyright(c) 2007 - 2013 Intel Corporation. All rights reserved.
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
+ * Copyright(c) 2016 Intel Deutschland GmbH
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -58,6 +58,8 @@
  * BSD LICENSE
  *
  * Copyright(c) 2005 - 2013 Intel Corporation. All rights reserved.
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
+ * Copyright(c) 2016 Intel Deutschland GmbH
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -129,6 +131,7 @@
 #include 
 #endif
 #include 
+#include 
 #include 
 
 #include 
@@ -205,6 +208,11 @@ const int iwm_mcs2ridx[] = {
IWM_RATE_MCS_7_INDEX,
 };
 
+struct iwm_nvm_section {
+   uint16_t length;
+   uint8_t *data;
+};
+
 intiwm_store_cscheme(struct iwm_softc *, uint8_t *, size_t);
 intiwm_firmware_store_section(struct iwm_softc *, enum iwm_ucode_type,
uint8_t *, size_t);
@@ -260,7 +268,7 @@ voidiwm_mvm_nic_config(struct iwm_softc
 intiwm_nic_rx_init(struct iwm_softc *);
 intiwm_nic_tx_init(struct iwm_softc *);
 intiwm_nic_init(struct iwm_softc *);
-void   iwm_enable_txq(struct iwm_softc *, int, int);
+intiwm_enable_txq(struct iwm_softc *, int, int, int);
 intiwm_post_alive(struct iwm_softc *);
 struct iwm_phy_db_entry *iwm_phy_db_get_section(struct iwm_softc *,
enum iwm_phy_db_section_type, uint16_t);
@@ -287,8 +295,9 @@ voidiwm_mvm_protect_session(struct iwm_
 intiwm_nvm_read_chunk(struct iwm_softc *, uint16_t, uint16_t, uint16_t,
uint8_t *, uint16_t *);
 intiwm_nvm_read_section(struct iwm_softc *, uint16_t, uint8_t *,
-   uint16_t *);
-void   iwm_init_channel_map(struct iwm_softc *, const uint16_t * const);
+   uint16_t *, size_t);
+void   iwm_init_channel_map(struct iwm_softc *, const uint16_t * const,
+   const uint8_t *nvm_channels, size_t nchan);
 void   iwm_setup_ht_rates(struct iwm_softc *);
 void   iwm_htprot_task(void *);
 void   iwm_update_htprot(struct ieee80211com *, struct ieee80211_node *);
@@ -307,14 +316,16 @@ void  iwm_ampdu_tx_stop(struct ieee80211c
 void   iwm_ba_task(void *);
 
 intiwm_parse_nvm_data(struct iwm_softc *, const uint16_t *,
-   const uint16_t *, const uint16_t *, uint8_t,
-   uint8_t);
-#ifdef notyet
+   const uint16_t *, const uint16_t *,
+   const uint16_t *, const uint16_t *,
+   const uint16_t *);
 intiwm_parse_nvm_sections(struct iwm_softc *, struct iwm_nvm_section *);
-#endif
 

ehci panic fix

2016-05-18 Thread Martin Pieuchot
New version of my fix for the "ehci_device_clear_toggle: queue active"
panic.  This diff gets bigger and bigger after the years but the logic
remains the same.

It changes when QH are added and removed to/from the async list.  Instead
of keeping a QH on the list as long as a pipe is open we now add/remove it
on a per-transfer basis.  This allows us to cancel a transfer by simply
unlinking a QH.

As reported by many over the years it seems enough to prevent the race in
ehci_abort_xfer() resulting in the infamous ehci_device_clear_toggle()
panic.

Now the previous version exposed a bug during the suspend/resume sequence
resulting in unrecoverable error upon resume.   So this diff changes the
order of port-related operations when resuming introducing ehci_start().
With it I could not generate an unrecoverable error.

Please test and report back.

Index: ehci.c
===
RCS file: /cvs/src/sys/dev/usb/ehci.c,v
retrieving revision 1.190
diff -u -p -r1.190 ehci.c
--- ehci.c  11 Dec 2015 12:23:09 -  1.190
+++ ehci.c  17 May 2016 17:37:34 -
@@ -116,6 +116,7 @@ usbd_status ehci_open(struct usbd_pipe *
 intehci_setaddr(struct usbd_device *, int);
 void   ehci_poll(struct usbd_bus *);
 void   ehci_softintr(void *);
+intehci_start(struct ehci_softc *);
 intehci_intr1(struct ehci_softc *);
 void   ehci_waitintr(struct ehci_softc *, struct usbd_xfer *);
 void   ehci_check_intr(struct ehci_softc *, struct usbd_xfer *);
@@ -189,12 +190,11 @@ int   ehci_alloc_sitd_chain(struct ehci_s
 void   ehci_abort_isoc_xfer(struct usbd_xfer *xfer,
usbd_status status);
 
-usbd_statusehci_device_setintr(struct ehci_softc *, struct ehci_soft_qh *,
-   int ival);
+struct ehci_soft_qh * ehci_intr_get_sqh(struct usbd_pipe *);
 
-void   ehci_add_qh(struct ehci_soft_qh *, struct ehci_soft_qh *);
-void   ehci_rem_qh(struct ehci_softc *, struct ehci_soft_qh *);
-void   ehci_set_qh_qtd(struct ehci_soft_qh *, struct ehci_soft_qtd *);
+void   ehci_add_qh(struct usbd_pipe *, struct ehci_soft_qh *,
+   struct ehci_soft_qtd *);
+void   ehci_rem_qh(struct ehci_softc *, struct usbd_pipe *);
 void   ehci_sync_hc(struct ehci_softc *);
 
 void   ehci_close_pipe(struct usbd_pipe *);
@@ -296,7 +296,7 @@ ehci_reverse_bits(u_int8_t c, int nbits)
 usbd_status
 ehci_init(struct ehci_softc *sc)
 {
-   u_int32_t sparams, cparams, hcr;
+   uint32_t sparams;
u_int i, j;
usbd_status err;
struct ehci_soft_qh *sqh;
@@ -317,20 +317,8 @@ ehci_init(struct ehci_softc *sc)
sparams = EREAD4(sc, EHCI_HCSPARAMS);
DPRINTF(("ehci_init: sparams=0x%x\n", sparams));
sc->sc_noport = EHCI_HCS_N_PORTS(sparams);
-   cparams = EREAD4(sc, EHCI_HCCPARAMS);
-   DPRINTF(("ehci_init: cparams=0x%x\n", cparams));
-
-   /* MUST clear segment register if 64 bit capable. */
-   if (EHCI_HCC_64BIT(cparams))
-   EWRITE4(sc, EHCI_CTRLDSSEGMENT, 0);
-
sc->sc_bus.usbrev = USBREV_2_0;
 
-   DPRINTF(("%s: resetting\n", sc->sc_bus.bdev.dv_xname));
-   err = ehci_reset(sc);
-   if (err)
-   return (err);
-
if (ehcixfer == NULL) {
ehcixfer = malloc(sizeof(struct pool), M_DEVBUF, M_NOWAIT);
if (ehcixfer == NULL) {
@@ -367,8 +355,6 @@ ehci_init(struct ehci_softc *sc)
for (i = 0; i < sc->sc_flsize; i++)
sc->sc_flist[i] = htole32(EHCI_LINK_TERMINATE);
 
-   EOWRITE4(sc, EHCI_PERIODICLISTBASE, DMAADDR(>sc_fldma, 0));
-
sc->sc_softitds = mallocarray(sc->sc_flsize,
sizeof(struct ehci_soft_itd *), M_USB, M_NOWAIT | M_ZERO);
if (sc->sc_softitds == NULL) {
@@ -414,7 +400,6 @@ ehci_init(struct ehci_softc *sc)
sqh->qh.qh_qtd.qtd_next = htole32(EHCI_LINK_TERMINATE);
sqh->qh.qh_qtd.qtd_altnext = htole32(EHCI_LINK_TERMINATE);
sqh->qh.qh_qtd.qtd_status = htole32(EHCI_QTD_HALTED);
-   sqh->sqtd = NULL;
usb_syncmem(>dma, sqh->offs, sizeof(sqh->qh),
BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
}
@@ -445,18 +430,47 @@ ehci_init(struct ehci_softc *sc)
sqh->qh.qh_qtd.qtd_next = htole32(EHCI_LINK_TERMINATE);
sqh->qh.qh_qtd.qtd_altnext = htole32(EHCI_LINK_TERMINATE);
sqh->qh.qh_qtd.qtd_status = htole32(EHCI_QTD_HALTED);
-   sqh->sqtd = NULL;
usb_syncmem(>dma, sqh->offs, sizeof(sqh->qh),
BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 
/* Point to async list */
sc->sc_async_head = sqh;
-   EOWRITE4(sc, EHCI_ASYNCLISTADDR, sqh->physaddr | EHCI_LINK_QH);
 
timeout_set(>sc_tmo_intrlist, ehci_intrlist_timeout, sc);
 
rw_init(>sc_doorbell_lock, "ehcidb");
 
+ 

Fewer if_get(9)

2016-05-18 Thread Martin Pieuchot
Now what we are calling ARP input routines directly from ether_input()
there's no need to use another if_get()/if_put() dance.

ok?

Index: net/if_ethersubr.c
===
RCS file: /cvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.235
diff -u -p -r1.235 if_ethersubr.c
--- net/if_ethersubr.c  1 Apr 2016 04:03:35 -   1.235
+++ net/if_ethersubr.c  18 May 2016 08:06:28 -
@@ -372,13 +372,13 @@ decapsulate:
case ETHERTYPE_ARP:
if (ifp->if_flags & IFF_NOARP)
goto dropanyway;
-   arpinput(m);
+   arpinput(ifp, m);
return (1);
 
case ETHERTYPE_REVARP:
if (ifp->if_flags & IFF_NOARP)
goto dropanyway;
-   revarpinput(m);
+   revarpinput(ifp, m);
return (1);
 
 #ifdef INET6
Index: netinet/if_ether.c
===
RCS file: /cvs/src/sys/netinet/if_ether.c,v
retrieving revision 1.206
diff -u -p -r1.206 if_ether.c
--- netinet/if_ether.c  18 May 2016 08:05:51 -  1.206
+++ netinet/if_ether.c  18 May 2016 08:06:56 -
@@ -81,8 +81,8 @@ int   arpt_down = 20; /* once declared do
 void arptfree(struct rtentry *);
 void arptimer(void *);
 struct rtentry *arplookup(u_int32_t, int, int, u_int);
-void in_arpinput(struct mbuf *);
-void in_revarpinput(struct mbuf *);
+void in_arpinput(struct ifnet *, struct mbuf *);
+void in_revarpinput(struct ifnet *, struct mbuf *);
 int arpcache(struct ifnet *, struct ether_arp *, struct rtentry *);
 
 LIST_HEAD(, llinfo_arp) arp_list;
@@ -413,7 +413,7 @@ bad:
  * then the protocol-specific routine is called.
  */
 void
-arpinput(struct mbuf *m)
+arpinput(struct ifnet *ifp, struct mbuf *m)
 {
struct arphdr *ar;
int len;
@@ -438,7 +438,7 @@ arpinput(struct mbuf *m)
if (m->m_len < len && (m = m_pullup(m, len)) == NULL)
return;
 
-   in_arpinput(m);
+   in_arpinput(ifp, m);
 }
 
 /*
@@ -447,10 +447,9 @@ arpinput(struct mbuf *m)
  * protocol address, to catch impersonators.
  */
 void
-in_arpinput(struct mbuf *m)
+in_arpinput(struct ifnet *ifp, struct mbuf *m)
 {
struct ether_arp *ea;
-   struct ifnet *ifp;
struct ether_header *eh;
struct rtentry *rt = NULL;
struct sockaddr sa;
@@ -463,11 +462,6 @@ in_arpinput(struct mbuf *m)
 
rdomain = rtable_l2(m->m_pkthdr.ph_rtableid);
 
-   ifp = if_get(m->m_pkthdr.ph_ifidx);
-   if (ifp == NULL) {
-   m_freem(m);
-   return;
-   }
ea = mtod(m, struct ether_arp *);
op = ntohs(ea->arp_op);
if ((op != ARPOP_REQUEST) && (op != ARPOP_REPLY))
@@ -557,12 +551,10 @@ in_arpinput(struct mbuf *m)
sa.sa_family = pseudo_AF_HDRCMPLT;
sa.sa_len = sizeof(sa);
ifp->if_output(ifp, m, , NULL);
-   if_put(ifp);
return;
 
 out:
rtfree(rt);
-   if_put(ifp);
m_freem(m);
 }
 
@@ -770,7 +762,7 @@ arpproxy(struct in_addr in, unsigned int
  * then the protocol-specific routine is called.
  */
 void
-revarpinput(struct mbuf *m)
+revarpinput(struct ifnet *ifp, struct mbuf *m)
 {
struct arphdr *ar;
 
@@ -784,7 +776,7 @@ revarpinput(struct mbuf *m)
switch (ntohs(ar->ar_pro)) {
 
case ETHERTYPE_IP:
-   in_revarpinput(m);
+   in_revarpinput(ifp, m);
return;
 
default:
@@ -806,9 +798,8 @@ out:
  * Note: also supports ARP via RARP packets, per the RFC.
  */
 void
-in_revarpinput(struct mbuf *m)
+in_revarpinput(struct ifnet *ifp, struct mbuf *m)
 {
-   struct ifnet *ifp = NULL;
struct ether_arp *ar;
int op;
 
@@ -817,7 +808,7 @@ in_revarpinput(struct mbuf *m)
switch (op) {
case ARPOP_REQUEST:
case ARPOP_REPLY:   /* per RFC */
-   in_arpinput(m);
+   in_arpinput(ifp, m);
return;
case ARPOP_REVREPLY:
break;
@@ -832,9 +823,6 @@ in_revarpinput(struct mbuf *m)
goto out;
if (revarp_finished)
goto wake;
-   ifp = if_get(revarp_ifidx);
-   if (ifp == NULL)
-   goto out;
if (memcmp(ar->arp_tha, LLADDR(ifp->if_sadl), sizeof(ar->arp_tha)))
goto out;
memcpy(_srvip, ar->arp_spa, sizeof(revarp_srvip));
@@ -842,11 +830,10 @@ in_revarpinput(struct mbuf *m)
revarp_finished = 1;
 wake:  /* Do wakeup every time in case it was missed. */
wakeup((caddr_t)_myip);
-#endif
+#endif /* NFSCLIENT */
 
 out:
m_freem(m);
-   if_put(ifp);
 }
 
 /*
Index: netinet/if_ether.h
===
RCS file: /cvs/src/sys/netinet/if_ether.h,v
retrieving revision 1.70
diff -u -p -r1.70 if_ether.h
--- netinet/if_ether.h  30 Mar 2016 10:13:14 -  1.70
+++ 

Re: Accept cnmac as a valid rootdev from uboot on octeon

2016-05-18 Thread Kim Lidström
Visa Hankala  wrote:
> On Tue, May 17, 2016 at 02:02:37AM +0200, Kim Lidström wrote:
> > Is this patch better? I have tested it by trying both cnmac0, cnmac1 and
> > cnmac2 as rootdev and it seems to work properly.
> > I also removed the outdated comment, changed the pointless text (Maybe
> > it'd be more appropriate to remove it?) and changed a memcpy() to
> > strlcpy().
> > Oh, I added that strncmp too!
> 
> The patch is better now, thanks. I committed it with a few tweaks.
> I kept the strcmp() in device_register() because the buffers are
> null-terminated and because the code is supposed check if the strings
> are equal (not if bootdev is a prefix of dev->dv_xname).
> 

Thanks!



Re: [patch] daemon.3

2016-05-18 Thread Remco

Op 05/18/16 om 01:49 schreef Edgar Pettijohn:

The wording made it hard for me to understand at first.  The "unless"
"non-zero" seem like double negatives.


Index: daemon.3
===
RCS file: /cvs/src/lib/libc/gen/daemon.3,v
retrieving revision 1.12
diff -u -p -u -r1.12 daemon.3
--- daemon.35 Jun 2013 03:39:22 -1.12
+++ daemon.317 May 2016 23:42:25 -
@@ -43,16 +43,16 @@ The
  function is for programs wishing to detach themselves from the
  controlling terminal and run in the background as system daemons.
  .Pp
-Unless the argument
+If the argument
  .Fa nochdir
-is non-zero,
+is zero,
  .Fn daemon
  changes the current working directory to the root
  .Pq Pa / .
  .Pp
-Unless the argument
+If the argument
  .Fa noclose
-is non-zero,
+is zero,
  .Fn daemon
  will redirect standard input, standard output and standard error to
  .Pa /dev/null .




You overlooked a double negation in the CAVEATS section.

I personally think the cause of confusion is the negated parameters, 
"nochdir" and "noclose", so in my mind your patch still leaves the 
confusion in place.


I'd like to propose the following:

Don't use negated parameters by renaming "nochdr" to "cd" and "noclose" 
to "redir" and adjust the man page accordingly. I didn't rename 
"nochdir" to "chdir" and "noclose" to "close" to avoid name clashes with 
chdir(2) and close(2))


Does the following patch provide a clear enough description ?


Index: daemon.3
===
RCS file: /cvs/src/lib/libc/gen/daemon.3,v
retrieving revision 1.12
diff -u -p -u -r1.12 daemon.3
--- daemon.35 Jun 2013 03:39:22 -   1.12
+++ daemon.318 May 2016 08:10:07 -
@@ -36,22 +36,22 @@
 .Sh SYNOPSIS
 .In stdlib.h
 .Ft int
-.Fn daemon "int nochdir" "int noclose"
+.Fn daemon "int cd" "int redir"
 .Sh DESCRIPTION
 The
 .Fn daemon
 function is for programs wishing to detach themselves from the
 controlling terminal and run in the background as system daemons.
 .Pp
-Unless the argument
-.Fa nochdir
+If the argument
+.Fa cd
 is non-zero,
 .Fn daemon
 changes the current working directory to the root
 .Pq Pa / .
 .Pp
-Unless the argument
-.Fa noclose
+If the argument
+.Fa redir
 is non-zero,
 .Fn daemon
 will redirect standard input, standard output and standard error to
@@ -78,8 +78,8 @@ The
 function first appeared in
 .Bx 4.4 .
 .Sh CAVEATS
-Unless the
-.Ar noclose
+If the
+.Ar redir
 argument is non-zero,
 .Fn daemon
 will close the first three file descriptors and redirect them to



Re: AMRR improvements for rt2860

2016-05-18 Thread Stefan Sperling
On Wed, May 18, 2016 at 06:24:15AM +0800, Nathanael Rensen wrote:
> On 27 April 2016 at 17:33, Stefan Sperling  wrote:
> 
> > This version includes minor tweak: When the AP goes down, we don't
> > need to send disassoc frames to nodes in COLLECT state.
> 
> While testing this diff I found some additional ieee80211 code paths
> that rely on ni_associd == 0 to detect a non-associated node. These
> caused issues for rt2860.
> 
> a) The rt2860 driver removes the corresponding WCID from the hardware
> table when a node dissociates. The WCID is added when the ic_newassoc()
> hook is called with the newassoc flag set. However, ieee80211_node_join()
> relies on ni_associd == 0 to determine whether to set the newassoc flag.
> If a cached node that already has a non-zero aid is reused the newassoc
> flag is not set and the WCID is not added to the hardware table.
> 
> b) A node that is inactive for a long period is placed into
> IEEE80211_STA_COLLECT by ieee80211_clean_nodes() and must reassociate
> before it can exchange data. If the node believes it is still associated
> then it will continue to use the defunct association. There is code in
> ieee80211_input() to detect this and send a management frame informing
> the node that it must reassociate. The detection also relies on
> ni_associd == 0, so a previously associated node that has retained its
> ni_associd will not be instructed to reassociate and will continue to
> use the defunct association (I saw this behaviour with android phones).
> 
> With the approach of retaining the aid for nodes in IEEE80211_STA_COLLECT
> ni_associd == 0 is no longer a reliable way to infer node state. I think
> it is better to rely on the node state directly. The diff below includes
> stsp@'s diff along with additional changes to use the node state directly
> to drive the logic.
> 
> Nathanael

Thanks, committed with a slight tweak:

@@ -1496,7 +1496,7 @@ void
 ieee80211_node_join(struct ieee80211com *ic, struct ieee80211_node *ni,
 int resp)
 {
-   int newassoc;
+   int newassoc = (ni->ni_state != IEEE80211_STA_ASSOC);
 
if (ni->ni_associd == 0) {
u_int16_t aid;


Please help me with watching the lists for regression reports.

> Index: ieee80211_input.c
> ===
> RCS file: /cvs/src/sys/net80211/ieee80211_input.c,v
> retrieving revision 1.176
> diff -u -p -r1.176 ieee80211_input.c
> --- ieee80211_input.c 2 May 2016 09:35:49 -   1.176
> +++ ieee80211_input.c 10 May 2016 01:05:22 -
> @@ -447,7 +447,7 @@ ieee80211_input(struct ifnet *ifp, struc
>   ic->ic_stats.is_rx_notassoc++;
>   goto err;
>   }
> - if (ni->ni_associd == 0) {
> + if (ni->ni_state != IEEE80211_STA_ASSOC) {
>   DPRINTF(("data from unassoc src %s\n",
>   ether_sprintf(wh->i_addr2)));
>   IEEE80211_SEND_MGMT(ic, ni,
> Index: ieee80211_node.c
> ===
> RCS file: /cvs/src/sys/net80211/ieee80211_node.c,v
> retrieving revision 1.101
> diff -u -p -r1.101 ieee80211_node.c
> --- ieee80211_node.c  12 Apr 2016 14:33:27 -  1.101
> +++ ieee80211_node.c  10 May 2016 01:05:22 -
> @@ -1496,7 +1496,10 @@ void
>  ieee80211_node_join(struct ieee80211com *ic, struct ieee80211_node *ni,
>  int resp)
>  {
> - int newassoc;
> + int newassoc = 1;
> +
> + if (ni->ni_state == IEEE80211_STA_ASSOC)
> + newassoc = 0;
>  
>   if (ni->ni_associd == 0) {
>   u_int16_t aid;
> @@ -1518,13 +1521,11 @@ ieee80211_node_join(struct ieee80211com 
>   }
>   ni->ni_associd = aid | 0xc000;
>   IEEE80211_AID_SET(ni->ni_associd, ic->ic_aid_bitmap);
> - newassoc = 1;
>   if (ic->ic_curmode == IEEE80211_MODE_11G ||
>   (ic->ic_curmode == IEEE80211_MODE_11N &&
>   IEEE80211_IS_CHAN_2GHZ(ic->ic_bss->ni_chan)))
>   ieee80211_node_join_11g(ic, ni);
> - } else
> - newassoc = 0;
> + }
>  
>   DPRINTF(("station %s %s associated at aid %d\n",
>   ether_sprintf(ni->ni_macaddr), newassoc ? "newly" : "already",
> @@ -1699,8 +1700,6 @@ ieee80211_node_leave(struct ieee80211com
>   if (ic->ic_node_leave != NULL)
>   (*ic->ic_node_leave)(ic, ni);
>  
> - IEEE80211_AID_CLR(ni->ni_associd, ic->ic_aid_bitmap);
> - ni->ni_associd = 0;
>   ieee80211_node_newstate(ni, IEEE80211_STA_COLLECT);
>  
>  #if NBRIDGE > 0
> Index: ieee80211_proto.c
> ===
> RCS file: /cvs/src/sys/net80211/ieee80211_proto.c,v
> retrieving revision 1.66
> diff -u -p -r1.66 ieee80211_proto.c
> --- ieee80211_proto.c 27 Apr 2016 11:58:10 

Re: [ntpd] Simultaneously listen on IPv4 and IPv6

2016-05-18 Thread Stuart Henderson
Removing the sysctl should be very pretty safe as far as ports goes (I did 
wonder if thing s might read the sysctl and change behaviour but it seems 
that's not the case). Looks like only nsh will break from doing that and it's 
easily fixed.

I did a search for things using the ioctl too. It looks like probably 
everything that listens with dual sockets uses it.

On 18 May 2016 06:48:06 BST, Damien Miller  wrote:
>On Tue, 17 May 2016, Henning Brauer wrote:
>
>> > What about systems with net.inet6.ip6.v6only=0? 
>> 
>> Those haven't been taken into consideration by yours truly and might
>be
>> the compelling argument to have this code :)
>
>That sysctl isn't hooked up to anything, it should be removed.
>(compare IPV6CTL_VARS against IPV6CTL_NAMES in in6.h)
>
>-d

-- 
Sent from a phone, please excuse the formatting.



Re: [patch] daemon.3

2016-05-18 Thread Theo de Raadt
> i agree your text is easier to read. actually reading things like this
> seems clear until you try and think about what it means.
> 
> still, you are changing the emphasis of the text. it seems the
> author chose that wording deliberately.  it reads like the author
> wants to say that it would be unusual for nochdir and noclose to
> be non-zero. if that's important it might be unwise to undo the
> text so completely.
> 
> i have no idea whether it's an important point though. if not, i agree
> it would make sense to go with the simpler text.

i don't see cause for the emphasis.  the manual page was probably
written by a non-native speaker.



Re: [patch] daemon.3

2016-05-18 Thread Jason McIntyre
On Tue, May 17, 2016 at 06:49:27PM -0500, Edgar Pettijohn wrote:
> The wording made it hard for me to understand at first.  The "unless"
> "non-zero" seem like double negatives.
> 

i agree your text is easier to read. actually reading things like this
seems clear until you try and think about what it means.

still, you are changing the emphasis of the text. it seems the
author chose that wording deliberately.  it reads like the author
wants to say that it would be unusual for nochdir and noclose to
be non-zero. if that's important it might be unwise to undo the
text so completely.

i have no idea whether it's an important point though. if not, i agree
it would make sense to go with the simpler text.

note there is also one more example of this text structure in CAVEATS.

jmc

> 
> Index: daemon.3
> ===
> RCS file: /cvs/src/lib/libc/gen/daemon.3,v
> retrieving revision 1.12
> diff -u -p -u -r1.12 daemon.3
> --- daemon.35 Jun 2013 03:39:22 -1.12
> +++ daemon.317 May 2016 23:42:25 -
> @@ -43,16 +43,16 @@ The
>  function is for programs wishing to detach themselves from the
>  controlling terminal and run in the background as system daemons.
>  .Pp
> -Unless the argument
> +If the argument
>  .Fa nochdir
> -is non-zero,
> +is zero,
>  .Fn daemon
>  changes the current working directory to the root
>  .Pq Pa / .
>  .Pp
> -Unless the argument
> +If the argument
>  .Fa noclose
> -is non-zero,
> +is zero,
>  .Fn daemon
>  will redirect standard input, standard output and standard error to
>  .Pa /dev/null .
>