2005-01-07 02:30:35 +00:00
|
|
|
/*-
|
2017-11-20 19:43:44 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
1999-11-22 02:45:11 +00:00
|
|
|
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
|
|
|
* All rights reserved.
|
2019-10-23 23:01:18 +00:00
|
|
|
* Copyright (c) 2019 Netflix, Inc.
|
1999-11-22 02:45:11 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the project nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
2007-12-10 16:03:40 +00:00
|
|
|
*
|
|
|
|
* $KAME: frag6.c,v 1.33 2002/01/07 11:34:48 kjc Exp $
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
|
|
|
|
2007-12-10 16:03:40 +00:00
|
|
|
#include <sys/cdefs.h>
|
2015-11-06 23:07:43 +00:00
|
|
|
#include "opt_rss.h"
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
#include <sys/param.h>
|
2019-08-03 16:56:44 +00:00
|
|
|
#include <sys/systm.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
#include <sys/domain.h>
|
2016-01-09 09:34:39 +00:00
|
|
|
#include <sys/eventhandler.h>
|
2019-08-02 10:06:54 +00:00
|
|
|
#include <sys/hash.h>
|
2019-04-22 08:32:00 +00:00
|
|
|
#include <sys/kernel.h>
|
2019-08-02 10:06:54 +00:00
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mbuf.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
#include <sys/protosw.h>
|
2019-10-23 23:01:18 +00:00
|
|
|
#include <sys/queue.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
#include <sys/socket.h>
|
2019-08-02 10:29:53 +00:00
|
|
|
#include <sys/sysctl.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
#include <sys/syslog.h>
|
|
|
|
|
|
|
|
#include <net/if.h>
|
2013-10-26 17:58:36 +00:00
|
|
|
#include <net/if_var.h>
|
2023-01-23 15:05:29 +00:00
|
|
|
#include <net/if_private.h>
|
2015-11-06 23:07:43 +00:00
|
|
|
#include <net/netisr.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
#include <net/route.h>
|
Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual
network stack memory allocator. Modify vnet to use the allocator
instead of monolithic global container structures (vinet, ...). This
change solves many binary compatibility problems associated with
VIMAGE, and restores ELF symbols for virtualized global variables.
Each virtualized global variable exists as a "reference copy", and also
once per virtual network stack. Virtualized global variables are
tagged at compile-time, placing the in a special linker set, which is
loaded into a contiguous region of kernel memory. Virtualized global
variables in the base kernel are linked as normal, but those in modules
are copied and relocated to a reserved portion of the kernel's vnet
region with the help of a the kernel linker.
Virtualized global variables exist in per-vnet memory set up when the
network stack instance is created, and are initialized statically from
the reference copy. Run-time access occurs via an accessor macro, which
converts from the current vnet and requested symbol to a per-vnet
address. When "options VIMAGE" is not compiled into the kernel, normal
global ELF symbols will be used instead and indirection is avoided.
This change restores static initialization for network stack global
variables, restores support for non-global symbols and types, eliminates
the need for many subsystem constructors, eliminates large per-subsystem
structures that caused many binary compatibility issues both for
monitoring applications (netstat) and kernel modules, removes the
per-function INIT_VNET_*() macros throughout the stack, eliminates the
need for vnet_symmap ksym(2) munging, and eliminates duplicate
definitions of virtualized globals under VIMAGE_GLOBALS.
Bump __FreeBSD_version and update UPDATING.
Portions submitted by: bz
Reviewed by: bz, zec
Discussed with: gnn, jamie, jeff, jhb, julian, sam
Suggested by: peter
Approved by: re (kensmith)
2009-07-14 22:48:30 +00:00
|
|
|
#include <net/vnet.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_var.h>
|
2000-07-04 16:35:15 +00:00
|
|
|
#include <netinet/ip6.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
#include <netinet6/ip6_var.h>
|
2000-07-04 16:35:15 +00:00
|
|
|
#include <netinet/icmp6.h>
|
2019-08-08 09:42:57 +00:00
|
|
|
#include <netinet/in_systm.h> /* For ECN definitions. */
|
|
|
|
#include <netinet/ip.h> /* For ECN definitions. */
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2019-08-02 10:06:54 +00:00
|
|
|
#ifdef MAC
|
2008-10-26 22:45:18 +00:00
|
|
|
#include <security/mac/mac_framework.h>
|
2019-08-02 10:06:54 +00:00
|
|
|
#endif
|
2008-10-26 22:45:18 +00:00
|
|
|
|
2019-10-23 23:10:12 +00:00
|
|
|
/*
|
|
|
|
* A "big picture" of how IPv6 fragment queues are all linked together.
|
|
|
|
*
|
|
|
|
* struct ip6qbucket ip6qb[...]; hashed buckets
|
|
|
|
* ||||||||
|
|
|
|
* |
|
|
|
|
* +--- TAILQ(struct ip6q, packets) *q6; tailq entries holding
|
|
|
|
* |||||||| fragmented packets
|
|
|
|
* | (1 per original packet)
|
|
|
|
* |
|
|
|
|
* +--- TAILQ(struct ip6asfrag, ip6q_frags) *af6; tailq entries of IPv6
|
|
|
|
* | *ip6af;fragment packets
|
|
|
|
* | for one original packet
|
|
|
|
* + *mbuf
|
|
|
|
*/
|
|
|
|
|
2019-08-08 09:42:57 +00:00
|
|
|
/* Reassembly headers are stored in hash buckets. */
|
2018-08-14 17:32:07 +00:00
|
|
|
#define IP6REASS_NHASH_LOG2 10
|
2018-08-14 17:17:37 +00:00
|
|
|
#define IP6REASS_NHASH (1 << IP6REASS_NHASH_LOG2)
|
|
|
|
#define IP6REASS_HMASK (IP6REASS_NHASH - 1)
|
|
|
|
|
2019-10-23 23:01:18 +00:00
|
|
|
TAILQ_HEAD(ip6qhead, ip6q);
|
2018-08-14 17:17:37 +00:00
|
|
|
struct ip6qbucket {
|
2019-10-23 23:01:18 +00:00
|
|
|
struct ip6qhead packets;
|
2018-08-14 17:17:37 +00:00
|
|
|
struct mtx lock;
|
2018-08-14 17:27:41 +00:00
|
|
|
int count;
|
2018-08-14 17:17:37 +00:00
|
|
|
};
|
|
|
|
|
2019-10-23 23:01:18 +00:00
|
|
|
struct ip6asfrag {
|
|
|
|
TAILQ_ENTRY(ip6asfrag) ip6af_tq;
|
2019-08-08 10:59:54 +00:00
|
|
|
struct mbuf *ip6af_m;
|
2019-10-23 23:10:12 +00:00
|
|
|
int ip6af_offset; /* Offset in ip6af_m to next header. */
|
|
|
|
int ip6af_frglen; /* Fragmentable part length. */
|
|
|
|
int ip6af_off; /* Fragment offset. */
|
|
|
|
bool ip6af_mff; /* More fragment bit in frag off. */
|
2019-08-08 10:59:54 +00:00
|
|
|
};
|
|
|
|
|
2019-08-02 10:54:57 +00:00
|
|
|
static MALLOC_DEFINE(M_FRAG6, "frag6", "IPv6 fragment reassembly header");
|
|
|
|
|
2019-10-21 08:48:47 +00:00
|
|
|
#ifdef VIMAGE
|
|
|
|
/* A flag to indicate if IPv6 fragmentation is initialized. */
|
|
|
|
VNET_DEFINE_STATIC(bool, frag6_on);
|
|
|
|
#define V_frag6_on VNET(frag6_on)
|
|
|
|
#endif
|
|
|
|
|
2019-10-23 20:37:15 +00:00
|
|
|
/* System wide (global) maximum and count of packets in reassembly queues. */
|
2019-08-02 10:29:53 +00:00
|
|
|
static int ip6_maxfrags;
|
2021-08-13 11:28:39 +00:00
|
|
|
static u_int __exclusive_cache_line frag6_nfrags;
|
Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual
network stack memory allocator. Modify vnet to use the allocator
instead of monolithic global container structures (vinet, ...). This
change solves many binary compatibility problems associated with
VIMAGE, and restores ELF symbols for virtualized global variables.
Each virtualized global variable exists as a "reference copy", and also
once per virtual network stack. Virtualized global variables are
tagged at compile-time, placing the in a special linker set, which is
loaded into a contiguous region of kernel memory. Virtualized global
variables in the base kernel are linked as normal, but those in modules
are copied and relocated to a reserved portion of the kernel's vnet
region with the help of a the kernel linker.
Virtualized global variables exist in per-vnet memory set up when the
network stack instance is created, and are initialized statically from
the reference copy. Run-time access occurs via an accessor macro, which
converts from the current vnet and requested symbol to a per-vnet
address. When "options VIMAGE" is not compiled into the kernel, normal
global ELF symbols will be used instead and indirection is avoided.
This change restores static initialization for network stack global
variables, restores support for non-global symbols and types, eliminates
the need for many subsystem constructors, eliminates large per-subsystem
structures that caused many binary compatibility issues both for
monitoring applications (netstat) and kernel modules, removes the
per-function INIT_VNET_*() macros throughout the stack, eliminates the
need for vnet_symmap ksym(2) munging, and eliminates duplicate
definitions of virtualized globals under VIMAGE_GLOBALS.
Bump __FreeBSD_version and update UPDATING.
Portions submitted by: bz
Reviewed by: bz, zec
Discussed with: gnn, jamie, jeff, jhb, julian, sam
Suggested by: peter
Approved by: re (kensmith)
2009-07-14 22:48:30 +00:00
|
|
|
|
2019-08-02 10:29:53 +00:00
|
|
|
/* Maximum and current packets in per-VNET reassembly queue. */
|
|
|
|
VNET_DEFINE_STATIC(int, ip6_maxfragpackets);
|
|
|
|
VNET_DEFINE_STATIC(volatile u_int, frag6_nfragpackets);
|
|
|
|
#define V_ip6_maxfragpackets VNET(ip6_maxfragpackets)
|
2009-07-16 21:13:04 +00:00
|
|
|
#define V_frag6_nfragpackets VNET(frag6_nfragpackets)
|
2019-08-02 10:29:53 +00:00
|
|
|
|
2023-06-01 12:04:49 +00:00
|
|
|
/* Maximum per-VNET reassembly timeout (milliseconds) */
|
|
|
|
VNET_DEFINE_STATIC(u_int, ip6_fraglifetime) = IPV6_DEFFRAGTTL;
|
|
|
|
#define V_ip6_fraglifetime VNET(ip6_fraglifetime)
|
|
|
|
|
2019-08-02 10:29:53 +00:00
|
|
|
/* Maximum per-VNET reassembly queues per bucket and fragments per packet. */
|
|
|
|
VNET_DEFINE_STATIC(int, ip6_maxfragbucketsize);
|
|
|
|
VNET_DEFINE_STATIC(int, ip6_maxfragsperpacket);
|
|
|
|
#define V_ip6_maxfragbucketsize VNET(ip6_maxfragbucketsize)
|
|
|
|
#define V_ip6_maxfragsperpacket VNET(ip6_maxfragsperpacket)
|
|
|
|
|
|
|
|
/* Per-VNET reassembly queue buckets. */
|
2019-08-05 11:01:12 +00:00
|
|
|
VNET_DEFINE_STATIC(struct ip6qbucket, ip6qb[IP6REASS_NHASH]);
|
|
|
|
VNET_DEFINE_STATIC(uint32_t, ip6qb_hashseed);
|
|
|
|
#define V_ip6qb VNET(ip6qb)
|
|
|
|
#define V_ip6qb_hashseed VNET(ip6qb_hashseed)
|
2003-10-22 15:29:42 +00:00
|
|
|
|
2019-08-05 11:01:12 +00:00
|
|
|
#define IP6QB_LOCK(_b) mtx_lock(&V_ip6qb[(_b)].lock)
|
|
|
|
#define IP6QB_TRYLOCK(_b) mtx_trylock(&V_ip6qb[(_b)].lock)
|
|
|
|
#define IP6QB_LOCK_ASSERT(_b) mtx_assert(&V_ip6qb[(_b)].lock, MA_OWNED)
|
|
|
|
#define IP6QB_UNLOCK(_b) mtx_unlock(&V_ip6qb[(_b)].lock)
|
2019-10-23 23:01:18 +00:00
|
|
|
#define IP6QB_HEAD(_b) (&V_ip6qb[(_b)].packets)
|
2003-10-22 15:29:42 +00:00
|
|
|
|
2018-08-14 17:32:07 +00:00
|
|
|
/*
|
|
|
|
* By default, limit the number of IP6 fragments across all reassembly
|
|
|
|
* queues to 1/32 of the total number of mbuf clusters.
|
|
|
|
*
|
|
|
|
* Limit the total number of reassembly queues per VNET to the
|
|
|
|
* IP6 fragment limit, but ensure the limit will not allow any bucket
|
|
|
|
* to grow above 100 items. (The bucket limit is
|
|
|
|
* IP_MAXFRAGPACKETS / (IPREASS_NHASH / 2), so the 50 is the correct
|
|
|
|
* multiplier to reach a 100-item limit.)
|
|
|
|
* The 100-item limit was chosen as brief testing seems to show that
|
|
|
|
* this produces "reasonable" performance on some subset of systems
|
|
|
|
* under DoS attack.
|
|
|
|
*/
|
|
|
|
#define IP6_MAXFRAGS (nmbclusters / 32)
|
|
|
|
#define IP6_MAXFRAGPACKETS (imin(IP6_MAXFRAGS, IP6REASS_NHASH * 50))
|
|
|
|
|
2023-06-01 12:04:49 +00:00
|
|
|
/* Interval between periodic reassembly queue inspections */
|
|
|
|
#define IP6_CALLOUT_INTERVAL_MS 500
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
/*
|
2019-08-02 10:29:53 +00:00
|
|
|
* Sysctls and helper function.
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
2019-08-02 10:29:53 +00:00
|
|
|
SYSCTL_DECL(_net_inet6_ip6);
|
|
|
|
|
2019-10-21 08:36:15 +00:00
|
|
|
SYSCTL_UINT(_net_inet6_ip6, OID_AUTO, frag6_nfrags,
|
2021-08-13 11:28:39 +00:00
|
|
|
CTLFLAG_RD, &frag6_nfrags, 0,
|
2019-10-21 08:36:15 +00:00
|
|
|
"Global number of IPv6 fragments across all reassembly queues.");
|
|
|
|
|
2019-08-02 10:29:53 +00:00
|
|
|
static void
|
2019-08-02 11:05:00 +00:00
|
|
|
frag6_set_bucketsize(void)
|
2018-08-14 17:27:41 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if ((i = V_ip6_maxfragpackets) > 0)
|
|
|
|
V_ip6_maxfragbucketsize = imax(i / (IP6REASS_NHASH / 2), 1);
|
|
|
|
}
|
|
|
|
|
2019-08-02 10:29:53 +00:00
|
|
|
SYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGS, maxfrags,
|
|
|
|
CTLFLAG_RW, &ip6_maxfrags, 0,
|
|
|
|
"Maximum allowed number of outstanding IPv6 packet fragments. "
|
2021-11-30 06:24:44 +00:00
|
|
|
"A value of 0 means no fragmented packets will be accepted, while "
|
2019-08-02 10:29:53 +00:00
|
|
|
"a value of -1 means no limit");
|
|
|
|
|
|
|
|
static int
|
|
|
|
sysctl_ip6_maxfragpackets(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
|
|
|
int error, val;
|
|
|
|
|
|
|
|
val = V_ip6_maxfragpackets;
|
|
|
|
error = sysctl_handle_int(oidp, &val, 0, req);
|
|
|
|
if (error != 0 || !req->newptr)
|
|
|
|
return (error);
|
|
|
|
V_ip6_maxfragpackets = val;
|
|
|
|
frag6_set_bucketsize();
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
SYSCTL_PROC(_net_inet6_ip6, IPV6CTL_MAXFRAGPACKETS, maxfragpackets,
|
2020-02-26 14:26:36 +00:00
|
|
|
CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
|
|
|
|
NULL, 0, sysctl_ip6_maxfragpackets, "I",
|
2019-08-02 10:29:53 +00:00
|
|
|
"Default maximum number of outstanding fragmented IPv6 packets. "
|
|
|
|
"A value of 0 means no fragmented packets will be accepted, while a "
|
|
|
|
"a value of -1 means no limit");
|
2019-10-24 20:00:37 +00:00
|
|
|
SYSCTL_UINT(_net_inet6_ip6, OID_AUTO, frag6_nfragpackets,
|
|
|
|
CTLFLAG_VNET | CTLFLAG_RD,
|
|
|
|
__DEVOLATILE(u_int *, &VNET_NAME(frag6_nfragpackets)), 0,
|
|
|
|
"Per-VNET number of IPv6 fragments across all reassembly queues.");
|
2019-08-02 10:29:53 +00:00
|
|
|
SYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGSPERPACKET, maxfragsperpacket,
|
|
|
|
CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_maxfragsperpacket), 0,
|
|
|
|
"Maximum allowed number of fragments per packet");
|
|
|
|
SYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGBUCKETSIZE, maxfragbucketsize,
|
|
|
|
CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_maxfragbucketsize), 0,
|
|
|
|
"Maximum number of reassembly queues per hash bucket");
|
|
|
|
|
2023-06-01 12:04:49 +00:00
|
|
|
static int
|
|
|
|
frag6_milli_to_callout_ticks(int ms)
|
|
|
|
{
|
|
|
|
return (ms / IP6_CALLOUT_INTERVAL_MS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
frag6_callout_ticks_to_milli(int ms)
|
|
|
|
{
|
|
|
|
return (ms * IP6_CALLOUT_INTERVAL_MS);
|
|
|
|
}
|
|
|
|
|
|
|
|
_Static_assert(sizeof(((struct ip6q *)NULL)->ip6q_ttl) >= 2,
|
|
|
|
"ip6q_ttl field is not large enough");
|
|
|
|
|
|
|
|
static int
|
|
|
|
sysctl_ip6_fraglifetime(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
|
|
|
int error, val;
|
|
|
|
|
|
|
|
val = V_ip6_fraglifetime;
|
|
|
|
error = sysctl_handle_int(oidp, &val, 0, req);
|
|
|
|
if (error != 0 || !req->newptr)
|
|
|
|
return (error);
|
|
|
|
if (val <= 0)
|
|
|
|
val = IPV6_DEFFRAGTTL;
|
|
|
|
|
|
|
|
if (frag6_milli_to_callout_ticks(val) >= 65536)
|
|
|
|
val = frag6_callout_ticks_to_milli(65535);
|
|
|
|
#ifdef VIMAGE
|
|
|
|
if (!IS_DEFAULT_VNET(curvnet)) {
|
|
|
|
CURVNET_SET(vnet0);
|
|
|
|
int host_val = V_ip6_fraglifetime;
|
|
|
|
CURVNET_RESTORE();
|
|
|
|
|
|
|
|
if (val > host_val)
|
|
|
|
val = host_val;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
V_ip6_fraglifetime = val;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
SYSCTL_PROC(_net_inet6_ip6, OID_AUTO, fraglifetime_ms,
|
|
|
|
CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
|
|
|
|
NULL, 0, sysctl_ip6_fraglifetime, "I",
|
|
|
|
"Fragment lifetime, in milliseconds");
|
|
|
|
|
2019-08-02 10:29:53 +00:00
|
|
|
/*
|
2019-08-05 09:49:24 +00:00
|
|
|
* Remove the IPv6 fragmentation header from the mbuf.
|
2019-08-02 10:29:53 +00:00
|
|
|
*/
|
2019-08-05 09:49:24 +00:00
|
|
|
int
|
2019-11-15 21:40:40 +00:00
|
|
|
ip6_deletefraghdr(struct mbuf *m, int offset, int wait __unused)
|
2006-04-21 09:25:40 +00:00
|
|
|
{
|
2019-08-08 10:15:47 +00:00
|
|
|
struct ip6_hdr *ip6;
|
2018-08-14 17:24:26 +00:00
|
|
|
|
2019-11-15 21:40:40 +00:00
|
|
|
KASSERT(m->m_len >= offset + sizeof(struct ip6_frag),
|
|
|
|
("%s: ext headers not contigous in mbuf %p m_len %d >= "
|
|
|
|
"offset %d + %zu\n", __func__, m, m->m_len, offset,
|
|
|
|
sizeof(struct ip6_frag)));
|
2019-08-05 09:49:24 +00:00
|
|
|
|
2019-11-15 21:40:40 +00:00
|
|
|
/* Delete frag6 header. */
|
|
|
|
ip6 = mtod(m, struct ip6_hdr *);
|
|
|
|
bcopy(ip6, (char *)ip6 + sizeof(struct ip6_frag), offset);
|
|
|
|
m->m_data += sizeof(struct ip6_frag);
|
|
|
|
m->m_len -= sizeof(struct ip6_frag);
|
2019-08-05 09:49:24 +00:00
|
|
|
m->m_flags |= M_FRAGMENTED;
|
2019-11-15 21:40:40 +00:00
|
|
|
|
2019-08-05 09:49:24 +00:00
|
|
|
return (0);
|
2006-04-21 09:25:40 +00:00
|
|
|
}
|
|
|
|
|
2019-08-05 09:49:24 +00:00
|
|
|
/*
|
2019-08-08 09:42:57 +00:00
|
|
|
* Free a fragment reassembly header and all associated datagrams.
|
2019-08-05 09:49:24 +00:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
frag6_freef(struct ip6q *q6, uint32_t bucket)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
2019-08-08 10:15:47 +00:00
|
|
|
struct ip6_hdr *ip6;
|
2019-10-23 23:01:18 +00:00
|
|
|
struct ip6asfrag *af6;
|
2019-08-08 10:15:47 +00:00
|
|
|
struct mbuf *m;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2019-08-05 11:01:12 +00:00
|
|
|
IP6QB_LOCK_ASSERT(bucket);
|
2003-10-22 15:32:56 +00:00
|
|
|
|
2019-10-23 23:01:18 +00:00
|
|
|
while ((af6 = TAILQ_FIRST(&q6->ip6q_frags)) != NULL) {
|
2019-10-24 07:53:10 +00:00
|
|
|
m = af6->ip6af_m;
|
2019-10-23 23:01:18 +00:00
|
|
|
TAILQ_REMOVE(&q6->ip6q_frags, af6, ip6af_tq);
|
2019-08-05 09:49:24 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return ICMP time exceeded error for the 1st fragment.
|
|
|
|
* Just free other fragments.
|
|
|
|
*/
|
2019-10-16 09:11:49 +00:00
|
|
|
if (af6->ip6af_off == 0 && m->m_pkthdr.rcvif != NULL) {
|
2019-08-08 09:42:57 +00:00
|
|
|
/* Adjust pointer. */
|
2019-08-05 09:49:24 +00:00
|
|
|
ip6 = mtod(m, struct ip6_hdr *);
|
|
|
|
|
2019-08-08 09:42:57 +00:00
|
|
|
/* Restore source and destination addresses. */
|
2019-08-05 09:49:24 +00:00
|
|
|
ip6->ip6_src = q6->ip6q_src;
|
|
|
|
ip6->ip6_dst = q6->ip6q_dst;
|
|
|
|
|
|
|
|
icmp6_error(m, ICMP6_TIME_EXCEEDED,
|
2019-08-08 09:42:57 +00:00
|
|
|
ICMP6_TIME_EXCEED_REASSEMBLY, 0);
|
2019-08-05 09:49:24 +00:00
|
|
|
} else
|
|
|
|
m_freem(m);
|
2019-08-08 09:42:57 +00:00
|
|
|
|
2019-08-05 09:49:24 +00:00
|
|
|
free(af6, M_FRAG6);
|
|
|
|
}
|
2019-10-23 23:01:18 +00:00
|
|
|
|
|
|
|
TAILQ_REMOVE(IP6QB_HEAD(bucket), q6, ip6q_tq);
|
|
|
|
V_ip6qb[bucket].count--;
|
2019-08-05 09:49:24 +00:00
|
|
|
atomic_subtract_int(&frag6_nfrags, q6->ip6q_nfrag);
|
|
|
|
#ifdef MAC
|
|
|
|
mac_ip6q_destroy(q6);
|
|
|
|
#endif
|
|
|
|
free(q6, M_FRAG6);
|
|
|
|
atomic_subtract_int(&V_frag6_nfragpackets, 1);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
2019-10-16 09:11:49 +00:00
|
|
|
/*
|
|
|
|
* Drain off all datagram fragments belonging to
|
|
|
|
* the given network interface.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
frag6_cleanup(void *arg __unused, struct ifnet *ifp)
|
|
|
|
{
|
2019-10-23 23:01:18 +00:00
|
|
|
struct ip6qhead *head;
|
|
|
|
struct ip6q *q6;
|
2019-10-16 09:11:49 +00:00
|
|
|
struct ip6asfrag *af6;
|
2019-10-23 23:01:18 +00:00
|
|
|
uint32_t bucket;
|
2019-10-16 09:11:49 +00:00
|
|
|
|
|
|
|
KASSERT(ifp != NULL, ("%s: ifp is NULL", __func__));
|
|
|
|
|
2019-10-25 18:54:06 +00:00
|
|
|
CURVNET_SET_QUIET(ifp->if_vnet);
|
2019-10-21 08:48:47 +00:00
|
|
|
#ifdef VIMAGE
|
|
|
|
/*
|
|
|
|
* Skip processing if IPv6 reassembly is not initialised or
|
|
|
|
* torn down by frag6_destroy().
|
|
|
|
*/
|
2019-10-25 18:54:06 +00:00
|
|
|
if (!V_frag6_on) {
|
|
|
|
CURVNET_RESTORE();
|
2019-10-21 08:48:47 +00:00
|
|
|
return;
|
2019-10-25 18:54:06 +00:00
|
|
|
}
|
2019-10-21 08:48:47 +00:00
|
|
|
#endif
|
|
|
|
|
2019-10-23 23:01:18 +00:00
|
|
|
for (bucket = 0; bucket < IP6REASS_NHASH; bucket++) {
|
|
|
|
IP6QB_LOCK(bucket);
|
|
|
|
head = IP6QB_HEAD(bucket);
|
2019-10-16 09:11:49 +00:00
|
|
|
/* Scan fragment list. */
|
2019-10-23 23:01:18 +00:00
|
|
|
TAILQ_FOREACH(q6, head, ip6q_tq) {
|
|
|
|
TAILQ_FOREACH(af6, &q6->ip6q_frags, ip6af_tq) {
|
2019-10-23 23:10:12 +00:00
|
|
|
/* Clear no longer valid rcvif pointer. */
|
2019-10-24 07:53:10 +00:00
|
|
|
if (af6->ip6af_m->m_pkthdr.rcvif == ifp)
|
|
|
|
af6->ip6af_m->m_pkthdr.rcvif = NULL;
|
2019-10-16 09:11:49 +00:00
|
|
|
}
|
|
|
|
}
|
2019-10-23 23:01:18 +00:00
|
|
|
IP6QB_UNLOCK(bucket);
|
2019-10-16 09:11:49 +00:00
|
|
|
}
|
|
|
|
CURVNET_RESTORE();
|
|
|
|
}
|
|
|
|
EVENTHANDLER_DEFINE(ifnet_departure_event, frag6_cleanup, NULL, 0);
|
|
|
|
|
2000-07-04 16:35:15 +00:00
|
|
|
/*
|
2019-08-08 09:42:57 +00:00
|
|
|
* Like in RFC2460, in RFC8200, fragment and reassembly rules do not agree with
|
|
|
|
* each other, in terms of next header field handling in fragment header.
|
2000-07-04 16:35:15 +00:00
|
|
|
* While the sender will use the same value for all of the fragmented packets,
|
2019-08-08 09:42:57 +00:00
|
|
|
* receiver is suggested not to check for consistency.
|
2000-07-04 16:35:15 +00:00
|
|
|
*
|
2019-08-08 09:42:57 +00:00
|
|
|
* Fragment rules (p18,p19):
|
|
|
|
* (2) A Fragment header containing:
|
|
|
|
* The Next Header value that identifies the first header
|
|
|
|
* after the Per-Fragment headers of the original packet.
|
2000-07-04 16:35:15 +00:00
|
|
|
* -> next header field is same for all fragments
|
|
|
|
*
|
2019-08-08 09:42:57 +00:00
|
|
|
* Reassembly rule (p20):
|
|
|
|
* The Next Header field of the last header of the Per-Fragment
|
|
|
|
* headers is obtained from the Next Header field of the first
|
2000-07-04 16:35:15 +00:00
|
|
|
* fragment's Fragment header.
|
|
|
|
* -> should grab it from the first fragment only
|
|
|
|
*
|
2016-05-03 18:05:43 +00:00
|
|
|
* The following note also contradicts with fragment rule - no one is going to
|
2000-07-04 16:35:15 +00:00
|
|
|
* send different fragment with different next header field.
|
|
|
|
*
|
2019-08-08 09:42:57 +00:00
|
|
|
* Additional note (p22) [not an error]:
|
2000-07-04 16:35:15 +00:00
|
|
|
* The Next Header values in the Fragment headers of different
|
|
|
|
* fragments of the same original packet may differ. Only the value
|
|
|
|
* from the Offset zero fragment packet is used for reassembly.
|
|
|
|
* -> should grab it from the first fragment only
|
|
|
|
*
|
|
|
|
* There is no explicit reason given in the RFC. Historical reason maybe?
|
|
|
|
*/
|
1999-11-22 02:45:11 +00:00
|
|
|
/*
|
2019-08-08 09:42:57 +00:00
|
|
|
* Fragment input.
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
|
|
|
int
|
2007-07-05 16:23:49 +00:00
|
|
|
frag6_input(struct mbuf **mp, int *offp, int proto)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
2019-10-23 23:01:18 +00:00
|
|
|
struct mbuf *m, *t;
|
1999-11-22 02:45:11 +00:00
|
|
|
struct ip6_hdr *ip6;
|
|
|
|
struct ip6_frag *ip6f;
|
2019-10-23 23:01:18 +00:00
|
|
|
struct ip6qhead *head;
|
|
|
|
struct ip6q *q6;
|
|
|
|
struct ip6asfrag *af6, *ip6af, *af6tmp;
|
|
|
|
struct in6_ifaddr *ia6;
|
|
|
|
struct ifnet *dstifp, *srcifp;
|
2018-08-31 08:37:15 +00:00
|
|
|
uint32_t hashkey[(sizeof(struct in6_addr) * 2 +
|
|
|
|
sizeof(ip6f->ip6f_ident)) / sizeof(uint32_t)];
|
2019-08-05 11:01:12 +00:00
|
|
|
uint32_t bucket, *hashkeyp;
|
2019-08-08 10:15:47 +00:00
|
|
|
int fragoff, frgpartlen; /* Must be larger than uint16_t. */
|
|
|
|
int nxt, offset, plen;
|
|
|
|
uint8_t ecn, ecn0;
|
|
|
|
bool only_frag;
|
2015-11-06 23:07:43 +00:00
|
|
|
#ifdef RSS
|
|
|
|
struct ip6_direct_ctx *ip6dc;
|
2019-08-08 10:15:47 +00:00
|
|
|
struct m_tag *mtag;
|
2015-11-06 23:07:43 +00:00
|
|
|
#endif
|
|
|
|
|
2019-08-08 10:15:47 +00:00
|
|
|
m = *mp;
|
|
|
|
offset = *offp;
|
|
|
|
|
2019-11-08 14:36:44 +00:00
|
|
|
M_ASSERTPKTHDR(m);
|
|
|
|
|
2019-12-01 00:22:04 +00:00
|
|
|
if (m->m_len < offset + sizeof(struct ip6_frag)) {
|
|
|
|
m = m_pullup(m, offset + sizeof(struct ip6_frag));
|
|
|
|
if (m == NULL) {
|
|
|
|
IP6STAT_INC(ip6s_exthdrtoolong);
|
|
|
|
*mp = NULL;
|
|
|
|
return (IPPROTO_DONE);
|
|
|
|
}
|
2019-11-15 21:40:40 +00:00
|
|
|
}
|
|
|
|
ip6 = mtod(m, struct ip6_hdr *);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
dstifp = NULL;
|
2019-08-08 09:42:57 +00:00
|
|
|
/* Find the destination interface of the packet. */
|
2021-02-15 21:59:21 +00:00
|
|
|
ia6 = in6ifa_ifwithaddr(&ip6->ip6_dst, 0 /* XXX */, false);
|
|
|
|
if (ia6 != NULL)
|
2019-08-08 10:15:47 +00:00
|
|
|
dstifp = ia6->ia_ifp;
|
2019-08-08 09:42:57 +00:00
|
|
|
|
|
|
|
/* Jumbo payload cannot contain a fragment header. */
|
1999-11-22 02:45:11 +00:00
|
|
|
if (ip6->ip6_plen == 0) {
|
|
|
|
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER, offset);
|
|
|
|
in6_ifstat_inc(dstifp, ifs6_reass_fail);
|
2019-11-12 15:46:28 +00:00
|
|
|
*mp = NULL;
|
2019-08-08 10:15:47 +00:00
|
|
|
return (IPPROTO_DONE);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2019-08-08 09:42:57 +00:00
|
|
|
* Check whether fragment packet's fragment length is a
|
|
|
|
* multiple of 8 octets (unless it is the last one).
|
1999-11-22 02:45:11 +00:00
|
|
|
* sizeof(struct ip6_frag) == 8
|
|
|
|
* sizeof(struct ip6_hdr) = 40
|
|
|
|
*/
|
2019-11-15 21:40:40 +00:00
|
|
|
ip6f = (struct ip6_frag *)((caddr_t)ip6 + offset);
|
1999-11-22 02:45:11 +00:00
|
|
|
if ((ip6f->ip6f_offlg & IP6F_MORE_FRAG) &&
|
|
|
|
(((ntohs(ip6->ip6_plen) - offset) & 0x7) != 0)) {
|
2003-10-07 17:46:18 +00:00
|
|
|
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
|
|
|
|
offsetof(struct ip6_hdr, ip6_plen));
|
1999-11-22 02:45:11 +00:00
|
|
|
in6_ifstat_inc(dstifp, ifs6_reass_fail);
|
2019-11-12 15:46:28 +00:00
|
|
|
*mp = NULL;
|
2019-08-08 10:15:47 +00:00
|
|
|
return (IPPROTO_DONE);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
2013-04-09 07:11:22 +00:00
|
|
|
IP6STAT_INC(ip6s_fragments);
|
1999-11-22 02:45:11 +00:00
|
|
|
in6_ifstat_inc(dstifp, ifs6_reass_reqd);
|
2003-10-07 17:46:18 +00:00
|
|
|
|
2012-07-08 15:30:24 +00:00
|
|
|
/*
|
2019-04-19 17:06:43 +00:00
|
|
|
* Handle "atomic" fragments (offset and m bit set to 0) upfront,
|
2019-11-08 14:36:44 +00:00
|
|
|
* unrelated to any reassembly. We need to remove the frag hdr
|
|
|
|
* which is ugly.
|
2019-08-08 09:42:57 +00:00
|
|
|
* See RFC 6946 and section 4.5 of RFC 8200.
|
2012-07-08 15:30:24 +00:00
|
|
|
*/
|
|
|
|
if ((ip6f->ip6f_offlg & ~IP6F_RESERVED_MASK) == 0) {
|
2019-04-19 17:06:43 +00:00
|
|
|
IP6STAT_INC(ip6s_atomicfrags);
|
2019-11-08 14:36:44 +00:00
|
|
|
nxt = ip6f->ip6f_nxt;
|
|
|
|
/*
|
|
|
|
* Set nxt(-hdr field value) to the original value.
|
|
|
|
* We cannot just set ip6->ip6_nxt as there might be
|
|
|
|
* an unfragmentable part with extension headers and
|
|
|
|
* we must update the last one.
|
|
|
|
*/
|
|
|
|
m_copyback(m, ip6_get_prevhdr(m, offset), sizeof(uint8_t),
|
|
|
|
(caddr_t)&nxt);
|
|
|
|
ip6->ip6_plen = htons(ntohs(ip6->ip6_plen) -
|
|
|
|
sizeof(struct ip6_frag));
|
|
|
|
if (ip6_deletefraghdr(m, offset, M_NOWAIT) != 0)
|
|
|
|
goto dropfrag2;
|
|
|
|
m->m_pkthdr.len -= sizeof(struct ip6_frag);
|
2012-07-08 15:30:24 +00:00
|
|
|
in6_ifstat_inc(dstifp, ifs6_reass_ok);
|
2019-11-08 14:36:44 +00:00
|
|
|
*mp = m;
|
|
|
|
return (nxt);
|
2012-07-08 15:30:24 +00:00
|
|
|
}
|
|
|
|
|
2019-11-08 14:36:44 +00:00
|
|
|
/* Offset now points to data portion. */
|
|
|
|
offset += sizeof(struct ip6_frag);
|
|
|
|
|
2018-08-14 17:29:22 +00:00
|
|
|
/* Get fragment length and discard 0-byte fragments. */
|
|
|
|
frgpartlen = sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) - offset;
|
|
|
|
if (frgpartlen == 0) {
|
|
|
|
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
|
|
|
|
offsetof(struct ip6_hdr, ip6_plen));
|
|
|
|
in6_ifstat_inc(dstifp, ifs6_reass_fail);
|
|
|
|
IP6STAT_INC(ip6s_fragdropped);
|
2019-11-12 15:46:28 +00:00
|
|
|
*mp = NULL;
|
2019-08-08 10:15:47 +00:00
|
|
|
return (IPPROTO_DONE);
|
2018-08-14 17:29:22 +00:00
|
|
|
}
|
|
|
|
|
2019-10-24 11:58:24 +00:00
|
|
|
/*
|
|
|
|
* Enforce upper bound on number of fragments for the entire system.
|
|
|
|
* If maxfrag is 0, never accept fragments.
|
|
|
|
* If maxfrag is -1, accept all fragments without limitation.
|
|
|
|
*/
|
|
|
|
if (ip6_maxfrags < 0)
|
|
|
|
;
|
|
|
|
else if (atomic_load_int(&frag6_nfrags) >= (u_int)ip6_maxfrags)
|
|
|
|
goto dropfrag2;
|
|
|
|
|
2019-10-24 12:16:15 +00:00
|
|
|
/*
|
|
|
|
* Validate that a full header chain to the ULP is present in the
|
|
|
|
* packet containing the first fragment as per RFC RFC7112 and
|
|
|
|
* RFC 8200 pages 18,19:
|
|
|
|
* The first fragment packet is composed of:
|
|
|
|
* (3) Extension headers, if any, and the Upper-Layer header. These
|
|
|
|
* headers must be in the first fragment. ...
|
|
|
|
*/
|
|
|
|
fragoff = ntohs(ip6f->ip6f_offlg & IP6F_OFF_MASK);
|
|
|
|
/* XXX TODO. thj has D16851 open for this. */
|
|
|
|
/* Send ICMPv6 4,3 in case of violation. */
|
|
|
|
|
2019-10-24 08:15:40 +00:00
|
|
|
/* Store receive network interface pointer for later. */
|
|
|
|
srcifp = m->m_pkthdr.rcvif;
|
|
|
|
|
2019-08-08 09:42:57 +00:00
|
|
|
/* Generate a hash value for fragment bucket selection. */
|
2018-08-14 17:17:37 +00:00
|
|
|
hashkeyp = hashkey;
|
|
|
|
memcpy(hashkeyp, &ip6->ip6_src, sizeof(struct in6_addr));
|
|
|
|
hashkeyp += sizeof(struct in6_addr) / sizeof(*hashkeyp);
|
|
|
|
memcpy(hashkeyp, &ip6->ip6_dst, sizeof(struct in6_addr));
|
|
|
|
hashkeyp += sizeof(struct in6_addr) / sizeof(*hashkeyp);
|
|
|
|
*hashkeyp = ip6f->ip6f_ident;
|
2019-08-05 11:01:12 +00:00
|
|
|
bucket = jenkins_hash32(hashkey, nitems(hashkey), V_ip6qb_hashseed);
|
|
|
|
bucket &= IP6REASS_HMASK;
|
|
|
|
IP6QB_LOCK(bucket);
|
2019-10-23 23:01:18 +00:00
|
|
|
head = IP6QB_HEAD(bucket);
|
2003-10-22 15:29:42 +00:00
|
|
|
|
2019-10-23 23:01:18 +00:00
|
|
|
TAILQ_FOREACH(q6, head, ip6q_tq)
|
1999-11-22 02:45:11 +00:00
|
|
|
if (ip6f->ip6f_ident == q6->ip6q_ident &&
|
|
|
|
IN6_ARE_ADDR_EQUAL(&ip6->ip6_src, &q6->ip6q_src) &&
|
2008-10-26 22:45:18 +00:00
|
|
|
IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &q6->ip6q_dst)
|
|
|
|
#ifdef MAC
|
|
|
|
&& mac_ip6q_match(m, q6)
|
|
|
|
#endif
|
|
|
|
)
|
1999-11-22 02:45:11 +00:00
|
|
|
break;
|
|
|
|
|
2019-08-08 10:15:47 +00:00
|
|
|
only_frag = false;
|
2019-10-23 23:01:18 +00:00
|
|
|
if (q6 == NULL) {
|
2019-08-08 10:15:47 +00:00
|
|
|
/* A first fragment to arrive creates a reassembly queue. */
|
|
|
|
only_frag = true;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Enforce upper bound on number of fragmented packets
|
|
|
|
* for which we attempt reassembly;
|
2003-10-22 15:29:42 +00:00
|
|
|
* If maxfragpackets is 0, never accept fragments.
|
|
|
|
* If maxfragpackets is -1, accept all fragments without
|
|
|
|
* limitation.
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
if (V_ip6_maxfragpackets < 0)
|
2001-06-11 12:39:29 +00:00
|
|
|
;
|
2019-08-05 11:01:12 +00:00
|
|
|
else if (V_ip6qb[bucket].count >= V_ip6_maxfragbucketsize ||
|
2018-08-14 17:27:41 +00:00
|
|
|
atomic_load_int(&V_frag6_nfragpackets) >=
|
2018-08-14 17:17:37 +00:00
|
|
|
(u_int)V_ip6_maxfragpackets)
|
2001-06-11 12:39:29 +00:00
|
|
|
goto dropfrag;
|
2019-08-08 09:42:57 +00:00
|
|
|
|
|
|
|
/* Allocate IPv6 fragement packet queue entry. */
|
2019-08-02 10:54:57 +00:00
|
|
|
q6 = (struct ip6q *)malloc(sizeof(struct ip6q), M_FRAG6,
|
|
|
|
M_NOWAIT | M_ZERO);
|
1999-11-22 02:45:11 +00:00
|
|
|
if (q6 == NULL)
|
|
|
|
goto dropfrag;
|
2008-10-26 22:45:18 +00:00
|
|
|
#ifdef MAC
|
|
|
|
if (mac_ip6q_init(q6, M_NOWAIT) != 0) {
|
2019-08-02 10:54:57 +00:00
|
|
|
free(q6, M_FRAG6);
|
2008-10-26 22:45:18 +00:00
|
|
|
goto dropfrag;
|
|
|
|
}
|
|
|
|
mac_ip6q_create(m, q6);
|
|
|
|
#endif
|
2019-10-25 16:29:09 +00:00
|
|
|
atomic_add_int(&V_frag6_nfragpackets, 1);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2019-08-08 09:42:57 +00:00
|
|
|
/* ip6q_nxt will be filled afterwards, from 1st fragment. */
|
2019-10-23 23:01:18 +00:00
|
|
|
TAILQ_INIT(&q6->ip6q_frags);
|
1999-11-22 02:45:11 +00:00
|
|
|
q6->ip6q_ident = ip6f->ip6f_ident;
|
2023-06-01 12:04:49 +00:00
|
|
|
q6->ip6q_ttl = frag6_milli_to_callout_ticks(V_ip6_fraglifetime);
|
1999-11-22 02:45:11 +00:00
|
|
|
q6->ip6q_src = ip6->ip6_src;
|
|
|
|
q6->ip6q_dst = ip6->ip6_dst;
|
2021-03-04 10:26:40 +00:00
|
|
|
q6->ip6q_ecn = IPV6_ECN(ip6);
|
1999-11-22 02:45:11 +00:00
|
|
|
q6->ip6q_unfrglen = -1; /* The 1st fragment has not arrived. */
|
2003-10-22 15:29:42 +00:00
|
|
|
|
2019-10-23 23:01:18 +00:00
|
|
|
/* Add the fragemented packet to the bucket. */
|
|
|
|
TAILQ_INSERT_HEAD(head, q6, ip6q_tq);
|
|
|
|
V_ip6qb[bucket].count++;
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2019-08-08 09:42:57 +00:00
|
|
|
* If it is the 1st fragment, record the length of the
|
1999-11-22 02:45:11 +00:00
|
|
|
* unfragmentable part and the next header of the fragment header.
|
2019-10-24 22:07:45 +00:00
|
|
|
* Assume the first 1st fragement to arrive will be correct.
|
|
|
|
* We do not have any duplicate checks here yet so another packet
|
|
|
|
* with fragoff == 0 could come and overwrite the ip6q_unfrglen
|
|
|
|
* and worse, the next header, at any time.
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
2019-10-24 22:07:45 +00:00
|
|
|
if (fragoff == 0 && q6->ip6q_unfrglen == -1) {
|
2003-10-07 17:46:18 +00:00
|
|
|
q6->ip6q_unfrglen = offset - sizeof(struct ip6_hdr) -
|
|
|
|
sizeof(struct ip6_frag);
|
1999-11-22 02:45:11 +00:00
|
|
|
q6->ip6q_nxt = ip6f->ip6f_nxt;
|
2019-10-24 22:07:45 +00:00
|
|
|
/* XXX ECN? */
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check that the reassembled packet would not exceed 65535 bytes
|
|
|
|
* in size.
|
|
|
|
* If it would exceed, discard the fragment and return an ICMP error.
|
|
|
|
*/
|
|
|
|
if (q6->ip6q_unfrglen >= 0) {
|
|
|
|
/* The 1st fragment has already arrived. */
|
|
|
|
if (q6->ip6q_unfrglen + fragoff + frgpartlen > IPV6_MAXPACKET) {
|
2019-10-24 19:47:32 +00:00
|
|
|
if (only_frag) {
|
|
|
|
TAILQ_REMOVE(head, q6, ip6q_tq);
|
|
|
|
V_ip6qb[bucket].count--;
|
|
|
|
atomic_subtract_int(&V_frag6_nfragpackets, 1);
|
|
|
|
#ifdef MAC
|
|
|
|
mac_ip6q_destroy(q6);
|
|
|
|
#endif
|
|
|
|
free(q6, M_FRAG6);
|
|
|
|
}
|
|
|
|
IP6QB_UNLOCK(bucket);
|
1999-11-22 02:45:11 +00:00
|
|
|
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
|
2003-10-07 17:46:18 +00:00
|
|
|
offset - sizeof(struct ip6_frag) +
|
|
|
|
offsetof(struct ip6_frag, ip6f_offlg));
|
2019-11-12 15:46:28 +00:00
|
|
|
*mp = NULL;
|
2003-10-06 14:02:09 +00:00
|
|
|
return (IPPROTO_DONE);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2003-10-07 17:46:18 +00:00
|
|
|
} else if (fragoff + frgpartlen > IPV6_MAXPACKET) {
|
2019-10-24 19:47:32 +00:00
|
|
|
if (only_frag) {
|
|
|
|
TAILQ_REMOVE(head, q6, ip6q_tq);
|
|
|
|
V_ip6qb[bucket].count--;
|
|
|
|
atomic_subtract_int(&V_frag6_nfragpackets, 1);
|
|
|
|
#ifdef MAC
|
|
|
|
mac_ip6q_destroy(q6);
|
|
|
|
#endif
|
|
|
|
free(q6, M_FRAG6);
|
|
|
|
}
|
|
|
|
IP6QB_UNLOCK(bucket);
|
1999-11-22 02:45:11 +00:00
|
|
|
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
|
2003-10-07 17:46:18 +00:00
|
|
|
offset - sizeof(struct ip6_frag) +
|
|
|
|
offsetof(struct ip6_frag, ip6f_offlg));
|
2019-11-12 15:46:28 +00:00
|
|
|
*mp = NULL;
|
2003-10-06 14:02:09 +00:00
|
|
|
return (IPPROTO_DONE);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2019-10-23 23:10:12 +00:00
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
/*
|
2019-08-08 09:42:57 +00:00
|
|
|
* If it is the first fragment, do the above check for each
|
1999-11-22 02:45:11 +00:00
|
|
|
* fragment already stored in the reassembly queue.
|
|
|
|
*/
|
2019-10-24 19:57:18 +00:00
|
|
|
if (fragoff == 0 && !only_frag) {
|
2019-10-23 23:01:18 +00:00
|
|
|
TAILQ_FOREACH_SAFE(af6, &q6->ip6q_frags, ip6af_tq, af6tmp) {
|
2019-10-24 19:57:18 +00:00
|
|
|
if (q6->ip6q_unfrglen + af6->ip6af_off +
|
|
|
|
af6->ip6af_frglen > IPV6_MAXPACKET) {
|
1999-11-22 02:45:11 +00:00
|
|
|
struct ip6_hdr *ip6err;
|
2019-08-08 10:15:47 +00:00
|
|
|
struct mbuf *merr;
|
|
|
|
int erroff;
|
|
|
|
|
2019-10-24 07:53:10 +00:00
|
|
|
merr = af6->ip6af_m;
|
2019-08-08 10:15:47 +00:00
|
|
|
erroff = af6->ip6af_offset;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2019-08-08 09:42:57 +00:00
|
|
|
/* Dequeue the fragment. */
|
2019-10-23 23:01:18 +00:00
|
|
|
TAILQ_REMOVE(&q6->ip6q_frags, af6, ip6af_tq);
|
2019-10-24 19:57:18 +00:00
|
|
|
q6->ip6q_nfrag--;
|
|
|
|
atomic_subtract_int(&frag6_nfrags, 1);
|
2019-08-02 10:54:57 +00:00
|
|
|
free(af6, M_FRAG6);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2019-10-16 09:11:49 +00:00
|
|
|
/* Set a valid receive interface pointer. */
|
|
|
|
merr->m_pkthdr.rcvif = srcifp;
|
2019-10-23 20:37:15 +00:00
|
|
|
|
2019-08-08 09:42:57 +00:00
|
|
|
/* Adjust pointer. */
|
1999-11-22 02:45:11 +00:00
|
|
|
ip6err = mtod(merr, struct ip6_hdr *);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restore source and destination addresses
|
|
|
|
* in the erroneous IPv6 header.
|
|
|
|
*/
|
|
|
|
ip6err->ip6_src = q6->ip6q_src;
|
|
|
|
ip6err->ip6_dst = q6->ip6q_dst;
|
|
|
|
|
|
|
|
icmp6_error(merr, ICMP6_PARAM_PROB,
|
2003-10-07 17:46:18 +00:00
|
|
|
ICMP6_PARAMPROB_HEADER,
|
|
|
|
erroff - sizeof(struct ip6_frag) +
|
|
|
|
offsetof(struct ip6_frag, ip6f_offlg));
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-08 09:42:57 +00:00
|
|
|
/* Allocate an IPv6 fragement queue entry for this fragmented part. */
|
2019-08-02 10:54:57 +00:00
|
|
|
ip6af = (struct ip6asfrag *)malloc(sizeof(struct ip6asfrag), M_FRAG6,
|
|
|
|
M_NOWAIT | M_ZERO);
|
2000-07-04 16:35:15 +00:00
|
|
|
if (ip6af == NULL)
|
|
|
|
goto dropfrag;
|
2019-10-23 23:01:18 +00:00
|
|
|
ip6af->ip6af_mff = (ip6f->ip6f_offlg & IP6F_MORE_FRAG) ? true : false;
|
1999-11-22 02:45:11 +00:00
|
|
|
ip6af->ip6af_off = fragoff;
|
|
|
|
ip6af->ip6af_frglen = frgpartlen;
|
|
|
|
ip6af->ip6af_offset = offset;
|
2019-10-24 07:53:10 +00:00
|
|
|
ip6af->ip6af_m = m;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2019-08-08 10:15:47 +00:00
|
|
|
if (only_frag) {
|
2019-10-23 23:01:18 +00:00
|
|
|
/*
|
|
|
|
* Do a manual insert rather than a hard-to-understand cast
|
|
|
|
* to a different type relying on data structure order to work.
|
|
|
|
*/
|
|
|
|
TAILQ_INSERT_HEAD(&q6->ip6q_frags, ip6af, ip6af_tq);
|
|
|
|
goto postinsert;
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 09:42:57 +00:00
|
|
|
/* Do duplicate, condition, and boundry checks. */
|
2003-10-29 15:07:04 +00:00
|
|
|
/*
|
|
|
|
* Handle ECN by comparing this segment with the first one;
|
|
|
|
* if CE is set, do not lose CE.
|
2019-08-08 09:42:57 +00:00
|
|
|
* Drop if CE and not-ECT are mixed for the same packet.
|
2003-10-29 15:07:04 +00:00
|
|
|
*/
|
2021-03-04 10:26:40 +00:00
|
|
|
ecn = IPV6_ECN(ip6);
|
2007-06-04 06:06:35 +00:00
|
|
|
ecn0 = q6->ip6q_ecn;
|
2003-10-29 15:07:04 +00:00
|
|
|
if (ecn == IPTOS_ECN_CE) {
|
|
|
|
if (ecn0 == IPTOS_ECN_NOTECT) {
|
2019-08-02 10:54:57 +00:00
|
|
|
free(ip6af, M_FRAG6);
|
2003-10-29 15:07:04 +00:00
|
|
|
goto dropfrag;
|
|
|
|
}
|
|
|
|
if (ecn0 != IPTOS_ECN_CE)
|
2007-06-04 06:06:35 +00:00
|
|
|
q6->ip6q_ecn = IPTOS_ECN_CE;
|
2003-10-29 15:07:04 +00:00
|
|
|
}
|
|
|
|
if (ecn == IPTOS_ECN_NOTECT && ecn0 != IPTOS_ECN_NOTECT) {
|
2019-08-02 10:54:57 +00:00
|
|
|
free(ip6af, M_FRAG6);
|
2003-10-29 15:07:04 +00:00
|
|
|
goto dropfrag;
|
|
|
|
}
|
|
|
|
|
2019-08-08 09:42:57 +00:00
|
|
|
/* Find a fragmented part which begins after this one does. */
|
2019-10-23 23:01:18 +00:00
|
|
|
TAILQ_FOREACH(af6, &q6->ip6q_frags, ip6af_tq)
|
1999-11-22 02:45:11 +00:00
|
|
|
if (af6->ip6af_off > ip6af->ip6af_off)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the incoming framgent overlaps some existing fragments in
|
2019-08-08 09:42:57 +00:00
|
|
|
* the reassembly queue, drop both the new fragment and the
|
|
|
|
* entire reassembly queue. However, if the new fragment
|
|
|
|
* is an exact duplicate of an existing fragment, only silently
|
|
|
|
* drop the existing fragment and leave the fragmentation queue
|
|
|
|
* unchanged, as allowed by the RFC. (RFC 8200, 4.5)
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
2019-10-23 23:01:18 +00:00
|
|
|
if (af6 != NULL)
|
|
|
|
af6tmp = TAILQ_PREV(af6, ip6fraghead, ip6af_tq);
|
|
|
|
else
|
|
|
|
af6tmp = TAILQ_LAST(&q6->ip6q_frags, ip6fraghead);
|
|
|
|
if (af6tmp != NULL) {
|
|
|
|
if (af6tmp->ip6af_off + af6tmp->ip6af_frglen -
|
2019-08-08 10:15:47 +00:00
|
|
|
ip6af->ip6af_off > 0) {
|
2019-10-24 20:22:52 +00:00
|
|
|
if (af6tmp->ip6af_off != ip6af->ip6af_off ||
|
|
|
|
af6tmp->ip6af_frglen != ip6af->ip6af_frglen)
|
|
|
|
frag6_freef(q6, bucket);
|
2019-08-02 10:54:57 +00:00
|
|
|
free(ip6af, M_FRAG6);
|
1999-11-22 02:45:11 +00:00
|
|
|
goto dropfrag;
|
|
|
|
}
|
|
|
|
}
|
2019-10-23 23:01:18 +00:00
|
|
|
if (af6 != NULL) {
|
2019-08-08 10:15:47 +00:00
|
|
|
if (ip6af->ip6af_off + ip6af->ip6af_frglen -
|
|
|
|
af6->ip6af_off > 0) {
|
2019-10-24 20:22:52 +00:00
|
|
|
if (af6->ip6af_off != ip6af->ip6af_off ||
|
|
|
|
af6->ip6af_frglen != ip6af->ip6af_frglen)
|
|
|
|
frag6_freef(q6, bucket);
|
2019-08-02 10:54:57 +00:00
|
|
|
free(ip6af, M_FRAG6);
|
1999-11-22 02:45:11 +00:00
|
|
|
goto dropfrag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-26 22:45:18 +00:00
|
|
|
#ifdef MAC
|
2019-10-23 23:01:18 +00:00
|
|
|
mac_ip6q_update(m, q6);
|
2008-10-26 22:45:18 +00:00
|
|
|
#endif
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
/*
|
2019-08-08 09:42:57 +00:00
|
|
|
* Stick new segment in its place; check for complete reassembly.
|
|
|
|
* If not complete, check fragment limit. Move to front of packet
|
|
|
|
* queue, as we are the most recently active fragmented packet.
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
2019-10-23 23:01:18 +00:00
|
|
|
if (af6 != NULL)
|
|
|
|
TAILQ_INSERT_BEFORE(af6, ip6af, ip6af_tq);
|
|
|
|
else
|
|
|
|
TAILQ_INSERT_TAIL(&q6->ip6q_frags, ip6af, ip6af_tq);
|
|
|
|
postinsert:
|
2018-08-14 17:24:26 +00:00
|
|
|
atomic_add_int(&frag6_nfrags, 1);
|
2003-10-22 15:29:42 +00:00
|
|
|
q6->ip6q_nfrag++;
|
2019-10-23 20:37:15 +00:00
|
|
|
|
2019-08-08 10:15:47 +00:00
|
|
|
plen = 0;
|
2019-10-23 23:01:18 +00:00
|
|
|
TAILQ_FOREACH(af6, &q6->ip6q_frags, ip6af_tq) {
|
2019-08-08 10:15:47 +00:00
|
|
|
if (af6->ip6af_off != plen) {
|
2018-08-14 17:26:07 +00:00
|
|
|
if (q6->ip6q_nfrag > V_ip6_maxfragsperpacket) {
|
2019-02-19 19:57:55 +00:00
|
|
|
IP6STAT_ADD(ip6s_fragdropped, q6->ip6q_nfrag);
|
2019-08-05 11:01:12 +00:00
|
|
|
frag6_freef(q6, bucket);
|
2018-08-14 17:26:07 +00:00
|
|
|
}
|
2019-08-05 11:01:12 +00:00
|
|
|
IP6QB_UNLOCK(bucket);
|
2019-11-12 15:46:28 +00:00
|
|
|
*mp = NULL;
|
2019-08-08 10:15:47 +00:00
|
|
|
return (IPPROTO_DONE);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2019-08-08 10:15:47 +00:00
|
|
|
plen += af6->ip6af_frglen;
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2019-10-23 23:01:18 +00:00
|
|
|
af6 = TAILQ_LAST(&q6->ip6q_frags, ip6fraghead);
|
|
|
|
if (af6->ip6af_mff) {
|
2018-08-14 17:26:07 +00:00
|
|
|
if (q6->ip6q_nfrag > V_ip6_maxfragsperpacket) {
|
2019-02-19 19:57:55 +00:00
|
|
|
IP6STAT_ADD(ip6s_fragdropped, q6->ip6q_nfrag);
|
2019-08-05 11:01:12 +00:00
|
|
|
frag6_freef(q6, bucket);
|
2018-08-14 17:26:07 +00:00
|
|
|
}
|
2019-08-05 11:01:12 +00:00
|
|
|
IP6QB_UNLOCK(bucket);
|
2019-11-12 15:46:28 +00:00
|
|
|
*mp = NULL;
|
2019-08-08 10:15:47 +00:00
|
|
|
return (IPPROTO_DONE);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 09:42:57 +00:00
|
|
|
/* Reassembly is complete; concatenate fragments. */
|
2019-10-23 23:01:18 +00:00
|
|
|
ip6af = TAILQ_FIRST(&q6->ip6q_frags);
|
2019-10-24 07:53:10 +00:00
|
|
|
t = m = ip6af->ip6af_m;
|
2019-10-23 23:01:18 +00:00
|
|
|
TAILQ_REMOVE(&q6->ip6q_frags, ip6af, ip6af_tq);
|
|
|
|
while ((af6 = TAILQ_FIRST(&q6->ip6q_frags)) != NULL) {
|
2017-02-28 22:58:19 +00:00
|
|
|
m->m_pkthdr.csum_flags &=
|
2019-10-24 07:53:10 +00:00
|
|
|
af6->ip6af_m->m_pkthdr.csum_flags;
|
2017-02-28 22:58:19 +00:00
|
|
|
m->m_pkthdr.csum_data +=
|
2019-10-24 07:53:10 +00:00
|
|
|
af6->ip6af_m->m_pkthdr.csum_data;
|
2017-02-28 22:58:19 +00:00
|
|
|
|
2019-10-23 23:01:18 +00:00
|
|
|
TAILQ_REMOVE(&q6->ip6q_frags, af6, ip6af_tq);
|
2019-10-24 08:15:40 +00:00
|
|
|
t = m_last(t);
|
2019-10-24 07:53:10 +00:00
|
|
|
m_adj(af6->ip6af_m, af6->ip6af_offset);
|
|
|
|
m_demote_pkthdr(af6->ip6af_m);
|
|
|
|
m_cat(t, af6->ip6af_m);
|
2019-08-02 10:54:57 +00:00
|
|
|
free(af6, M_FRAG6);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
2017-02-28 22:58:19 +00:00
|
|
|
while (m->m_pkthdr.csum_data & 0xffff0000)
|
|
|
|
m->m_pkthdr.csum_data = (m->m_pkthdr.csum_data & 0xffff) +
|
|
|
|
(m->m_pkthdr.csum_data >> 16);
|
|
|
|
|
2019-08-08 09:42:57 +00:00
|
|
|
/* Adjust offset to point where the original next header starts. */
|
1999-11-22 02:45:11 +00:00
|
|
|
offset = ip6af->ip6af_offset - sizeof(struct ip6_frag);
|
2019-08-02 10:54:57 +00:00
|
|
|
free(ip6af, M_FRAG6);
|
2023-08-01 14:58:34 +00:00
|
|
|
if ((u_int)plen + (u_int)offset - sizeof(struct ip6_hdr) >
|
|
|
|
IPV6_MAXPACKET) {
|
|
|
|
frag6_freef(q6, bucket);
|
|
|
|
goto dropfrag;
|
|
|
|
}
|
2000-07-04 16:35:15 +00:00
|
|
|
ip6 = mtod(m, struct ip6_hdr *);
|
2019-08-08 10:15:47 +00:00
|
|
|
ip6->ip6_plen = htons((u_short)plen + offset - sizeof(struct ip6_hdr));
|
2007-06-04 06:06:35 +00:00
|
|
|
if (q6->ip6q_ecn == IPTOS_ECN_CE)
|
|
|
|
ip6->ip6_flow |= htonl(IPTOS_ECN_CE << 20);
|
1999-11-22 02:45:11 +00:00
|
|
|
nxt = q6->ip6q_nxt;
|
|
|
|
|
2019-10-23 23:01:18 +00:00
|
|
|
TAILQ_REMOVE(head, q6, ip6q_tq);
|
|
|
|
V_ip6qb[bucket].count--;
|
|
|
|
atomic_subtract_int(&frag6_nfrags, q6->ip6q_nfrag);
|
|
|
|
|
2019-11-15 21:40:40 +00:00
|
|
|
ip6_deletefraghdr(m, offset, M_NOWAIT);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2019-08-08 09:42:57 +00:00
|
|
|
/* Set nxt(-hdr field value) to the original value. */
|
2018-02-05 09:22:07 +00:00
|
|
|
m_copyback(m, ip6_get_prevhdr(m, offset), sizeof(uint8_t),
|
|
|
|
(caddr_t)&nxt);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2008-10-26 22:45:18 +00:00
|
|
|
#ifdef MAC
|
|
|
|
mac_ip6q_reassemble(q6, m);
|
|
|
|
mac_ip6q_destroy(q6);
|
|
|
|
#endif
|
2019-08-02 10:54:57 +00:00
|
|
|
free(q6, M_FRAG6);
|
2018-08-14 17:17:37 +00:00
|
|
|
atomic_subtract_int(&V_frag6_nfragpackets, 1);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
if (m->m_flags & M_PKTHDR) { /* Isn't it always true? */
|
2019-08-08 10:15:47 +00:00
|
|
|
|
|
|
|
plen = 0;
|
1999-11-22 02:45:11 +00:00
|
|
|
for (t = m; t; t = t->m_next)
|
|
|
|
plen += t->m_len;
|
|
|
|
m->m_pkthdr.len = plen;
|
2019-10-16 09:11:49 +00:00
|
|
|
/* Set a valid receive interface pointer. */
|
|
|
|
m->m_pkthdr.rcvif = srcifp;
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2003-10-07 17:46:18 +00:00
|
|
|
|
2015-11-06 23:07:43 +00:00
|
|
|
#ifdef RSS
|
|
|
|
mtag = m_tag_alloc(MTAG_ABI_IPV6, IPV6_TAG_DIRECT, sizeof(*ip6dc),
|
|
|
|
M_NOWAIT);
|
|
|
|
if (mtag == NULL)
|
|
|
|
goto dropfrag;
|
|
|
|
|
|
|
|
ip6dc = (struct ip6_direct_ctx *)(mtag + 1);
|
|
|
|
ip6dc->ip6dc_nxt = nxt;
|
|
|
|
ip6dc->ip6dc_off = offset;
|
|
|
|
|
|
|
|
m_tag_prepend(m, mtag);
|
|
|
|
#endif
|
|
|
|
|
2019-08-05 11:01:12 +00:00
|
|
|
IP6QB_UNLOCK(bucket);
|
2013-04-09 07:11:22 +00:00
|
|
|
IP6STAT_INC(ip6s_reassembled);
|
1999-11-22 02:45:11 +00:00
|
|
|
in6_ifstat_inc(dstifp, ifs6_reass_ok);
|
|
|
|
|
2015-11-06 23:07:43 +00:00
|
|
|
#ifdef RSS
|
2019-08-08 09:42:57 +00:00
|
|
|
/* Queue/dispatch for reprocessing. */
|
2015-11-06 23:07:43 +00:00
|
|
|
netisr_dispatch(NETISR_IPV6_DIRECT, m);
|
2019-11-12 15:46:28 +00:00
|
|
|
*mp = NULL;
|
2019-08-08 10:15:47 +00:00
|
|
|
return (IPPROTO_DONE);
|
2015-11-06 23:07:43 +00:00
|
|
|
#endif
|
|
|
|
|
2019-08-08 09:42:57 +00:00
|
|
|
/* Tell launch routine the next header. */
|
1999-11-22 02:45:11 +00:00
|
|
|
*mp = m;
|
|
|
|
*offp = offset;
|
|
|
|
|
2019-08-08 10:15:47 +00:00
|
|
|
return (nxt);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2019-08-08 10:15:47 +00:00
|
|
|
dropfrag:
|
2019-08-05 11:01:12 +00:00
|
|
|
IP6QB_UNLOCK(bucket);
|
2019-10-24 11:58:24 +00:00
|
|
|
dropfrag2:
|
1999-11-22 02:45:11 +00:00
|
|
|
in6_ifstat_inc(dstifp, ifs6_reass_fail);
|
2013-04-09 07:11:22 +00:00
|
|
|
IP6STAT_INC(ip6s_fragdropped);
|
1999-11-22 02:45:11 +00:00
|
|
|
m_freem(m);
|
2019-11-12 15:46:28 +00:00
|
|
|
*mp = NULL;
|
2019-08-08 10:15:47 +00:00
|
|
|
return (IPPROTO_DONE);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-06-11 12:39:29 +00:00
|
|
|
* IPv6 reassembling timer processing;
|
2019-08-08 09:42:57 +00:00
|
|
|
* if a timer expires on a reassembly queue, discard it.
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
2022-08-17 18:50:31 +00:00
|
|
|
static struct callout frag6_callout;
|
|
|
|
static void
|
|
|
|
frag6_slowtimo(void *arg __unused)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
VNET_ITERATOR_DECL(vnet_iter);
|
2019-10-23 23:01:18 +00:00
|
|
|
struct ip6qhead *head;
|
|
|
|
struct ip6q *q6, *q6tmp;
|
2019-08-05 11:01:12 +00:00
|
|
|
uint32_t bucket;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2021-08-13 11:32:03 +00:00
|
|
|
if (atomic_load_int(&frag6_nfrags) == 0)
|
2022-08-17 18:50:31 +00:00
|
|
|
goto done;
|
2021-08-13 11:32:03 +00:00
|
|
|
|
2009-07-19 14:20:53 +00:00
|
|
|
VNET_LIST_RLOCK_NOSLEEP();
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
VNET_FOREACH(vnet_iter) {
|
|
|
|
CURVNET_SET(vnet_iter);
|
2019-08-05 11:01:12 +00:00
|
|
|
for (bucket = 0; bucket < IP6REASS_NHASH; bucket++) {
|
2021-08-13 11:32:03 +00:00
|
|
|
if (V_ip6qb[bucket].count == 0)
|
|
|
|
continue;
|
2019-08-05 11:01:12 +00:00
|
|
|
IP6QB_LOCK(bucket);
|
|
|
|
head = IP6QB_HEAD(bucket);
|
2019-10-23 23:01:18 +00:00
|
|
|
TAILQ_FOREACH_SAFE(q6, head, ip6q_tq, q6tmp)
|
|
|
|
if (--q6->ip6q_ttl == 0) {
|
2019-02-19 19:57:55 +00:00
|
|
|
IP6STAT_ADD(ip6s_fragtimeout,
|
2019-10-23 23:01:18 +00:00
|
|
|
q6->ip6q_nfrag);
|
2018-08-14 17:27:41 +00:00
|
|
|
/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
|
2019-10-23 23:01:18 +00:00
|
|
|
frag6_freef(q6, bucket);
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
}
|
2018-08-14 17:17:37 +00:00
|
|
|
/*
|
|
|
|
* If we are over the maximum number of fragments
|
|
|
|
* (due to the limit being lowered), drain off
|
|
|
|
* enough to get down to the new limit.
|
2018-08-14 17:27:41 +00:00
|
|
|
* Note that we drain all reassembly queues if
|
|
|
|
* maxfragpackets is 0 (fragmentation is disabled),
|
2019-08-08 09:42:57 +00:00
|
|
|
* and do not enforce a limit when maxfragpackets
|
2018-08-14 17:27:41 +00:00
|
|
|
* is negative.
|
2018-08-14 17:17:37 +00:00
|
|
|
*/
|
2018-08-14 17:27:41 +00:00
|
|
|
while ((V_ip6_maxfragpackets == 0 ||
|
|
|
|
(V_ip6_maxfragpackets > 0 &&
|
2019-08-05 11:01:12 +00:00
|
|
|
V_ip6qb[bucket].count > V_ip6_maxfragbucketsize)) &&
|
2019-10-23 23:01:18 +00:00
|
|
|
(q6 = TAILQ_LAST(head, ip6qhead)) != NULL) {
|
|
|
|
IP6STAT_ADD(ip6s_fragoverflow, q6->ip6q_nfrag);
|
2018-08-14 17:17:37 +00:00
|
|
|
/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
|
2019-10-23 23:01:18 +00:00
|
|
|
frag6_freef(q6, bucket);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2019-08-05 11:01:12 +00:00
|
|
|
IP6QB_UNLOCK(bucket);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2018-08-14 17:27:41 +00:00
|
|
|
/*
|
|
|
|
* If we are still over the maximum number of fragmented
|
|
|
|
* packets, drain off enough to get down to the new limit.
|
|
|
|
*/
|
2019-08-05 11:01:12 +00:00
|
|
|
bucket = 0;
|
2018-08-14 17:27:41 +00:00
|
|
|
while (V_ip6_maxfragpackets >= 0 &&
|
|
|
|
atomic_load_int(&V_frag6_nfragpackets) >
|
|
|
|
(u_int)V_ip6_maxfragpackets) {
|
2019-08-05 11:01:12 +00:00
|
|
|
IP6QB_LOCK(bucket);
|
2019-10-23 23:01:18 +00:00
|
|
|
q6 = TAILQ_LAST(IP6QB_HEAD(bucket), ip6qhead);
|
|
|
|
if (q6 != NULL) {
|
|
|
|
IP6STAT_ADD(ip6s_fragoverflow, q6->ip6q_nfrag);
|
2018-08-14 17:27:41 +00:00
|
|
|
/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
|
2019-10-23 23:01:18 +00:00
|
|
|
frag6_freef(q6, bucket);
|
2018-08-14 17:27:41 +00:00
|
|
|
}
|
2019-08-05 11:01:12 +00:00
|
|
|
IP6QB_UNLOCK(bucket);
|
|
|
|
bucket = (bucket + 1) % IP6REASS_NHASH;
|
2018-08-14 17:27:41 +00:00
|
|
|
}
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
CURVNET_RESTORE();
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2009-07-19 14:20:53 +00:00
|
|
|
VNET_LIST_RUNLOCK_NOSLEEP();
|
2022-08-17 18:50:31 +00:00
|
|
|
done:
|
2023-06-01 12:04:49 +00:00
|
|
|
callout_reset_sbt(&frag6_callout, SBT_1MS * IP6_CALLOUT_INTERVAL_MS,
|
|
|
|
SBT_1MS * 10, frag6_slowtimo, NULL, 0);
|
2022-08-17 18:50:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
frag6_slowtimo_init(void *arg __unused)
|
|
|
|
{
|
|
|
|
|
|
|
|
callout_init(&frag6_callout, 1);
|
2023-06-01 12:04:49 +00:00
|
|
|
callout_reset_sbt(&frag6_callout, SBT_1MS * IP6_CALLOUT_INTERVAL_MS,
|
|
|
|
SBT_1MS * 10, frag6_slowtimo, NULL, 0);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2022-08-17 18:50:31 +00:00
|
|
|
SYSINIT(frag6, SI_SUB_VNET_DONE, SI_ORDER_ANY, frag6_slowtimo_init, NULL);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2019-08-08 09:42:57 +00:00
|
|
|
/*
|
|
|
|
* Eventhandler to adjust limits in case nmbclusters change.
|
|
|
|
*/
|
2019-08-05 09:49:24 +00:00
|
|
|
static void
|
|
|
|
frag6_change(void *tag)
|
|
|
|
{
|
|
|
|
VNET_ITERATOR_DECL(vnet_iter);
|
|
|
|
|
|
|
|
ip6_maxfrags = IP6_MAXFRAGS;
|
|
|
|
VNET_LIST_RLOCK_NOSLEEP();
|
|
|
|
VNET_FOREACH(vnet_iter) {
|
|
|
|
CURVNET_SET(vnet_iter);
|
|
|
|
V_ip6_maxfragpackets = IP6_MAXFRAGPACKETS;
|
|
|
|
frag6_set_bucketsize();
|
|
|
|
CURVNET_RESTORE();
|
|
|
|
}
|
|
|
|
VNET_LIST_RUNLOCK_NOSLEEP();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialise reassembly queue and fragment identifier.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
frag6_init(void)
|
|
|
|
{
|
2019-08-05 11:01:12 +00:00
|
|
|
uint32_t bucket;
|
2019-08-05 09:49:24 +00:00
|
|
|
|
|
|
|
V_ip6_maxfragpackets = IP6_MAXFRAGPACKETS;
|
|
|
|
frag6_set_bucketsize();
|
2019-08-05 11:01:12 +00:00
|
|
|
for (bucket = 0; bucket < IP6REASS_NHASH; bucket++) {
|
2019-10-23 23:01:18 +00:00
|
|
|
TAILQ_INIT(IP6QB_HEAD(bucket));
|
2019-10-24 08:15:40 +00:00
|
|
|
mtx_init(&V_ip6qb[bucket].lock, "ip6qb", NULL, MTX_DEF);
|
2019-08-05 11:01:12 +00:00
|
|
|
V_ip6qb[bucket].count = 0;
|
2019-08-05 09:49:24 +00:00
|
|
|
}
|
2019-08-05 11:01:12 +00:00
|
|
|
V_ip6qb_hashseed = arc4random();
|
2019-08-05 09:49:24 +00:00
|
|
|
V_ip6_maxfragsperpacket = 64;
|
2019-10-21 08:48:47 +00:00
|
|
|
#ifdef VIMAGE
|
|
|
|
V_frag6_on = true;
|
|
|
|
#endif
|
2019-08-05 09:49:24 +00:00
|
|
|
if (!IS_DEFAULT_VNET(curvnet))
|
|
|
|
return;
|
|
|
|
|
|
|
|
ip6_maxfrags = IP6_MAXFRAGS;
|
|
|
|
EVENTHANDLER_REGISTER(nmbclusters_change,
|
|
|
|
frag6_change, NULL, EVENTHANDLER_PRI_ANY);
|
|
|
|
}
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
/*
|
|
|
|
* Drain off all datagram fragments.
|
|
|
|
*/
|
2019-10-21 08:48:47 +00:00
|
|
|
static void
|
|
|
|
frag6_drain_one(void)
|
|
|
|
{
|
2019-10-23 23:01:18 +00:00
|
|
|
struct ip6q *q6;
|
2019-10-21 08:48:47 +00:00
|
|
|
uint32_t bucket;
|
|
|
|
|
|
|
|
for (bucket = 0; bucket < IP6REASS_NHASH; bucket++) {
|
|
|
|
IP6QB_LOCK(bucket);
|
2019-10-23 23:01:18 +00:00
|
|
|
while ((q6 = TAILQ_FIRST(IP6QB_HEAD(bucket))) != NULL) {
|
2019-10-21 08:48:47 +00:00
|
|
|
IP6STAT_INC(ip6s_fragdropped);
|
|
|
|
/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
|
2019-10-23 23:01:18 +00:00
|
|
|
frag6_freef(q6, bucket);
|
2019-10-21 08:48:47 +00:00
|
|
|
}
|
|
|
|
IP6QB_UNLOCK(bucket);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
void
|
2007-07-05 16:23:49 +00:00
|
|
|
frag6_drain(void)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
VNET_ITERATOR_DECL(vnet_iter);
|
2003-10-22 15:29:42 +00:00
|
|
|
|
2009-07-19 14:20:53 +00:00
|
|
|
VNET_LIST_RLOCK_NOSLEEP();
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
VNET_FOREACH(vnet_iter) {
|
|
|
|
CURVNET_SET(vnet_iter);
|
2019-10-21 08:48:47 +00:00
|
|
|
frag6_drain_one();
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
CURVNET_RESTORE();
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2009-07-19 14:20:53 +00:00
|
|
|
VNET_LIST_RUNLOCK_NOSLEEP();
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2015-02-16 05:58:32 +00:00
|
|
|
|
2019-10-21 08:48:47 +00:00
|
|
|
#ifdef VIMAGE
|
|
|
|
/*
|
|
|
|
* Clear up IPv6 reassembly structures.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
frag6_destroy(void)
|
|
|
|
{
|
|
|
|
uint32_t bucket;
|
|
|
|
|
|
|
|
frag6_drain_one();
|
|
|
|
V_frag6_on = false;
|
|
|
|
for (bucket = 0; bucket < IP6REASS_NHASH; bucket++) {
|
|
|
|
KASSERT(V_ip6qb[bucket].count == 0,
|
|
|
|
("%s: V_ip6qb[%d] (%p) count not 0 (%d)", __func__,
|
|
|
|
bucket, &V_ip6qb[bucket], V_ip6qb[bucket].count));
|
|
|
|
mtx_destroy(&V_ip6qb[bucket].lock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|