diff options
31 files changed, 52 insertions, 66 deletions
diff --git a/sys/alpha/alpha/busdma_machdep.c b/sys/alpha/alpha/busdma_machdep.c index 0b9ed6d..e2000cb 100644 --- a/sys/alpha/alpha/busdma_machdep.c +++ b/sys/alpha/alpha/busdma_machdep.c @@ -667,8 +667,7 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, KASSERT(dmat->lowaddr >= ptoa(Maxmem) || map != NULL, ("bus_dmamap_load_mbuf: No support for bounce pages!")); - KASSERT(m0->m_flags & M_PKTHDR, - ("bus_dmamap_load_mbuf: no packet header")); + M_ASSERTPKTHDR(m0); nsegs = 0; error = 0; diff --git a/sys/dev/snc/dp83932.c b/sys/dev/snc/dp83932.c index f0ebae1..58966ea 100644 --- a/sys/dev/snc/dp83932.c +++ b/sys/dev/snc/dp83932.c @@ -345,9 +345,7 @@ outloop: return; /* We need the header for m_pkthdr.len. */ - if ((m->m_flags & M_PKTHDR) == 0) - panic("%s: sncstart: no header mbuf", - device_get_nameunit(sc->sc_dev)); + M_ASSERTPKTHDR(m); /* * If bpf is listening on this interface, let it diff --git a/sys/dev/vx/if_vx.c b/sys/dev/vx/if_vx.c index 143a821..3106de0 100644 --- a/sys/dev/vx/if_vx.c +++ b/sys/dev/vx/if_vx.c @@ -400,12 +400,9 @@ vxstart(ifp) startagain: /* Sneak a peek at the next packet */ m = ifp->if_snd.ifq_head; - if (m == NULL) { - return; - } + /* We need to use m->m_pkthdr.len, so require the header */ - if ((m->m_flags & M_PKTHDR) == 0) - panic("vxstart: no header mbuf"); + M_ASSERTPKTHDR(m); len = m->m_pkthdr.len; pad = (4 - len) & 3; diff --git a/sys/ia64/ia64/busdma_machdep.c b/sys/ia64/ia64/busdma_machdep.c index 3feacca..d9c24dd 100644 --- a/sys/ia64/ia64/busdma_machdep.c +++ b/sys/ia64/ia64/busdma_machdep.c @@ -643,8 +643,7 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, KASSERT(dmat->lowaddr >= ptoa(Maxmem) || map != NULL, ("bus_dmamap_load_mbuf: No support for bounce pages!")); - KASSERT(m0->m_flags & M_PKTHDR, - ("bus_dmamap_load_mbuf: no packet header")); + M_ASSERTPKTHDR(m0); nsegs = 0; error = 0; diff --git a/sys/kern/kern_mac.c b/sys/kern/kern_mac.c index 17b37d8..38f7e9b 100644 --- a/sys/kern/kern_mac.c +++ b/sys/kern/kern_mac.c @@ -721,7 +721,7 @@ mac_init_mbuf(struct mbuf *m, int flag) { int error; - KASSERT(m->m_flags & M_PKTHDR, ("mac_init_mbuf on non-header mbuf")); + M_ASSERTPKTHDR(m); mac_init_label(&m->m_pkthdr.label); @@ -2270,7 +2270,7 @@ mac_check_ifnet_transmit(struct ifnet *ifnet, struct mbuf *mbuf) if (!mac_enforce_network) return (0); - KASSERT(mbuf->m_flags & M_PKTHDR, ("packet has no pkthdr")); + M_ASSERTPKTHDR(mbuf); if (!(mbuf->m_pkthdr.label.l_flags & MAC_FLAG_INITIALIZED)) if_printf(ifnet, "not initialized\n"); diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index c6ada18..9caeed9 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -87,8 +87,7 @@ m_move_pkthdr(struct mbuf *to, struct mbuf *from) #if 0 /* see below for why these are not enabled */ - KASSERT(to->m_flags & M_PKTHDR, - ("m_move_pkthdr: called on non-header")); + M_ASSERTPKTHDR(to); KASSERT(SLIST_EMPTY(&to->m_pkthdr.tags), ("m_move_pkthdr: to has tags")); #endif @@ -125,7 +124,7 @@ m_dup_pkthdr(struct mbuf *to, struct mbuf *from, int how) * smash the pkthdr as needed causing these * assertions to trip. For now just disable them. */ - KASSERT(to->m_flags & M_PKTHDR, ("m_dup_pkthdr: called on non-header")); + M_ASSERTPKTHDR(to); KASSERT(SLIST_EMPTY(&to->m_pkthdr.tags), ("m_dup_pkthdr: to has tags")); #endif #ifdef MAC @@ -349,7 +348,7 @@ m_dup(struct mbuf *m, int how) /* Sanity check */ if (m == NULL) return (NULL); - KASSERT((m->m_flags & M_PKTHDR) != 0, ("%s: !PKTHDR", __func__)); + M_ASSERTPKTHDR(m); /* While there's more data, get a new mbuf, tack it on, and fill it */ remain = m->m_pkthdr.len; diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c index 79775f1..cfc0432 100644 --- a/sys/net/if_disc.c +++ b/sys/net/if_disc.c @@ -155,8 +155,7 @@ static int discoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct rtentry *rt) { - if ((m->m_flags & M_PKTHDR) == 0) - panic("discoutput no HDR"); + M_ASSERTPKTHDR(m); /* BPF write needs to be handled specially */ if (dst->sa_family == AF_UNSPEC) { dst->sa_family = *(mtod(m, int *)); diff --git a/sys/net/if_faith.c b/sys/net/if_faith.c index 372786a..761f151 100644 --- a/sys/net/if_faith.c +++ b/sys/net/if_faith.c @@ -203,8 +203,7 @@ faithoutput(ifp, m, dst, rt) { int isr; - if ((m->m_flags & M_PKTHDR) == 0) - panic("faithoutput no HDR"); + M_ASSERTPKTHDR(m); /* BPF write needs to be handled specially */ if (dst->sa_family == AF_UNSPEC) { diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index 92add8a..09ba6a3 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -192,8 +192,8 @@ looutput(ifp, m, dst, rt) struct sockaddr *dst; register struct rtentry *rt; { - if ((m->m_flags & M_PKTHDR) == 0) - panic("looutput no HDR"); + + M_ASSERTPKTHDR(m); /* check if we have the packet header */ if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) { m_freem(m); @@ -276,7 +276,7 @@ if_simloop(ifp, m, af, hlen) { int isr; - KASSERT((m->m_flags & M_PKTHDR) != 0, ("if_simloop: no HDR")); + M_ASSERTPKTHDR(m); m->m_pkthdr.rcvif = ifp; /* BPF write needs to be handled specially */ diff --git a/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c b/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c index 2221f44..d8da877 100644 --- a/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c +++ b/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c @@ -451,8 +451,7 @@ ng_btsocket_hci_raw_data_input(struct mbuf *nam) KASSERT((nam->m_type == MT_SONAME), ("%s: m_type=%d\n", __func__, nam->m_type)); - KASSERT((m0->m_flags & M_PKTHDR), - ("%s: m_flags=%#x\n", __func__, m0->m_flags)); + M_ASSERTPKTHDR(m0); sa = mtod(nam, struct sockaddr_hci *); @@ -614,8 +613,7 @@ ng_btsocket_hci_raw_output(node_p node, hook_p hook, void *arg1, int arg2) KASSERT((nam->m_type == MT_SONAME), ("%s: m_type=%d\n", __func__, nam->m_type)); - KASSERT((m->m_flags & M_PKTHDR), - ("%s: m_flags=%#x\n", __func__, m->m_flags)); + M_ASSERTPKTHDR(m); sa = mtod(nam, struct sockaddr_hci *); diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index efa0e03..786eecd 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -335,8 +335,7 @@ static ng_ID_t nextID = 1; struct mbuf *n; \ int total; \ \ - if (((m)->m_flags & M_PKTHDR) == 0) \ - panic("%s: !PKTHDR", __func__); \ + M_ASSERTPKTHDR(m); \ for (total = 0, n = (m); n != NULL; n = n->m_next) \ total += n->m_len; \ if ((m)->m_pkthdr.len != total) { \ diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c index 07968ff..3aa34f2 100644 --- a/sys/netgraph/ng_iface.c +++ b/sys/netgraph/ng_iface.c @@ -739,7 +739,7 @@ ng_iface_rcvdata(hook_p hook, item_p item) NG_FREE_ITEM(item); /* Sanity checks */ KASSERT(iffam != NULL, ("%s: iffam", __func__)); - KASSERT(m->m_flags & M_PKTHDR, ("%s: not pkthdr", __func__)); + M_ASSERTPKTHDR(m); if (m == NULL) return (EINVAL); if ((ifp->if_flags & IFF_UP) == 0) { diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 162d7f7..d10ed97 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -180,7 +180,7 @@ divert_packet(struct mbuf *m, int incoming, int port, int rule) struct ifaddr *ifa; /* Sanity check */ - KASSERT((m->m_flags & M_PKTHDR), ("%s: !PKTHDR", __func__)); + M_ASSERTPKTHDR(m); /* Find IP address for receive interface */ TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrhead, ifa_link) { diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index e26cc8d..5cf4ff4 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -334,8 +334,7 @@ ip_input(struct mbuf *m) } } - KASSERT(m != NULL && (m->m_flags & M_PKTHDR) != 0, - ("ip_input: no HDR")); + M_ASSERTPKTHDR(m); if (args.rule) { /* dummynet already filtered us */ ip = mtod(m, struct ip *); diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 8c7d890..5abf2ee 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -1827,8 +1827,7 @@ X_rsvp_input(struct mbuf *m, int off) printf("rsvp_input: check vifs\n"); #ifdef DIAGNOSTIC - if (!(m->m_flags & M_PKTHDR)) - panic("rsvp_input no hdr"); + M_ASSERTPKTHDR(m); #endif ifp = m->m_pkthdr.rcvif; diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 478a0d5..c303c93 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -199,7 +199,7 @@ ip_output(m0, opt, ro, flags, imo, inp) } m = m0; - KASSERT(!m || (m->m_flags & M_PKTHDR) != 0, ("ip_output: no HDR")); + M_ASSERTPKTHDR(m); #ifndef FAST_IPSEC KASSERT(ro != NULL, ("ip_output: no route, proto %d", mtod(m, struct ip *)->ip_p)); diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c index d61c15b..4b587f4 100644 --- a/sys/netipsec/keysock.c +++ b/sys/netipsec/keysock.c @@ -114,8 +114,7 @@ key_output(m, va_alist) } } - if ((m->m_flags & M_PKTHDR) == 0) - panic("key_output: not M_PKTHDR ??"); + M_ASSERTPKTHDR(m); KEYDEBUG(KEYDEBUG_KEY_DUMP, kdebug_mbuf(m)); diff --git a/sys/netkey/keysock.c b/sys/netkey/keysock.c index dbc48a8..5cf0924 100644 --- a/sys/netkey/keysock.c +++ b/sys/netkey/keysock.c @@ -110,8 +110,7 @@ key_output(m, va_alist) } } - if ((m->m_flags & M_PKTHDR) == 0) - panic("key_output: not M_PKTHDR ??"); + M_ASSERTPKTHDR(m); KEYDEBUG(KEYDEBUG_KEY_DUMP, kdebug_mbuf(m)); diff --git a/sys/netnatm/natm.c b/sys/netnatm/natm.c index 2df3c22..87269fe 100644 --- a/sys/netnatm/natm.c +++ b/sys/netnatm/natm.c @@ -705,8 +705,7 @@ natmintr(struct mbuf *m) struct natmpcb *npcb; #ifdef DIAGNOSTIC - if ((m->m_flags & M_PKTHDR) == 0) - panic("natmintr no HDR"); + M_ASSERTPKTHDR(m); #endif npcb = (struct natmpcb *) m->m_pkthdr.rcvif; /* XXX: overloaded */ diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c index 7401e27..9e4727f 100644 --- a/sys/powerpc/powerpc/busdma_machdep.c +++ b/sys/powerpc/powerpc/busdma_machdep.c @@ -417,8 +417,7 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, struct mbuf *m0, #endif int nsegs = 0, error = 0; - KASSERT(m0->m_flags & M_PKTHDR, - ("bus_dmamap_load_mbuf: no packet header")); + M_ASSERTPKTHDR(m0); if (m0->m_pkthdr.len <= dmat->maxsize) { int first = 1; diff --git a/sys/security/mac/mac_framework.c b/sys/security/mac/mac_framework.c index 17b37d8..38f7e9b 100644 --- a/sys/security/mac/mac_framework.c +++ b/sys/security/mac/mac_framework.c @@ -721,7 +721,7 @@ mac_init_mbuf(struct mbuf *m, int flag) { int error; - KASSERT(m->m_flags & M_PKTHDR, ("mac_init_mbuf on non-header mbuf")); + M_ASSERTPKTHDR(m); mac_init_label(&m->m_pkthdr.label); @@ -2270,7 +2270,7 @@ mac_check_ifnet_transmit(struct ifnet *ifnet, struct mbuf *mbuf) if (!mac_enforce_network) return (0); - KASSERT(mbuf->m_flags & M_PKTHDR, ("packet has no pkthdr")); + M_ASSERTPKTHDR(mbuf); if (!(mbuf->m_pkthdr.label.l_flags & MAC_FLAG_INITIALIZED)) if_printf(ifnet, "not initialized\n"); diff --git a/sys/security/mac/mac_internal.h b/sys/security/mac/mac_internal.h index 17b37d8..38f7e9b 100644 --- a/sys/security/mac/mac_internal.h +++ b/sys/security/mac/mac_internal.h @@ -721,7 +721,7 @@ mac_init_mbuf(struct mbuf *m, int flag) { int error; - KASSERT(m->m_flags & M_PKTHDR, ("mac_init_mbuf on non-header mbuf")); + M_ASSERTPKTHDR(m); mac_init_label(&m->m_pkthdr.label); @@ -2270,7 +2270,7 @@ mac_check_ifnet_transmit(struct ifnet *ifnet, struct mbuf *mbuf) if (!mac_enforce_network) return (0); - KASSERT(mbuf->m_flags & M_PKTHDR, ("packet has no pkthdr")); + M_ASSERTPKTHDR(mbuf); if (!(mbuf->m_pkthdr.label.l_flags & MAC_FLAG_INITIALIZED)) if_printf(ifnet, "not initialized\n"); diff --git a/sys/security/mac/mac_net.c b/sys/security/mac/mac_net.c index 17b37d8..38f7e9b 100644 --- a/sys/security/mac/mac_net.c +++ b/sys/security/mac/mac_net.c @@ -721,7 +721,7 @@ mac_init_mbuf(struct mbuf *m, int flag) { int error; - KASSERT(m->m_flags & M_PKTHDR, ("mac_init_mbuf on non-header mbuf")); + M_ASSERTPKTHDR(m); mac_init_label(&m->m_pkthdr.label); @@ -2270,7 +2270,7 @@ mac_check_ifnet_transmit(struct ifnet *ifnet, struct mbuf *mbuf) if (!mac_enforce_network) return (0); - KASSERT(mbuf->m_flags & M_PKTHDR, ("packet has no pkthdr")); + M_ASSERTPKTHDR(mbuf); if (!(mbuf->m_pkthdr.label.l_flags & MAC_FLAG_INITIALIZED)) if_printf(ifnet, "not initialized\n"); diff --git a/sys/security/mac/mac_pipe.c b/sys/security/mac/mac_pipe.c index 17b37d8..38f7e9b 100644 --- a/sys/security/mac/mac_pipe.c +++ b/sys/security/mac/mac_pipe.c @@ -721,7 +721,7 @@ mac_init_mbuf(struct mbuf *m, int flag) { int error; - KASSERT(m->m_flags & M_PKTHDR, ("mac_init_mbuf on non-header mbuf")); + M_ASSERTPKTHDR(m); mac_init_label(&m->m_pkthdr.label); @@ -2270,7 +2270,7 @@ mac_check_ifnet_transmit(struct ifnet *ifnet, struct mbuf *mbuf) if (!mac_enforce_network) return (0); - KASSERT(mbuf->m_flags & M_PKTHDR, ("packet has no pkthdr")); + M_ASSERTPKTHDR(mbuf); if (!(mbuf->m_pkthdr.label.l_flags & MAC_FLAG_INITIALIZED)) if_printf(ifnet, "not initialized\n"); diff --git a/sys/security/mac/mac_process.c b/sys/security/mac/mac_process.c index 17b37d8..38f7e9b 100644 --- a/sys/security/mac/mac_process.c +++ b/sys/security/mac/mac_process.c @@ -721,7 +721,7 @@ mac_init_mbuf(struct mbuf *m, int flag) { int error; - KASSERT(m->m_flags & M_PKTHDR, ("mac_init_mbuf on non-header mbuf")); + M_ASSERTPKTHDR(m); mac_init_label(&m->m_pkthdr.label); @@ -2270,7 +2270,7 @@ mac_check_ifnet_transmit(struct ifnet *ifnet, struct mbuf *mbuf) if (!mac_enforce_network) return (0); - KASSERT(mbuf->m_flags & M_PKTHDR, ("packet has no pkthdr")); + M_ASSERTPKTHDR(mbuf); if (!(mbuf->m_pkthdr.label.l_flags & MAC_FLAG_INITIALIZED)) if_printf(ifnet, "not initialized\n"); diff --git a/sys/security/mac/mac_syscalls.c b/sys/security/mac/mac_syscalls.c index 17b37d8..38f7e9b 100644 --- a/sys/security/mac/mac_syscalls.c +++ b/sys/security/mac/mac_syscalls.c @@ -721,7 +721,7 @@ mac_init_mbuf(struct mbuf *m, int flag) { int error; - KASSERT(m->m_flags & M_PKTHDR, ("mac_init_mbuf on non-header mbuf")); + M_ASSERTPKTHDR(m); mac_init_label(&m->m_pkthdr.label); @@ -2270,7 +2270,7 @@ mac_check_ifnet_transmit(struct ifnet *ifnet, struct mbuf *mbuf) if (!mac_enforce_network) return (0); - KASSERT(mbuf->m_flags & M_PKTHDR, ("packet has no pkthdr")); + M_ASSERTPKTHDR(mbuf); if (!(mbuf->m_pkthdr.label.l_flags & MAC_FLAG_INITIALIZED)) if_printf(ifnet, "not initialized\n"); diff --git a/sys/security/mac/mac_system.c b/sys/security/mac/mac_system.c index 17b37d8..38f7e9b 100644 --- a/sys/security/mac/mac_system.c +++ b/sys/security/mac/mac_system.c @@ -721,7 +721,7 @@ mac_init_mbuf(struct mbuf *m, int flag) { int error; - KASSERT(m->m_flags & M_PKTHDR, ("mac_init_mbuf on non-header mbuf")); + M_ASSERTPKTHDR(m); mac_init_label(&m->m_pkthdr.label); @@ -2270,7 +2270,7 @@ mac_check_ifnet_transmit(struct ifnet *ifnet, struct mbuf *mbuf) if (!mac_enforce_network) return (0); - KASSERT(mbuf->m_flags & M_PKTHDR, ("packet has no pkthdr")); + M_ASSERTPKTHDR(mbuf); if (!(mbuf->m_pkthdr.label.l_flags & MAC_FLAG_INITIALIZED)) if_printf(ifnet, "not initialized\n"); diff --git a/sys/security/mac/mac_vfs.c b/sys/security/mac/mac_vfs.c index 17b37d8..38f7e9b 100644 --- a/sys/security/mac/mac_vfs.c +++ b/sys/security/mac/mac_vfs.c @@ -721,7 +721,7 @@ mac_init_mbuf(struct mbuf *m, int flag) { int error; - KASSERT(m->m_flags & M_PKTHDR, ("mac_init_mbuf on non-header mbuf")); + M_ASSERTPKTHDR(m); mac_init_label(&m->m_pkthdr.label); @@ -2270,7 +2270,7 @@ mac_check_ifnet_transmit(struct ifnet *ifnet, struct mbuf *mbuf) if (!mac_enforce_network) return (0); - KASSERT(mbuf->m_flags & M_PKTHDR, ("packet has no pkthdr")); + M_ASSERTPKTHDR(mbuf); if (!(mbuf->m_pkthdr.label.l_flags & MAC_FLAG_INITIALIZED)) if_printf(ifnet, "not initialized\n"); diff --git a/sys/sparc64/sparc64/bus_machdep.c b/sys/sparc64/sparc64/bus_machdep.c index 1b97419..2b3ddc87 100644 --- a/sys/sparc64/sparc64/bus_machdep.c +++ b/sys/sparc64/sparc64/bus_machdep.c @@ -446,8 +446,7 @@ nexus_dmamap_load_mbuf(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, #endif int nsegs, error; - KASSERT(m0->m_flags & M_PKTHDR, - ("nexus_dmamap_load_mbuf: no packet header")); + M_ASSERTPKTHDR(m0); nsegs = 0; error = 0; diff --git a/sys/sparc64/sparc64/iommu.c b/sys/sparc64/sparc64/iommu.c index 8eccb04..9dc8d96 100644 --- a/sys/sparc64/sparc64/iommu.c +++ b/sys/sparc64/sparc64/iommu.c @@ -906,8 +906,7 @@ iommu_dvmamap_load_mbuf(bus_dma_tag_t pt, bus_dma_tag_t dt, struct mbuf *m; int error = 0, first = 1, nsegs = -1; - KASSERT(m0->m_flags & M_PKTHDR, - ("iommu_dvmamap_load_mbuf: no packet header")); + M_ASSERTPKTHDR(m0); if (map->dm_loaded) { #ifdef DIAGNOSTIC diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index ae8025a..dd21312 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -334,6 +334,13 @@ struct mbstat { & M_EXT) || !MEXT_IS_REF(m))) /* + * Check if the supplied mbuf has a packet header, or else panic. + */ +#define M_ASSERTPKTHDR(m) \ + KASSERT(m != NULL && m->m_flags & M_PKTHDR, \ + ("%s: no mbuf packet header!", __func__)) + +/* * Set the m_data pointer of a newly-allocated mbuf (m_get/MGET) to place * an object of the specified size at the end of the mbuf, longword aligned. */ |