Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
2770834c
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
2770834c
编写于
8月 24, 2006
作者:
D
David S. Miller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[XFRM]: Pull xfrm_state_bydst hash table knowledge out of afinfo.
Signed-off-by:
N
David S. Miller
<
davem@davemloft.net
>
上级
64d9fdda
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
100 addition
and
135 deletion
+100
-135
include/net/xfrm.h
include/net/xfrm.h
+0
-16
net/ipv4/xfrm4_state.c
net/ipv4/xfrm4_state.c
+0
-53
net/ipv6/xfrm6_state.c
net/ipv6/xfrm6_state.c
+0
-56
net/xfrm/xfrm_state.c
net/xfrm/xfrm_state.c
+100
-10
未找到文件。
include/net/xfrm.h
浏览文件 @
2770834c
...
...
@@ -243,7 +243,6 @@ extern int __xfrm_state_delete(struct xfrm_state *x);
struct
xfrm_state_afinfo
{
unsigned
short
family
;
struct
list_head
*
state_bydst
;
struct
list_head
*
state_bysrc
;
struct
list_head
*
state_byspi
;
int
(
*
init_flags
)(
struct
xfrm_state
*
x
);
...
...
@@ -252,9 +251,6 @@ struct xfrm_state_afinfo {
xfrm_address_t
*
daddr
,
xfrm_address_t
*
saddr
);
struct
xfrm_state
*
(
*
state_lookup
)(
xfrm_address_t
*
daddr
,
u32
spi
,
u8
proto
);
struct
xfrm_state
*
(
*
state_lookup_byaddr
)(
xfrm_address_t
*
daddr
,
xfrm_address_t
*
saddr
,
u8
proto
);
struct
xfrm_state
*
(
*
find_acq
)(
u8
mode
,
u32
reqid
,
u8
proto
,
xfrm_address_t
*
daddr
,
xfrm_address_t
*
saddr
,
int
create
);
int
(
*
tmpl_sort
)(
struct
xfrm_tmpl
**
dst
,
struct
xfrm_tmpl
**
src
,
int
n
);
int
(
*
state_sort
)(
struct
xfrm_state
**
dst
,
struct
xfrm_state
**
src
,
int
n
);
};
...
...
@@ -455,18 +451,6 @@ unsigned __xfrm6_dst_hash(xfrm_address_t *addr)
return
h
;
}
static
__inline__
unsigned
xfrm_dst_hash
(
xfrm_address_t
*
addr
,
unsigned
short
family
)
{
switch
(
family
)
{
case
AF_INET
:
return
__xfrm4_dst_hash
(
addr
);
case
AF_INET6
:
return
__xfrm6_dst_hash
(
addr
);
}
return
0
;
}
static
__inline__
unsigned
__xfrm4_src_hash
(
xfrm_address_t
*
addr
)
{
...
...
net/ipv4/xfrm4_state.c
浏览文件 @
2770834c
...
...
@@ -88,65 +88,12 @@ __xfrm4_state_lookup_byaddr(xfrm_address_t *daddr, xfrm_address_t *saddr,
return
NULL
;
}
static
struct
xfrm_state
*
__xfrm4_find_acq
(
u8
mode
,
u32
reqid
,
u8
proto
,
xfrm_address_t
*
daddr
,
xfrm_address_t
*
saddr
,
int
create
)
{
struct
xfrm_state
*
x
,
*
x0
;
unsigned
h
=
__xfrm4_dst_hash
(
daddr
);
x0
=
NULL
;
list_for_each_entry
(
x
,
xfrm4_state_afinfo
.
state_bydst
+
h
,
bydst
)
{
if
(
x
->
props
.
family
==
AF_INET
&&
daddr
->
a4
==
x
->
id
.
daddr
.
a4
&&
mode
==
x
->
props
.
mode
&&
proto
==
x
->
id
.
proto
&&
saddr
->
a4
==
x
->
props
.
saddr
.
a4
&&
reqid
==
x
->
props
.
reqid
&&
x
->
km
.
state
==
XFRM_STATE_ACQ
&&
!
x
->
id
.
spi
)
{
x0
=
x
;
break
;
}
}
if
(
!
x0
&&
create
&&
(
x0
=
xfrm_state_alloc
())
!=
NULL
)
{
x0
->
sel
.
daddr
.
a4
=
daddr
->
a4
;
x0
->
sel
.
saddr
.
a4
=
saddr
->
a4
;
x0
->
sel
.
prefixlen_d
=
32
;
x0
->
sel
.
prefixlen_s
=
32
;
x0
->
props
.
saddr
.
a4
=
saddr
->
a4
;
x0
->
km
.
state
=
XFRM_STATE_ACQ
;
x0
->
id
.
daddr
.
a4
=
daddr
->
a4
;
x0
->
id
.
proto
=
proto
;
x0
->
props
.
family
=
AF_INET
;
x0
->
props
.
mode
=
mode
;
x0
->
props
.
reqid
=
reqid
;
x0
->
props
.
family
=
AF_INET
;
x0
->
lft
.
hard_add_expires_seconds
=
XFRM_ACQ_EXPIRES
;
xfrm_state_hold
(
x0
);
x0
->
timer
.
expires
=
jiffies
+
XFRM_ACQ_EXPIRES
*
HZ
;
add_timer
(
&
x0
->
timer
);
xfrm_state_hold
(
x0
);
list_add_tail
(
&
x0
->
bydst
,
xfrm4_state_afinfo
.
state_bydst
+
h
);
h
=
__xfrm4_src_hash
(
saddr
);
xfrm_state_hold
(
x0
);
list_add_tail
(
&
x0
->
bysrc
,
xfrm4_state_afinfo
.
state_bysrc
+
h
);
wake_up
(
&
km_waitq
);
}
if
(
x0
)
xfrm_state_hold
(
x0
);
return
x0
;
}
static
struct
xfrm_state_afinfo
xfrm4_state_afinfo
=
{
.
family
=
AF_INET
,
.
init_flags
=
xfrm4_init_flags
,
.
init_tempsel
=
__xfrm4_init_tempsel
,
.
state_lookup
=
__xfrm4_state_lookup
,
.
state_lookup_byaddr
=
__xfrm4_state_lookup_byaddr
,
.
find_acq
=
__xfrm4_find_acq
,
};
void
__init
xfrm4_state_init
(
void
)
...
...
net/ipv6/xfrm6_state.c
浏览文件 @
2770834c
...
...
@@ -101,61 +101,6 @@ __xfrm6_state_lookup(xfrm_address_t *daddr, u32 spi, u8 proto)
return
NULL
;
}
static
struct
xfrm_state
*
__xfrm6_find_acq
(
u8
mode
,
u32
reqid
,
u8
proto
,
xfrm_address_t
*
daddr
,
xfrm_address_t
*
saddr
,
int
create
)
{
struct
xfrm_state
*
x
,
*
x0
;
unsigned
h
=
__xfrm6_dst_hash
(
daddr
);
x0
=
NULL
;
list_for_each_entry
(
x
,
xfrm6_state_afinfo
.
state_bydst
+
h
,
bydst
)
{
if
(
x
->
props
.
family
==
AF_INET6
&&
ipv6_addr_equal
((
struct
in6_addr
*
)
daddr
,
(
struct
in6_addr
*
)
x
->
id
.
daddr
.
a6
)
&&
mode
==
x
->
props
.
mode
&&
proto
==
x
->
id
.
proto
&&
ipv6_addr_equal
((
struct
in6_addr
*
)
saddr
,
(
struct
in6_addr
*
)
x
->
props
.
saddr
.
a6
)
&&
reqid
==
x
->
props
.
reqid
&&
x
->
km
.
state
==
XFRM_STATE_ACQ
&&
!
x
->
id
.
spi
)
{
x0
=
x
;
break
;
}
}
if
(
!
x0
&&
create
&&
(
x0
=
xfrm_state_alloc
())
!=
NULL
)
{
ipv6_addr_copy
((
struct
in6_addr
*
)
x0
->
sel
.
daddr
.
a6
,
(
struct
in6_addr
*
)
daddr
);
ipv6_addr_copy
((
struct
in6_addr
*
)
x0
->
sel
.
saddr
.
a6
,
(
struct
in6_addr
*
)
saddr
);
x0
->
sel
.
prefixlen_d
=
128
;
x0
->
sel
.
prefixlen_s
=
128
;
ipv6_addr_copy
((
struct
in6_addr
*
)
x0
->
props
.
saddr
.
a6
,
(
struct
in6_addr
*
)
saddr
);
x0
->
km
.
state
=
XFRM_STATE_ACQ
;
ipv6_addr_copy
((
struct
in6_addr
*
)
x0
->
id
.
daddr
.
a6
,
(
struct
in6_addr
*
)
daddr
);
x0
->
id
.
proto
=
proto
;
x0
->
props
.
family
=
AF_INET6
;
x0
->
props
.
mode
=
mode
;
x0
->
props
.
reqid
=
reqid
;
x0
->
lft
.
hard_add_expires_seconds
=
XFRM_ACQ_EXPIRES
;
xfrm_state_hold
(
x0
);
x0
->
timer
.
expires
=
jiffies
+
XFRM_ACQ_EXPIRES
*
HZ
;
add_timer
(
&
x0
->
timer
);
xfrm_state_hold
(
x0
);
list_add_tail
(
&
x0
->
bydst
,
xfrm6_state_afinfo
.
state_bydst
+
h
);
h
=
__xfrm6_src_hash
(
saddr
);
xfrm_state_hold
(
x0
);
list_add_tail
(
&
x0
->
bysrc
,
xfrm6_state_afinfo
.
state_bysrc
+
h
);
wake_up
(
&
km_waitq
);
}
if
(
x0
)
xfrm_state_hold
(
x0
);
return
x0
;
}
static
int
__xfrm6_state_sort
(
struct
xfrm_state
**
dst
,
struct
xfrm_state
**
src
,
int
n
)
{
...
...
@@ -280,7 +225,6 @@ static struct xfrm_state_afinfo xfrm6_state_afinfo = {
.
init_tempsel
=
__xfrm6_init_tempsel
,
.
state_lookup
=
__xfrm6_state_lookup
,
.
state_lookup_byaddr
=
__xfrm6_state_lookup_byaddr
,
.
find_acq
=
__xfrm6_find_acq
,
.
tmpl_sort
=
__xfrm6_tmpl_sort
,
.
state_sort
=
__xfrm6_state_sort
,
};
...
...
net/xfrm/xfrm_state.c
浏览文件 @
2770834c
...
...
@@ -48,6 +48,18 @@ static struct list_head xfrm_state_bydst[XFRM_DST_HSIZE];
static
struct
list_head
xfrm_state_bysrc
[
XFRM_DST_HSIZE
];
static
struct
list_head
xfrm_state_byspi
[
XFRM_DST_HSIZE
];
static
__inline__
unsigned
xfrm_dst_hash
(
xfrm_address_t
*
addr
,
unsigned
short
family
)
{
switch
(
family
)
{
case
AF_INET
:
return
__xfrm4_dst_hash
(
addr
);
case
AF_INET6
:
return
__xfrm6_dst_hash
(
addr
);
}
return
0
;
}
DECLARE_WAIT_QUEUE_HEAD
(
km_waitq
);
EXPORT_SYMBOL
(
km_waitq
);
...
...
@@ -489,6 +501,89 @@ void xfrm_state_insert(struct xfrm_state *x)
}
EXPORT_SYMBOL
(
xfrm_state_insert
);
/* xfrm_state_lock is held */
static
struct
xfrm_state
*
__find_acq_core
(
unsigned
short
family
,
u8
mode
,
u32
reqid
,
u8
proto
,
xfrm_address_t
*
daddr
,
xfrm_address_t
*
saddr
,
int
create
)
{
unsigned
int
h
=
xfrm_dst_hash
(
daddr
,
family
);
struct
xfrm_state
*
x
;
list_for_each_entry
(
x
,
xfrm_state_bydst
+
h
,
bydst
)
{
if
(
x
->
props
.
reqid
!=
reqid
||
x
->
props
.
mode
!=
mode
||
x
->
props
.
family
!=
family
||
x
->
km
.
state
!=
XFRM_STATE_ACQ
||
x
->
id
.
spi
!=
0
)
continue
;
switch
(
family
)
{
case
AF_INET
:
if
(
x
->
id
.
daddr
.
a4
!=
daddr
->
a4
||
x
->
props
.
saddr
.
a4
!=
saddr
->
a4
)
continue
;
break
;
case
AF_INET6
:
if
(
!
ipv6_addr_equal
((
struct
in6_addr
*
)
x
->
id
.
daddr
.
a6
,
(
struct
in6_addr
*
)
daddr
)
||
!
ipv6_addr_equal
((
struct
in6_addr
*
)
x
->
props
.
saddr
.
a6
,
(
struct
in6_addr
*
)
saddr
))
continue
;
break
;
};
xfrm_state_hold
(
x
);
return
x
;
}
if
(
!
create
)
return
NULL
;
x
=
xfrm_state_alloc
();
if
(
likely
(
x
))
{
switch
(
family
)
{
case
AF_INET
:
x
->
sel
.
daddr
.
a4
=
daddr
->
a4
;
x
->
sel
.
saddr
.
a4
=
saddr
->
a4
;
x
->
sel
.
prefixlen_d
=
32
;
x
->
sel
.
prefixlen_s
=
32
;
x
->
props
.
saddr
.
a4
=
saddr
->
a4
;
x
->
id
.
daddr
.
a4
=
daddr
->
a4
;
break
;
case
AF_INET6
:
ipv6_addr_copy
((
struct
in6_addr
*
)
x
->
sel
.
daddr
.
a6
,
(
struct
in6_addr
*
)
daddr
);
ipv6_addr_copy
((
struct
in6_addr
*
)
x
->
sel
.
saddr
.
a6
,
(
struct
in6_addr
*
)
saddr
);
x
->
sel
.
prefixlen_d
=
128
;
x
->
sel
.
prefixlen_s
=
128
;
ipv6_addr_copy
((
struct
in6_addr
*
)
x
->
props
.
saddr
.
a6
,
(
struct
in6_addr
*
)
saddr
);
ipv6_addr_copy
((
struct
in6_addr
*
)
x
->
id
.
daddr
.
a6
,
(
struct
in6_addr
*
)
daddr
);
break
;
};
x
->
km
.
state
=
XFRM_STATE_ACQ
;
x
->
id
.
proto
=
proto
;
x
->
props
.
family
=
family
;
x
->
props
.
mode
=
mode
;
x
->
props
.
reqid
=
reqid
;
x
->
lft
.
hard_add_expires_seconds
=
XFRM_ACQ_EXPIRES
;
xfrm_state_hold
(
x
);
x
->
timer
.
expires
=
jiffies
+
XFRM_ACQ_EXPIRES
*
HZ
;
add_timer
(
&
x
->
timer
);
xfrm_state_hold
(
x
);
list_add_tail
(
&
x
->
bydst
,
xfrm_state_bydst
+
h
);
h
=
xfrm_src_hash
(
saddr
,
family
);
xfrm_state_hold
(
x
);
list_add_tail
(
&
x
->
bysrc
,
xfrm_state_bysrc
+
h
);
wake_up
(
&
km_waitq
);
}
return
x
;
}
static
inline
struct
xfrm_state
*
__xfrm_state_locate
(
struct
xfrm_state_afinfo
*
afinfo
,
struct
xfrm_state
*
x
,
int
use_spi
)
...
...
@@ -533,9 +628,9 @@ int xfrm_state_add(struct xfrm_state *x)
}
if
(
use_spi
&&
!
x1
)
x1
=
afinfo
->
find_acq
(
x
->
props
.
mode
,
x
->
props
.
reqid
,
x
->
id
.
proto
,
&
x
->
id
.
daddr
,
&
x
->
props
.
saddr
,
0
);
x1
=
__find_acq_core
(
family
,
x
->
props
.
mode
,
x
->
props
.
reqid
,
x
->
id
.
proto
,
&
x
->
id
.
daddr
,
&
x
->
props
.
saddr
,
0
);
__xfrm_state_insert
(
x
);
err
=
0
;
...
...
@@ -716,14 +811,11 @@ xfrm_find_acq(u8 mode, u32 reqid, u8 proto,
int
create
,
unsigned
short
family
)
{
struct
xfrm_state
*
x
;
struct
xfrm_state_afinfo
*
afinfo
=
xfrm_state_get_afinfo
(
family
);
if
(
!
afinfo
)
return
NULL
;
spin_lock_bh
(
&
xfrm_state_lock
);
x
=
afinfo
->
find_acq
(
mode
,
reqid
,
proto
,
daddr
,
saddr
,
create
);
x
=
__find_acq_core
(
family
,
mode
,
reqid
,
proto
,
daddr
,
saddr
,
create
);
spin_unlock_bh
(
&
xfrm_state_lock
);
xfrm_state_put_afinfo
(
afinfo
);
return
x
;
}
EXPORT_SYMBOL
(
xfrm_find_acq
);
...
...
@@ -1181,7 +1273,6 @@ int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo)
if
(
unlikely
(
xfrm_state_afinfo
[
afinfo
->
family
]
!=
NULL
))
err
=
-
ENOBUFS
;
else
{
afinfo
->
state_bydst
=
xfrm_state_bydst
;
afinfo
->
state_bysrc
=
xfrm_state_bysrc
;
afinfo
->
state_byspi
=
xfrm_state_byspi
;
xfrm_state_afinfo
[
afinfo
->
family
]
=
afinfo
;
...
...
@@ -1206,7 +1297,6 @@ int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo)
xfrm_state_afinfo
[
afinfo
->
family
]
=
NULL
;
afinfo
->
state_byspi
=
NULL
;
afinfo
->
state_bysrc
=
NULL
;
afinfo
->
state_bydst
=
NULL
;
}
}
write_unlock_bh
(
&
xfrm_state_afinfo_lock
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录