当前位置:网站首页>SYSCALL_ Define5 setsockopt code flow
SYSCALL_ Define5 setsockopt code flow
2022-06-24 21:24:00 【already_ skb】
SYSCALL_DEFINE5(setsockopt, int, fd, int, level, int, optname,
char __user *, optval, int, optlen)
{
int err, fput_needed;
struct socket *sock;
if (optlen < 0)
return -EINVAL;
sock = sockfd_lookup_light(fd, &err, &fput_needed);
if (sock != NULL) {
err = security_socket_setsockopt(sock, level, optname);
if (err)
goto out_put;
if (level == SOL_SOCKET)
err =
sock_setsockopt(sock, level, optname, optval,
optlen);
else
err =
sock->ops->setsockopt(sock, level, optname, optval,
optlen);
out_put:
fput_light(sock->file, fput_needed);
}
return err;
}
const struct proto_ops inet_stream_ops = {
.family = PF_INET,
.owner = THIS_MODULE,
.release = inet_release,
.bind = inet_bind,
.connect = inet_stream_connect,
.socketpair = sock_no_socketpair,
.accept = inet_accept,
.getname = inet_getname,
.poll = tcp_poll,
.ioctl = inet_ioctl,
.listen = inet_listen,
.shutdown = inet_shutdown,
.setsockopt = sock_common_setsockopt,
.getsockopt = sock_common_getsockopt,
err = -ENOBUFS;
sk = sk_alloc(net, PF_INET, GFP_KERNEL, answer_prot);
if (sk == NULL)
goto out;
/*
* Set socket options on an inet socket.
*/
int sock_common_setsockopt(struct socket *sock, int level, int optname,
char __user *optval, unsigned int optlen)
{
struct sock *sk = sock->sk;
//call tcp_prot setsockopt api
return sk->sk_prot->setsockopt(sk, level, optname, optval, optlen);
}
int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
unsigned int optlen)
{
const struct inet_connection_sock *icsk = inet_csk(sk);
//IP option handler
if (level != SOL_TCP)
return icsk->icsk_af_ops->setsockopt(sk, level, optname,
optval, optlen);
//TCP option handler
return do_tcp_setsockopt(sk, level, optname, optval, optlen);
}
EXPORT_SYMBOL(tcp_setsockopt);
边栏推荐
- Pyaudio audio recording
- Read all text from stdin to a string
- Why do we always "give up halfway"?
- Pytest test framework II
- Network security review office starts network security review on HowNet
- Role of wait function
- JMeter parameterization
- Big factories go out to sea and lose "posture"
- JMeter basic learning records
- Analysis of errors in JSON conversion using objectmapper
猜你喜欢

Concepts of kubernetes components

Football information query system based on C language course report + project source code + demo ppt+ project screenshot

Capture the whole process of accessing web pages through Wireshark

Power apps Guide

Static routing experiment

Learn to use a new technology quickly

Summary of message protocol problems

Failed to open after installing Charles without any prompt

After screwing the screws in the factory for two years, I earned more than 10000 yuan a month by "testing" and counterattacked

Appium desktop introduction
随机推荐
HCIA assessment
Pytest test framework II
Curl command
VirtualBox虚拟机安装Win10企业版
Logical backup: mysqldump vs physical backup: xtrabackup
Create a multithreaded thread class
A/B测试助力游戏业务增长
浅谈MySql update会锁定哪些范围的数据
Pytest testing framework
Steps of JMeter performance test
Golang daily question
NPM download speed is slow
Appium introduction and environment installation
Remember the frequently forgotten problem of continuously reading pictures -%04d
Common self realization functions in C language development
Nifi quick installation (stand-alone / cluster)
Jar package operation
go_ keyword
PHP script calls command to get real-time output
I feel that I am bald again when I help my children with their homework. I feel pity for my parents all over the world