summary
Each family
has a corresponding array element of struct net_proto_family
,
which will be called in system call socket
.
Data Structure
1 | 181 struct net_proto_family { |
The create
is important, which is first and basic function during
system call socket
.
1 | 164 static DEFINE_SPINLOCK(net_family_lock); |
NOTE:
- A pointer array and a spin_lock to protect it.
- The spin_lock is used for mutex of multi writer (register or unregister).
- RUC lock is used for the mutex between writer and reader .
Register/Unregister a net famliy’s ops
sock_register
1 | 2567 /** |
sock_unregister
1 | 2601 /** |
who are registered to net_families
1 | net/phonet/af_phonet.c: err = sock_register(&phonet_proto_family); |
For example:
AF_INET
and inet_family_ops
.
1 | 1019 static const struct net_proto_family inet_family_ops = { |
register when inet init.
1 | 1670 static int __init inet_init(void) |
net_families
is used in system call socket
1 | 1243 int __sock_create(struct net *net, int family, int type, int protocol, |