Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
73ab4e08
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看板
提交
73ab4e08
编写于
1月 10, 2008
作者:
M
Mark McLoughlin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add iptablesSaveRules(), and don't save the rules to disk
and run lokkit each time a new rule is added.
上级
2d2e4108
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
50 addition
and
29 deletion
+50
-29
ChangeLog
ChangeLog
+8
-0
src/iptables.c
src/iptables.c
+35
-28
src/iptables.h
src/iptables.h
+1
-0
src/qemu_driver.c
src/qemu_driver.c
+6
-1
未找到文件。
ChangeLog
浏览文件 @
73ab4e08
Thu Jan 10 13:59:15 GMT 2008 Mark McLoughlin <markmc@redhat.com>
* src/iptables.[ch]: add iptablesSaveRules(), and don't
save the rules to disk and run lokkit each time a new
rule is added
* src/qemu_driver.c: use iptablesSaveRules()
Thu Jan 10 13:57:56 GMT 2008 Mark McLoughlin <markmc@redhat.com>
* src/iptables.c: now that we only use built-in iptables
...
...
src/iptables.c
浏览文件 @
73ab4e08
...
...
@@ -232,6 +232,25 @@ writeRules(const char *path,
}
#endif
/* ENABLE_IPTABLES_LOKKIT */
static
void
iptRulesSave
(
iptRules
*
rules
)
{
#ifdef ENABLE_IPTABLES_LOKKIT
int
err
;
if
((
err
=
writeRules
(
rules
->
path
,
rules
->
rules
,
rules
->
nrules
)))
{
qemudLog
(
QEMUD_WARN
,
"Failed to saves iptables rules to %s : %s"
,
rules
->
path
,
strerror
(
err
));
return
;
}
if
(
rules
->
nrules
>
0
)
notifyRulesUpdated
(
rules
->
table
,
rules
->
path
);
else
notifyRulesRemoved
(
rules
->
table
,
rules
->
path
);
#endif
/* ENABLE_IPTABLES_LOKKIT */
}
static
void
iptRuleFree
(
iptRule
*
rule
)
{
...
...
@@ -272,20 +291,6 @@ iptRulesAppend(iptRules *rules,
rules
->
nrules
++
;
#ifdef ENABLE_IPTABLES_LOKKIT
{
int
err
;
if
((
err
=
virFileMakePath
(
rules
->
dir
)))
return
err
;
if
((
err
=
writeRules
(
rules
->
path
,
rules
->
rules
,
rules
->
nrules
)))
return
err
;
}
notifyRulesUpdated
(
rules
->
table
,
rules
->
path
);
#endif
/* ENABLE_IPTABLES_LOKKIT */
return
0
;
}
...
...
@@ -310,20 +315,6 @@ iptRulesRemove(iptRules *rules,
rules
->
nrules
--
;
#ifdef ENABLE_IPTABLES_LOKKIT
{
int
err
;
if
((
err
=
writeRules
(
rules
->
path
,
rules
->
rules
,
rules
->
nrules
)))
return
err
;
}
if
(
rules
->
nrules
>
0
)
notifyRulesUpdated
(
rules
->
table
,
rules
->
path
);
else
notifyRulesRemoved
(
rules
->
table
,
rules
->
path
);
#endif
/* ENABLE_IPTABLES_LOKKIT */
return
0
;
}
...
...
@@ -559,6 +550,22 @@ iptablesContextFree(iptablesContext *ctx)
free
(
ctx
);
}
/**
* iptablesSaveRules:
* @ctx: pointer to the IP table context
*
* Saves all the IP table rules associated with a context
* to disk so that if iptables is restarted, the rules
* will automatically be reload.
*/
void
iptablesSaveRules
(
iptablesContext
*
ctx
)
{
iptRulesSave
(
ctx
->
input_filter
);
iptRulesSave
(
ctx
->
forward_filter
);
iptRulesSave
(
ctx
->
nat_postrouting
);
}
static
void
iptRulesReload
(
iptRules
*
rules
)
{
...
...
src/iptables.h
浏览文件 @
73ab4e08
...
...
@@ -29,6 +29,7 @@ typedef struct _iptablesContext iptablesContext;
iptablesContext
*
iptablesContextNew
(
void
);
void
iptablesContextFree
(
iptablesContext
*
ctx
);
void
iptablesSaveRules
(
iptablesContext
*
ctx
);
void
iptablesReloadRules
(
iptablesContext
*
ctx
);
int
iptablesAddTcpInput
(
iptablesContext
*
ctx
,
...
...
src/qemu_driver.c
浏览文件 @
73ab4e08
...
...
@@ -1009,8 +1009,10 @@ qemudAddIptablesRules(virConnectPtr conn,
/* The remaining rules are only needed for IP forwarding */
if
(
!
network
->
def
->
forward
)
if
(
!
network
->
def
->
forward
)
{
iptablesSaveRules
(
driver
->
iptables
);
return
1
;
}
/* allow forwarding packets from the bridge interface */
if
((
err
=
iptablesAddForwardAllowOut
(
driver
->
iptables
,
...
...
@@ -1044,6 +1046,8 @@ qemudAddIptablesRules(virConnectPtr conn,
goto
err10
;
}
iptablesSaveRules
(
driver
->
iptables
);
return
1
;
err10:
...
...
@@ -1100,6 +1104,7 @@ qemudRemoveIptablesRules(struct qemud_driver *driver,
iptablesRemoveTcpInput
(
driver
->
iptables
,
network
->
bridge
,
53
);
iptablesRemoveUdpInput
(
driver
->
iptables
,
network
->
bridge
,
67
);
iptablesRemoveTcpInput
(
driver
->
iptables
,
network
->
bridge
,
67
);
iptablesSaveRules
(
driver
->
iptables
);
}
static
int
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录