net/bluetooth/smp.c
Source file repositories/reference/linux-study-clean/net/bluetooth/smp.c
File Facts
- System
- Linux kernel
- Corpus path
net/bluetooth/smp.c- Extension
.c- Size
- 94199 bytes
- Lines
- 3794
- 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.
- 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
linux/debugfs.hlinux/scatterlist.hcrypto/aes-cbc-macs.hcrypto/aes.hcrypto/kpp.hcrypto/utils.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.hnet/bluetooth/l2cap.hnet/bluetooth/mgmt.hecdh_helper.hsmp.h
Detected Declarations
struct smp_devstruct smp_chanfunction swap_buffunction smp_aes_cmacfunction smp_f4function smp_f5function smp_f6function smp_g2function smp_h6function smp_h7function smp_efunction smp_c1function smp_s1function smp_ahfunction smp_irk_matchesfunction smp_generate_rpafunction smp_generate_oobfunction smp_send_cmdfunction authreq_to_seclevelfunction seclevel_to_authreqfunction build_pairing_cmdfunction check_enc_key_sizefunction smp_chan_destroyfunction smp_failurefunction get_auth_methodfunction tk_requestfunction smp_confirmfunction smp_randomfunction smp_notify_keysfunction onfunction sc_add_ltkfunction sc_generate_link_keyfunction smp_allow_key_distfunction sc_generate_ltkfunction smp_distribute_keysfunction smp_timeoutfunction sc_mackey_and_ltkfunction sc_dhkey_checkfunction sc_passkey_send_confirmfunction sc_passkey_roundfunction sc_user_replyfunction smp_user_confirm_replyfunction build_bredr_pairing_cmdfunction smp_cmd_pairing_reqfunction sc_send_public_keyfunction smp_cmd_pairing_rspfunction sc_check_confirmfunction fixup_sc_false_positive
Annotated Snippet
static const struct file_operations test_smp_fops = {
.open = simple_open,
.read = test_smp_read,
.llseek = default_llseek,
};
static int __init run_selftests(struct crypto_kpp *tfm_ecdh)
{
ktime_t calltime, delta, rettime;
unsigned long long duration;
int err;
calltime = ktime_get();
err = test_debug_key(tfm_ecdh);
if (err) {
BT_ERR("debug_key test failed");
goto done;
}
err = test_ah();
if (err) {
BT_ERR("smp_ah test failed");
goto done;
}
err = test_c1();
if (err) {
BT_ERR("smp_c1 test failed");
goto done;
}
err = test_s1();
if (err) {
BT_ERR("smp_s1 test failed");
goto done;
}
err = test_f4();
if (err) {
BT_ERR("smp_f4 test failed");
goto done;
}
err = test_f5();
if (err) {
BT_ERR("smp_f5 test failed");
goto done;
}
err = test_f6();
if (err) {
BT_ERR("smp_f6 test failed");
goto done;
}
err = test_g2();
if (err) {
BT_ERR("smp_g2 test failed");
goto done;
}
err = test_h6();
if (err) {
BT_ERR("smp_h6 test failed");
goto done;
}
rettime = ktime_get();
delta = ktime_sub(rettime, calltime);
duration = (unsigned long long) ktime_to_ns(delta) >> 10;
BT_INFO("SMP test passed in %llu usecs", duration);
done:
if (!err)
snprintf(test_smp_buffer, sizeof(test_smp_buffer),
"PASS (%llu usecs)\n", duration);
else
snprintf(test_smp_buffer, sizeof(test_smp_buffer), "FAIL\n");
debugfs_create_file("selftest_smp", 0444, bt_debugfs, NULL,
&test_smp_fops);
return err;
}
int __init bt_selftest_smp(void)
{
struct crypto_kpp *tfm_ecdh;
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/scatterlist.h`, `crypto/aes-cbc-macs.h`, `crypto/aes.h`, `crypto/kpp.h`, `crypto/utils.h`, `net/bluetooth/bluetooth.h`, `net/bluetooth/hci_core.h`.
- Detected declarations: `struct smp_dev`, `struct smp_chan`, `function swap_buf`, `function smp_aes_cmac`, `function smp_f4`, `function smp_f5`, `function smp_f6`, `function smp_g2`, `function smp_h6`, `function smp_h7`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern 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.