summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2004-08-27 18:33:08 +0000
committerandre <andre@FreeBSD.org>2004-08-27 18:33:08 +0000
commit21264022388cc795478511d03b72ddc0ce213c5b (patch)
tree5e40bb2ff1fccfd1425f4b8ada947f22f8df6605 /sys/net
parent4e16b35c5bbfa63f8794131592ae3b1ac4d05cfd (diff)
downloadFreeBSD-src-21264022388cc795478511d03b72ddc0ce213c5b.zip
FreeBSD-src-21264022388cc795478511d03b72ddc0ce213c5b.tar.gz
Apply error and success logic consistently to the function netisr_queue() and
its users. netisr_queue() now returns (0) on success and ERRNO on failure. At the moment ENXIO (netisr queue not functional) and ENOBUFS (netisr queue full) are supported. Previously it would return (1) on success but the return value of IF_HANDOFF() was interpreted wrongly and (0) was actually returned on success. Due to this schednetisr() was never called to kick the scheduling of the isr. However this was masked by other normal packets coming through netisr_dispatch() causing the dequeueing of waiting packets. PR: kern/70988 Found by: MOROHOSHI Akihiko <moro@remus.dti.ne.jp> MFC after: 3 days
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_loop.c2
-rw-r--r--sys/net/if_ppp.c4
-rw-r--r--sys/net/if_sl.c2
-rw-r--r--sys/net/if_spppsubr.c2
-rw-r--r--sys/net/netisr.c8
-rw-r--r--sys/net/rtsock.c2
6 files changed, 11 insertions, 9 deletions
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index 21f8026..1ddf74f 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -311,7 +311,7 @@ if_simloop(ifp, m, af, hlen)
}
ifp->if_ipackets++;
ifp->if_ibytes += m->m_pkthdr.len;
- netisr_queue(isr, m);
+ netisr_queue(isr, m); /* mbuf is free'd on failure. */
return (0);
}
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c
index 8f06594..eaab431 100644
--- a/sys/net/if_ppp.c
+++ b/sys/net/if_ppp.c
@@ -1611,8 +1611,8 @@ ppp_inproc(sc, m)
if (isr == -1)
rv = IF_HANDOFF(&sc->sc_inq, m, NULL);
else
- rv = netisr_queue(isr, m);
- if (!rv) {
+ rv = netisr_queue(isr, m); /* (0) on success. */
+ if ((isr == -1 && !rv) || (isr != -1 && rv)) {
if (sc->sc_flags & SC_DEBUG)
if_printf(ifp, "input queue full\n");
ifp->if_iqdrops++;
diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c
index 2a23b16..37db1c0 100644
--- a/sys/net/if_sl.c
+++ b/sys/net/if_sl.c
@@ -960,7 +960,7 @@ slinput(int c, struct tty *tp)
m_freem(m);
goto newpack;
}
- if (! netisr_queue(NETISR_IP, m)) {
+ if (netisr_queue(NETISR_IP, m)) { /* (0) on success. */
sc->sc_if.if_ierrors++;
sc->sc_if.if_iqdrops++;
}
diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c
index 4c9f304..7101975 100644
--- a/sys/net/if_spppsubr.c
+++ b/sys/net/if_spppsubr.c
@@ -715,7 +715,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m)
goto drop;
/* Check queue. */
- if (! netisr_queue(isr, m)) {
+ if (netisr_queue(isr, m)) { /* (0) on success. */
if (debug)
log(LOG_DEBUG, SPP_FMT "protocol queue overflow\n",
SPP_ARGS(ifp));
diff --git a/sys/net/netisr.c b/sys/net/netisr.c
index ca2a6cb..8f573d9 100644
--- a/sys/net/netisr.c
+++ b/sys/net/netisr.c
@@ -204,6 +204,8 @@ netisr_dispatch(int num, struct mbuf *m)
* Same as above, but always queue.
* This is either used in places where we are not confident that
* direct dispatch is possible, or where queueing is required.
+ * It returns (0) on success and ERRNO on failure. On failure the
+ * mbuf has been free'd.
*/
int
netisr_queue(int num, struct mbuf *m)
@@ -216,13 +218,13 @@ netisr_queue(int num, struct mbuf *m)
if (ni->ni_queue == NULL) {
isrstat.isrs_drop++;
m_freem(m);
- return (1);
+ return (ENXIO);
}
isrstat.isrs_queued++;
if (!IF_HANDOFF(ni->ni_queue, m, NULL))
- return (0);
+ return (ENOBUFS); /* IF_HANDOFF has free'd the mbuf */
schednetisr(num);
- return (1);
+ return (0);
}
static void
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 0108f5e..8616e23 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -978,7 +978,7 @@ rt_dispatch(struct mbuf *m, const struct sockaddr *sa)
*family = sa ? sa->sa_family : 0;
m_tag_prepend(m, tag);
}
- netisr_queue(NETISR_ROUTE, m);
+ netisr_queue(NETISR_ROUTE, m); /* mbuf is free'd on failure. */
}
/*
OpenPOWER on IntegriCloud