net/bluetooth/selftest.c
Source file repositories/reference/linux-study-clean/net/bluetooth/selftest.c
File Facts
- System
- Linux kernel
- Corpus path
net/bluetooth/selftest.c- Extension
.c- Size
- 8560 bytes
- Lines
- 307
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/debugfs.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.hecdh_helper.hsmp.hselftest.h
Detected Declarations
function test_ecdh_samplefunction test_ecdh_readfunction test_ecdhfunction test_ecdhfunction run_selftestfunction bt_selftestfunction late_initcall
Annotated Snippet
static const struct file_operations test_ecdh_fops = {
.open = simple_open,
.read = test_ecdh_read,
.llseek = default_llseek,
};
static int __init test_ecdh(void)
{
struct crypto_kpp *tfm;
ktime_t calltime, delta, rettime;
unsigned long long duration = 0;
int err;
calltime = ktime_get();
tfm = crypto_alloc_kpp("ecdh-nist-p256", 0, 0);
if (IS_ERR(tfm)) {
BT_ERR("Unable to create ECDH crypto context");
err = PTR_ERR(tfm);
goto done;
}
err = test_ecdh_sample(tfm, priv_a_1, priv_b_1, pub_a_1, pub_b_1,
dhkey_1);
if (err) {
BT_ERR("ECDH sample 1 failed");
goto done;
}
err = test_ecdh_sample(tfm, priv_a_2, priv_b_2, pub_a_2, pub_b_2,
dhkey_2);
if (err) {
BT_ERR("ECDH sample 2 failed");
goto done;
}
err = test_ecdh_sample(tfm, priv_a_3, priv_a_3, pub_a_3, pub_a_3,
dhkey_3);
if (err) {
BT_ERR("ECDH sample 3 failed");
goto done;
}
crypto_free_kpp(tfm);
rettime = ktime_get();
delta = ktime_sub(rettime, calltime);
duration = (unsigned long long) ktime_to_ns(delta) >> 10;
BT_INFO("ECDH test passed in %llu usecs", duration);
done:
if (!err)
snprintf(test_ecdh_buffer, sizeof(test_ecdh_buffer),
"PASS (%llu usecs)\n", duration);
else
snprintf(test_ecdh_buffer, sizeof(test_ecdh_buffer), "FAIL\n");
debugfs_create_file("selftest_ecdh", 0444, bt_debugfs, NULL,
&test_ecdh_fops);
return err;
}
#else
static inline int test_ecdh(void)
{
return 0;
}
#endif
static int __init run_selftest(void)
{
int err;
BT_INFO("Starting self testing");
err = test_ecdh();
if (err)
goto done;
err = bt_selftest_smp();
done:
BT_INFO("Finished self testing");
return err;
}
Annotation
- Immediate include surface: `linux/debugfs.h`, `net/bluetooth/bluetooth.h`, `net/bluetooth/hci_core.h`, `ecdh_helper.h`, `smp.h`, `selftest.h`.
- Detected declarations: `function test_ecdh_sample`, `function test_ecdh_read`, `function test_ecdh`, `function test_ecdh`, `function run_selftest`, `function bt_selftest`, `function late_initcall`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern 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.