Linux socket创建
2019-05-15 10:05:57 0 举报
Linux 内核socket创建流程
作者其他创作
大纲/内容
inetsw_array[1]
struct list_head inetsw[SOCK_RAW]
struct module\t*owner;
struct list_head inetsw[SOCK_DGRAM]
d_delete = sockfs_delete_dentry
struct list_head inetsw[SOCK_STREAM]
struct inode
inet_sock
AF_PACKET = PF_PACKET(af_packet.c)
struct dentry_operations *d_op;
list_for_each_entry inetsw
struct inet_protosw inetsw_array[]
查找inetsw
1
tcp_v4_init_sock()
prot = &raw_prot
int family;
sk_prot_alloc() tcp_prot.slab
与socket绑定
struct sock sk;
2
AF_INET6 = PF_INET6(af_inet6.c)
3
inetsw_array[2]
sock
申请dentry
sock_alloc_fd()
struct inet_connection_sock\tinet_conn;
init_file()初始化file
af_inet.c
初始化conn_sock和tcp_sock
splice_read =\tsock_splice_read
创建
no_check = UDP_CSUM_DEFAULT
struct file\t *file
sock_map_fd()
syscall_socket()
struct sock *sk
struct inode *d_inode;
struct sock
struct file
struct proto*__sk_common.skc_prot
sk_alloc()
unlocked_ioctl = sock_ioctl
protocol = IPPROTO_TCP
inet6_create()
sock_alloc()
struct file_operations *f_op;
open = sock_no_open
no_check = 0
packet_create()
create callback;
unix_create()
struct file_operations socket_file_ops
tcp_sock
AF_IPX = PF_IPX(af_ipx.c)
4
inetsw_array[0]
struct socket
ops = &inet_dgram_ops
new_inode()
struct list_head inetsw[SOCK_PACKET]
socket.c net.h
ops = &inet_sockraw_ops
struct tcp_sock
struct list_head inetsw[SOCK_MAX]
pf-create
inet_connection_sock
capability = CAP_NET_RAW
struct dentry *dentry;
初始化inet_sock
fd_install()文件号和文件绑定
sock_init_data()关联socket和sock
struct dentry_operations sockfs_dentry_operations
release =\tsock_close
sk-sk_prot-init()tcp_v4_init_sock()
sock_create()
d_alloc()申请目录
申请file
poll = sock_poll
struct proto_ops ops = &inet_stream_ops
struct inet_sock
struct net_proto_family *net_families[NPROTO]
d_dname = sockfs_dname
get_unused_fd_flags()
type = SOCK_DGRAM
sock_attach_fd()
type = SOCK_RAW
struct socket_alloc
sock_alloc_inode()
5
protocol = IPPROTO_UDP
void\t *private_data;
struct dentry
inet_sk()
create callback; inet6_create
protocol = IPPROTO_IP
struct path f_path;
ipx_create()
AF_INET = PF_INET(af_inet.c)
mmap = sock_mmap
splice_write = generic_splice_sendpage
udp_sock
struct proto prot = &tcp_prot
struct proto *sk_prot_creator
struct inet_sock icsk_inet;
tcp_port.init()
capability = -1
type = SOCK_STREAM
AF_UNIX = PF_UNIX(af_unix.c)
各个子协议通过调用sock_register函数注册 socket.c net.h
struct sock_common\t__sk_common
alloc_inode()
inet_create()
__sock_create()
create callback; inet_create
sock.c sock.h
struct socket *socket
prot = &udp_prot
struct proto_ops *ops
struct fasync_struct\t*fasync_list
struct inet_connection_sock
get_empty_filp()
wait_queue_head_t wait
收藏
0 条评论
下一页