drivers/infiniband/sw/rxe/rxe_ns.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/sw/rxe/rxe_ns.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/sw/rxe/rxe_ns.c- Extension
.c- Size
- 2492 bytes
- Lines
- 125
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/sock.hnet/netns/generic.hnet/net_namespace.hlinux/module.hlinux/skbuff.hlinux/pid_namespace.hnet/udp_tunnel.hrxe_ns.h
Detected Declarations
struct rxe_ns_sockfunction rxe_ns_initfunction rxe_ns_exitfunction rxe_ns_pernet_set_sk4function rxe_ns_pernet_set_sk6function rxe_namespace_initfunction rxe_namespace_exit
Annotated Snippet
struct rxe_ns_sock {
struct sock __rcu *rxe_sk4;
struct sock __rcu *rxe_sk6;
};
/*
* Index to store custom data for each network namespace.
*/
static unsigned int rxe_pernet_id;
/*
* Called for every existing and added network namespaces
*/
static int rxe_ns_init(struct net *net)
{
/* defer socket create in the namespace to the first
* device create.
*/
return 0;
}
static void rxe_ns_exit(struct net *net)
{
/* called when the network namespace is removed
*/
struct rxe_ns_sock *ns_sk = net_generic(net, rxe_pernet_id);
struct sock *sk;
rcu_read_lock();
sk = rcu_dereference(ns_sk->rxe_sk4);
rcu_read_unlock();
if (sk) {
rcu_assign_pointer(ns_sk->rxe_sk4, NULL);
udp_tunnel_sock_release(sk);
}
#if IS_ENABLED(CONFIG_IPV6)
rcu_read_lock();
sk = rcu_dereference(ns_sk->rxe_sk6);
rcu_read_unlock();
if (sk) {
rcu_assign_pointer(ns_sk->rxe_sk6, NULL);
udp_tunnel_sock_release(sk);
}
#endif
}
/*
* callback to make the module network namespace aware
*/
static struct pernet_operations rxe_net_ops = {
.init = rxe_ns_init,
.exit = rxe_ns_exit,
.id = &rxe_pernet_id,
.size = sizeof(struct rxe_ns_sock),
};
struct sock *rxe_ns_pernet_sk4(struct net *net)
{
struct rxe_ns_sock *ns_sk = net_generic(net, rxe_pernet_id);
struct sock *sk;
rcu_read_lock();
sk = rcu_dereference(ns_sk->rxe_sk4);
rcu_read_unlock();
return sk;
}
void rxe_ns_pernet_set_sk4(struct net *net, struct sock *sk)
{
struct rxe_ns_sock *ns_sk = net_generic(net, rxe_pernet_id);
rcu_assign_pointer(ns_sk->rxe_sk4, sk);
synchronize_rcu();
}
#if IS_ENABLED(CONFIG_IPV6)
struct sock *rxe_ns_pernet_sk6(struct net *net)
{
struct rxe_ns_sock *ns_sk = net_generic(net, rxe_pernet_id);
struct sock *sk;
rcu_read_lock();
sk = rcu_dereference(ns_sk->rxe_sk6);
rcu_read_unlock();
return sk;
}
Annotation
- Immediate include surface: `net/sock.h`, `net/netns/generic.h`, `net/net_namespace.h`, `linux/module.h`, `linux/skbuff.h`, `linux/pid_namespace.h`, `net/udp_tunnel.h`, `rxe_ns.h`.
- Detected declarations: `struct rxe_ns_sock`, `function rxe_ns_init`, `function rxe_ns_exit`, `function rxe_ns_pernet_set_sk4`, `function rxe_ns_pernet_set_sk6`, `function rxe_namespace_init`, `function rxe_namespace_exit`.
- Atlas domain: Driver Families / drivers/infiniband.
- 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.