net/wireless/tests/fragmentation.c
Source file repositories/reference/linux-study-clean/net/wireless/tests/fragmentation.c
File Facts
- System
- Linux kernel
- Corpus path
net/wireless/tests/fragmentation.c- Extension
.c- Size
- 4606 bytes
- Lines
- 178
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ieee80211.hnet/cfg80211.hkunit/test.h
Detected Declarations
function Copyrightfunction defragment_1function defragment_2function defragment_at_end
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* KUnit tests for element fragmentation
*
* Copyright (C) 2023-2024 Intel Corporation
*/
#include <linux/ieee80211.h>
#include <net/cfg80211.h>
#include <kunit/test.h>
static void defragment_0(struct kunit *test)
{
ssize_t ret;
static const u8 input[] = {
[0] = WLAN_EID_EXTENSION,
[1] = 254,
[2] = WLAN_EID_EXT_EHT_MULTI_LINK,
[27] = 27,
[123] = 123,
[254 + 2] = WLAN_EID_FRAGMENT,
[254 + 3] = 7,
[254 + 3 + 7] = 0, /* for size */
};
u8 *data = kunit_kzalloc(test, sizeof(input), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, data);
ret = cfg80211_defragment_element((void *)input,
input, sizeof(input),
NULL, 0,
WLAN_EID_FRAGMENT);
KUNIT_EXPECT_EQ(test, ret, 253);
ret = cfg80211_defragment_element((void *)input,
input, sizeof(input),
data, ret,
WLAN_EID_FRAGMENT);
KUNIT_EXPECT_EQ(test, ret, 253);
KUNIT_EXPECT_MEMEQ(test, data, input + 3, 253);
}
static void defragment_1(struct kunit *test)
{
ssize_t ret;
static const u8 input[] = {
[0] = WLAN_EID_EXTENSION,
[1] = 255,
[2] = WLAN_EID_EXT_EHT_MULTI_LINK,
[27] = 27,
[123] = 123,
[255 + 2] = WLAN_EID_FRAGMENT,
[255 + 3] = 7,
[255 + 3 + 1] = 0xaa,
[255 + 3 + 8] = WLAN_EID_FRAGMENT, /* not used */
[255 + 3 + 9] = 1,
[255 + 3 + 10] = 0, /* for size */
};
u8 *data = kunit_kzalloc(test, sizeof(input), GFP_KERNEL);
const struct element *elem;
int count = 0;
KUNIT_ASSERT_NOT_NULL(test, data);
for_each_element(elem, input, sizeof(input))
count++;
/* check the elements are right */
KUNIT_ASSERT_EQ(test, count, 3);
ret = cfg80211_defragment_element((void *)input,
input, sizeof(input),
NULL, 0,
WLAN_EID_FRAGMENT);
KUNIT_EXPECT_EQ(test, ret, 254 + 7);
ret = cfg80211_defragment_element((void *)input,
input, sizeof(input),
data, ret,
WLAN_EID_FRAGMENT);
/* this means the last fragment was not used */
KUNIT_EXPECT_EQ(test, ret, 254 + 7);
KUNIT_EXPECT_MEMEQ(test, data, input + 3, 254);
KUNIT_EXPECT_MEMEQ(test, data + 254, input + 255 + 4, 7);
}
static void defragment_2(struct kunit *test)
{
ssize_t ret;
static const u8 input[] = {
[0] = WLAN_EID_EXTENSION,
[1] = 255,
[2] = WLAN_EID_EXT_EHT_MULTI_LINK,
Annotation
- Immediate include surface: `linux/ieee80211.h`, `net/cfg80211.h`, `kunit/test.h`.
- Detected declarations: `function Copyright`, `function defragment_1`, `function defragment_2`, `function defragment_at_end`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.