net/smc/af_smc.c
Source file repositories/reference/linux-study-clean/net/smc/af_smc.c
File Facts
- System
- Linux kernel
- Corpus path
net/smc/af_smc.c- Extension
.c- Size
- 93254 bytes
- Lines
- 3608
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/module.hlinux/socket.hlinux/workqueue.hlinux/in.hlinux/sched/signal.hlinux/if_vlan.hlinux/rcupdate_wait.hlinux/ctype.hlinux/splice.hnet/sock.hnet/inet_common.hnet/ipv6.hnet/tcp.hnet/smc.hasm/ioctls.hnet/net_namespace.hnet/netns/generic.hsmc_netns.hsmc.hsmc_clc.hsmc_llc.hsmc_cdc.hsmc_core.hsmc_ib.hsmc_ism.hsmc_pnet.hsmc_netlink.hsmc_tx.hsmc_rx.hsmc_close.hsmc_stats.hsmc_tracepoint.h
Detected Declarations
function smc_nl_dump_hs_limitationfunction smc_nl_enable_hs_limitationfunction smc_nl_disable_hs_limitationfunction smc_set_keepalivefunction voidfunction smc_hs_congestedfunction smc_hash_skfunction smc_unhash_skfunction smc_release_cbfunction smc_fback_restore_callbacksfunction smc_restore_fallback_changesfunction __smc_releasefunction smc_releasefunction smc_destructfunction smc_sk_initfunction smc_bindfunction socketfunction smc_copy_sock_settingsfunction smc_copy_sock_settings_to_clcfunction smc_copy_sock_settings_to_smcfunction smcr_lgr_reg_sndbufsfunction smcr_lgr_reg_rmbsfunction smcr_clnt_conf_first_linkfunction smc_isasciifunction smc_conn_save_peer_info_fcefunction smcr_conn_save_peer_infofunction smcd_conn_save_peer_infofunction smc_conn_save_peer_infofunction smc_link_save_peer_infofunction smc_stat_inc_fback_rsn_cntfunction smc_stat_fallbackfunction smc_fback_wakeup_waitqueuefunction smc_fback_mark_wokenfunction smc_fback_forward_wakeupfunction smc_fback_state_changefunction smc_fback_data_readyfunction smc_fback_write_spacefunction smc_fback_error_reportfunction smc_fback_replace_callbacksfunction smc_switch_to_fallbackfunction smc_connect_fallbackfunction smc_connect_decline_fallbackfunction smc_conn_abortfunction smc_find_rdma_devicefunction smc_find_ism_devicefunction smc_find_ism_v2_is_unique_chidfunction smc_find_ism_v2_device_clntfunction smc_connect_ism_vlan_setup
Annotated Snippet
static const struct proto_ops smc_sock_ops = {
.family = PF_SMC,
.owner = THIS_MODULE,
.release = smc_release,
.bind = smc_bind,
.connect = smc_connect,
.socketpair = sock_no_socketpair,
.accept = smc_accept,
.getname = smc_getname,
.poll = smc_poll,
.ioctl = smc_ioctl,
.listen = smc_listen,
.shutdown = smc_shutdown,
.setsockopt = smc_setsockopt,
.getsockopt = smc_getsockopt,
.sendmsg = smc_sendmsg,
.recvmsg = smc_recvmsg,
.mmap = sock_no_mmap,
.splice_read = smc_splice_read,
};
int smc_create_clcsk(struct net *net, struct sock *sk, int family)
{
struct smc_sock *smc = smc_sk(sk);
int rc;
rc = sock_create_kern(net, family, SOCK_STREAM, IPPROTO_TCP,
&smc->clcsock);
if (rc)
return rc;
/* smc_clcsock_release() does not wait smc->clcsock->sk's
* destruction; its sk_state might not be TCP_CLOSE after
* smc->sk is close()d, and TCP timers can be fired later,
* which need net ref.
*/
sk = smc->clcsock->sk;
sk_net_refcnt_upgrade(sk);
return 0;
}
static int smc_create(struct net *net, struct socket *sock, int protocol,
int kern)
{
int family = (protocol == SMCPROTO_SMC6) ? PF_INET6 : PF_INET;
struct sock *sk;
int rc;
rc = -ESOCKTNOSUPPORT;
if (sock->type != SOCK_STREAM)
goto out;
rc = -EPROTONOSUPPORT;
if (protocol != SMCPROTO_SMC && protocol != SMCPROTO_SMC6)
goto out;
rc = -ENOBUFS;
sock->ops = &smc_sock_ops;
sock->state = SS_UNCONNECTED;
sk = smc_sock_alloc(net, sock, protocol);
if (!sk)
goto out;
rc = smc_create_clcsk(net, sk, family);
if (rc) {
sk_common_release(sk);
sock->sk = NULL;
}
out:
return rc;
}
static const struct net_proto_family smc_sock_family_ops = {
.family = PF_SMC,
.owner = THIS_MODULE,
.create = smc_create,
};
unsigned int smc_net_id;
static __net_init int smc_net_init(struct net *net)
{
int rc;
rc = smc_sysctl_net_init(net);
if (rc)
return rc;
return smc_pnet_net_init(net);
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/socket.h`, `linux/workqueue.h`, `linux/in.h`, `linux/sched/signal.h`, `linux/if_vlan.h`, `linux/rcupdate_wait.h`, `linux/ctype.h`.
- Detected declarations: `function smc_nl_dump_hs_limitation`, `function smc_nl_enable_hs_limitation`, `function smc_nl_disable_hs_limitation`, `function smc_set_keepalive`, `function void`, `function smc_hs_congested`, `function smc_hash_sk`, `function smc_unhash_sk`, `function smc_release_cb`, `function smc_fback_restore_callbacks`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.