Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
9b067034
cloud-kernel
项目概览
openanolis
/
cloud-kernel
接近 2 年 前同步成功
通知
170
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9b067034
编写于
11月 07, 2014
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
switch drivers/net/tun.c to ->read_iter()
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
7eab8d9e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
15 addition
and
25 deletion
+15
-25
drivers/net/tun.c
drivers/net/tun.c
+15
-25
未找到文件。
drivers/net/tun.c
浏览文件 @
9b067034
...
@@ -1339,18 +1339,17 @@ static ssize_t tun_put_user(struct tun_struct *tun,
...
@@ -1339,18 +1339,17 @@ static ssize_t tun_put_user(struct tun_struct *tun,
}
}
static
ssize_t
tun_do_read
(
struct
tun_struct
*
tun
,
struct
tun_file
*
tfile
,
static
ssize_t
tun_do_read
(
struct
tun_struct
*
tun
,
struct
tun_file
*
tfile
,
const
struct
iovec
*
iv
,
unsigned
long
segs
,
struct
iov_iter
*
to
,
ssize_t
len
,
int
noblock
)
int
noblock
)
{
{
struct
sk_buff
*
skb
;
struct
sk_buff
*
skb
;
ssize_t
ret
=
0
;
ssize_t
ret
;
int
peeked
,
err
,
off
=
0
;
int
peeked
,
err
,
off
=
0
;
struct
iov_iter
iter
;
tun_debug
(
KERN_INFO
,
tun
,
"tun_do_read
\n
"
);
tun_debug
(
KERN_INFO
,
tun
,
"tun_do_read
\n
"
);
if
(
!
len
)
if
(
!
iov_iter_count
(
to
)
)
return
ret
;
return
0
;
if
(
tun
->
dev
->
reg_state
!=
NETREG_REGISTERED
)
if
(
tun
->
dev
->
reg_state
!=
NETREG_REGISTERED
)
return
-
EIO
;
return
-
EIO
;
...
@@ -1359,37 +1358,27 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
...
@@ -1359,37 +1358,27 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
skb
=
__skb_recv_datagram
(
tfile
->
socket
.
sk
,
noblock
?
MSG_DONTWAIT
:
0
,
skb
=
__skb_recv_datagram
(
tfile
->
socket
.
sk
,
noblock
?
MSG_DONTWAIT
:
0
,
&
peeked
,
&
off
,
&
err
);
&
peeked
,
&
off
,
&
err
);
if
(
!
skb
)
if
(
!
skb
)
return
ret
;
return
0
;
iov_iter_init
(
&
iter
,
READ
,
iv
,
segs
,
len
);
ret
=
tun_put_user
(
tun
,
tfile
,
skb
,
to
);
ret
=
tun_put_user
(
tun
,
tfile
,
skb
,
&
iter
);
kfree_skb
(
skb
);
kfree_skb
(
skb
);
return
ret
;
return
ret
;
}
}
static
ssize_t
tun_chr_aio_read
(
struct
kiocb
*
iocb
,
const
struct
iovec
*
iv
,
static
ssize_t
tun_chr_read_iter
(
struct
kiocb
*
iocb
,
struct
iov_iter
*
to
)
unsigned
long
count
,
loff_t
pos
)
{
{
struct
file
*
file
=
iocb
->
ki_filp
;
struct
file
*
file
=
iocb
->
ki_filp
;
struct
tun_file
*
tfile
=
file
->
private_data
;
struct
tun_file
*
tfile
=
file
->
private_data
;
struct
tun_struct
*
tun
=
__tun_get
(
tfile
);
struct
tun_struct
*
tun
=
__tun_get
(
tfile
);
ssize_t
len
,
ret
;
ssize_t
len
=
iov_iter_count
(
to
)
,
ret
;
if
(
!
tun
)
if
(
!
tun
)
return
-
EBADFD
;
return
-
EBADFD
;
len
=
iov_length
(
iv
,
count
);
ret
=
tun_do_read
(
tun
,
tfile
,
to
,
file
->
f_flags
&
O_NONBLOCK
);
if
(
len
<
0
)
{
ret
=
-
EINVAL
;
goto
out
;
}
ret
=
tun_do_read
(
tun
,
tfile
,
iv
,
count
,
len
,
file
->
f_flags
&
O_NONBLOCK
);
ret
=
min_t
(
ssize_t
,
ret
,
len
);
ret
=
min_t
(
ssize_t
,
ret
,
len
);
if
(
ret
>
0
)
if
(
ret
>
0
)
iocb
->
ki_pos
=
ret
;
iocb
->
ki_pos
=
ret
;
out:
tun_put
(
tun
);
tun_put
(
tun
);
return
ret
;
return
ret
;
}
}
...
@@ -1471,6 +1460,7 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
...
@@ -1471,6 +1460,7 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
{
{
struct
tun_file
*
tfile
=
container_of
(
sock
,
struct
tun_file
,
socket
);
struct
tun_file
*
tfile
=
container_of
(
sock
,
struct
tun_file
,
socket
);
struct
tun_struct
*
tun
=
__tun_get
(
tfile
);
struct
tun_struct
*
tun
=
__tun_get
(
tfile
);
struct
iov_iter
to
;
int
ret
;
int
ret
;
if
(
!
tun
)
if
(
!
tun
)
...
@@ -1485,8 +1475,8 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
...
@@ -1485,8 +1475,8 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
SOL_PACKET
,
TUN_TX_TIMESTAMP
);
SOL_PACKET
,
TUN_TX_TIMESTAMP
);
goto
out
;
goto
out
;
}
}
ret
=
tun_do_read
(
tun
,
tfile
,
m
->
msg_iov
,
m
->
msg_iovlen
,
total_len
,
iov_iter_init
(
&
to
,
READ
,
m
->
msg_iov
,
m
->
msg_iovlen
,
total_len
);
flags
&
MSG_DONTWAIT
);
ret
=
tun_do_read
(
tun
,
tfile
,
&
to
,
flags
&
MSG_DONTWAIT
);
if
(
ret
>
total_len
)
{
if
(
ret
>
total_len
)
{
m
->
msg_flags
|=
MSG_TRUNC
;
m
->
msg_flags
|=
MSG_TRUNC
;
ret
=
flags
&
MSG_TRUNC
?
ret
:
total_len
;
ret
=
flags
&
MSG_TRUNC
?
ret
:
total_len
;
...
@@ -2242,8 +2232,8 @@ static int tun_chr_show_fdinfo(struct seq_file *m, struct file *f)
...
@@ -2242,8 +2232,8 @@ static int tun_chr_show_fdinfo(struct seq_file *m, struct file *f)
static
const
struct
file_operations
tun_fops
=
{
static
const
struct
file_operations
tun_fops
=
{
.
owner
=
THIS_MODULE
,
.
owner
=
THIS_MODULE
,
.
llseek
=
no_llseek
,
.
llseek
=
no_llseek
,
.
read
=
do
_sync_read
,
.
read
=
new
_sync_read
,
.
aio_read
=
tun_chr_aio_read
,
.
read_iter
=
tun_chr_read_iter
,
.
write
=
do_sync_write
,
.
write
=
do_sync_write
,
.
aio_write
=
tun_chr_aio_write
,
.
aio_write
=
tun_chr_aio_write
,
.
poll
=
tun_chr_poll
,
.
poll
=
tun_chr_poll
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录