net/mctp/test/route-test.c
Source file repositories/reference/linux-study-clean/net/mctp/test/route-test.c
File Facts
- System
- Linux kernel
- Corpus path
net/mctp/test/route-test.c- Extension
.c- Size
- 48654 bytes
- Lines
- 1755
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
kunit/test.hnet/mctp.hnet/mctpdevice.hutils.h
Detected Declarations
struct mctp_frag_teststruct mctp_rx_input_teststruct mctp_route_input_sk_teststruct mctp_route_input_sk_reasm_teststruct mctp_route_input_sk_keys_teststruct test_netstruct mctp_route_gw_mtu_teststruct mctp_test_llhdrstruct mctp_bind_lookup_testfunction mctp_test_fragmentfunction mctp_frag_test_to_descfunction mctp_test_rx_inputfunction mctp_rx_input_test_to_descfunction __mctp_route_test_initfunction __mctp_route_test_finifunction mctp_test_route_input_skfunction mctp_route_input_sk_to_descfunction mctp_test_route_input_sk_reasmfunction mctp_route_input_sk_reasm_to_descfunction mctp_test_route_input_sk_keysfunction mctp_route_input_sk_keys_to_descfunction mctp_test_route_input_multiple_nets_bind_initfunction mctp_test_route_input_multiple_nets_bind_finifunction mctp_test_route_input_multiple_nets_bindfunction mctp_test_route_input_multiple_nets_key_initfunction mctp_test_route_input_multiple_nets_key_finifunction mctp_test_route_input_multiple_nets_keyfunction mctp_test_route_input_sk_fail_singlefunction mctp_test_route_input_sk_fail_fragfunction mctp_test_route_input_cloned_fragfunction mctp_test_route_input_null_eidfunction mctp_test_flow_initfunction mctp_test_flow_finifunction mctp_test_packet_flowfunction mctp_test_fragment_flowfunction mctp_test_packet_flowfunction mctp_test_fragment_flowfunction mctp_test_route_output_key_createfunction mctp_test_route_extaddr_inputfunction mctp_test_route_gw_lookupfunction mctp_test_route_gw_loopfunction mctp_route_gw_mtu_to_descfunction mctp_test_route_gw_mtufunction test_dev_header_createfunction mctp_test_route_gw_outputfunction mctp_bind_lookup_descfunction mctp_test_bind_lookupfunction mctp_test_route_output_direct_no_eids
Annotated Snippet
struct mctp_frag_test {
unsigned int mtu;
unsigned int msgsize;
unsigned int n_frags;
};
static void mctp_test_fragment(struct kunit *test)
{
const struct mctp_frag_test *params;
int rc, i, n, mtu, msgsize;
struct mctp_test_dev *dev;
struct mctp_dst dst;
struct sk_buff *skb;
struct mctp_hdr hdr;
u8 seq;
params = test->param_value;
mtu = params->mtu;
msgsize = params->msgsize;
hdr.ver = 1;
hdr.src = 8;
hdr.dest = 10;
hdr.flags_seq_tag = MCTP_HDR_FLAG_TO;
skb = mctp_test_create_skb(&hdr, msgsize);
KUNIT_ASSERT_TRUE(test, skb);
dev = mctp_test_create_dev();
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
mctp_test_dst_setup(test, &dst, dev, mtu);
rc = mctp_do_fragment_route(&dst, skb, mtu, MCTP_TAG_OWNER);
KUNIT_EXPECT_FALSE(test, rc);
n = dev->pkts.qlen;
KUNIT_EXPECT_EQ(test, n, params->n_frags);
for (i = 0;; i++) {
struct mctp_hdr *hdr2;
struct sk_buff *skb2;
u8 tag_mask, seq2;
bool first, last;
first = i == 0;
last = i == (n - 1);
skb2 = skb_dequeue(&dev->pkts);
if (!skb2)
break;
/* avoid copying single-skb messages */
if (first && last)
KUNIT_EXPECT_PTR_EQ(test, skb, skb2);
hdr2 = mctp_hdr(skb2);
tag_mask = MCTP_HDR_TAG_MASK | MCTP_HDR_FLAG_TO;
KUNIT_EXPECT_EQ(test, hdr2->ver, hdr.ver);
KUNIT_EXPECT_EQ(test, hdr2->src, hdr.src);
KUNIT_EXPECT_EQ(test, hdr2->dest, hdr.dest);
KUNIT_EXPECT_EQ(test, hdr2->flags_seq_tag & tag_mask,
hdr.flags_seq_tag & tag_mask);
KUNIT_EXPECT_EQ(test,
!!(hdr2->flags_seq_tag & MCTP_HDR_FLAG_SOM), first);
KUNIT_EXPECT_EQ(test,
!!(hdr2->flags_seq_tag & MCTP_HDR_FLAG_EOM), last);
seq2 = (hdr2->flags_seq_tag >> MCTP_HDR_SEQ_SHIFT) &
MCTP_HDR_SEQ_MASK;
if (first) {
seq = seq2;
} else {
seq++;
KUNIT_EXPECT_EQ(test, seq2, seq & MCTP_HDR_SEQ_MASK);
}
if (!last)
KUNIT_EXPECT_EQ(test, skb2->len, mtu);
else
KUNIT_EXPECT_LE(test, skb2->len, mtu);
kfree_skb(skb2);
}
mctp_dst_release(&dst);
Annotation
- Immediate include surface: `kunit/test.h`, `net/mctp.h`, `net/mctpdevice.h`, `utils.h`.
- Detected declarations: `struct mctp_frag_test`, `struct mctp_rx_input_test`, `struct mctp_route_input_sk_test`, `struct mctp_route_input_sk_reasm_test`, `struct mctp_route_input_sk_keys_test`, `struct test_net`, `struct mctp_route_gw_mtu_test`, `struct mctp_test_llhdr`, `struct mctp_bind_lookup_test`, `function mctp_test_fragment`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.