当前位置:网站首页>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);
边栏推荐
- Common data model (updating)
- Failed to open after installing Charles without any prompt
- Power apps Guide
- 基于C语言实现的足球信息查询系统 课程报告+项目源码+演示PPT+项目截图
- Shrimp skin test surface treated
- Limit summary (under update)
- Format method and parse method of dateformat class
- Steps of JMeter performance test
- Pytest test framework II
- regular expression
猜你喜欢

How to apply agile development ideas to other work

Appium desktop introduction

What are the problems with traditional IO? Why is zero copy introduced?

Haitai Advanced Technology | application of privacy computing technology in medical data protection

大厂出海,败于“姿态”

Summary of message protocol problems

Realization of truth table assignment by discrete mathematical programming

Appium introduction and environment installation

Postman assertion

How Fiddler works
随机推荐
Realization of truth table assignment by discrete mathematical programming
Rip/ospf protocol notes sorting
PHP script calls command to get real-time output
More than ten years' work experience is recommended at the bottom of the box: how much does it cost to find a job? See here! Brothers and sisters are recommended to collect and pay attention
Time standard and format
It was Tencent who jumped out of the job with 26k. It really wiped my ass with sandpaper. It gave me a hand
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
Pytest testing framework
Summary of idea practical skills: how to rename a project or module to completely solve all the problems you encounter that do not work. It is suggested that the five-star collection be your daughter
Microsoft Certification (dynamic 365) test
Return of missing persons
how to install clustershell
Rewrite, maplocal and maplocal operations of Charles
database/sql
Pod lifecycle in kubernetes
Web automation: web control interaction / multi window processing / Web page frame
Learn to use a new technology quickly
GDB debugging
Mr. Hu Bo, CIO of weiduomei, a scientific innovator: digitalization is a bloodless revolution, and the correct answer lies in the field of business
123. 买卖股票的最佳时机 III