summaryrefslogtreecommitdiff
path: root/sys/net/pf.c
diff options
context:
space:
mode:
authorjasoni <jasoni@cvs.openbsd.org>2001-11-30 17:01:55 +0000
committerjasoni <jasoni@cvs.openbsd.org>2001-11-30 17:01:55 +0000
commitc9e5e44025b83bf3cab322dd8844458ade3132f9 (patch)
tree55a134c2281d5b5a06cbf237f0aedd565e3dab32 /sys/net/pf.c
parentc4d144f99675fb8c8dea2c93c6ec0e19c0a79356 (diff)
only make a copy of the mbuf if the route rule is dup-to
Diffstat (limited to 'sys/net/pf.c')
-rw-r--r--sys/net/pf.c24
1 files changed, 15 insertions, 9 deletions
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;
}
}