From bf30351bdc06ccc70d66fe501faf31795c673bac Mon Sep 17 00:00:00 2001 From: Hartmut Brandt Date: Sat, 21 Feb 2004 13:01:54 +0000 Subject: [PATCH] Make sure that the first mbuf in the chain passed to atm_intr always contains a packet header. --- sys/dev/harp/if_harp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/dev/harp/if_harp.c b/sys/dev/harp/if_harp.c index ac38b02aec2d..87711b9adc4f 100644 --- a/sys/dev/harp/if_harp.c +++ b/sys/dev/harp/if_harp.c @@ -560,23 +560,27 @@ harp_input(struct ifnet *ifp, struct mbuf **mp, struct atm_pseudohdr *ah, /* fit two pointers into the mbuf - assume, that the the data is * pointer aligned. If it doesn't fit into the first mbuf, prepend - * another one, but leave the packet header where it is. atm_intr - * relies on this. */ + * another one. + * Don't count the new fields in the packet length (XXX) + */ mlen = m->m_pkthdr.len; pfxlen = sizeof(atm_intr_func_t) + sizeof(void *); if (M_LEADINGSPACE(m) < pfxlen) { - MGET(m0, 0, MT_DATA); + MGETHDR(m0, 0, MT_DATA); if (m0 == NULL) { printf("%s: no leading space in buffer\n", __func__); goto drop; } m0->m_len = 0; m0->m_next = m; + + M_MOVE_PKTHDR(m0, m); + m = m0; } m->m_len += pfxlen; m->m_data -= pfxlen; - KB_DATASTART(m, cp, char *); + cp = mtod(m, char *); *((atm_intr_func_t *)cp) = harp_recv_stack; cp += sizeof(atm_intr_func_t); *((void **)cp) = (void *)vcc;