Revert r220768 for ng_ksocket. This node is special and

when it is cloning, its constructor method may be called
in a context that isn't allowed to sleep.

Noticed by:	Vadim Goncharov
This commit is contained in:
glebius 2012-05-24 18:22:57 +00:00
parent 08333340b6
commit 9b587cf418
2 changed files with 18 additions and 23 deletions

View File

@ -524,7 +524,9 @@ ng_ksocket_constructor(node_p node)
priv_p priv; priv_p priv;
/* Allocate private structure */ /* Allocate private structure */
priv = malloc(sizeof(*priv), M_NETGRAPH_KSOCKET, M_WAITOK | M_ZERO); priv = malloc(sizeof(*priv), M_NETGRAPH_KSOCKET, M_NOWAIT | M_ZERO);
if (priv == NULL)
return (ENOMEM);
LIST_INIT(&priv->embryos); LIST_INIT(&priv->embryos);
/* cross link them */ /* cross link them */

View File

@ -98,15 +98,6 @@ static MALLOC_DEFINE(M_NETGRAPH_MPPC, "netgraph_mppc", "netgraph mppc node");
/* Key length */ /* Key length */
#define KEYLEN(b) (((b) & MPPE_128) ? 16 : 8) #define KEYLEN(b) (((b) & MPPE_128) ? 16 : 8)
/*
* When packets are lost with MPPE, we may have to re-key arbitrarily
* many times to 'catch up' to the new jumped-ahead sequence number.
* Since this can be expensive, we pose a limit on how many re-keyings
* we will do at one time to avoid a possible D.O.S. vulnerability.
* This should instead be a configurable parameter.
*/
#define MPPE_MAX_REKEY 1000
/* MPPC packet header bits */ /* MPPC packet header bits */
#define MPPC_FLAG_FLUSHED 0x8000 /* xmitter reset state */ #define MPPC_FLAG_FLUSHED 0x8000 /* xmitter reset state */
#define MPPC_FLAG_RESTART 0x4000 /* compress history restart */ #define MPPC_FLAG_RESTART 0x4000 /* compress history restart */
@ -641,20 +632,22 @@ ng_mppc_decompress(node_p node, struct mbuf **datap)
#endif #endif
#ifdef NETGRAPH_MPPC_ENCRYPTION #ifdef NETGRAPH_MPPC_ENCRYPTION
if ((d->cfg.bits & MPPE_BITS) != 0) { if ((d->cfg.bits & MPPE_BITS) != 0) {
u_int rekey; u_int rekey;
/* How many times are we going to have to re-key? */
rekey = ((d->cfg.bits & MPPE_STATELESS) != 0) ?
numLost : (numLost / (MPPE_UPDATE_MASK + 1));
if (rekey > 1000)
log(LOG_ERR, "%s: %d packets dropped, "
"node [%x]\n", __func__, numLost,
node->nd_ID);
/* How many times are we going to have to re-key? */ /*
rekey = ((d->cfg.bits & MPPE_STATELESS) != 0) ? * When packets are lost or re-ordered with MPPE,
numLost : (numLost / (MPPE_UPDATE_MASK + 1)); * we may have to re-key up to 0xfff times to 'catch
if (rekey > MPPE_MAX_REKEY) { * up' to the new jumped-ahead sequence number. Yep,
log(LOG_ERR, "%s: too many (%d) packets" * this is heavy, but what else can we do?
" dropped, disabling node %p!", */
__func__, numLost, node);
priv->recv.cfg.enable = 0;
goto failed;
}
/* Re-key as necessary to catch up to peer */
while (d->cc != cc) { while (d->cc != cc) {
if ((d->cfg.bits & MPPE_STATELESS) != 0 if ((d->cfg.bits & MPPE_STATELESS) != 0
|| (d->cc & MPPE_UPDATE_MASK) || (d->cc & MPPE_UPDATE_MASK)