summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2010-11-29 06:48:09 +0000
committerdlg <dlg@openbsd.org>2010-11-29 06:48:09 +0000
commit7803b86442713a6e7e93ceebb3c00357a6193df8 (patch)
treeab78212f5b7ed4719b450650d00e4c7cc9d47faf
parentget rid of struct pfsync_pkt. it was used to store data on the stack to (diff)
downloadwireguard-openbsd-7803b86442713a6e7e93ceebb3c00357a6193df8.tar.xz
wireguard-openbsd-7803b86442713a6e7e93ceebb3c00357a6193df8.zip
use m_pulldown to get a contig view of the pfsync_header instead of
m_pullup. not really a significant change since most rx bufs (which we read pfsync packets from) are a single contig cluster coming off the network, so we rarely hit the case m_pullup was called in.
-rw-r--r--sys/net/if_pfsync.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/sys/net/if_pfsync.c b/sys/net/if_pfsync.c
index 052cc39bd36..9bb4997b9b9 100644
--- a/sys/net/if_pfsync.c
+++ b/sys/net/if_pfsync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pfsync.c,v 1.158 2010/11/29 05:31:38 dlg Exp $ */
+/* $OpenBSD: if_pfsync.c,v 1.159 2010/11/29 06:48:09 dlg Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff
@@ -665,19 +665,12 @@ pfsync_input(struct mbuf *m, ...)
}
offset = ip->ip_hl << 2;
- if (m->m_pkthdr.len < offset + sizeof(*ph)) {
+ mp = m_pulldown(m, offset, sizeof(*ph), &offp);
+ if (mp == NULL) {
pfsyncstats.pfsyncs_hdrops++;
- goto done;
- }
-
- if (offset + sizeof(*ph) > m->m_len) {
- if (m_pullup(m, offset + sizeof(*ph)) == NULL) {
- pfsyncstats.pfsyncs_hdrops++;
- return;
- }
- ip = mtod(m, struct ip *);
+ return;
}
- ph = (struct pfsync_header *)((char *)ip + offset);
+ ph = (struct pfsync_header *)(mp->m_data + offp);
/* verify the version */
if (ph->version != PFSYNC_VERSION) {