net/rds/ib.c
Source file repositories/reference/linux-study-clean/net/rds/ib.c
File Facts
- System
- Linux kernel
- Corpus path
net/rds/ib.c- Extension
.c- Size
- 17948 bytes
- Lines
- 626
- 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.
- 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/kernel.hlinux/in.hlinux/if.hlinux/netdevice.hlinux/inetdevice.hlinux/if_arp.hlinux/delay.hlinux/slab.hlinux/module.hnet/addrconf.hrds_single_path.hrds.hib.hib_mr.h
Detected Declarations
function rds_ib_nodev_connectfunction rds_ib_dev_shutdownfunction rds_ib_destroy_mr_poolfunction list_for_each_entry_safefunction rds_ib_dev_putfunction rds_ib_add_onefunction rds_ib_remove_onefunction rds_ib_conn_info_visitorfunction rds6_ib_conn_info_visitorfunction rds_ib_ic_infofunction rds6_ib_ic_infofunction rds_ib_laddr_check_cmfunction rdma_bind_addrfunction rds_ib_laddr_checkfunction rds_ib_unregister_clientfunction rds_ib_set_unloadingfunction rds_ib_is_unloadingfunction rds_ib_exitfunction rds_ib_get_tos_mapfunction rds_ib_init
Annotated Snippet
if (ipv6_addr_type(addr) & IPV6_ADDR_LINKLOCAL) {
struct net_device *dev;
if (scope_id == 0) {
ret = -EADDRNOTAVAIL;
goto out;
}
/* Use init_net for now as RDS is not network
* name space aware.
*/
dev = dev_get_by_index(&init_net, scope_id);
if (!dev) {
ret = -EADDRNOTAVAIL;
goto out;
}
if (!ipv6_chk_addr(&init_net, addr, dev, 1)) {
dev_put(dev);
ret = -EADDRNOTAVAIL;
goto out;
}
dev_put(dev);
}
#else
ret = -EADDRNOTAVAIL;
goto out;
#endif
}
/* rdma_bind_addr will only succeed for IB & iWARP devices */
ret = rdma_bind_addr(cm_id, sa);
/* due to this, we will claim to support iWARP devices unless we
check node_type. */
if (ret || !cm_id->device ||
cm_id->device->node_type != RDMA_NODE_IB_CA)
ret = -EADDRNOTAVAIL;
rdsdebug("addr %pI6c%%%u ret %d node type %d\n",
addr, scope_id, ret,
cm_id->device ? cm_id->device->node_type : -1);
out:
rdma_destroy_id(cm_id);
return ret;
}
static int rds_ib_laddr_check(struct net *net, const struct in6_addr *addr,
__u32 scope_id)
{
struct rds_ib_device *rds_ibdev = NULL;
/* RDS/IB is restricted to the initial network namespace */
if (!net_eq(net, &init_net))
return -EPROTOTYPE;
if (ipv6_addr_v4mapped(addr)) {
rds_ibdev = rds_ib_get_device(addr->s6_addr32[3]);
if (rds_ibdev) {
rds_ib_dev_put(rds_ibdev);
return 0;
}
}
return rds_ib_laddr_check_cm(net, addr, scope_id);
}
static void rds_ib_unregister_client(void)
{
ib_unregister_client(&rds_ib_client);
/* wait for rds_ib_dev_free() to complete */
flush_workqueue(rds_wq);
}
static void rds_ib_set_unloading(void)
{
atomic_set(&rds_ib_unloading, 1);
}
static bool rds_ib_is_unloading(struct rds_connection *conn)
{
struct rds_conn_path *cp = &conn->c_path[0];
return (test_bit(RDS_DESTROY_PENDING, &cp->cp_flags) ||
atomic_read(&rds_ib_unloading) != 0);
}
void rds_ib_exit(void)
{
rds_ib_set_unloading();
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/in.h`, `linux/if.h`, `linux/netdevice.h`, `linux/inetdevice.h`, `linux/if_arp.h`, `linux/delay.h`, `linux/slab.h`.
- Detected declarations: `function rds_ib_nodev_connect`, `function rds_ib_dev_shutdown`, `function rds_ib_destroy_mr_pool`, `function list_for_each_entry_safe`, `function rds_ib_dev_put`, `function rds_ib_add_one`, `function rds_ib_remove_one`, `function rds_ib_conn_info_visitor`, `function rds6_ib_conn_info_visitor`, `function rds_ib_ic_info`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.