From dd3d14b6c50bd86815f0e69d0e471c7b9c994d78 Mon Sep 17 00:00:00 2001 From: sobomax Date: Fri, 13 Sep 2002 06:24:27 +0000 Subject: [PATCH] Restore original behaviour of recursion preventer. Submitted by: sumikawa --- sys/net/if_gif.c | 11 +++++++---- sys/net/if_gif.h | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index c5da47c9c523..784c68789015 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -201,7 +201,6 @@ 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) @@ -341,6 +340,7 @@ 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,11 +353,14 @@ 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 (++(sc->called) > max_gif_nesting) { + if (++called > max_gif_nesting) { log(LOG_NOTICE, "gif_output: recursively called too many times(%d)\n", - sc->called); + called); m_freem(m); error = EIO; /* is there better errno? */ goto end; @@ -414,7 +417,7 @@ gif_output(ifp, m, dst, rt) } end: - sc->called = 0; /* reset recursion counter */ + 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 51e28db08d5a..1d02348e0bf0 100644 --- a/sys/net/if_gif.h +++ b/sys/net/if_gif.h @@ -69,7 +69,6 @@ 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 */ };