mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-12 09:58:36 +00:00
Make recursion prevention variable per-instance and remove XXX comment
about thread-unsafety. MFC after: 2 weeks
This commit is contained in:
parent
c74af4fac1
commit
070dba1cfe
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=102968
@ -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;
|
||||
|
@ -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 */
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user