Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
bd3129fc
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
163
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看板
提交
bd3129fc
编写于
9月 30, 2013
作者:
J
Jozsef Kadlecsik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
netfilter: ipset: order matches and targets separatedly in xt_set.c
Signed-off-by:
N
Jozsef Kadlecsik
<
kadlec@blackhole.kfki.hu
>
上级
60b0fe37
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
96 addition
and
92 deletion
+96
-92
net/netfilter/xt_set.c
net/netfilter/xt_set.c
+96
-92
未找到文件。
net/netfilter/xt_set.c
浏览文件 @
bd3129fc
...
...
@@ -109,6 +109,101 @@ set_match_v0_destroy(const struct xt_mtdtor_param *par)
ip_set_nfnl_put
(
info
->
match_set
.
index
);
}
/* Revision 1 match */
static
bool
set_match_v1
(
const
struct
sk_buff
*
skb
,
struct
xt_action_param
*
par
)
{
const
struct
xt_set_info_match_v1
*
info
=
par
->
matchinfo
;
ADT_OPT
(
opt
,
par
->
family
,
info
->
match_set
.
dim
,
info
->
match_set
.
flags
,
0
,
UINT_MAX
);
if
(
opt
.
flags
&
IPSET_RETURN_NOMATCH
)
opt
.
cmdflags
|=
IPSET_FLAG_RETURN_NOMATCH
;
return
match_set
(
info
->
match_set
.
index
,
skb
,
par
,
&
opt
,
info
->
match_set
.
flags
&
IPSET_INV_MATCH
);
}
static
int
set_match_v1_checkentry
(
const
struct
xt_mtchk_param
*
par
)
{
struct
xt_set_info_match_v1
*
info
=
par
->
matchinfo
;
ip_set_id_t
index
;
index
=
ip_set_nfnl_get_byindex
(
info
->
match_set
.
index
);
if
(
index
==
IPSET_INVALID_ID
)
{
pr_warning
(
"Cannot find set indentified by id %u to match
\n
"
,
info
->
match_set
.
index
);
return
-
ENOENT
;
}
if
(
info
->
match_set
.
dim
>
IPSET_DIM_MAX
)
{
pr_warning
(
"Protocol error: set match dimension "
"is over the limit!
\n
"
);
ip_set_nfnl_put
(
info
->
match_set
.
index
);
return
-
ERANGE
;
}
return
0
;
}
static
void
set_match_v1_destroy
(
const
struct
xt_mtdtor_param
*
par
)
{
struct
xt_set_info_match_v1
*
info
=
par
->
matchinfo
;
ip_set_nfnl_put
(
info
->
match_set
.
index
);
}
/* Revision 3 match */
static
bool
match_counter
(
u64
counter
,
const
struct
ip_set_counter_match
*
info
)
{
switch
(
info
->
op
)
{
case
IPSET_COUNTER_NONE
:
return
true
;
case
IPSET_COUNTER_EQ
:
return
counter
==
info
->
value
;
case
IPSET_COUNTER_NE
:
return
counter
!=
info
->
value
;
case
IPSET_COUNTER_LT
:
return
counter
<
info
->
value
;
case
IPSET_COUNTER_GT
:
return
counter
>
info
->
value
;
}
return
false
;
}
static
bool
set_match_v3
(
const
struct
sk_buff
*
skb
,
struct
xt_action_param
*
par
)
{
const
struct
xt_set_info_match_v3
*
info
=
par
->
matchinfo
;
ADT_OPT
(
opt
,
par
->
family
,
info
->
match_set
.
dim
,
info
->
match_set
.
flags
,
info
->
flags
,
UINT_MAX
);
int
ret
;
if
(
info
->
packets
.
op
!=
IPSET_COUNTER_NONE
||
info
->
bytes
.
op
!=
IPSET_COUNTER_NONE
)
opt
.
cmdflags
|=
IPSET_FLAG_MATCH_COUNTERS
;
ret
=
match_set
(
info
->
match_set
.
index
,
skb
,
par
,
&
opt
,
info
->
match_set
.
flags
&
IPSET_INV_MATCH
);
if
(
!
(
ret
&&
opt
.
cmdflags
&
IPSET_FLAG_MATCH_COUNTERS
))
return
ret
;
if
(
!
match_counter
(
opt
.
ext
.
packets
,
&
info
->
packets
))
return
0
;
return
match_counter
(
opt
.
ext
.
bytes
,
&
info
->
bytes
);
}
#define set_match_v3_checkentry set_match_v1_checkentry
#define set_match_v3_destroy set_match_v1_destroy
/* Revision 0 interface: backward compatible with netfilter/iptables */
static
unsigned
int
set_target_v0
(
struct
sk_buff
*
skb
,
const
struct
xt_action_param
*
par
)
{
...
...
@@ -180,52 +275,7 @@ set_target_v0_destroy(const struct xt_tgdtor_param *par)
ip_set_nfnl_put
(
info
->
del_set
.
index
);
}
/* Revision 1 match and target */
static
bool
set_match_v1
(
const
struct
sk_buff
*
skb
,
struct
xt_action_param
*
par
)
{
const
struct
xt_set_info_match_v1
*
info
=
par
->
matchinfo
;
ADT_OPT
(
opt
,
par
->
family
,
info
->
match_set
.
dim
,
info
->
match_set
.
flags
,
0
,
UINT_MAX
);
if
(
opt
.
flags
&
IPSET_RETURN_NOMATCH
)
opt
.
cmdflags
|=
IPSET_FLAG_RETURN_NOMATCH
;
return
match_set
(
info
->
match_set
.
index
,
skb
,
par
,
&
opt
,
info
->
match_set
.
flags
&
IPSET_INV_MATCH
);
}
static
int
set_match_v1_checkentry
(
const
struct
xt_mtchk_param
*
par
)
{
struct
xt_set_info_match_v1
*
info
=
par
->
matchinfo
;
ip_set_id_t
index
;
index
=
ip_set_nfnl_get_byindex
(
info
->
match_set
.
index
);
if
(
index
==
IPSET_INVALID_ID
)
{
pr_warning
(
"Cannot find set indentified by id %u to match
\n
"
,
info
->
match_set
.
index
);
return
-
ENOENT
;
}
if
(
info
->
match_set
.
dim
>
IPSET_DIM_MAX
)
{
pr_warning
(
"Protocol error: set match dimension "
"is over the limit!
\n
"
);
ip_set_nfnl_put
(
info
->
match_set
.
index
);
return
-
ERANGE
;
}
return
0
;
}
static
void
set_match_v1_destroy
(
const
struct
xt_mtdtor_param
*
par
)
{
struct
xt_set_info_match_v1
*
info
=
par
->
matchinfo
;
ip_set_nfnl_put
(
info
->
match_set
.
index
);
}
/* Revision 1 target */
static
unsigned
int
set_target_v1
(
struct
sk_buff
*
skb
,
const
struct
xt_action_param
*
par
)
...
...
@@ -320,52 +370,6 @@ set_target_v2(struct sk_buff *skb, const struct xt_action_param *par)
#define set_target_v2_checkentry set_target_v1_checkentry
#define set_target_v2_destroy set_target_v1_destroy
/* Revision 3 match */
static
bool
match_counter
(
u64
counter
,
const
struct
ip_set_counter_match
*
info
)
{
switch
(
info
->
op
)
{
case
IPSET_COUNTER_NONE
:
return
true
;
case
IPSET_COUNTER_EQ
:
return
counter
==
info
->
value
;
case
IPSET_COUNTER_NE
:
return
counter
!=
info
->
value
;
case
IPSET_COUNTER_LT
:
return
counter
<
info
->
value
;
case
IPSET_COUNTER_GT
:
return
counter
>
info
->
value
;
}
return
false
;
}
static
bool
set_match_v3
(
const
struct
sk_buff
*
skb
,
struct
xt_action_param
*
par
)
{
const
struct
xt_set_info_match_v3
*
info
=
par
->
matchinfo
;
ADT_OPT
(
opt
,
par
->
family
,
info
->
match_set
.
dim
,
info
->
match_set
.
flags
,
info
->
flags
,
UINT_MAX
);
int
ret
;
if
(
info
->
packets
.
op
!=
IPSET_COUNTER_NONE
||
info
->
bytes
.
op
!=
IPSET_COUNTER_NONE
)
opt
.
cmdflags
|=
IPSET_FLAG_MATCH_COUNTERS
;
ret
=
match_set
(
info
->
match_set
.
index
,
skb
,
par
,
&
opt
,
info
->
match_set
.
flags
&
IPSET_INV_MATCH
);
if
(
!
(
ret
&&
opt
.
cmdflags
&
IPSET_FLAG_MATCH_COUNTERS
))
return
ret
;
if
(
!
match_counter
(
opt
.
ext
.
packets
,
&
info
->
packets
))
return
0
;
return
match_counter
(
opt
.
ext
.
bytes
,
&
info
->
bytes
);
}
#define set_match_v3_checkentry set_match_v1_checkentry
#define set_match_v3_destroy set_match_v1_destroy
static
struct
xt_match
set_matches
[]
__read_mostly
=
{
{
.
name
=
"set"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录