summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_ppp.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2004-12-06 19:49:55 +0000
committerglebius <glebius@FreeBSD.org>2004-12-06 19:49:55 +0000
commit535ed5b0e2c263dbbaa5d51fa02837565a5d6023 (patch)
treea1e6321aad60903e9ea3fe70cbf90649d861e967 /sys/netgraph/ng_ppp.c
parent39311fe2e6ef7decd73eaab4cdd8822310a0d27d (diff)
downloadFreeBSD-src-535ed5b0e2c263dbbaa5d51fa02837565a5d6023.zip
FreeBSD-src-535ed5b0e2c263dbbaa5d51fa02837565a5d6023.tar.gz
- Use ng_callout() instead of timeout(9).
- Do not put/remove node references, since this no longer needed. - Remove timerActive flag, use callout flags. - Schedule next callout after doing current one. Reviewed by: archie Approved by: julian (mentor)
Diffstat (limited to 'sys/netgraph/ng_ppp.c')
-rw-r--r--sys/netgraph/ng_ppp.c51
1 files changed, 14 insertions, 37 deletions
diff --git a/sys/netgraph/ng_ppp.c b/sys/netgraph/ng_ppp.c
index 94930f7..6811443 100644
--- a/sys/netgraph/ng_ppp.c
+++ b/sys/netgraph/ng_ppp.c
@@ -200,7 +200,6 @@ struct ng_ppp_private {
int32_t mseq; /* min links[i].seq */
u_char vjCompHooked; /* VJ comp hooked up? */
u_char allLinksEqual; /* all xmit the same? */
- u_char timerActive; /* frag timer active? */
u_int numActiveLinks; /* how many links up */
int activeLinks[NG_PPP_MAX_LINKS]; /* indicies */
u_int lastLink; /* for round robin */
@@ -208,7 +207,7 @@ struct ng_ppp_private {
TAILQ_HEAD(ng_ppp_fraglist, ng_ppp_frag) /* fragment queue */
frags;
int qlen; /* fraq queue length */
- struct callout_handle fragTimer; /* fraq queue check */
+ struct callout fragTimer; /* fraq queue check */
};
typedef struct ng_ppp_private *priv_p;
@@ -230,7 +229,8 @@ static int ng_ppp_check_packet(node_p node);
static void ng_ppp_get_packet(node_p node, struct mbuf **mp);
static int ng_ppp_frag_process(node_p node);
static int ng_ppp_frag_trim(node_p node);
-static void ng_ppp_frag_timeout(void *arg);
+static void ng_ppp_frag_timeout(node_p node, hook_p hook, void *arg1,
+ int arg2);
static void ng_ppp_frag_checkstale(node_p node);
static void ng_ppp_frag_reset(node_p node);
static int ng_ppp_mp_output(node_p node, struct mbuf *m);
@@ -393,7 +393,7 @@ ng_ppp_constructor(node_p node)
TAILQ_INIT(&priv->frags);
for (i = 0; i < NG_PPP_MAX_LINKS; i++)
priv->links[i].seq = MP_NOSEQ;
- callout_handle_init(&priv->fragTimer);
+ ng_callout_init(&priv->fragTimer);
/* Done */
return (0);
@@ -1469,31 +1469,17 @@ ng_ppp_frag_checkstale(node_p node)
* Periodically call ng_ppp_frag_checkstale()
*/
static void
-ng_ppp_frag_timeout(void *arg)
+ng_ppp_frag_timeout(node_p node, hook_p hook, void *arg1, int arg2)
{
- const node_p node = arg;
- const priv_p priv = NG_NODE_PRIVATE(node);
- int s = splnet();
-
- /* Handle the race where shutdown happens just before splnet() above */
- if (NG_NODE_NOT_VALID(node)) {
- NG_NODE_UNREF(node);
- splx(s);
+ /* XXX: is this needed? */
+ if (NG_NODE_NOT_VALID(node))
return;
- }
- /* Reset timer state after timeout */
- KASSERT(priv->timerActive, ("%s: !timerActive", __func__));
- priv->timerActive = 0;
- KASSERT(node->nd_refs > 1, ("%s: nd_refs=%d", __func__, node->nd_refs));
- NG_NODE_UNREF(node);
+ /* Scan the fragment queue */
+ ng_ppp_frag_checkstale(node);
/* Start timer again */
ng_ppp_start_frag_timer(node);
-
- /* Scan the fragment queue */
- ng_ppp_frag_checkstale(node);
- splx(s);
}
/*
@@ -2038,12 +2024,9 @@ ng_ppp_start_frag_timer(node_p node)
{
const priv_p priv = NG_NODE_PRIVATE(node);
- if (!priv->timerActive) {
- priv->fragTimer = timeout(ng_ppp_frag_timeout,
- node, MP_FRAGTIMER_INTERVAL);
- priv->timerActive = 1;
- NG_NODE_REF(node);
- }
+ if (!(priv->fragTimer.c_flags & CALLOUT_PENDING))
+ ng_callout(&priv->fragTimer, node, NULL, MP_FRAGTIMER_INTERVAL,
+ ng_ppp_frag_timeout, NULL, 0);
}
/*
@@ -2054,12 +2037,6 @@ ng_ppp_stop_frag_timer(node_p node)
{
const priv_p priv = NG_NODE_PRIVATE(node);
- if (priv->timerActive) {
- untimeout(ng_ppp_frag_timeout, node, priv->fragTimer);
- priv->timerActive = 0;
- KASSERT(node->nd_refs > 1,
- ("%s: nd_refs=%d", __func__, node->nd_refs));
- NG_NODE_UNREF(node);
- }
+ if (priv->fragTimer.c_flags & CALLOUT_PENDING)
+ ng_uncallout(&priv->fragTimer, node);
}
-
OpenPOWER on IntegriCloud