Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
0a9bbe74
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0a9bbe74
编写于
6月 03, 2016
作者:
J
Ján Tomko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reuse the socket in virNetDevGetFeatures
This speeds up node_device_udev driver startup 11x.
上级
d59ca0b0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
36 deletion
+46
-36
src/util/virnetdev.c
src/util/virnetdev.c
+46
-36
未找到文件。
src/util/virnetdev.c
浏览文件 @
0a9bbe74
...
...
@@ -3200,26 +3200,17 @@ virNetDevRDMAFeature(const char *ifname,
* virNetDevSendEthtoolIoctl
* This function sends ethtool ioctl request
*
* @
ifname: name of the interface
* @
cmd: reference to an ethtool command structure
* @
fd: socket to operate on
* @
ifr: struct ifreq with the command
*
* Returns 0 on success, -1 on failure.
*/
static
int
virNetDevSendEthtoolIoctl
(
const
char
*
ifname
,
void
*
cmd
)
virNetDevSendEthtoolIoctl
(
int
fd
,
struct
ifreq
*
ifr
)
{
int
ret
=
-
1
;
int
fd
=
-
1
;
struct
ifreq
ifr
;
/* Ultimately uses AF_PACKET for socket which requires privileged
* daemon support.
*/
if
((
fd
=
virNetDevSetupControl
(
ifname
,
&
ifr
))
<
0
)
return
ret
;
ifr
.
ifr_data
=
cmd
;
ret
=
ioctl
(
fd
,
SIOCETHTOOL
,
&
ifr
);
ret
=
ioctl
(
fd
,
SIOCETHTOOL
,
ifr
);
if
(
ret
!=
0
)
{
switch
(
errno
)
{
case
EINVAL
:
/* kernel doesn't support SIOCETHTOOL */
...
...
@@ -3230,12 +3221,10 @@ virNetDevSendEthtoolIoctl(const char *ifname, void *cmd)
break
;
default:
virReportSystemError
(
errno
,
"%s"
,
_
(
"ethtool ioctl error"
));
goto
cleanup
;
break
;
}
}
cleanup:
VIR_FORCE_CLOSE
(
fd
);
return
ret
;
}
...
...
@@ -3249,16 +3238,17 @@ struct virNetDevEthtoolFeatureCmd {
* virNetDevFeatureAvailable
* This function checks for the availability of a network device feature
*
* @ifname: name of the interface
* @fd: socket to operate on
* @ifr: struct ifreq with the command
* @cmd: reference to an ethtool command structure
*
* Returns true if the feature is available, false otherwise.
*/
static
bool
virNetDevFeatureAvailable
(
const
char
*
ifname
,
struct
ethtool_value
*
cmd
)
virNetDevFeatureAvailable
(
int
fd
,
struct
ifreq
*
ifr
,
struct
ethtool_value
*
cmd
)
{
cmd
=
(
void
*
)
cmd
;
if
(
virNetDevSendEthtoolIoctl
(
ifname
,
cmd
)
==
0
&&
ifr
->
ifr_data
=
(
void
*
)
cmd
;
if
(
virNetDevSendEthtoolIoctl
(
fd
,
ifr
)
==
0
&&
cmd
->
data
>
0
)
return
true
;
return
false
;
...
...
@@ -3267,7 +3257,8 @@ virNetDevFeatureAvailable(const char *ifname, struct ethtool_value *cmd)
static
void
virNetDevGetEthtoolFeatures
(
virBitmapPtr
bitmap
,
const
char
*
ifname
)
int
fd
,
struct
ifreq
*
ifr
)
{
size_t
i
;
struct
ethtool_value
cmd
=
{
0
};
...
...
@@ -3307,13 +3298,13 @@ virNetDevGetEthtoolFeatures(virBitmapPtr bitmap,
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
ethtool_cmds
);
i
++
)
{
cmd
.
cmd
=
ethtool_cmds
[
i
].
cmd
;
if
(
virNetDevFeatureAvailable
(
ifname
,
&
cmd
))
if
(
virNetDevFeatureAvailable
(
fd
,
ifr
,
&
cmd
))
ignore_value
(
virBitmapSetBit
(
bitmap
,
ethtool_cmds
[
i
].
feat
));
}
# if HAVE_DECL_ETHTOOL_GFLAGS
cmd
.
cmd
=
ETHTOOL_GFLAGS
;
if
(
virNetDevFeatureAvailable
(
ifname
,
&
cmd
))
{
if
(
virNetDevFeatureAvailable
(
fd
,
ifr
,
&
cmd
))
{
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
flags
);
i
++
)
{
if
(
cmd
.
data
&
flags
[
i
].
cmd
)
ignore_value
(
virBitmapSetBit
(
bitmap
,
flags
[
i
].
feat
));
...
...
@@ -3328,16 +3319,19 @@ virNetDevGetEthtoolFeatures(virBitmapPtr bitmap,
* virNetDevGFeatureAvailable
* This function checks for the availability of a network device gfeature
*
* @ifname: name of the interface
* @cmd: reference to a gfeatures ethtool command structure
* @fd: socket to operate on
* @ifr: struct ifreq with the command
* @cmd: reference to an ethtool command structure
*
* Returns true if the feature is available, false otherwise.
*/
static
bool
virNetDevGFeatureAvailable
(
const
char
*
ifname
,
struct
ethtool_gfeatures
*
cmd
)
virNetDevGFeatureAvailable
(
int
fd
,
struct
ifreq
*
ifr
,
struct
ethtool_gfeatures
*
cmd
)
{
cmd
=
(
void
*
)
cmd
;
if
(
virNetDevSendEthtoolIoctl
(
ifname
,
cmd
)
==
0
)
ifr
->
ifr_data
=
(
void
*
)
cmd
;
if
(
virNetDevSendEthtoolIoctl
(
fd
,
ifr
)
==
0
)
return
!!
FEATURE_BIT_IS_SET
(
cmd
->
features
,
TX_UDP_TNL
,
active
);
return
false
;
}
...
...
@@ -3345,7 +3339,8 @@ virNetDevGFeatureAvailable(const char *ifname, struct ethtool_gfeatures *cmd)
static
int
virNetDevGetEthtoolGFeatures
(
virBitmapPtr
bitmap
,
const
char
*
ifname
)
int
fd
,
struct
ifreq
*
ifr
)
{
struct
ethtool_gfeatures
*
g_cmd
;
...
...
@@ -3355,7 +3350,7 @@ virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap,
g_cmd
->
cmd
=
ETHTOOL_GFEATURES
;
g_cmd
->
size
=
GFEATURES_SIZE
;
if
(
virNetDevGFeatureAvailable
(
ifname
,
g_cmd
))
if
(
virNetDevGFeatureAvailable
(
fd
,
ifr
,
g_cmd
))
ignore_value
(
virBitmapSetBit
(
bitmap
,
VIR_NET_DEV_FEAT_TXUDPTNL
));
VIR_FREE
(
g_cmd
);
return
0
;
...
...
@@ -3363,7 +3358,8 @@ virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap,
# else
static
int
virNetDevGetEthtoolGFeatures
(
virBitmapPtr
bitmap
ATTRIBUTE_UNUSED
,
const
char
*
ifname
ATTRIBUTE_UNUSED
)
int
fd
ATTRIBUTE_UNUSED
,
struct
ifreq
*
ifr
ATTRIBUGE_UNUSED
)
{
return
0
;
}
...
...
@@ -3384,6 +3380,10 @@ int
virNetDevGetFeatures
(
const
char
*
ifname
,
virBitmapPtr
*
out
)
{
struct
ifreq
ifr
;
int
ret
=
-
1
;
int
fd
=
-
1
;
if
(
!
(
*
out
=
virBitmapNew
(
VIR_NET_DEV_FEAT_LAST
)))
return
-
1
;
...
...
@@ -3393,14 +3393,24 @@ virNetDevGetFeatures(const char *ifname,
return
0
;
}
virNetDevGetEthtoolFeatures
(
*
out
,
ifname
);
/* Ultimately uses AF_PACKET for socket which requires privileged
* daemon support.
*/
if
((
fd
=
virNetDevSetupControl
(
ifname
,
&
ifr
))
<
0
)
goto
cleanup
;
if
(
virNetDevGetEthtoolGFeatures
(
*
out
,
ifname
)
<
0
)
return
-
1
;
virNetDevGetEthtoolFeatures
(
*
out
,
fd
,
&
ifr
);
if
(
virNetDevGetEthtoolGFeatures
(
*
out
,
fd
,
&
ifr
)
<
0
)
goto
cleanup
;
if
(
virNetDevRDMAFeature
(
ifname
,
out
)
<
0
)
return
-
1
;
return
0
;
goto
cleanup
;
ret
=
0
;
cleanup:
VIR_FORCE_CLOSE
(
fd
);
return
ret
;
}
#else
int
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录