From 4018ea9a2b2b5bc59752ea88cf38c451fc4fcf60 Mon Sep 17 00:00:00 2001 From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 15:30:24 +0000 Subject: [PATCH] Implement handling of "atomic fragements" as outlined in draft-gont-6man-ipv6-atomic-fragments to mitigate one class of possible fragmentation-based attacks. MFC after: 5 days --- sys/netinet6/frag6.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/netinet6/frag6.c b/sys/netinet6/frag6.c index 1523133d3db..b2e8e047bd5 100644 --- a/sys/netinet6/frag6.c +++ b/sys/netinet6/frag6.c @@ -221,6 +221,19 @@ frag6_input(struct mbuf **mp, int *offp, int proto) /* offset now points to data portion */ offset += sizeof(struct ip6_frag); + /* + * XXX-BZ RFC XXXX (draft-gont-6man-ipv6-atomic-fragments) + * Handle "atomic" fragments (offset and m bit set to 0) upfront, + * unrelated to any reassembly. Just skip the fragment header. + */ + if ((ip6f->ip6f_offlg & ~IP6F_RESERVED_MASK) == 0) { + /* XXX-BZ we want dedicated counters for this. */ + V_ip6stat.ip6s_reassembled++; + in6_ifstat_inc(dstifp, ifs6_reass_ok); + *offp = offset; + return (ip6f->ip6f_nxt); + } + IP6Q_LOCK(); /*