Re: improve realloc(3)

2017-01-12 Thread Otto Moerbeek
On Mon, Jan 09, 2017 at 07:49:24PM +0100, Otto Moerbeek wrote:

> Hi,
> 
> this diff implements some improvements to realloc and some cleanup of
> the MALLOC_MOVE code.
> 
> 1. When shrinking a chunk allocation, compare the size of the current
> allocation to the size of the new allocation (instead of the requested size).
> Current code does a malloc-free-copy dance in too many cases.
> 
> 2. Current code takes the easy way and always reallocates if C is
> active. This diff fixes by carefully updating the recorded requested
> size in all cases, and writing the canary bytes in the proper location
> after reallocating.
> 
> 3. Introduce defines to test if MALLOC_MOVE should be done and to
> compute the new value.
> 
> Please review and test with you favorite (and other) combination of
> malloc flags.

Anybody tested?

No feedback no progress, Jimi Hendrix could have said

-Otto


> 
> Index: malloc.c
> ===
> RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v
> retrieving revision 1.211
> diff -u -p -r1.211 malloc.c
> --- malloc.c  4 Nov 2016 09:11:20 -   1.211
> +++ malloc.c  9 Jan 2017 13:35:29 -
> @@ -73,6 +73,12 @@
>   * Set to zero to be the most strict.
>   */
>  #define MALLOC_LEEWAY0
> +#define MALLOC_MOVE_COND(sz) ((sz) - mopts.malloc_guard <\
> + MALLOC_PAGESIZE - MALLOC_LEEWAY)
> +#define MALLOC_MOVE(p, sz)   (((char *)(p)) +\
> + ((MALLOC_PAGESIZE - MALLOC_LEEWAY - \
> + ((sz) - mopts.malloc_guard)) &  \
> + ~(MALLOC_MINSIZE - 1)))
>  
>  #define PAGEROUND(x)  (((x) + (MALLOC_PAGEMASK)) & ~MALLOC_PAGEMASK)
>  
> @@ -199,6 +205,7 @@ char  *malloc_options;/* compile-time 
> o
>  static u_char getrbyte(struct dir_info *d);
>  static __dead void wrterror(struct dir_info *d, char *msg, ...)
>  __attribute__((__format__ (printf, 2, 3)));
> +static void fill_canary(char *ptr, size_t sz, size_t allocated);
>  
>  #ifdef MALLOC_STATS
>  void malloc_dump(int, int, struct dir_info *);
> @@ -209,8 +216,8 @@ static void malloc_exit(void);
>  #define CALLER   NULL
>  #endif
>  
> -/* low bits of r->p determine size: 0 means >= page size and p->size holding
> - *  real size, otherwise r->size is a shift count, or 1 for malloc(0)
> +/* low bits of r->p determine size: 0 means >= page size and r->size holding
> + * real size, otherwise low bits are a shift count, or 1 for malloc(0)
>   */
>  #define REALSIZE(sz, r)  \
>   (sz) = (uintptr_t)(r)->p & MALLOC_PAGEMASK, \
> @@ -905,23 +912,10 @@ omalloc_make_chunks(struct dir_info *d, 
>   return bp;
>  }
>  
> -
> -/*
> - * Allocate a chunk
> - */
> -static void *
> -malloc_bytes(struct dir_info *d, size_t argsize, void *f)
> +static int
> +find_chunksize(size_t size)
>  {
> - int i, j, listnum;
> - size_t  k, size;
> - u_short u, *lp;
> - struct chunk_info *bp;
> -
> - if (mopts.malloc_canary != (d->canary1 ^ (u_int32_t)(uintptr_t)d) ||
> - d->canary1 != ~d->canary2)
> - wrterror(d, "internal struct corrupt");
> -
> - size = argsize;
> + int i, j;
>  
>   /* Don't bother with anything less than this */
>   /* unless we have a malloc(0) requests */
> @@ -937,6 +931,25 @@ malloc_bytes(struct dir_info *d, size_t 
>   while (i >>= 1)
>   j++;
>   }
> + return j;
> +}
> +
> +/*
> + * Allocate a chunk
> + */
> +static void *
> +malloc_bytes(struct dir_info *d, size_t size, void *f)
> +{
> + int i, j, listnum;
> + size_t  k;
> + u_short u, *lp;
> + struct chunk_info *bp;
> +
> + if (mopts.malloc_canary != (d->canary1 ^ (u_int32_t)(uintptr_t)d) ||
> + d->canary1 != ~d->canary2)
> + wrterror(d, "internal struct corrupt");
> +
> + j = find_chunksize(size);
>  
>   listnum = getrbyte(d) % MALLOC_CHUNK_LISTS;
>   /* If it's empty, make a page more of that size chunks */
> @@ -990,25 +1003,30 @@ malloc_bytes(struct dir_info *d, size_t 
>   k += (lp - bp->bits) * MALLOC_BITS;
>   
>   if (mopts.chunk_canaries)
> - bp->bits[bp->offset + k] = argsize;
> + bp->bits[bp->offset + k] = size;
>  
>   k <<= bp->shift;
>  
>   if (bp->size > 0) {
>   if (mopts.malloc_junk == 2)
>   memset((char *)bp->page + k, SOME_JUNK, bp->size);
> - else if (mopts.chunk_canaries) {
> - size_t sz = bp->size - argsize;
> -
> - if (sz > CHUNK_CHECK_LENGTH)
> - sz = CHUNK_CHECK_LENGTH;
> - memset((char *)bp->page + k + argsize, SOME_JUNK, sz);
> - }
> +  

Re: pfkey vs splsoftnet()

2017-01-12 Thread Alexander Bluhm
On Tue, Jan 10, 2017 at 10:37:38AM +0100, Martin Pieuchot wrote:
> In pfkey_sendup() we call sorwakeup() which asserts for NET_LOCK(), so
> we are already at IPL_SOFTNET.
> 
> pfkeyv2_send() is called via pfkey_output() which is also called with
> the NET_LOCK() held.
> 
> Finally replace a comment above pfkeyv2_ipo_walk() by the corresponding
> assert.
> 
> ok?

OK bluhm@

> 
> Index: net/pfkey.c
> ===
> RCS file: /cvs/src/sys/net/pfkey.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 pfkey.c
> --- net/pfkey.c   29 Nov 2016 10:22:30 -  1.33
> +++ net/pfkey.c   10 Jan 2017 09:29:59 -
> @@ -136,7 +136,8 @@ int
>  pfkey_sendup(struct socket *socket, struct mbuf *packet, int more)
>  {
>   struct mbuf *packet2;
> - int s;
> +
> + splsoftassert(IPL_SOFTNET);
>  
>   if (more) {
>   if (!(packet2 = m_dup_pkt(packet, 0, M_DONTWAIT)))
> @@ -144,13 +145,10 @@ pfkey_sendup(struct socket *socket, stru
>   } else
>   packet2 = packet;
>  
> - s = splsoftnet();
>   if (!sbappendaddr(>so_rcv, _addr, packet2, NULL)) {
>   m_freem(packet2);
> - splx(s);
>   return (ENOBUFS);
>   }
> - splx(s);
>  
>   sorwakeup(socket);
>   return (0);
> Index: net/pfkeyv2.c
> ===
> RCS file: /cvs/src/sys/net/pfkeyv2.c,v
> retrieving revision 1.148
> diff -u -p -r1.148 pfkeyv2.c
> --- net/pfkeyv2.c 15 Sep 2016 02:00:18 -  1.148
> +++ net/pfkeyv2.c 10 Jan 2017 09:29:41 -
> @@ -783,7 +783,7 @@ int
>  pfkeyv2_send(struct socket *socket, void *message, int len)
>  {
>   int i, j, rval = 0, mode = PFKEYV2_SENDMESSAGE_BROADCAST;
> - int delflag = 0, s;
> + int delflag = 0;
>   struct sockaddr_encap encapdst, encapnetmask;
>   struct ipsec_policy *ipo, *tmpipo;
>   struct ipsec_acquire *ipa;
> @@ -807,6 +807,8 @@ pfkeyv2_send(struct socket *socket, void
>  
>   u_int rdomain;
>  
> + splsoftassert(IPL_SOFTNET);
> +
>   /* Verify that we received this over a legitimate pfkeyv2 socket */
>   bzero(headers, sizeof(headers));
>  
> @@ -940,8 +942,6 @@ pfkeyv2_send(struct socket *socket, void
>   }
>  #endif /* IPSEC */
>  
> - s = splsoftnet();
> -
>   /* Find TDB */
>   sa2 = gettdb(rdomain, ssa->sadb_sa_spi, sunionp,
>   SADB_X_GETSPROTO(smsg->sadb_msg_satype));
> @@ -949,7 +949,7 @@ pfkeyv2_send(struct socket *socket, void
>   /* If there's no such SA, we're done */
>   if (sa2 == NULL) {
>   rval = ESRCH;
> - goto splxret;
> + goto ret;
>   }
>  
>   /* If this is a reserved SA */
> @@ -969,7 +969,7 @@ pfkeyv2_send(struct socket *socket, void
>   >tdb_sproto, ))) {
>   tdb_free(freeme);
>   freeme = NULL;
> - goto splxret;
> + goto ret;
>   }
>  
>   /* Initialize SA */
> @@ -1020,7 +1020,7 @@ pfkeyv2_send(struct socket *socket, void
>   rval = EINVAL;
>   tdb_free(freeme);
>   freeme = NULL;
> - goto splxret;
> + goto ret;
>   }
>  
>   newsa->tdb_cur_allocations = sa2->tdb_cur_allocations;
> @@ -1041,7 +1041,7 @@ pfkeyv2_send(struct socket *socket, void
>   headers[SADB_EXT_IDENTITY_DST] ||
>   headers[SADB_EXT_SENSITIVITY]) {
>   rval = EINVAL;
> - goto splxret;
> + goto ret;
>   }
>  
>   import_sa(sa2, headers[SADB_EXT_SA], NULL);
> @@ -1059,7 +1059,6 @@ pfkeyv2_send(struct socket *socket, void
>  #endif
>   }
>  
> - splx(s);
>   break;
>   case SADB_ADD:
>   ssa = (struct sadb_sa *) headers[SADB_EXT_SA];
> @@ -1092,21 +1091,19 @@ pfkeyv2_send(struct socket *socket, void
>   }
>  #endif /* IPSEC */
>  
> - s = splsoftnet();
> -
>   sa2 = gettdb(rdomain, ssa->sadb_sa_spi, sunionp,
>   SADB_X_GETSPROTO(smsg->sadb_msg_satype));
>  
>   /* We can't add an existing SA! */
>   if (sa2 != NULL) {
>   rval = EEXIST;
> - goto splxret;
> + goto ret;
>   }
>  
>   /* We can only add "mature" SAs */
>   if (ssa->sadb_sa_state != SADB_SASTATE_MATURE) {
>   rval = EINVAL;
> - goto splxret;
> +  

Re: pfkey vs splsoftnet()

2017-01-12 Thread Hrvoje Popovski
On 12.1.2017. 16:20, Martin Pieuchot wrote:
> On 10/01/17(Tue) 10:37, Martin Pieuchot wrote:
>> In pfkey_sendup() we call sorwakeup() which asserts for NET_LOCK(), so
>> we are already at IPL_SOFTNET.
>>
>> pfkeyv2_send() is called via pfkey_output() which is also called with
>> the NET_LOCK() held.
>>
>> Finally replace a comment above pfkeyv2_ipo_walk() by the corresponding
>> assert.
> Anybody tested or reviewed this diff?
> 


I applied this diff in production box with

carp
pf
pfsync
isakmpd -K4
sasyncd
dhcpd
dhcpd sync
tcpdump -lnqttti pflog0

and everything seems fine ...



mount point FOREACH_SAFE is unsafe

2017-01-12 Thread Alexander Bluhm
Hi,

When traversing the mount list, the current mount point is locked
with vfs_busy().  When a FOREACH_SAFE macro is used, the next pointer
is not locked and could be freed by another process.

I remember that someone showed me a panic that ended in one of these
functions, but I have lost the bug report.

Anyway, the fix is easy in most places, do not use _SAFE as it is
unsafe.  In vfs_unmountall() the current pointer is actullay freed.
I have added a comment and will think about it again after my other
dounmount() fix has been commited.

The problem has been introduced in 2013 with this commit message.
> Change 'mountlist' from CIRCLEQ to TAILQ. Be paranoid and
> use TAILQ_*_SAFE more than might be needed.

ok?

bluhm

Index: kern/vfs_subr.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/kern/vfs_subr.c,v
retrieving revision 1.256
diff -u -p -r1.256 vfs_subr.c
--- kern/vfs_subr.c 10 Jan 2017 19:56:34 -  1.256
+++ kern/vfs_subr.c 12 Jan 2017 15:52:51 -
@@ -1251,12 +1251,12 @@ vprint(char *label, struct vnode *vp)
 void
 printlockedvnodes(void)
 {
-   struct mount *mp, *nmp;
+   struct mount *mp;
struct vnode *vp;
 
printf("Locked vnodes\n");
 
-   TAILQ_FOREACH_SAFE(mp, , mnt_list, nmp) {
+   TAILQ_FOREACH(mp, , mnt_list) {
if (vfs_busy(mp, VB_READ|VB_NOWAIT))
continue;
LIST_FOREACH(vp, >mnt_vnodelist, v_mntvnodes) {
@@ -1574,8 +1574,9 @@ vfs_unmountall(void)
  retry:
allerror = 0;
TAILQ_FOREACH_REVERSE_SAFE(mp, , mntlist, mnt_list, nmp) {
-   if ((vfs_busy(mp, VB_WRITE|VB_NOWAIT)) != 0)
+   if (vfs_busy(mp, VB_WRITE|VB_NOWAIT))
continue;
+   /* XXX Here is a race, the next pointer is not locked. */
if ((error = dounmount(mp, MNT_FORCE, curproc)) != 0) {
printf("unmount of %s failed with error %d\n",
mp->mnt_stat.f_mntonname, error);
Index: kern/vfs_syscalls.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/kern/vfs_syscalls.c,v
retrieving revision 1.267
diff -u -p -r1.267 vfs_syscalls.c
--- kern/vfs_syscalls.c 10 Jan 2017 20:13:17 -  1.267
+++ kern/vfs_syscalls.c 12 Jan 2017 15:44:37 -
@@ -425,10 +425,10 @@ struct ctldebug debug0 = { "syncprt", 
 int
 sys_sync(struct proc *p, void *v, register_t *retval)
 {
-   struct mount *mp, *nmp;
+   struct mount *mp;
int asyncflag;
 
-   TAILQ_FOREACH_REVERSE_SAFE(mp, , mntlist, mnt_list, nmp) {
+   TAILQ_FOREACH_REVERSE(mp, , mntlist, mnt_list) {
if (vfs_busy(mp, VB_READ|VB_NOWAIT))
continue;
if ((mp->mnt_flag & MNT_RDONLY) == 0) {
@@ -570,7 +570,7 @@ sys_getfsstat(struct proc *p, void *v, r
syscallarg(size_t) bufsize;
syscallarg(int) flags;
} */ *uap = v;
-   struct mount *mp, *nmp;
+   struct mount *mp;
struct statfs *sp;
struct statfs *sfsp;
size_t count, maxcount;
@@ -580,7 +580,7 @@ sys_getfsstat(struct proc *p, void *v, r
sfsp = SCARG(uap, buf);
count = 0;
 
-   TAILQ_FOREACH_SAFE(mp, , mnt_list, nmp) {
+   TAILQ_FOREACH(mp, , mnt_list) {
if (vfs_busy(mp, VB_READ|VB_NOWAIT))
continue;
if (sfsp && count < maxcount) {



Re: FreeType 2.7.1

2017-01-12 Thread Christian Weisgerber
Stuart Henderson:

> > And, if you can, put it in your next bulk build.
> 
> i386 bulk was clean.

amd64 also looks fine.
(iridium and chromium are still building on their n-th try...)

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



Re: 11n support for athn(4)

2017-01-12 Thread Stefan Sperling
On Tue, Jan 10, 2017 at 12:27:47AM +0100, Stefan Sperling wrote:
> On Mon, Jan 09, 2017 at 01:54:55PM +0100, Stefan Sperling wrote:
> > This diff adds 11n support to the athn(4) driver.
> > Requires -current net80211 code from today.
> 
> A better diff which fixes several bugs.

jmc@ found out I didn't enable 11n on 2GHz-only cards (such as AR9287).
This was a stupid logic error in the previous diff. This version is fixed.

Apart from that I have had no reports of problems. Can this go in?

Index: dev/cardbus/if_athn_cardbus.c
===
RCS file: /cvs/src/sys/dev/cardbus/if_athn_cardbus.c,v
retrieving revision 1.14
diff -u -p -r1.14 if_athn_cardbus.c
--- dev/cardbus/if_athn_cardbus.c   24 Nov 2015 17:11:39 -  1.14
+++ dev/cardbus/if_athn_cardbus.c   8 Jan 2017 09:31:28 -
@@ -43,6 +43,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
Index: dev/ic/ar5008.c
===
RCS file: /cvs/src/sys/dev/ic/ar5008.c,v
retrieving revision 1.37
diff -u -p -r1.37 ar5008.c
--- dev/ic/ar5008.c 29 Nov 2016 10:22:30 -  1.37
+++ dev/ic/ar5008.c 12 Jan 2017 06:10:49 -
@@ -51,6 +51,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -213,12 +214,24 @@ ar5008_attach(struct athn_softc *sc)
return (EINVAL);
}
 
-   if (base->opCapFlags & AR_OPFLAGS_11A)
+   if (base->opCapFlags & AR_OPFLAGS_11A) {
sc->flags |= ATHN_FLAG_11A;
-   if (base->opCapFlags & AR_OPFLAGS_11G)
+   if ((base->opCapFlags & AR_OPFLAGS_11N_5G20) == 0)
+   sc->flags |= ATHN_FLAG_11N;
+#ifdef notyet
+   if ((base->opCapFlags & AR_OPFLAGS_11N_5G40) == 0)
+   sc->flags |= ATHN_FLAG_11N;
+#endif
+   }
+   if (base->opCapFlags & AR_OPFLAGS_11G) {
sc->flags |= ATHN_FLAG_11G;
-   if (base->opCapFlags & AR_OPFLAGS_11N)
-   sc->flags |= ATHN_FLAG_11N;
+   if ((base->opCapFlags & AR_OPFLAGS_11N_2G20) == 0)
+   sc->flags |= ATHN_FLAG_11N;
+#ifdef notyet
+   if ((base->opCapFlags & AR_OPFLAGS_11N_2G40) == 0)
+   sc->flags |= ATHN_FLAG_11N;
+#endif
+   }
 
IEEE80211_ADDR_COPY(ic->ic_myaddr, base->macAddr);
 
@@ -952,9 +965,11 @@ ar5008_tx_process(struct athn_softc *sc,
struct ifnet *ifp = >ic_if;
struct athn_txq *txq = >txq[qid];
struct athn_node *an;
+   struct ieee80211_node *ni;
struct athn_tx_buf *bf;
struct ar_tx_desc *ds;
uint8_t failcnt;
+   int txfail;
 
bf = SIMPLEQ_FIRST(>head);
if (bf == NULL)
@@ -970,13 +985,16 @@ ar5008_tx_process(struct athn_softc *sc,
 
sc->sc_tx_timer = 0;
 
-   if (ds->ds_status1 & AR_TXS1_EXCESSIVE_RETRIES)
+   txfail = (ds->ds_status1 & AR_TXS1_EXCESSIVE_RETRIES);
+   if (txfail)
ifp->if_oerrors++;
 
if (ds->ds_status1 & AR_TXS1_UNDERRUN)
athn_inc_tx_trigger_level(sc);
 
an = (struct athn_node *)bf->bf_ni;
+   ni = (struct ieee80211_node *)bf->bf_ni;
+
/*
 * NB: the data fail count contains the number of un-acked tries
 * for the final series used.  We must add the number of tries for
@@ -987,10 +1005,26 @@ ar5008_tx_process(struct athn_softc *sc,
failcnt += MS(ds->ds_status9, AR_TXS9_FINAL_IDX) * 2;
 
/* Update rate control statistics. */
-   an->amn.amn_txcnt++;
-   if (failcnt > 0)
-   an->amn.amn_retrycnt++;
-
+   if (ni->ni_flags & IEEE80211_NODE_HT) {
+   an->mn.frames++;
+   an->mn.ampdu_size = bf->bf_m->m_pkthdr.len + IEEE80211_CRC_LEN;
+   an->mn.agglen = 1; /* XXX We do not yet support Tx agg. */
+   if (failcnt > 0)
+   an->mn.retries++;
+   if (txfail)
+   an->mn.txfail++;
+   if (ic->ic_state == IEEE80211_S_RUN) {
+#ifndef IEEE80211_STA_ONLY
+   if (ic->ic_opmode != IEEE80211_M_HOSTAP ||
+   ni->ni_state == IEEE80211_STA_ASSOC)
+#endif
+   ieee80211_mira_choose(>mn, ic, ni);
+   }
+   } else {
+   an->amn.amn_txcnt++;
+   if (failcnt > 0)
+   an->amn.amn_retrycnt++;
+   }
DPRINTFN(5, ("Tx done qid=%d status1=%d fail count=%d\n",
qid, ds->ds_status1, failcnt));
 
@@ -1110,7 +1144,7 @@ ar5008_swba_intr(struct athn_softc *sc)
ds->ds_ctl2 = SM(AR_TXC2_XMIT_DATA_TRIES0, 1);
 
/* Write Tx rate. */
-   ridx = (ic->ic_curmode == IEEE80211_MODE_11A) ?
+   ridx = IEEE80211_IS_CHAN_5GHZ(ni->ni_chan) ?
ATHN_RIDX_OFDM6 : ATHN_RIDX_CCK1;
hwrate = athn_rates[ridx].hwrate;
ds->ds_ctl3 = SM(AR_TXC3_XMIT_RATE0, 

Re: pfkey vs splsoftnet()

2017-01-12 Thread Martin Pieuchot
On 10/01/17(Tue) 10:37, Martin Pieuchot wrote:
> In pfkey_sendup() we call sorwakeup() which asserts for NET_LOCK(), so
> we are already at IPL_SOFTNET.
> 
> pfkeyv2_send() is called via pfkey_output() which is also called with
> the NET_LOCK() held.
> 
> Finally replace a comment above pfkeyv2_ipo_walk() by the corresponding
> assert.

Anybody tested or reviewed this diff?

> Index: net/pfkey.c
> ===
> RCS file: /cvs/src/sys/net/pfkey.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 pfkey.c
> --- net/pfkey.c   29 Nov 2016 10:22:30 -  1.33
> +++ net/pfkey.c   10 Jan 2017 09:29:59 -
> @@ -136,7 +136,8 @@ int
>  pfkey_sendup(struct socket *socket, struct mbuf *packet, int more)
>  {
>   struct mbuf *packet2;
> - int s;
> +
> + splsoftassert(IPL_SOFTNET);
>  
>   if (more) {
>   if (!(packet2 = m_dup_pkt(packet, 0, M_DONTWAIT)))
> @@ -144,13 +145,10 @@ pfkey_sendup(struct socket *socket, stru
>   } else
>   packet2 = packet;
>  
> - s = splsoftnet();
>   if (!sbappendaddr(>so_rcv, _addr, packet2, NULL)) {
>   m_freem(packet2);
> - splx(s);
>   return (ENOBUFS);
>   }
> - splx(s);
>  
>   sorwakeup(socket);
>   return (0);
> Index: net/pfkeyv2.c
> ===
> RCS file: /cvs/src/sys/net/pfkeyv2.c,v
> retrieving revision 1.148
> diff -u -p -r1.148 pfkeyv2.c
> --- net/pfkeyv2.c 15 Sep 2016 02:00:18 -  1.148
> +++ net/pfkeyv2.c 10 Jan 2017 09:29:41 -
> @@ -783,7 +783,7 @@ int
>  pfkeyv2_send(struct socket *socket, void *message, int len)
>  {
>   int i, j, rval = 0, mode = PFKEYV2_SENDMESSAGE_BROADCAST;
> - int delflag = 0, s;
> + int delflag = 0;
>   struct sockaddr_encap encapdst, encapnetmask;
>   struct ipsec_policy *ipo, *tmpipo;
>   struct ipsec_acquire *ipa;
> @@ -807,6 +807,8 @@ pfkeyv2_send(struct socket *socket, void
>  
>   u_int rdomain;
>  
> + splsoftassert(IPL_SOFTNET);
> +
>   /* Verify that we received this over a legitimate pfkeyv2 socket */
>   bzero(headers, sizeof(headers));
>  
> @@ -940,8 +942,6 @@ pfkeyv2_send(struct socket *socket, void
>   }
>  #endif /* IPSEC */
>  
> - s = splsoftnet();
> -
>   /* Find TDB */
>   sa2 = gettdb(rdomain, ssa->sadb_sa_spi, sunionp,
>   SADB_X_GETSPROTO(smsg->sadb_msg_satype));
> @@ -949,7 +949,7 @@ pfkeyv2_send(struct socket *socket, void
>   /* If there's no such SA, we're done */
>   if (sa2 == NULL) {
>   rval = ESRCH;
> - goto splxret;
> + goto ret;
>   }
>  
>   /* If this is a reserved SA */
> @@ -969,7 +969,7 @@ pfkeyv2_send(struct socket *socket, void
>   >tdb_sproto, ))) {
>   tdb_free(freeme);
>   freeme = NULL;
> - goto splxret;
> + goto ret;
>   }
>  
>   /* Initialize SA */
> @@ -1020,7 +1020,7 @@ pfkeyv2_send(struct socket *socket, void
>   rval = EINVAL;
>   tdb_free(freeme);
>   freeme = NULL;
> - goto splxret;
> + goto ret;
>   }
>  
>   newsa->tdb_cur_allocations = sa2->tdb_cur_allocations;
> @@ -1041,7 +1041,7 @@ pfkeyv2_send(struct socket *socket, void
>   headers[SADB_EXT_IDENTITY_DST] ||
>   headers[SADB_EXT_SENSITIVITY]) {
>   rval = EINVAL;
> - goto splxret;
> + goto ret;
>   }
>  
>   import_sa(sa2, headers[SADB_EXT_SA], NULL);
> @@ -1059,7 +1059,6 @@ pfkeyv2_send(struct socket *socket, void
>  #endif
>   }
>  
> - splx(s);
>   break;
>   case SADB_ADD:
>   ssa = (struct sadb_sa *) headers[SADB_EXT_SA];
> @@ -1092,21 +1091,19 @@ pfkeyv2_send(struct socket *socket, void
>   }
>  #endif /* IPSEC */
>  
> - s = splsoftnet();
> -
>   sa2 = gettdb(rdomain, ssa->sadb_sa_spi, sunionp,
>   SADB_X_GETSPROTO(smsg->sadb_msg_satype));
>  
>   /* We can't add an existing SA! */
>   if (sa2 != NULL) {
>   rval = EEXIST;
> - goto splxret;
> + goto ret;
>   }
>  
>   /* We can only add "mature" SAs */
>   if (ssa->sadb_sa_state != SADB_SASTATE_MATURE) {
>   rval = EINVAL;
> - goto splxret;
> +

Re: FreeType 2.7.1

2017-01-12 Thread David Coppa
On Thu, Jan 12, 2017 at 1:46 PM, Stuart Henderson  wrote:
> On 2017/01/09 15:29, David Coppa wrote:
>> Here's the update to freetype-2.7.1, both inline and as attachment.
>
>> As usual, please test it.
>>
>> And, if you can, put it in your next bulk build.
>
> i386 bulk was clean.

Thank you, Stuart.

So... Ok to commit?

Ciao!
David



Re: FreeType 2.7.1

2017-01-12 Thread Stuart Henderson
On 2017/01/09 15:29, David Coppa wrote:
> Here's the update to freetype-2.7.1, both inline and as attachment.

> As usual, please test it.
> 
> And, if you can, put it in your next bulk build.

i386 bulk was clean.



wsfont.c: remove sony8x16 and sony12x24?

2017-01-12 Thread Frederic Cambus
Hi tech@,

Most fonts in wsfont are not compiled in by default, and while some are
worth keeping and using, I would like to propose deleting some of them
in order to make space for larger sized fonts.

The Sony fonts are Serif, which doesn't work very well for monospaced
bitmap fonts intended for console use, are not very readable, and have
no slashed or dotted zeros. Delete them?

For obvious reasons, I didn't run cvs rm on sony8x16.h and sony12x24.h
before generating the diff.

Comments? OK?

Index: distrib/sets/lists/comp/mi
===
RCS file: /cvs/src/distrib/sets/lists/comp/mi,v
retrieving revision 1.1322
diff -u -p -r1.1322 mi
--- distrib/sets/lists/comp/mi  7 Jan 2017 16:04:13 -   1.1322
+++ distrib/sets/lists/comp/mi  11 Jan 2017 21:45:55 -
@@ -813,8 +813,6 @@
 ./usr/include/dev/wsfont/lucida16x29.h
 ./usr/include/dev/wsfont/omron12x20.h
 ./usr/include/dev/wsfont/qvss8x15.h
-./usr/include/dev/wsfont/sony12x24.h
-./usr/include/dev/wsfont/sony8x16.h
 ./usr/include/dev/wsfont/vt220l8x10.h
 ./usr/include/dev/wsfont/vt220l8x8.h
 ./usr/include/dev/wsfont/wsfont.h
Index: sys/dev/wsfont/wsfont.c
===
RCS file: /cvs/src/sys/dev/wsfont/wsfont.c,v
retrieving revision 1.45
diff -u -p -r1.45 wsfont.c
--- sys/dev/wsfont/wsfont.c 6 Oct 2016 07:30:19 -   1.45
+++ sys/dev/wsfont/wsfont.c 11 Jan 2017 21:45:55 -
@@ -64,16 +64,6 @@
 #include 
 #endif
 
-#ifdef FONT_SONY8x16
-#define HAVE_FONT 1
-#include 
-#endif
-
-#ifdef FONT_SONY12x24
-#define HAVE_FONT 1
-#include 
-#endif
-
 #ifdef FONT_OMRON12x20
 #define HAVE_FONT 1
 #include 
@@ -154,14 +144,8 @@ static struct font builtin_fonts[] = {
 #ifdef FONT_VT220L8x10
BUILTIN_FONT(vt220l8x10, 7),
 #endif
-#ifdef FONT_SONY8x16
-   BUILTIN_FONT(sony8x16, 8),
-#endif
-#ifdef FONT_SONY12x24
-   BUILTIN_FONT(sony12x24, 9),
-#endif
 #ifdef FONT_OMRON12x20
-   BUILTIN_FONT(omron12x20, 10),
+   BUILTIN_FONT(omron12x20, 8),
 #endif
 #undef BUILTIN_FONT
 };



Ansify cpu_sysctl() on alpha, arm, arm64, luna88k and sparc64

2017-01-12 Thread Frederic Cambus
Hi tech@,

Here is a diff to ansify cpu_sysctl() where not previously done.

Comments? OK?

Index: sys/arch/alpha/alpha/machdep.c
===
RCS file: /cvs/src/sys/arch/alpha/alpha/machdep.c,v
retrieving revision 1.176
diff -u -p -r1.176 machdep.c
--- sys/arch/alpha/alpha/machdep.c  9 Oct 2016 11:25:39 -   1.176
+++ sys/arch/alpha/alpha/machdep.c  12 Jan 2017 10:48:51 -
@@ -1553,14 +1553,8 @@ sys_sigreturn(struct proc *p, void *v, r
  * machine dependent system variables.
  */
 int
-cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
-   int *name;
-   u_int namelen;
-   void *oldp;
-   size_t *oldlenp;
-   void *newp;
-   size_t newlen;
-   struct proc *p;
+cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
+size_t newlen, struct proc *p)
 {
dev_t consdev;
 #if NIOASIC > 0
Index: sys/arch/arm/arm/arm32_machdep.c
===
RCS file: /cvs/src/sys/arch/arm/arm/arm32_machdep.c,v
retrieving revision 1.52
diff -u -p -r1.52 arm32_machdep.c
--- sys/arch/arm/arm/arm32_machdep.c23 Sep 2016 11:38:21 -  1.52
+++ sys/arch/arm/arm/arm32_machdep.c12 Jan 2017 10:48:51 -
@@ -300,14 +300,8 @@ cpu_startup()
  */
 
 int
-cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
-   int *name;
-   u_int namelen;
-   void *oldp;
-   size_t *oldlenp;
-   void *newp;
-   size_t newlen;
-   struct proc *p;
+cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
+size_t newlen, struct proc *p)
 {
 #if NAPM > 0
extern int cpu_apmwarn;
Index: sys/arch/arm64/arm64/machdep.c
===
RCS file: /cvs/src/sys/arch/arm64/arm64/machdep.c,v
retrieving revision 1.2
diff -u -p -r1.2 machdep.c
--- sys/arch/arm64/arm64/machdep.c  19 Dec 2016 07:44:54 -  1.2
+++ sys/arch/arm64/arm64/machdep.c  12 Jan 2017 10:48:51 -
@@ -293,14 +293,8 @@ cpu_startup()
  */
 
 int
-cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
-   int *name;
-   u_int namelen;
-   void *oldp;
-   size_t *oldlenp;
-   void *newp;
-   size_t newlen;
-   struct proc *p;
+cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
+size_t newlen, struct proc *p)
 {
/* all sysctl names at this level are terminal */
if (namelen != 1)
Index: sys/arch/luna88k/luna88k/machdep.c
===
RCS file: /cvs/src/sys/arch/luna88k/luna88k/machdep.c,v
retrieving revision 1.121
diff -u -p -r1.121 machdep.c
--- sys/arch/luna88k/luna88k/machdep.c  9 Oct 2016 11:25:40 -   1.121
+++ sys/arch/luna88k/luna88k/machdep.c  12 Jan 2017 10:48:51 -
@@ -916,14 +916,8 @@ sys_sysarch(p, v, retval)
  */
 
 int
-cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
-   int *name;
-   u_int namelen;
-   void *oldp;
-   size_t *oldlenp;
-   void *newp;
-   size_t newlen;
-   struct proc *p;
+cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
+size_t newlen, struct proc *p)
 {
dev_t consdev;
 
Index: sys/arch/sparc64/sparc64/machdep.c
===
RCS file: /cvs/src/sys/arch/sparc64/sparc64/machdep.c,v
retrieving revision 1.181
diff -u -p -r1.181 machdep.c
--- sys/arch/sparc64/sparc64/machdep.c  9 Oct 2016 11:25:40 -   1.181
+++ sys/arch/sparc64/sparc64/machdep.c  12 Jan 2017 10:48:52 -
@@ -367,14 +367,8 @@ struct sigframe {
  * machine dependent system variables.
  */
 int
-cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
-   int *name;
-   u_int namelen;
-   void *oldp;
-   size_t *oldlenp;
-   void *newp;
-   size_t newlen;
-   struct proc *p;
+cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
+size_t newlen, struct proc *p)
 {
int oldval, ret;
 



Re: BFD: route get and route monitor

2017-01-12 Thread Hrvoje Popovski
On 23.12.2016. 16:57, Hrvoje Popovski wrote:
> On 21.12.2016. 23:15, Sebastian Benoit wrote:
>>> Hi,
>>>
>>> it seems that bfd is working with Force10 S4810 and Extreme Networks
>>> x460 switches. I can test it with cisco c6k5 if you want?
>>
>> Hei,
>>
>> i'm sure phessler (who might not read this for a couple of days) is happy
>> about any test you can do.
>>
>> And thanks for doing these tests!
>>
>> /Benno
> 
> Hi,
> 
> no bfd for me on Cisco c6k5. Will upgrade and report back.
> 
> Tnx for bfd, really great feature ...
> 
> 

Hi all,

at last i upgrade c6k5 and bfd is working

openbsd - 192.168.112.1

# route -n get 192.168.112.2 -bfd
   route to: 192.168.112.2
destination: 192.168.112.2
   mask: 255.255.255.255
  interface: ix1
 if address: 192.168.112.1
   priority: 3 ()
  flags: 
BFD: async state up remote up laststate down error 0
 diag none remote none
 discr 2428102669 remote 1
 uptime 34s last state time 26m30s
 mintx 75 minrx 75 minecho 0 multiplier 3
 use   mtuexpire
  55 0   626
sockaddrs: 



c6k5 - 192.168.112.2

c6k5#sh bfd neighbors details

IPv4 Sessions
NeighAddr  LD/RD RH/RS State Int
192.168.112.1   1/2428102669 UpUp
Gi6/1
Session state is UP and not using echo function.
Session Host: Software
OurAddr: 192.168.112.2
Handle: 1
Local Diag: 0, Demand mode: 0, Poll bit: 1
MinTxInt: 75, MinRxInt: 75, Multiplier: 3
Received MinRxInt: 75, Received Multiplier: 3
Holddown (hits): 2436(0), Hello (hits): 750(185)
Rx Count: 205, Rx Interval (ms) min/max/avg: 520/840/595 last: 564 ms ago
Tx Count: 186, Tx Interval (ms) min/max/avg: 568/752/661 last: 388 ms ago
Elapsed time watermarks: 0 0 (last: 0)
Registered protocols: IPv4 Static CEF
Uptime: 00:02:02
Last packet: Version: 1  - Diagnostic: 0
 State bit: Up   - Demand bit: 0
 Poll bit: 0 - Final bit: 0
 C bit: 0
 Multiplier: 3   - Length: 24
 My Discr.: 2428102669   - Your Discr.: 1
 Min tx interval: 75 - Min rx interval: 75
 Min Echo interval: 0