summaryrefslogtreecommitdiff
path: root/sys/net/pf_norm.c
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2011-09-28 17:15:46 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2011-09-28 17:15:46 +0000
commit492af1a2279d21401f3ec4e410176f986926f8af (patch)
treea86a5feb69fe87f6bf16f9cc4f45e7f378a7b244 /sys/net/pf_norm.c
parentccddcd8fdb7830903bef146d167e6122bdfe90ac (diff)
As requested by henning, move the mbuf pointer into struct pf_pdesc.
Also sort pd to the beginning of the functions' parameter lists for consistency. ok henning
Diffstat (limited to 'sys/net/pf_norm.c')
-rw-r--r--sys/net/pf_norm.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/sys/net/pf_norm.c b/sys/net/pf_norm.c
index c89c37367a7..a5ed6ce43e4 100644
--- a/sys/net/pf_norm.c
+++ b/sys/net/pf_norm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_norm.c,v 1.145 2011/09/22 14:57:12 bluhm Exp $ */
+/* $OpenBSD: pf_norm.c,v 1.146 2011/09/28 17:15:45 bluhm Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
@@ -808,7 +808,7 @@ pf_normalize_ip6(struct mbuf **m0, int dir, int off, int extoff,
#endif /* INET6 */
int
-pf_normalize_tcp(struct mbuf *m, struct pf_pdesc *pd)
+pf_normalize_tcp(struct pf_pdesc *pd)
{
struct tcphdr *th = pd->hdr.tcp;
u_short reason;
@@ -857,7 +857,7 @@ pf_normalize_tcp(struct mbuf *m, struct pf_pdesc *pd)
/* copy back packet headers if we sanitized */
if (rewrite)
- m_copyback(m, pd->off, sizeof(*th), th, M_NOWAIT);
+ m_copyback(pd->m, pd->off, sizeof(*th), th, M_NOWAIT);
return (PF_PASS);
@@ -867,8 +867,8 @@ pf_normalize_tcp(struct mbuf *m, struct pf_pdesc *pd)
}
int
-pf_normalize_tcp_init(struct mbuf *m, struct pf_pdesc *pd,
- struct pf_state_peer *src, struct pf_state_peer *dst)
+pf_normalize_tcp_init(struct pf_pdesc *pd, struct pf_state_peer *src,
+ struct pf_state_peer *dst)
{
struct tcphdr *th = pd->hdr.tcp;
u_int32_t tsval, tsecr;
@@ -885,14 +885,14 @@ pf_normalize_tcp_init(struct mbuf *m, struct pf_pdesc *pd,
switch (pd->af) {
#ifdef INET
case AF_INET: {
- struct ip *h = mtod(m, struct ip *);
+ struct ip *h = mtod(pd->m, struct ip *);
src->scrub->pfss_ttl = h->ip_ttl;
break;
}
#endif /* INET */
#ifdef INET6
case AF_INET6: {
- struct ip6_hdr *h = mtod(m, struct ip6_hdr *);
+ struct ip6_hdr *h = mtod(pd->m, struct ip6_hdr *);
src->scrub->pfss_ttl = h->ip6_hlim;
break;
}
@@ -909,7 +909,8 @@ pf_normalize_tcp_init(struct mbuf *m, struct pf_pdesc *pd,
if (th->th_off > (sizeof(struct tcphdr) >> 2) && src->scrub &&
- pf_pull_hdr(m, pd->off, hdr, th->th_off << 2, NULL, NULL, pd->af)) {
+ pf_pull_hdr(pd->m, pd->off, hdr, th->th_off << 2, NULL, NULL,
+ pd->af)) {
/* Diddle with TCP options */
int hlen;
opt = hdr + sizeof(struct tcphdr);
@@ -962,9 +963,9 @@ pf_normalize_tcp_cleanup(struct pf_state *state)
}
int
-pf_normalize_tcp_stateful(struct mbuf *m, struct pf_pdesc *pd,
- u_short *reason, struct pf_state *state,
- struct pf_state_peer *src, struct pf_state_peer *dst, int *writeback)
+pf_normalize_tcp_stateful(struct pf_pdesc *pd, u_short *reason,
+ struct pf_state *state, struct pf_state_peer *src,
+ struct pf_state_peer *dst, int *writeback)
{
struct tcphdr *th = pd->hdr.tcp;
struct timeval uptime;
@@ -986,7 +987,7 @@ pf_normalize_tcp_stateful(struct mbuf *m, struct pf_pdesc *pd,
#ifdef INET
case AF_INET: {
if (src->scrub) {
- struct ip *h = mtod(m, struct ip *);
+ struct ip *h = mtod(pd->m, struct ip *);
if (h->ip_ttl > src->scrub->pfss_ttl)
src->scrub->pfss_ttl = h->ip_ttl;
h->ip_ttl = src->scrub->pfss_ttl;
@@ -997,7 +998,7 @@ pf_normalize_tcp_stateful(struct mbuf *m, struct pf_pdesc *pd,
#ifdef INET6
case AF_INET6: {
if (src->scrub) {
- struct ip6_hdr *h = mtod(m, struct ip6_hdr *);
+ struct ip6_hdr *h = mtod(pd->m, struct ip6_hdr *);
if (h->ip6_hlim > src->scrub->pfss_ttl)
src->scrub->pfss_ttl = h->ip6_hlim;
h->ip6_hlim = src->scrub->pfss_ttl;
@@ -1010,7 +1011,8 @@ pf_normalize_tcp_stateful(struct mbuf *m, struct pf_pdesc *pd,
if (th->th_off > (sizeof(struct tcphdr) >> 2) &&
((src->scrub && (src->scrub->pfss_flags & PFSS_TIMESTAMP)) ||
(dst->scrub && (dst->scrub->pfss_flags & PFSS_TIMESTAMP))) &&
- pf_pull_hdr(m, pd->off, hdr, th->th_off << 2, NULL, NULL, pd->af)) {
+ pf_pull_hdr(pd->m, pd->off, hdr, th->th_off << 2, NULL, NULL,
+ pd->af)) {
/* Diddle with TCP options */
int hlen;
opt = hdr + sizeof(struct tcphdr);
@@ -1080,7 +1082,7 @@ pf_normalize_tcp_stateful(struct mbuf *m, struct pf_pdesc *pd,
if (copyback) {
/* Copyback the options, caller copys back header */
*writeback = 1;
- m_copyback(m, pd->off + sizeof(struct tcphdr),
+ m_copyback(pd->m, pd->off + sizeof(struct tcphdr),
(th->th_off << 2) - sizeof(struct tcphdr), hdr +
sizeof(struct tcphdr), M_NOWAIT);
}
@@ -1362,7 +1364,7 @@ pf_normalize_tcp_stateful(struct mbuf *m, struct pf_pdesc *pd,
}
int
-pf_normalize_mss(struct mbuf *m, struct pf_pdesc *pd, u_int16_t maxmss)
+pf_normalize_mss(struct pf_pdesc *pd, u_int16_t maxmss)
{
struct tcphdr *th = pd->hdr.tcp;
u_int16_t mss;
@@ -1374,7 +1376,7 @@ pf_normalize_mss(struct mbuf *m, struct pf_pdesc *pd, u_int16_t maxmss)
thoff = th->th_off << 2;
cnt = thoff - sizeof(struct tcphdr);
- if (cnt > 0 && !pf_pull_hdr(m, pd->off + sizeof(*th), opts, cnt,
+ if (cnt > 0 && !pf_pull_hdr(pd->m, pd->off + sizeof(*th), opts, cnt,
NULL, NULL, pd->af))
return (0);
@@ -1398,10 +1400,10 @@ pf_normalize_mss(struct mbuf *m, struct pf_pdesc *pd, u_int16_t maxmss)
th->th_sum = pf_cksum_fixup(th->th_sum,
mss, htons(maxmss), 0);
mss = htons(maxmss);
- m_copyback(m,
+ m_copyback(pd->m,
pd->off + sizeof(*th) + optp + 2 - opts,
2, &mss, M_NOWAIT);
- m_copyback(m, pd->off, sizeof(*th), th,
+ m_copyback(pd->m, pd->off, sizeof(*th), th,
M_NOWAIT);
}
break;