avoid scan_dmesg in armv7 md_installboot

2017-08-21 Thread Jonathan Gray
If there is whitespace in the pattern sed returns scan_dmesg will sort
all of the words.  As hw.product is available on ramdisks use that
instead to avoid the problem.

Index: install.md
===
RCS file: /cvs/src/distrib/armv7/ramdisk/install.md,v
retrieving revision 1.46
diff -u -p -r1.46 install.md
--- install.md  28 Jul 2017 18:15:44 -  1.46
+++ install.md  22 Aug 2017 02:40:18 -
@@ -37,8 +37,7 @@ MOUNT_ARGS_msdos="-o-l"
 md_installboot() {
local _disk=/dev/$1 _mdec _plat
 
-   # Identify ARMv7 platform based on dmesg.
-   case $(scan_dmesg 's/^mainbus0 at root: \(.*\)$/\1/p') in
+   case $(sysctl -n hw.product) in
*AM335x*)   _plat=am335x;;
*'OMAP3 BeagleBoard'*)  _plat=beagle;;
*OMAP4*)_plat=panda;;



Synaptics touchpads: coordinate limits

2017-08-21 Thread Ulf Brosziewski
This patch adds a query for the lower coordinate limits to the Synaptics
part of pms.  Up to now, the driver always uses the "typical bezel
limits" as given in the "Synaptics PS/2 Interfacing Guide".  These limits
are indeed typical and often work well, but they aren't exact and you
cannot control the edge area sizes precisely.

I hope the query solves the problem for the models that support it, and
I would expect that it only causes minor changes in current setups.  A
few tests would be nice.

A quick way to check whether it has effects is
# wsconsctl mouse.scale
The first and the third value of the result should be different from
mouse.scale=1472,...,1408,...,...,...


Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.78
diff -u -p -r1.78 pms.c
--- pms.c   21 Jul 2017 20:10:10 -  1.78
+++ pms.c   21 Aug 2017 20:46:45 -
@@ -84,7 +84,7 @@ struct synaptics_softc {
int identify;
int capabilities, ext_capabilities, ext2_capabilities;
int model, ext_model;
-   int resolution, dimension;
+   int resolution, max_coords, min_coords;
int modes;

int mode;
@@ -928,9 +928,15 @@ synaptics_get_hwinfo(struct pms_softc *s
synaptics_query(sc, SYNAPTICS_QUE_RESOLUTION, >resolution))
return (-1);
if ((SYNAPTICS_CAP_EXTENDED_QUERIES(syn->capabilities) >= 5) &&
-   (syn->ext_capabilities & SYNAPTICS_EXT_CAP_MAX_DIMENSIONS) &&
-   synaptics_query(sc, SYNAPTICS_QUE_EXT_DIMENSIONS, >dimension))
+   (syn->ext_capabilities & SYNAPTICS_EXT_CAP_MAX_COORDS) &&
+   synaptics_query(sc, SYNAPTICS_QUE_EXT_MAX_COORDS, >max_coords))
return (-1);
+   if ((SYNAPTICS_CAP_EXTENDED_QUERIES(syn->capabilities) >= 7 ||
+   SYNAPTICS_ID_FULL(syn->identify) == 0x801) &&
+   (syn->ext_capabilities & SYNAPTICS_EXT_CAP_MIN_COORDS) &&
+   synaptics_query(sc, SYNAPTICS_QUE_EXT_MIN_COORDS, >min_coords))
+   return (-1);
+
if (SYNAPTICS_ID_FULL(syn->identify) >= 0x705) {
if (synaptics_query(sc, SYNAPTICS_QUE_MODES, >modes))
return (-1);
@@ -954,12 +960,15 @@ synaptics_get_hwinfo(struct pms_softc *s
hw->h_res = SYNAPTICS_RESOLUTION_X(syn->resolution);
hw->v_res = SYNAPTICS_RESOLUTION_Y(syn->resolution);
}
-   hw->x_min = SYNAPTICS_XMIN_BEZEL;
-   hw->y_min = SYNAPTICS_YMIN_BEZEL;
-   hw->x_max = (syn->dimension) ?
-   SYNAPTICS_DIM_X(syn->dimension) : SYNAPTICS_XMAX_BEZEL;
-   hw->y_max = (syn->dimension) ?
-   SYNAPTICS_DIM_Y(syn->dimension) : SYNAPTICS_YMAX_BEZEL;
+
+   hw->x_min = (syn->min_coords ?
+   SYNAPTICS_X_LIMIT(syn->min_coords) : SYNAPTICS_XMIN_BEZEL);
+   hw->y_min = (syn->min_coords ?
+   SYNAPTICS_Y_LIMIT(syn->min_coords) : SYNAPTICS_YMIN_BEZEL);
+   hw->x_max = (syn->max_coords ?
+   SYNAPTICS_X_LIMIT(syn->max_coords) : SYNAPTICS_XMAX_BEZEL);
+   hw->y_max = (syn->max_coords ?
+   SYNAPTICS_Y_LIMIT(syn->max_coords) : SYNAPTICS_YMAX_BEZEL);

hw->contacts_max = SYNAPTICS_MAX_FINGERS;

Index: pmsreg.h
===
RCS file: /cvs/src/sys/dev/pckbc/pmsreg.h,v
retrieving revision 1.13
diff -u -p -r1.13 pmsreg.h
--- pmsreg.h5 Sep 2015 14:02:21 -   1.13
+++ pmsreg.h21 Aug 2017 20:46:45 -
@@ -73,7 +73,8 @@
 #define SYNAPTICS_QUE_RESOLUTION   0x08
 #define SYNAPTICS_QUE_EXT_MODEL0x09
 #define SYNAPTICS_QUE_EXT_CAPABILITIES 0x0c
-#define SYNAPTICS_QUE_EXT_DIMENSIONS   0x0d
+#define SYNAPTICS_QUE_EXT_MAX_COORDS   0x0d
+#define SYNAPTICS_QUE_EXT_MIN_COORDS   0x0f
 #define SYNAPTICS_QUE_EXT2_CAPABILITIES0x10

 #define SYNAPTICS_CMD_SET_MODE 0x14
@@ -137,13 +138,14 @@
 /* Extended Capability bits */
 #define SYNAPTICS_EXT_CAP_CLICKPAD (1 << 20)
 #define SYNAPTICS_EXT_CAP_ADV_GESTURE  (1 << 19)
-#define SYNAPTICS_EXT_CAP_MAX_DIMENSIONS   (1 << 17)
+#define SYNAPTICS_EXT_CAP_MAX_COORDS   (1 << 17)
+#define SYNAPTICS_EXT_CAP_MIN_COORDS   (1 << 13)
 #define SYNAPTICS_EXT_CAP_CLICKPAD_2BTN(1 << 8)

-/* Extended Dimensions */
-#define SYNAPTICS_DIM_X(d) d) & 0xff) >> 11) | \
+/* Coordinate Limits */
+#define SYNAPTICS_X_LIMIT(d)   d) & 0xff) >> 11) | \
 (((d) & 0xf00) >> 7))
