From c9e5e44025b83bf3cab322dd8844458ade3132f9 Mon Sep 17 00:00:00 2001 From: jasoni Date: Fri, 30 Nov 2001 17:01:55 +0000 Subject: only make a copy of the mbuf if the route rule is dup-to --- sys/net/pf.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'sys/net/pf.c') diff --git a/sys/net/pf.c b/sys/net/pf.c index 8acfc769110..bdffc69942e 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.173 2001/11/27 20:29:25 jasoni Exp $ */ +/* $OpenBSD: pf.c,v 1.174 2001/11/30 17:01:54 jasoni Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -4341,9 +4341,12 @@ pf_route(struct mbuf *m, struct pf_rule *r) if (m == NULL) return; - m0 = m_copym2(m, 0, M_COPYALL, M_NOWAIT); - if (m0 == NULL) - return; + if (r->rt == PF_DUPTO) { + m0 = m_copym2(m, 0, M_COPYALL, M_NOWAIT); + if (m0 == NULL) + return; + } else + m0 = m; ip = mtod(m0, struct ip *); hlen = ip->ip_hl << 2; @@ -4535,9 +4538,12 @@ pf_route6(struct mbuf *m, struct pf_rule *r) if (m == NULL) return; - m0 = m_copym2(m, 0, M_COPYALL, M_NOWAIT); - if (m0 == NULL) - return; + if (r->rt == PF_DUPTO) { + m0 = m_copym2(m, 0, M_COPYALL, M_NOWAIT); + if (m0 == NULL) + return; + } else + m0 = m; ip6 = mtod(m0, struct ip6_hdr *); @@ -4730,7 +4736,7 @@ done: if (r && r->rt) { pf_route(m, r); if (r->rt != PF_DUPTO) { - m_freem(*m0); + /* m0 already freed */ *m0 = NULL; } } @@ -4912,7 +4918,7 @@ done: if (r && r->rt) { pf_route6(m, r); if (r->rt != PF_DUPTO) { - m_freem(*m0); + /* m0 already freed */ *m0 = NULL; } } -- cgit v1.2.3