summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2011-03-06 19:55:54 +0000
committerbluhm <bluhm@openbsd.org>2011-03-06 19:55:54 +0000
commit202df550822e532c47cc8952e2c0519fd81397d2 (patch)
tree88ffc410a8a3fb375f7008b4fdba67607bff39d1
parentMake sure MEMORYBARRIER(SYNC_REG) performs a read/write bus_space_barrier, (diff)
downloadwireguard-openbsd-202df550822e532c47cc8952e2c0519fd81397d2.tar.xz
wireguard-openbsd-202df550822e532c47cc8952e2c0519fd81397d2.zip
Extract the new function frag6_deletefraghdr() from frag6_input()
to make it reusable by pf. No functional change. ok henning@, claudio@
-rw-r--r--sys/netinet6/frag6.c49
-rw-r--r--sys/netinet6/ip6_var.h3
2 files changed, 33 insertions, 19 deletions
diff --git a/sys/netinet6/frag6.c b/sys/netinet6/frag6.c
index 756d1091c15..4caa0656e96 100644
--- a/sys/netinet6/frag6.c
+++ b/sys/netinet6/frag6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frag6.c,v 1.31 2011/01/13 23:36:53 bluhm Exp $ */
+/* $OpenBSD: frag6.c,v 1.32 2011/03/06 19:55:54 bluhm Exp $ */
/* $KAME: frag6.c,v 1.40 2002/05/27 21:40:31 itojun Exp $ */
/*
@@ -546,23 +546,12 @@ insert:
#endif
/* Delete frag6 header */
- if (m->m_len >= offset + sizeof(struct ip6_frag)) {
- /* This is the only possible case with !PULLDOWN_TEST */
- ovbcopy((caddr_t)ip6, (caddr_t)ip6 + sizeof(struct ip6_frag),
- offset);
- m->m_data += sizeof(struct ip6_frag);
- m->m_len -= sizeof(struct ip6_frag);
- } else {
- /* this comes with no copy if the boundary is on cluster */
- if ((t = m_split(m, offset, M_DONTWAIT)) == NULL) {
- frag6_remque(q6);
- frag6_nfrags -= q6->ip6q_nfrag;
- free(q6, M_FTABLE);
- frag6_nfragpackets--;
- goto dropfrag;
- }
- m_adj(t, sizeof(struct ip6_frag));
- m_cat(m, t);
+ if (frag6_deletefraghdr(m, offset) != 0) {
+ frag6_remque(q6);
+ frag6_nfrags -= q6->ip6q_nfrag;
+ free(q6, M_FTABLE);
+ frag6_nfragpackets--;
+ goto dropfrag;
}
/*
@@ -607,6 +596,30 @@ insert:
}
/*
+ * Delete fragment header after the unfragmentable header portions.
+ */
+int
+frag6_deletefraghdr(struct mbuf *m, int offset)
+{
+ struct mbuf *t;
+
+ if (m->m_len >= offset + sizeof(struct ip6_frag)) {
+ ovbcopy(mtod(m, caddr_t), mtod(m, caddr_t) +
+ sizeof(struct ip6_frag), offset);
+ m->m_data += sizeof(struct ip6_frag);
+ m->m_len -= sizeof(struct ip6_frag);
+ } else {
+ /* this comes with no copy if the boundary is on cluster */
+ if ((t = m_split(m, offset, M_DONTWAIT)) == NULL)
+ return (ENOBUFS);
+ m_adj(t, sizeof(struct ip6_frag));
+ m_cat(m, t);
+ }
+
+ return (0);
+}
+
+/*
* Free a fragment reassembly header and all
* associated datagrams.
*/
diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h
index bf1ebee56d4..3bac2025420 100644
--- a/sys/netinet6/ip6_var.h
+++ b/sys/netinet6/ip6_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_var.h,v 1.38 2010/12/21 13:12:59 claudio Exp $ */
+/* $OpenBSD: ip6_var.h,v 1.39 2011/03/06 19:55:54 bluhm Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
@@ -303,6 +303,7 @@ int route6_input(struct mbuf **, int *, int);
void frag6_init(void);
int frag6_input(struct mbuf **, int *, int);
+int frag6_deletefraghdr(struct mbuf *, int);
void frag6_slowtimo(void);
void frag6_drain(void);