-#define SYNAPTICS_DIM_Y(d) d) & 0xff) << 5) | \
+#define SYNAPTICS_Y_LIMIT(d)   d) & 0xff) << 5) | \
 (((d) & 0xf000) >> 11))

 /* Extended Capability 2 */



Re: ospfd: add IMSG_IFADDRADD to deal with "sh /etc/netstart if"

2017-08-21 Thread Remi Locherer
On Mon, Jul 24, 2017 at 04:59:46PM +0200, Remi Locherer wrote:
> On Fri, Jul 21, 2017 at 06:24:06PM +0200, Remi Locherer wrote:
> > On Fri, Jul 21, 2017 at 02:45:03PM +0200, Florian Riehm wrote:
> > > On 06/25/17 23:47, Remi Locherer wrote:
> > > > Hi,
> > > > 
> > > > ospfd does not react nicely when running "sh /etc/netstart if".
> > > > 
> > > > This is because adding the same address again do an interface results
> > > > in RTM_DELADDR and RTM_NEWADDR. ospfd handles the former but the later.
> > > > If this happens ospfd says "interface vether0:192.168.250.1 gone".
> > > > Adjacencies on that interface are down and ospfd can not recover.
> > > > 
> > > > The below patch adds IMSG_IFADDRADD to deal with that. With it ospfd
> > > > logs the following after "ifconfig vether0 192.168.250.1/24" (same 
> > > > address
> > > > as active before):
> > > > 
> > > 
> > > Hi Remi,
> > > 
> > > thanks for your report and your patch.
> > > I think it is the right approach, but unfortunately it doesn't work in my 
> > > setup.
> > > If I run 'sh /etc/netstart vio1' vio1 goes down and stays down.
> > > Please have a look to my config / logs. What is the differece between 
> > > your and
> > > my test?
> > 
> > I tested with an interface connected to stub network. Your output shows an
> > interface connected to a transit network. In my test setup I did not get the
> > error message: "if_join_group: error IP_ADD_MEMBERSHIP"
> > 
> > I'll look into it and try to fix this.
> 
> I could reproduce the behaviour you see with my patch when testing with
> vmm and vio interfaces. It looks like in the IFADDRDEL case the interface
> can not leave the multicast group.
> 
> I do not see this when testing with vether, pair or vlan (over ix)
> interfaces. Could this be a bug with multicast handling in vio?


Today I did a test with an unpatched ospfd and a vio interface in vmm.

I started ospfd and waited till adjacency was up. Then I did
"ifconfig vio0 192.168.250.101/24" (same ip as set before).

The debug output from ospfd:

[...]
if_leave_group: error IP_DROP_MEMBERSHIP, interface vio0 address 224.0.0.5: 
Can't assign requested address
if_leave_group: error IP_DROP_MEMBERSHIP, interface vio0 address 224.0.0.6: 
Can't assign requested address
orig_rtr_lsa: area 0.0.0.0
orig_rtr_lsa: stub net, interface vio0
orig_rtr_lsa: stub net, interface vether0
if_act_elect: interface vio0 old dr 192.168.250.1 new dr 192.168.250.101, old 
bdr 192.168.250.101 new bdr none
orig_rtr_lsa: area 0.0.0.0
[...]

Doing the same with a pair or vether interface does not produce the message
"if_leave_group: error IP_DROP_MEMBERSHIP ".

