net/smc/smc_clc.c
Source file repositories/reference/linux-study-clean/net/smc/smc_clc.c
File Facts
- System
- Linux kernel
- Corpus path
net/smc/smc_clc.c- Extension
.c- Size
- 38299 bytes
- Lines
- 1371
- 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
linux/in.hlinux/inetdevice.hlinux/if_ether.hlinux/sched/signal.hlinux/utsname.hlinux/ctype.hnet/addrconf.hnet/sock.hnet/tcp.hsmc.hsmc_core.hsmc_clc.hsmc_ib.hsmc_ism.hsmc_netlink.h
Detected Declarations
struct smc_clc_eid_tablestruct smc_clc_eid_entryfunction befunction smc_clc_ueid_addfunction smc_clc_ueid_countfunction smc_nl_add_ueidfunction smc_clc_ueid_removefunction smc_nl_remove_ueidfunction smc_nl_flush_ueidfunction smc_nl_ueid_dumpinfofunction _smc_nl_ueid_dumpfunction smc_nl_dump_ueidfunction smc_nl_dump_seidfunction smc_nl_enable_seidfunction smc_nl_disable_seidfunction _smc_clc_match_ueidfunction list_for_each_entryfunction smc_clc_match_eidfunction smc_clc_msg_prop_validfunction smc_clc_msg_acc_conf_validfunction smc_clc_msg_decl_validfunction smc_clc_fill_fce_v2xfunction smc_clc_msg_hdr_validfunction smc_clc_prfx_set4_rcufunction in_dev_for_each_ifa_rcufunction smc_clc_prfx_set6_rcufunction smc_clc_prfx_setfunction smc_clc_prfx_match4_rcufunction smc_clc_prfx_match6_rcufunction smc_clc_prfx_matchfunction smc_clc_wait_msgfunction smc_clc_send_declinefunction smc_clc_send_proposalfunction list_for_each_entryfunction smcd_clc_prep_confirm_acceptfunction smcr_clc_prep_confirm_acceptfunction smc_clc_send_confirm_acceptfunction smc_clc_send_confirmfunction smc_clc_send_acceptfunction smc_clc_srv_v2x_features_validatefunction smc_clc_clnt_v2x_features_validatefunction smc_clc_v2x_features_confirm_checkfunction smc_clc_get_hostnamefunction smc_clc_initfunction smc_clc_exit
Annotated Snippet
struct smc_clc_eid_table {
rwlock_t lock;
struct list_head list;
u8 ueid_cnt;
u8 seid_enabled;
};
static struct smc_clc_eid_table smc_clc_eid_table;
struct smc_clc_eid_entry {
struct list_head list;
u8 eid[SMC_MAX_EID_LEN];
};
/* The size of a user EID is 32 characters.
* Valid characters should be (single-byte character set) A-Z, 0-9, '.' and '-'.
* Blanks should only be used to pad to the expected size.
* First character must be alphanumeric.
*/
static bool smc_clc_ueid_valid(char *ueid)
{
char *end = ueid + SMC_MAX_EID_LEN;
while (--end >= ueid && isspace(*end))
;
if (end < ueid)
return false;
if (!isalnum(*ueid) || islower(*ueid))
return false;
while (ueid <= end) {
if ((!isalnum(*ueid) || islower(*ueid)) && *ueid != '.' &&
*ueid != '-')
return false;
ueid++;
}
return true;
}
static int smc_clc_ueid_add(char *ueid)
{
struct smc_clc_eid_entry *new_ueid, *tmp_ueid;
int rc;
if (!smc_clc_ueid_valid(ueid))
return -EINVAL;
/* add a new ueid entry to the ueid table if there isn't one */
new_ueid = kzalloc_obj(*new_ueid);
if (!new_ueid)
return -ENOMEM;
memcpy(new_ueid->eid, ueid, SMC_MAX_EID_LEN);
write_lock(&smc_clc_eid_table.lock);
if (smc_clc_eid_table.ueid_cnt >= SMC_MAX_UEID) {
rc = -ERANGE;
goto err_out;
}
list_for_each_entry(tmp_ueid, &smc_clc_eid_table.list, list) {
if (!memcmp(tmp_ueid->eid, ueid, SMC_MAX_EID_LEN)) {
rc = -EEXIST;
goto err_out;
}
}
list_add_tail(&new_ueid->list, &smc_clc_eid_table.list);
smc_clc_eid_table.ueid_cnt++;
write_unlock(&smc_clc_eid_table.lock);
return 0;
err_out:
write_unlock(&smc_clc_eid_table.lock);
kfree(new_ueid);
return rc;
}
int smc_clc_ueid_count(void)
{
int count;
read_lock(&smc_clc_eid_table.lock);
count = smc_clc_eid_table.ueid_cnt;
read_unlock(&smc_clc_eid_table.lock);
return count;
}
int smc_nl_add_ueid(struct sk_buff *skb, struct genl_info *info)
{
struct nlattr *nla_ueid = info->attrs[SMC_NLA_EID_TABLE_ENTRY];
char *ueid;
Annotation
- Immediate include surface: `linux/in.h`, `linux/inetdevice.h`, `linux/if_ether.h`, `linux/sched/signal.h`, `linux/utsname.h`, `linux/ctype.h`, `net/addrconf.h`, `net/sock.h`.
- Detected declarations: `struct smc_clc_eid_table`, `struct smc_clc_eid_entry`, `function be`, `function smc_clc_ueid_add`, `function smc_clc_ueid_count`, `function smc_nl_add_ueid`, `function smc_clc_ueid_remove`, `function smc_nl_remove_ueid`, `function smc_nl_flush_ueid`, `function smc_nl_ueid_dumpinfo`.
- 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.