summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorsobomax <sobomax@FreeBSD.org>2002-09-05 15:35:38 +0000
committersobomax <sobomax@FreeBSD.org>2002-09-05 15:35:38 +0000
commit9265bc02ccce5a3d198501e7cdebc78b9f66469e (patch)
tree54d7237dc37f592b6b67cbd34557ce00dcb247d6 /sys/net
parent3ce35c4922859b56a2188d30eb66a64abed37523 (diff)
downloadFreeBSD-src-9265bc02ccce5a3d198501e7cdebc78b9f66469e.zip
FreeBSD-src-9265bc02ccce5a3d198501e7cdebc78b9f66469e.tar.gz
Make recursion prevention variable per-instance and remove XXX comment
about thread-unsafety. MFC after: 2 weeks
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_gif.c11
-rw-r--r--sys/net/if_gif.h1
2 files changed, 5 insertions, 7 deletions
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index dc3ad0e..fb81960 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -201,6 +201,7 @@ gif_clone_create(ifc, unit)
sc->gif_if.if_output = gif_output;
sc->gif_if.if_type = IFT_GIF;
sc->gif_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
+ sc->called = 0;
if_attach(&sc->gif_if);
bpfattach(&sc->gif_if, DLT_NULL, sizeof(u_int));
if (ng_gif_attach_p != NULL)
@@ -340,7 +341,6 @@ gif_output(ifp, m, dst, rt)
{
struct gif_softc *sc = (struct gif_softc*)ifp;
int error = 0;
- static int called = 0; /* XXX: MUTEX */
#ifdef MAC
error = mac_check_ifnet_transmit(ifp, m);
@@ -353,14 +353,11 @@ gif_output(ifp, m, dst, rt)
/*
* gif may cause infinite recursion calls when misconfigured.
* We'll prevent this by introducing upper limit.
- * XXX: this mechanism may introduce another problem about
- * mutual exclusion of the variable CALLED, especially if we
- * use kernel thread.
*/
- if (++called > max_gif_nesting) {
+ if (++(sc->called) > max_gif_nesting) {
log(LOG_NOTICE,
"gif_output: recursively called too many times(%d)\n",
- called);
+ sc->called);
m_freem(m);
error = EIO; /* is there better errno? */
goto end;
@@ -417,7 +414,7 @@ gif_output(ifp, m, dst, rt)
}
end:
- called = 0; /* reset recursion counter */
+ sc->called = 0; /* reset recursion counter */
if (error)
ifp->if_oerrors++;
return error;
diff --git a/sys/net/if_gif.h b/sys/net/if_gif.h
index 1d02348..51e28db 100644
--- a/sys/net/if_gif.h
+++ b/sys/net/if_gif.h
@@ -69,6 +69,7 @@ struct gif_softc {
const struct encaptab *encap_cookie4;
const struct encaptab *encap_cookie6;
void *gif_netgraph; /* ng_gif(4) netgraph node info */
+ int called; /* anti foot-shooter */
LIST_ENTRY(gif_softc) gif_link; /* all gif's are linked */
};
OpenPOWER on IntegriCloud