summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2001-08-15 23:59:00 +0000
committerjulian <julian@FreeBSD.org>2001-08-15 23:59:00 +0000
commit35478e0db2b6c2bf559b202fa009a2dd0ce06fb8 (patch)
tree763b7b02cb58616cc1382ede743253ab12337aae /sys
parent3682fdb5a95737599e5991370e298b67840538d4 (diff)
downloadFreeBSD-src-35478e0db2b6c2bf559b202fa009a2dd0ce06fb8.zip
FreeBSD-src-35478e0db2b6c2bf559b202fa009a2dd0ce06fb8.tar.gz
Don't allocate an entire 1500 byte buffer on the stack.
May need more review in light of SMP. MFC after: 2 weeks
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if_sl.c18
-rw-r--r--sys/net/if_slvar.h1
2 files changed, 14 insertions, 5 deletions
diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c
index 8871bfd..8621880 100644
--- a/sys/net/if_sl.c
+++ b/sys/net/if_sl.c
@@ -264,6 +264,13 @@ slcreate()
struct mbuf *m;
MALLOC(sc, struct sl_softc *, sizeof(*sc), M_SL, M_WAITOK | M_ZERO);
+ if (!sc)
+ return (NULL);
+ MALLOC(sc->bpfbuf, u_char *, SLTMAX + SLIP_HDRLEN, M_SL, M_NOWAIT);
+ if (!sc->bpfbuf) {
+ FREE(sc, M_SL);
+ return (NULL);
+ }
m = m_gethdr(M_TRYWAIT, MT_DATA);
if (m != NULL) {
@@ -276,6 +283,7 @@ slcreate()
if (m == NULL) {
printf("sl: can't allocate buffer\n");
+ FREE(sc->bpfbuf, M_SL);
FREE(sc, M_SL);
return (NULL);
}
@@ -386,6 +394,7 @@ sldestroy(struct sl_softc *sc)
LIST_REMOVE(sc, sl_next);
m_free(sc->sc_mbuf);
mtx_destroy(&sc->sc_fastq.ifq_mtx);
+ FREE(sc->bpfbuf, M_SL);
FREE(sc, M_SL);
}
@@ -600,7 +609,6 @@ slstart(tp)
register struct ip *ip;
int s;
struct mbuf *m2;
- u_char bpfbuf[SLTMAX + SLIP_HDRLEN];
register int len = 0;
for (;;) {
@@ -653,7 +661,7 @@ slstart(tp)
* to the packet transmission time).
*/
register struct mbuf *m1 = m;
- register u_char *cp = bpfbuf + SLIP_HDRLEN;
+ register u_char *cp = sc->bpfbuf + SLIP_HDRLEN;
len = 0;
do {
@@ -676,9 +684,9 @@ slstart(tp)
* compressed header is now at the beginning of the
* mbuf.
*/
- bpfbuf[SLX_DIR] = SLIPDIR_OUT;
- bcopy(mtod(m, caddr_t), &bpfbuf[SLX_CHDR], CHDR_LEN);
- bpf_tap(&sc->sc_if, bpfbuf, len + SLIP_HDRLEN);
+ sc->bpfbuf[SLX_DIR] = SLIPDIR_OUT;
+ bcopy(mtod(m, caddr_t), &sc->bpfbuf[SLX_CHDR], CHDR_LEN);
+ bpf_tap(&sc->sc_if, sc->bpfbuf, len + SLIP_HDRLEN);
}
/*
diff --git a/sys/net/if_slvar.h b/sys/net/if_slvar.h
index 9529c81..0abb285 100644
--- a/sys/net/if_slvar.h
+++ b/sys/net/if_slvar.h
@@ -69,6 +69,7 @@ struct sl_softc {
struct callout_handle sc_kahandle;
struct slcompress sc_comp; /* tcp compression data */
LIST_ENTRY(sl_softc) sl_next;
+ u_char *bpfbuf; /* hing buffer for bpf here */
};
/* internal flags */
OpenPOWER on IntegriCloud