From b16cb0a948acd6a3b5f47aa494607a001944c194 Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 30 Dec 2002 20:22:40 +0000 Subject: Correct mbuf packet header propagation. Previously, packet headers were sometimes propagated using M_COPY_PKTHDR which actually did something between a "move" and a "copy" operation. This is replaced by M_MOVE_PKTHDR (which copies the pkthdr contents and "removes" it from the source mbuf) and m_dup_pkthdr which copies the packet header contents including any m_tag chain. This corrects numerous problems whereby mbuf tags could be lost during packet manipulations. These changes also introduce arguments to m_tag_copy and m_tag_copy_chain to specify if the tag copy work should potentially block. This introduces an incompatibility with openbsd which we may want to revisit. Note that move/dup of packet headers does not handle target mbufs that have a cluster bound to them. We may want to support this; for now we watch for it with an assert. Finally, M_COPYFLAGS was updated to include M_FIRSTFRAG|M_LASTFRAG. Supported by: Vernier Networks Reviewed by: Robert Watson --- sys/dev/hifn/hifn7751.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sys/dev/hifn') diff --git a/sys/dev/hifn/hifn7751.c b/sys/dev/hifn/hifn7751.c index ea87bd6..accb531 100644 --- a/sys/dev/hifn/hifn7751.c +++ b/sys/dev/hifn/hifn7751.c @@ -1668,6 +1668,10 @@ hifn_crypto( if (cmd->src_m->m_flags & M_PKTHDR) { len = MHLEN; MGETHDR(m0, M_DONTWAIT, MT_DATA); + if (m0 && !m_dup_pkthdr(m0, cmd->src_m, M_DONTWAIT)) { + m_free(m0); + m0 = NULL; + } } else { len = MLEN; MGET(m0, M_DONTWAIT, MT_DATA); @@ -1677,9 +1681,6 @@ hifn_crypto( err = dma->cmdu ? ERESTART : ENOMEM; goto err_srcmap; } - if (len == MHLEN) { - M_COPY_PKTHDR(m0, cmd->src_m); - } if (totlen >= MINCLSIZE) { MCLGET(m0, M_DONTWAIT); if ((m0->m_flags & M_EXT) == 0) { -- cgit v1.1