Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
8abed96d
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8abed96d
编写于
7月 04, 2013
作者:
M
Michal Privoznik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapt to VIR_ALLOC and virAsprintf in src/nwfilter/*
上级
9729d847
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
91 deletion
+33
-91
src/nwfilter/nwfilter_dhcpsnoop.c
src/nwfilter/nwfilter_dhcpsnoop.c
+7
-22
src/nwfilter/nwfilter_driver.c
src/nwfilter/nwfilter_driver.c
+3
-10
src/nwfilter/nwfilter_ebiptables_driver.c
src/nwfilter/nwfilter_ebiptables_driver.c
+15
-31
src/nwfilter/nwfilter_gentech_driver.c
src/nwfilter/nwfilter_gentech_driver.c
+5
-19
src/nwfilter/nwfilter_learnipaddr.c
src/nwfilter/nwfilter_learnipaddr.c
+3
-9
未找到文件。
src/nwfilter/nwfilter_dhcpsnoop.c
浏览文件 @
8abed96d
...
...
@@ -303,10 +303,8 @@ virNWFilterSnoopActivate(virNWFilterSnoopReqPtr req)
{
char
*
key
;
if
(
virAsprintf
(
&
key
,
"%p-%d"
,
req
,
req
->
ifindex
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
key
,
"%p-%d"
,
req
,
req
->
ifindex
)
<
0
)
return
NULL
;
}
virNWFilterSnoopActiveLock
();
...
...
@@ -583,10 +581,8 @@ virNWFilterSnoopReqNew(const char *ifkey)
return
NULL
;
}
if
(
VIR_ALLOC
(
req
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
req
)
<
0
)
return
NULL
;
}
req
->
threadStatus
=
THREAD_STATUS_NONE
;
...
...
@@ -762,10 +758,8 @@ virNWFilterSnoopReqLeaseAdd(virNWFilterSnoopReqPtr req,
virNWFilterSnoopReqUnlock
(
req
);
if
(
VIR_ALLOC
(
pl
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
pl
)
<
0
)
return
-
1
;
}
*
pl
=
*
plnew
;
/* protect req->threadkey */
...
...
@@ -1091,10 +1085,8 @@ virNWFilterSnoopDHCPOpen(const char *ifname, virMacAddr *mac,
* more unlikely parameters first, then go for the MAC
*/
if
(
virAsprintf
(
&
ext_filter
,
"%s and ether src %s"
,
filter
,
macaddr
)
<
0
)
{
virReportOOMError
();
"%s and ether src %s"
,
filter
,
macaddr
)
<
0
)
return
NULL
;
}
}
else
{
/*
* Some DHCP servers respond via MAC broadcast; we rely on later
...
...
@@ -1195,10 +1187,8 @@ virNWFilterSnoopDHCPDecodeJobSubmit(virThreadPoolPtr pool,
if
(
len
<=
MIN_VALID_DHCP_PKT_SIZE
||
len
>
sizeof
(
job
->
packet
))
return
0
;
if
(
VIR_ALLOC
(
job
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
job
)
<
0
)
return
-
1
;
}
memcpy
(
job
->
packet
,
pep
,
len
);
job
->
caplen
=
len
;
...
...
@@ -1633,10 +1623,8 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
VIR_STRDUP
(
req
->
linkdev
,
linkdev
)
<
0
)
goto
exit_snoopreqput
;
if
(
!
req
->
vars
||
tmp
<
0
)
{
virReportOOMError
();
if
(
!
req
->
vars
||
tmp
<
0
)
goto
exit_snoopreqput
;
}
/* check that all tools are available for applying the filters (late) */
if
(
!
techdriver
->
canApplyBasicRules
())
{
...
...
@@ -1781,7 +1769,6 @@ virNWFilterSnoopLeaseFileWrite(int lfd, const char *ifkey,
ifkey
,
ipstr
,
dhcpstr
);
if
(
len
<
0
)
{
virReportOOMError
();
ret
=
-
1
;
goto
cleanup
;
}
...
...
@@ -2089,10 +2076,8 @@ virNWFilterDHCPSnoopInit(void)
if
(
!
virNWFilterSnoopState
.
ifnameToKey
||
!
virNWFilterSnoopState
.
snoopReqs
||
!
virNWFilterSnoopState
.
active
)
{
virReportOOMError
();
!
virNWFilterSnoopState
.
active
)
goto
err_exit
;
}
virNWFilterSnoopLeaseFileLoad
();
virNWFilterSnoopLeaseFileOpen
();
...
...
src/nwfilter/nwfilter_driver.c
浏览文件 @
8abed96d
...
...
@@ -178,10 +178,8 @@ nwfilterStateInitialize(bool privileged,
sysbus
=
virDBusGetSystemBus
();
#endif
/* WITH_DBUS */
if
(
VIR_ALLOC
(
driverState
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
driverState
)
<
0
)
return
-
1
;
}
if
(
virMutexInit
(
&
driverState
->
lock
)
<
0
)
goto
err_free_driverstate
;
...
...
@@ -227,7 +225,7 @@ nwfilterStateInitialize(bool privileged,
if
(
virAsprintf
(
&
driverState
->
configDir
,
"%s/nwfilter"
,
base
)
==
-
1
)
goto
out_of_memory
;
goto
error
;
VIR_FREE
(
base
);
...
...
@@ -240,9 +238,6 @@ nwfilterStateInitialize(bool privileged,
return
0
;
out_of_memory:
virReportOOMError
();
error:
VIR_FREE
(
base
);
nwfilterDriverUnlock
(
driverState
);
...
...
@@ -518,10 +513,8 @@ nwfilterConnectListAllNWFilters(virConnectPtr conn,
goto
cleanup
;
}
if
(
VIR_ALLOC_N
(
tmp_filters
,
driver
->
nwfilters
.
count
+
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
tmp_filters
,
driver
->
nwfilters
.
count
+
1
)
<
0
)
goto
cleanup
;
}
for
(
i
=
0
;
i
<
driver
->
nwfilters
.
count
;
i
++
)
{
obj
=
driver
->
nwfilters
.
objs
[
i
];
...
...
src/nwfilter/nwfilter_ebiptables_driver.c
浏览文件 @
8abed96d
...
...
@@ -494,10 +494,8 @@ ebiptablesAddRuleInst(virNWFilterRuleInstPtr res,
{
ebiptablesRuleInstPtr
inst
;
if
(
VIR_ALLOC
(
inst
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
inst
)
<
0
)
return
-
1
;
}
inst
->
commandTemplate
=
commandTemplate
;
inst
->
neededProtocolChain
=
neededChain
;
...
...
@@ -3016,10 +3014,8 @@ ebtablesCreateTmpSubChain(ebiptablesRuleInstPtr *inst,
break
;
}
if
(
!
protostr
)
{
virReportOOMError
();
if
(
!
protostr
)
return
-
1
;
}
virBufferAsprintf
(
&
buf
,
CMD_DEF
(
"$EBT -t nat -F %s"
)
CMD_SEPARATOR
...
...
@@ -3393,10 +3389,8 @@ ebtablesApplyDHCPOnlyRules(const char *ifname,
dhcpserver
=
virNWFilterVarValueGetNthValue
(
dhcpsrvrs
,
idx
);
if
(
virAsprintf
(
&
srcIPParam
,
"--ip-src %s"
,
dhcpserver
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
srcIPParam
,
"--ip-src %s"
,
dhcpserver
)
<
0
)
goto
tear_down_tmpebchains
;
}
}
/*
...
...
@@ -3720,10 +3714,8 @@ ebiptablesApplyNewRules(const char *ifname,
if
(
inst
==
NULL
)
nruleInstances
=
0
;
if
(
!
chains_in_set
||
!
chains_out_set
)
{
virReportOOMError
();
if
(
!
chains_in_set
||
!
chains_out_set
)
goto
exit_free_sets
;
}
if
(
nruleInstances
>
1
&&
inst
)
qsort
(
inst
,
nruleInstances
,
sizeof
(
inst
[
0
]),
...
...
@@ -3736,16 +3728,12 @@ ebiptablesApplyNewRules(const char *ifname,
const
char
*
name
=
inst
[
i
]
->
neededProtocolChain
;
if
(
inst
[
i
]
->
chainprefix
==
CHAINPREFIX_HOST_IN_TEMP
)
{
if
(
virHashUpdateEntry
(
chains_in_set
,
name
,
&
inst
[
i
]
->
chainPriority
)
<
0
)
{
virReportOOMError
();
&
inst
[
i
]
->
chainPriority
)
<
0
)
goto
exit_free_sets
;
}
}
else
{
if
(
virHashUpdateEntry
(
chains_out_set
,
name
,
&
inst
[
i
]
->
chainPriority
)
<
0
)
{
virReportOOMError
();
&
inst
[
i
]
->
chainPriority
)
<
0
)
goto
exit_free_sets
;
}
}
}
}
...
...
@@ -4210,19 +4198,15 @@ ebiptablesDriverInitWithFirewallD(void)
}
else
{
VIR_INFO
(
"firewalld support enabled for nwfilter"
);
ignore_value
(
virAsprintf
(
&
ebtables_cmd_path
,
"%s --direct --passthrough eb"
,
firewall_cmd_path
));
ignore_value
(
virAsprintf
(
&
iptables_cmd_path
,
"%s --direct --passthrough ipv4"
,
firewall_cmd_path
));
ignore_value
(
virAsprintf
(
&
ip6tables_cmd_path
,
"%s --direct --passthrough ipv6"
,
firewall_cmd_path
));
if
(
!
ebtables_cmd_path
||
!
iptables_cmd_path
||
!
ip6tables_cmd_path
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
ebtables_cmd_path
,
"%s --direct --passthrough eb"
,
firewall_cmd_path
)
<
0
||
virAsprintf
(
&
iptables_cmd_path
,
"%s --direct --passthrough ipv4"
,
firewall_cmd_path
)
<
0
||
virAsprintf
(
&
ip6tables_cmd_path
,
"%s --direct --passthrough ipv6"
,
firewall_cmd_path
)
<
0
)
{
VIR_FREE
(
ebtables_cmd_path
);
VIR_FREE
(
iptables_cmd_path
);
VIR_FREE
(
ip6tables_cmd_path
);
...
...
src/nwfilter/nwfilter_gentech_driver.c
浏览文件 @
8abed96d
...
...
@@ -110,10 +110,8 @@ int
virNWFilterRuleInstAddData
(
virNWFilterRuleInstPtr
res
,
void
*
data
)
{
if
(
VIR_REALLOC_N
(
res
->
data
,
res
->
ndata
+
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_REALLOC_N
(
res
->
data
,
res
->
ndata
+
1
)
<
0
)
return
-
1
;
}
res
->
data
[
res
->
ndata
++
]
=
data
;
return
0
;
}
...
...
@@ -201,10 +199,8 @@ virNWFilterHashTablePtr
virNWFilterCreateVarHashmap
(
char
*
macaddr
,
const
virNWFilterVarValuePtr
ipaddr
)
{
virNWFilterHashTablePtr
table
=
virNWFilterHashTableCreate
(
0
);
if
(
!
table
)
{
virReportOOMError
();
if
(
!
table
)
return
NULL
;
}
if
(
virNWFilterVarHashmapAddStdValues
(
table
,
macaddr
,
ipaddr
)
<
0
)
{
virNWFilterHashTableFree
(
table
);
...
...
@@ -303,10 +299,8 @@ virNWFilterRuleInstantiate(virNWFilterTechDriverPtr techdriver,
int
i
;
virNWFilterRuleInstPtr
ret
;
if
(
VIR_ALLOC
(
ret
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
ret
)
<
0
)
return
NULL
;
}
ret
->
techdriver
=
techdriver
;
...
...
@@ -340,10 +334,8 @@ virNWFilterCreateVarsFrom(virNWFilterHashTablePtr vars1,
virNWFilterHashTablePtr
vars2
)
{
virNWFilterHashTablePtr
res
=
virNWFilterHashTableCreate
(
0
);
if
(
!
res
)
{
virReportOOMError
();
if
(
!
res
)
return
NULL
;
}
if
(
virNWFilterHashTablePutAll
(
vars1
,
res
)
<
0
)
goto
err_exit
;
...
...
@@ -415,7 +407,6 @@ _virNWFilterInstantiateRec(virNWFilterTechDriverPtr techdriver,
}
if
(
VIR_REALLOC_N
(
*
insts
,
(
*
nEntries
)
+
1
)
<
0
)
{
virReportOOMError
();
rc
=
-
1
;
break
;
}
...
...
@@ -441,7 +432,6 @@ _virNWFilterInstantiateRec(virNWFilterTechDriverPtr techdriver,
virNWFilterCreateVarsFrom
(
inc
->
params
,
vars
);
if
(
!
tmpvars
)
{
virReportOOMError
();
rc
=
-
1
;
virNWFilterObjUnlock
(
obj
);
break
;
...
...
@@ -553,7 +543,6 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
virNWFilterCreateVarsFrom
(
inc
->
params
,
vars
);
if
(
!
tmpvars
)
{
virReportOOMError
();
rc
=
-
1
;
virNWFilterObjUnlock
(
obj
);
break
;
...
...
@@ -611,10 +600,8 @@ virNWFilterRuleInstancesToArray(int nEntries,
if
((
*
nptrs
)
==
0
)
return
0
;
if
(
VIR_ALLOC_N
((
*
ptrs
),
(
*
nptrs
))
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
((
*
ptrs
),
(
*
nptrs
))
<
0
)
return
-
1
;
}
(
*
nptrs
)
=
0
;
...
...
@@ -674,7 +661,6 @@ virNWFilterInstantiate(const unsigned char *vmuuid ATTRIBUTE_UNUSED,
virNWFilterHashTablePtr
missing_vars
=
virNWFilterHashTableCreate
(
0
);
if
(
!
missing_vars
)
{
virReportOOMError
();
rc
=
-
1
;
goto
err_exit
;
}
...
...
src/nwfilter/nwfilter_learnipaddr.c
浏览文件 @
8abed96d
...
...
@@ -143,10 +143,8 @@ virNWFilterLockIface(const char *ifname) {
ifaceLock
=
virHashLookup
(
ifaceLockMap
,
ifname
);
if
(
!
ifaceLock
)
{
if
(
VIR_ALLOC
(
ifaceLock
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
ifaceLock
)
<
0
)
goto
err_exit
;
}
if
(
virMutexInitRecursive
(
&
ifaceLock
->
lock
)
<
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
...
...
@@ -699,16 +697,12 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
return
-
1
;
}
if
(
VIR_ALLOC
(
req
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
req
)
<
0
)
goto
err_no_req
;
}
ht
=
virNWFilterHashTableCreate
(
0
);
if
(
ht
==
NULL
)
{
virReportOOMError
();
if
(
ht
==
NULL
)
goto
err_free_req
;
}
if
(
virNWFilterHashTablePutAll
(
filterparams
,
ht
)
<
0
)
goto
err_free_ht
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录