My conclusion of this is that the error is problem with the vio driver and
not with my patch for ospfd. 

Could we proceed with the proposed ospfd patch and attack the vio problem
separately?

> > > Beside that:
> > > - I would rename 'struct ifaddrdel' to 'struct ifaddr' and extend it. So 
> > > we
> > >   can use it in if_newaddr() and if_deladdr() and avoid 'struct 
> > > ifaddrnew'.
> > 
> > Makes sense.
> 
> The below patch introduces struct ifaddr and removes struct ifaddrdel. It
> also introduces two additional debug messages in interface.c:
> 
> if_act_reset: interface vether0 left group 224.0.0.5
> if_act_start: interface vether0 joined group 224.0.0.5
> 
> I added those to see a bit better what's going on. But I would not commit
> them. They are now printed even if joining the group is not successful
> (the message before would tell it).
> 
> 
> Index: interface.c
> ===
> RCS file: /cvs/src/usr.sbin/ospfd/interface.c,v
> retrieving revision 1.81
> diff -u -p -r1.81 interface.c
> --- interface.c   5 Dec 2015 12:20:13 -   1.81
> +++ interface.c   24 Jul 2017 14:55:58 -
> @@ -357,6 +357,8 @@ if_act_start(struct iface *iface)
>   inet_aton(AllSPFRouters, );
>   if (if_join_group(iface, ))
>   return (-1);
> + log_debug("if_act_start: interface %s joined group %s",
> + iface->name, AllSPFRouters);
>   iface->state = IF_STA_POINTTOPOINT;
>   break;
>   case IF_TYPE_VIRTUALLINK:
> @@ -371,6 +373,8 @@ if_act_start(struct iface *iface)
>   inet_aton(AllSPFRouters, );
>   if (if_join_group(iface, ))
>   return (-1);
> + log_debug("if_act_start: interface %s joined group %s",
> + iface->name, AllSPFRouters);
>   if (iface->priority == 0) {
>   iface->state = IF_STA_DROTHER;
>   } else {
> @@ -547,6 +551,8 @@ if_act_reset(struct iface *iface)
>   /* try to cleanup */
>   inet_aton(AllSPFRouters, );
>   if_leave_group(iface, );
> + log_debug("if_act_reset: interface %s left group %s",
> + iface->name, AllSPFRouters);
>   if (iface->state & 

Re: Update inaccurate comment in rasops(9)

2017-08-21 Thread Frederic Cambus
On Fri, Aug 04, 2017 at 11:31:00PM +0200, Frederic Cambus wrote:

> Update inaccurate comment: rasops_copycols() doesn't use bcopy()
> anymore, but either memmove() or slow_bcopy().
> 
> Comments? OK?

Ping. Anyone?

> Index: sys/dev/rasops/rasops.c
> ===
> RCS file: /cvs/src/sys/dev/rasops/rasops.c,v
> retrieving revision 1.45
> diff -u -p -r1.45 rasops.c
> --- sys/dev/rasops/rasops.c   16 May 2017 02:22:51 -  1.45
> +++ sys/dev/rasops/rasops.c   1 Aug 2017 21:32:14 -
> @@ -660,8 +660,8 @@ rasops_copyrows(void *cookie, int src, i
>  /*
>   * Copy columns. This is slow, and hard to optimize due to alignment,
>   * and the fact that we have to copy both left->right and right->left.
> - * We simply cop-out here and use bcopy(), since it handles all of
> - * these cases anyway.
> + * We simply cop-out here and use either memmove() or slow_bcopy(),
> + * since they handle all of these cases anyway.
>   */
>  int
>  rasops_copycols(void *cookie, int row, int src, int dst, int num)



Re: Please test: HZ bump

2017-08-21 Thread Chris Cappuccio
I've been testing the second version of this diff in a number of areas 
(servers, desktop, laptop, routers) and I haven't noticed anything interesting
with power usage, run time on the laptops nor anything else, anywhere. That's
probably a good thing...



Blocking mem alloc & sosetopt()

2017-08-21 Thread Martin Pieuchot
In order to stop allocating multiple mbufs and possibly waiting with
the socket lock held in NFS, I'd like sosetopt() to no longer free the
mbuf it receives.

This diff makes sosetopt() similar to sogetopt(), the caller is
responsible for allocating & freeing the option mbuf.

ok?

Index: kern/uipc_socket.c
===
RCS file: /cvs/src/sys/kern/uipc_socket.c,v
retrieving revision 1.201
diff -u -p -r1.201 uipc_socket.c
--- kern/uipc_socket.c  10 Aug 2017 19:20:43 -  1.201
+++ kern/uipc_socket.c  21 Aug 2017 13:39:50 -
@@ -1558,17 +1558,16 @@ sowwakeup(struct socket *so)
 }
 
 int
-sosetopt(struct socket *so, int level, int optname, struct mbuf *m0)
+sosetopt(struct socket *so, int level, int optname, struct mbuf *m)
 {
int error = 0;
-   struct mbuf *m = m0;
 
soassertlocked(so);
 
if (level != SOL_SOCKET) {
if (so->so_proto->pr_ctloutput) {
error = (*so->so_proto->pr_ctloutput)(PRCO_SETOPT, so,
-   level, optname, m0);
+   level, optname, m);
return (error);
}
error = ENOPROTOOPT;
@@ -1576,7 +1575,7 @@ sosetopt(struct socket *so, int level, i
switch (optname) {
case SO_BINDANY:
if ((error = suser(curproc, 0)) != 0)   /* XXX */
-   goto bad;
+   return (error);
break;
}
 
@@ -1585,10 +1584,8 @@ sosetopt(struct socket *so, int level, i
case SO_LINGER:
if (m == NULL || m->m_len != sizeof (struct linger) ||
mtod(m, struct linger *)->l_linger < 0 ||
-   mtod(m, struct linger *)->l_linger > SHRT_MAX) {
-   error = EINVAL;
-   goto bad;
-   }
+   mtod(m, struct linger *)->l_linger > SHRT_MAX)
+   return (EINVAL);
so->so_linger = mtod(m, struct linger *)->l_linger;
/* FALLTHROUGH */
 
@@ -1602,10 +1599,8 @@ sosetopt(struct socket *so, int level, i
case SO_OOBINLINE:
case SO_TIMESTAMP:
case SO_ZEROIZE:
-   if (m == NULL || m->m_len < sizeof (int)) {
-   error = EINVAL;
-   goto bad;
-   }
+   if (m == NULL || m->m_len < sizeof (int))
+   return (EINVAL);
if (*mtod(m, int *))
so->so_options |= optname;
else
@@ -1613,10 +1608,8 @@ sosetopt(struct socket *so, int level, i
break;
 
case SO_DONTROUTE:
-   if (m == NULL || m->m_len < sizeof (int)) {
-   error = EINVAL;
-   goto bad;
-   }
+   if (m == NULL || m->m_len < sizeof (int))
+   return (EINVAL);
if (*mtod(m, int *))
error = EOPNOTSUPP;
break;
@@ -1628,38 +1621,28 @@ sosetopt(struct socket *so, int level, i
{
u_long cnt;
 
-   if (m == NULL || m->m_len < sizeof (int)) {
-   error = EINVAL;
-   goto bad;
-   }
+   if (m == NULL || m->m_len < sizeof (int))
+   return (EINVAL);
cnt = *mtod(m, int *);
if ((long)cnt <= 0)
cnt = 1;
switch (optname) {
 
case SO_SNDBUF:
-   if (so->so_state & SS_CANTSENDMORE) {
-   error = EINVAL;
-   goto bad;
-   }
+   if (so->so_state & SS_CANTSENDMORE)
+   return (EINVAL);
if (sbcheckreserve(cnt, so->so_snd.sb_wat) ||
-   sbreserve(so, >so_snd, cnt)) {
-   error = ENOBUFS;
-   goto bad;
-   }
+   sbreserve(so, >so_snd, cnt))
+   return (ENOBUFS);
so->so_snd.sb_wat = cnt;
break;
 
case SO_RCVBUF:
-   if (so->so_state & 

Re: RETGUARD

2017-08-21 Thread Christian Weisgerber
Edd Barrett:

> > lang/pypy   retguard
> 
> I'm looking into PyPy.
> 
> Can you provide the build output?

Oops, sorry, I forgot to save the logs before I cleaned the machines
yesterday.  Should be straightforward to reproduce, though.  At
some point the build dies with a segfault.

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



Re: Blocking memory allocation & solock()

2017-08-21 Thread Mark Kettenis
> Date: Mon, 21 Aug 2017 15:35:30 +0200
> From: Martin Pieuchot 
> 
> On 21/08/17(Mon) 15:33, Martin Pieuchot wrote:
> > I'd like to reduce the number of blocking memory allocations holding
> > the NET_LOCK().
> > 
> > Diff below moves m_get(M_WAIT) before grabbing the socket lock for
> > sogetopt().
> 
> Diff below includes the prototype change.
> 
> ok?

Totally makes sense; ok kettenis@

> Index: kern/uipc_socket.c
> ===
> RCS file: /cvs/src/sys/kern/uipc_socket.c,v
> retrieving revision 1.201
> diff -u -p -r1.201 uipc_socket.c
> --- kern/uipc_socket.c10 Aug 2017 19:20:43 -  1.201
> +++ kern/uipc_socket.c21 Aug 2017 13:22:27 -
> @@ -1755,30 +1755,24 @@ bad:
>  }
>  
>  int
> -sogetopt(struct socket *so, int level, int optname, struct mbuf **mp)
> +sogetopt(struct socket *so, int level, int optname, struct mbuf *m)
>  {
>   int error = 0;
> - struct mbuf *m;
>  
>   soassertlocked(so);
>  
>   if (level != SOL_SOCKET) {
>   if (so->so_proto->pr_ctloutput) {
> - m = m_get(M_WAIT, MT_SOOPTS);
>   m->m_len = 0;
>  
>   error = (*so->so_proto->pr_ctloutput)(PRCO_GETOPT, so,
>   level, optname, m);
> - if (error) {
> - m_free(m);
> + if (error)
>   return (error);
> - }
> - *mp = m;
>   return (0);
>   } else
>   return (ENOPROTOOPT);
>   } else {
> - m = m_get(M_WAIT, MT_SOOPTS);
>   m->m_len = sizeof (int);
>  
>   switch (optname) {
> @@ -1856,13 +1850,10 @@ sogetopt(struct socket *so, int level, i
>   level = dom->dom_protosw->pr_protocol;
>   error = (*so->so_proto->pr_ctloutput)
>   (PRCO_GETOPT, so, level, optname, m);
> - if (error) {
> - (void)m_free(m);
> + if (error)
>   return (error);
> - }
>   break;
>   }
> - (void)m_free(m);
>   return (ENOPROTOOPT);
>  
>  #ifdef SOCKET_SPLICE
> @@ -1887,17 +1878,13 @@ sogetopt(struct socket *so, int level, i
>   &(unp->unp_connid), m->m_len);
>   break;
>   }
> - (void)m_free(m);
>   return (ENOTCONN);
>   }
> - (void)m_free(m);
>   return (EOPNOTSUPP);
>  
>   default:
> - (void)m_free(m);
>   return (ENOPROTOOPT);
>   }
> - *mp = m;
>   return (0);
>   }
>  }
> Index: kern/uipc_syscalls.c
> ===
> RCS file: /cvs/src/sys/kern/uipc_syscalls.c,v
> retrieving revision 1.158
> diff -u -p -r1.158 uipc_syscalls.c
> --- kern/uipc_syscalls.c  10 Aug 2017 19:20:43 -  1.158
> +++ kern/uipc_syscalls.c  21 Aug 2017 13:17:17 -
> @@ -1014,9 +1014,10 @@ sys_getsockopt(struct proc *p, void *v, 
>   goto out;
>   } else
>   valsize = 0;
> + m = m_get(M_WAIT, MT_SOOPTS);
>   so = fp->f_data;
>   s = solock(so);
> - error = sogetopt(so, SCARG(uap, level), SCARG(uap, name), );
> + error = sogetopt(so, SCARG(uap, level), SCARG(uap, name), m);
>   sounlock(s);
>   if (error == 0 && SCARG(uap, val) && valsize && m != NULL) {
>   if (valsize > m->m_len)
> @@ -1026,9 +1027,9 @@ sys_getsockopt(struct proc *p, void *v, 
>   error = copyout(,
>   SCARG(uap, avalsize), sizeof (valsize));
>   }
> + m_free(m);
>  out:
>   FRELE(fp, p);
> - m_free(m);
>   return (error);
>  }
>  
> Index: sys/socketvar.h
> ===
> RCS file: /cvs/src/sys/sys/socketvar.h,v
> retrieving revision 1.74
> diff -u -p -r1.74 socketvar.h
> --- sys/socketvar.h   12 Jul 2017 10:56:47 -  1.74
> +++ sys/socketvar.h   21 Aug 2017 13:15:54 -
> @@ -312,8 +312,7 @@ int   soconnect2(struct socket *so1, struc
>  int  socreate(int dom, struct socket **aso, int type, int proto);
>  int  sodisconnect(struct socket *so);
>  void sofree(struct socket *so);
> -int  sogetopt(struct socket *so, int level, int optname,
> - struct mbuf **mp);
> +int  sogetopt(struct socket *so, int level, int optname, struct mbuf *m);
>  void sohasoutofband(struct socket 

Re: Blocking memory allocation & solock()

2017-08-21 Thread Martin Pieuchot
On 21/08/17(Mon) 15:33, Martin Pieuchot wrote:
> I'd like to reduce the number of blocking memory allocations holding
> the NET_LOCK().
> 
> Diff below moves m_get(M_WAIT) before grabbing the socket lock for
> sogetopt().

Diff below includes the prototype change.

ok?

Index: kern/uipc_socket.c
===
RCS file: /cvs/src/sys/kern/uipc_socket.c,v
retrieving revision 1.201
diff -u -p -r1.201 uipc_socket.c
--- kern/uipc_socket.c  10 Aug 2017 19:20:43 -  1.201
+++ kern/uipc_socket.c  21 Aug 2017 13:22:27 -
@@ -1755,30 +1755,24 @@ bad:
 }
 
 int
-sogetopt(struct socket *so, int level, int optname, struct mbuf **mp)
+sogetopt(struct socket *so, int level, int optname, struct mbuf *m)
 {
int error = 0;
-   struct mbuf *m;
 
soassertlocked(so);
 
if (level != SOL_SOCKET) {
if (so->so_proto->pr_ctloutput) {
-   m = m_get(M_WAIT, MT_SOOPTS);
m->m_len = 0;
 
error = (*so->so_proto->pr_ctloutput)(PRCO_GETOPT, so,
level, optname, m);
-   if (error) {
-   m_free(m);
+   if (error)
return (error);
-   }
-   *mp = m;
return (0);
} else
return (ENOPROTOOPT);
} else {
-   m = m_get(M_WAIT, MT_SOOPTS);
m->m_len = sizeof (int);
 
switch (optname) {
@@ -1856,13 +1850,10 @@ sogetopt(struct socket *so, int level, i
level = dom->dom_protosw->pr_protocol;
error = (*so->so_proto->pr_ctloutput)
(PRCO_GETOPT, so, level, optname, m);
-   if (error) {
-   (void)m_free(m);
+   if (error)
return (error);
-   }
break;
}
-   (void)m_free(m);
return (ENOPROTOOPT);
 
 #ifdef SOCKET_SPLICE
@@ -1887,17 +1878,13 @@ sogetopt(struct socket *so, int level, i
&(unp->unp_connid), m->m_len);
break;
}
-   (void)m_free(m);
return (ENOTCONN);
}
-   (void)m_free(m);
return (EOPNOTSUPP);
 
default:
-   (void)m_free(m);
return (ENOPROTOOPT);
}
-   *mp = m;
return (0);
}
 }
Index: kern/uipc_syscalls.c
===
RCS file: /cvs/src/sys/kern/uipc_syscalls.c,v
retrieving revision 1.158
diff -u -p -r1.158 uipc_syscalls.c
--- kern/uipc_syscalls.c10 Aug 2017 19:20:43 -  1.158
+++ kern/uipc_syscalls.c21 Aug 2017 13:17:17 -
@@ -1014,9 +1014,10 @@ sys_getsockopt(struct proc *p, void *v, 
goto out;
} else
valsize = 0;
+   m = m_get(M_WAIT, MT_SOOPTS);
so = fp->f_data;
s = solock(so);
-   error = sogetopt(so, SCARG(uap, level), SCARG(uap, name), );
+   error = sogetopt(so, SCARG(uap, level), SCARG(uap, name), m);
sounlock(s);
if (error == 0 && SCARG(uap, val) && valsize && m != NULL) {
if (valsize > m->m_len)
@@ -1026,9 +1027,9 @@ sys_getsockopt(struct proc *p, void *v, 
error = copyout(,
SCARG(uap, avalsize), sizeof (valsize));
}
+   m_free(m);
 out:
FRELE(fp, p);
-   m_free(m);
return (error);
 }
 
Index: sys/socketvar.h
===
RCS file: /cvs/src/sys/sys/socketvar.h,v
retrieving revision 1.74
diff -u -p -r1.74 socketvar.h
--- sys/socketvar.h 12 Jul 2017 10:56:47 -  1.74
+++ sys/socketvar.h 21 Aug 2017 13:15:54 -
@@ -312,8 +312,7 @@ int soconnect2(struct socket *so1, struc
 intsocreate(int dom, struct socket **aso, int type, int proto);
 intsodisconnect(struct socket *so);
 void   sofree(struct socket *so);
-intsogetopt(struct socket *so, int level, int optname,
-   struct mbuf **mp);
+intsogetopt(struct socket *so, int level, int optname, struct mbuf *m);
 void   sohasoutofband(struct socket *so);
 void   soisconnected(struct socket *so);
 void   soisconnecting(struct socket *so);



Blocking memory allocation & solock()

2017-08-21 Thread Martin Pieuchot
I'd like to reduce the number of blocking memory allocations holding
the NET_LOCK().

Diff below moves m_get(M_WAIT) before grabbing the socket lock for
sogetopt().

ok?

Index: kern/uipc_socket.c
===
RCS file: /cvs/src/sys/kern/uipc_socket.c,v
retrieving revision 1.201
diff -u -p -r1.201 uipc_socket.c
--- kern/uipc_socket.c  10 Aug 2017 19:20:43 -  1.201
+++ kern/uipc_socket.c  21 Aug 2017 13:22:27 -
@@ -1755,30 +1755,24 @@ bad:
 }
 
 int
-sogetopt(struct socket *so, int level, int optname, struct mbuf **mp)
+sogetopt(struct socket *so, int level, int optname, struct mbuf *m)
 {
int error = 0;
-   struct mbuf *m;
 
soassertlocked(so);
 
if (level != SOL_SOCKET) {
if (so->so_proto->pr_ctloutput) {
-   m = m_get(M_WAIT, MT_SOOPTS);
m->m_len = 0;
 
error = (*so->so_proto->pr_ctloutput)(PRCO_GETOPT, so,
level, optname, m);
-   if (error) {
-   m_free(m);
+   if (error)
return (error);
-   }
-   *mp = m;
return (0);
} else
return (ENOPROTOOPT);
} else {
-   m = m_get(M_WAIT, MT_SOOPTS);
m->m_len = sizeof (int);
 
switch (optname) {
@@ -1856,13 +1850,10 @@ sogetopt(struct socket *so, int level, i
level = dom->dom_protosw->pr_protocol;
error = (*so->so_proto->pr_ctloutput)
(PRCO_GETOPT, so, level, optname, m);
-   if (error) {
-   (void)m_free(m);
+   if (error)
return (error);
-   }
break;
}
-   (void)m_free(m);
return (ENOPROTOOPT);
 
 #ifdef SOCKET_SPLICE
@@ -1887,17 +1878,13 @@ sogetopt(struct socket *so, int level, i
&(unp->unp_connid), m->m_len);
break;
}
-   (void)m_free(m);
return (ENOTCONN);
}
-   (void)m_free(m);
return (EOPNOTSUPP);
 
default:
-   (void)m_free(m);
return (ENOPROTOOPT);
}
-   *mp = m;
return (0);
}
 }
Index: kern/uipc_syscalls.c
===
RCS file: /cvs/src/sys/kern/uipc_syscalls.c,v
retrieving revision 1.158
diff -u -p -r1.158 uipc_syscalls.c
--- kern/uipc_syscalls.c10 Aug 2017 19:20:43 -  1.158
+++ kern/uipc_syscalls.c21 Aug 2017 13:17:17 -
@@ -1014,9 +1014,10 @@ sys_getsockopt(struct proc *p, void *v, 
goto out;
} else
valsize = 0;
+   m = m_get(M_WAIT, MT_SOOPTS);
so = fp->f_data;
s = solock(so);
-   error = sogetopt(so, SCARG(uap, level), SCARG(uap, name), );
+   error = sogetopt(so, SCARG(uap, level), SCARG(uap, name), m);
sounlock(s);
if (error == 0 && SCARG(uap, val) && valsize && m != NULL) {
if (valsize > m->m_len)
@@ -1026,9 +1027,9 @@ sys_getsockopt(struct proc *p, void *v, 
error = copyout(,
SCARG(uap, avalsize), sizeof (valsize));
}
+   m_free(m);
 out:
FRELE(fp, p);
-   m_free(m);
return (error);
 }
 



Re: twm.1: xdm -> xenodm

2017-08-21 Thread Matthieu Herrb
On Mon, Aug 21, 2017 at 12:11:34PM +0200, Klemens Nanni wrote:
> Feedback?

twm is an upstream man page. I prefer not to touch it.  You can submit
a patch upstream (xorg-de...@lists.freedesktop.org) to replace xdm by
'display manager' as there are a lots of them nowadays (gdm, kdm,
lightdm, xdm, xenodm,...)  that will be more correct.



> 
> Index: man/twm.man
> ===
> RCS file: /cvs/xenocara/app/twm/man/twm.man,v
> retrieving revision 1.5
> diff -u -p -r1.5 twm.man
> --- man/twm.man   10 May 2015 09:57:50 -  1.5
> +++ man/twm.man   21 Aug 2017 10:10:05 -
> @@ -51,7 +51,7 @@ click-to-type and pointer-driven keyboar
>  key and pointer button bindings.
>  .PP
>  This program is usually started by the user's session manager or
> -startup script.  When used from \fIxdm(__appmansuffix__)\fP or 
> \fIxinit(__appmansuffix__)\fP without
> +startup script.  When used from \fIxenodm(__appmansuffix__)\fP or 
> \fIxinit(__appmansuffix__)\fP without
>  a session manager, \fItwm\fP is frequently executed in the foreground
>  as the last client.  When run this way, exiting \fItwm\fP causes the
>  session to be terminated (i.e., logged out).
> @@ -1088,7 +1088,7 @@ integer in double quotes (e.g. "999" ). 
>  if the server supports the SYNC extension.
>  .IP "\fBf.quit\fP" 8
>  This function causes \fItwm\fP to restore the window's borders and exit.  If
> -\fItwm\fP is the first client invoked from \fIxdm\fP, this will result in a
> +\fItwm\fP is the first client invoked from \fIxenodm\fP, this will result in 
> a
>  server reset.
>  .IP "\fBf.raise\fP" 8
>  This function raises the selected window.
> @@ -1274,7 +1274,7 @@ This variable is used as the prefix for 
>  for locating the \fItwm\fP startup file.
>  .SH "SEE ALSO"
>  .PP
> -X(__miscmansuffix__), Xserver(__appmansuffix__), xdm(__appmansuffix__), 
> xrdb(__appmansuffix__)
> +X(__miscmansuffix__), Xserver(__appmansuffix__), xenodm(__appmansuffix__), 
> xrdb(__appmansuffix__)
>  .SH AUTHORS
>  Tom LaStrange, Solbourne Computer; Jim Fulton, MIT X Consortium;
>  Steve Pitschke, Stardent Computer; Keith Packard, MIT X Consortium;

-- 
Matthieu Herrb



Re: RETGUARD

2017-08-21 Thread Edd Barrett
On Mon, Aug 21, 2017 at 12:13:05PM -, Christian Weisgerber wrote:
> lang/pypy retguard

I'm looking into PyPy.

Can you provide the build output?

Cheers

-- 
Best Regards
Edd Barrett

http://www.theunixzoo.co.uk



Re: RETGUARD

2017-08-21 Thread Christian Weisgerber
On 2017-08-19, Theo de Raadt  wrote:

> We are at the point where userland and base are fully working without
> regressions, and the remaining impacts are in a few larger ports which
> directly access the return address (for a variety of reasons).

Fallout from building amd64 packages with a retguard snapshot:

lang/node   retguard
lang/pypy   retguard

And a bunch of ports using java, although jdk itself built fine:

databases/db/v4 retguard (java)
devel/intellij  retguard (java)
editors/libreoffice retguard (java)
games/jbrickshooter retguard (java)
games/lwjgl retguard (java)
geo/jeoip   retguard (java)
java/jBCryptretguard (java)
java/java-getoptretguard (java)
java/jnaretguard (java)
java/tanukiwrapper  retguard (java)
lang/abcl   retguard (java)
lang/clojureretguard (java)
lang/jruby  retguard (java)
lang/kawa   retguard (java)
net/openfireretguard (java)
sysutils/rundeckretguard (java)
textproc/link-grammar   retguard (java)
www/icedtea-web retguard (java)

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



twm.1: xdm -> xenodm

2017-08-21 Thread Klemens Nanni
Feedback?

Index: man/twm.man
===
RCS file: /cvs/xenocara/app/twm/man/twm.man,v
retrieving revision 1.5
diff -u -p -r1.5 twm.man
--- man/twm.man 10 May 2015 09:57:50 -  1.5
+++ man/twm.man 21 Aug 2017 10:10:05 -
@@ -51,7 +51,7 @@ click-to-type and pointer-driven keyboar
 key and pointer button bindings.
 .PP
 This program is usually started by the user's session manager or
-startup script.  When used from \fIxdm(__appmansuffix__)\fP or 
\fIxinit(__appmansuffix__)\fP without
+startup script.  When used from \fIxenodm(__appmansuffix__)\fP or 
\fIxinit(__appmansuffix__)\fP without
 a session manager, \fItwm\fP is frequently executed in the foreground
 as the last client.  When run this way, exiting \fItwm\fP causes the
 session to be terminated (i.e., logged out).
@@ -1088,7 +1088,7 @@ integer in double quotes (e.g. "999" ). 
 if the server supports the SYNC extension.
 .IP "\fBf.quit\fP" 8
 This function causes \fItwm\fP to restore the window's borders and exit.  If
-\fItwm\fP is the first client invoked from \fIxdm\fP, this will result in a
+\fItwm\fP is the first client invoked from \fIxenodm\fP, this will result in a
 server reset.
 .IP "\fBf.raise\fP" 8
 This function raises the selected window.
@@ -1274,7 +1274,7 @@ This variable is used as the prefix for 
 for locating the \fItwm\fP startup file.
 .SH "SEE ALSO"
 .PP
-X(__miscmansuffix__), Xserver(__appmansuffix__), xdm(__appmansuffix__), 
xrdb(__appmansuffix__)
+X(__miscmansuffix__), Xserver(__appmansuffix__), xenodm(__appmansuffix__), 
xrdb(__appmansuffix__)
 .SH AUTHORS
 Tom LaStrange, Solbourne Computer; Jim Fulton, MIT X Consortium;
 Steve Pitschke, Stardent Computer; Keith Packard, MIT X Consortium;



Re: Document the RI_ROTATE_CCW flag in rasops.9

2017-08-21 Thread Mark Kettenis
> Date: Mon, 21 Aug 2017 11:48:33 +0200
> From: Frederic Cambus 
> 
> Hi tech@,
> 
> Document the newly introduced RI_ROTATE_CCW flag.
> 
> Comments? OK?

Thanks!  ok kettenis@

> Index: share/man/man9/rasops.9
> ===
> RCS file: /cvs/src/share/man/man9/rasops.9,v
> retrieving revision 1.17
> diff -u -p -r1.17 rasops.9
> --- share/man/man9/rasops.9   18 Jan 2017 20:07:40 -  1.17
> +++ share/man/man9/rasops.9   21 Aug 2017 09:33:00 -
> @@ -153,6 +153,8 @@ Center the text area.
>  .\" Cursor is currently clipped
>  .It RI_ROTATE_CW
>  Rotate the text display quarter clockwise.
> +.It RI_ROTATE_CCW
> +Rotate the text display quarter counter-clockwise.
>  .It RI_CFGDONE
>  .Fn rasops_reconfig
>  completed successfully
> 
> 



Document the RI_ROTATE_CCW flag in rasops.9

2017-08-21 Thread Frederic Cambus
Hi tech@,

Document the newly introduced RI_ROTATE_CCW flag.

Comments? OK?

Index: share/man/man9/rasops.9
===
RCS file: /cvs/src/share/man/man9/rasops.9,v
retrieving revision 1.17
diff -u -p -r1.17 rasops.9
--- share/man/man9/rasops.9 18 Jan 2017 20:07:40 -  1.17
+++ share/man/man9/rasops.9 21 Aug 2017 09:33:00 -
@@ -153,6 +153,8 @@ Center the text area.
 .\" Cursor is currently clipped
 .It RI_ROTATE_CW
 Rotate the text display quarter clockwise.
+.It RI_ROTATE_CCW
+Rotate the text display quarter counter-clockwise.
 .It RI_CFGDONE
 .Fn rasops_reconfig
 completed successfully



make: setenv or esetenv

2017-08-21 Thread Michael W. Bombardieri
Hi,

In make(1), setenv() was mostly called through a wrapper function
esetenv() which exits on error.
When setting MAKEBASEDIRECTORY the return value of setenv() was
not checked. Converting the call to esetenv() makes it more consistent.
The third param of setenv(), overwrite, doesn't matter here. The
result of getenv() is checked first so nothing is written over.

- Michael


Index: main.c
===
RCS file: /cvs/src/usr.bin/make/main.c,v
retrieving revision 1.122
diff -u -p -u -r1.122 main.c
--- main.c  20 Apr 2017 03:04:11 -  1.122
+++ main.c  21 Aug 2017 08:17:07 -
@@ -713,7 +713,7 @@ main(int argc, char **argv)

basedirectory = getenv("MAKEBASEDIRECTORY");
if (basedirectory == NULL)
-   setenv("MAKEBASEDIRECTORY", d.current, 0);
+   esetenv("MAKEBASEDIRECTORY", d.current);
 
MainParseArgs(argc, argv);