Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
2ae2daf6
cloud-kernel
项目概览
openanolis
/
cloud-kernel
大约 1 年 前同步成功
通知
158
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2ae2daf6
编写于
1月 19, 2011
作者:
M
Marek Lindner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
batman-adv: protect ogm counter arrays with spinlock
Signed-off-by:
N
Marek Lindner
<
lindner_marek@yahoo.de
>
上级
16b1aba8
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
33 addition
and
6 deletion
+33
-6
net/batman-adv/originator.c
net/batman-adv/originator.c
+9
-2
net/batman-adv/routing.c
net/batman-adv/routing.c
+23
-4
net/batman-adv/types.h
net/batman-adv/types.h
+1
-0
未找到文件。
net/batman-adv/originator.c
浏览文件 @
2ae2daf6
...
...
@@ -207,6 +207,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)
return
NULL
;
INIT_HLIST_HEAD
(
&
orig_node
->
neigh_list
);
spin_lock_init
(
&
orig_node
->
ogm_cnt_lock
);
spin_lock_init
(
&
orig_node
->
neigh_list_lock
);
kref_init
(
&
orig_node
->
refcount
);
...
...
@@ -517,7 +518,7 @@ int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)
struct
hlist_head
*
head
;
struct
element_t
*
bucket
;
struct
orig_node
*
orig_node
;
int
i
;
int
i
,
ret
;
/* resize all orig nodes because orig_node->bcast_own(_sum) depend on
* if_num */
...
...
@@ -530,7 +531,11 @@ int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)
hlist_for_each_entry_rcu
(
bucket
,
walk
,
head
,
hlist
)
{
orig_node
=
bucket
->
data
;
if
(
orig_node_add_if
(
orig_node
,
max_if_num
)
==
-
1
)
spin_lock_bh
(
&
orig_node
->
ogm_cnt_lock
);
ret
=
orig_node_add_if
(
orig_node
,
max_if_num
);
spin_unlock_bh
(
&
orig_node
->
ogm_cnt_lock
);
if
(
ret
==
-
1
)
goto
err
;
}
rcu_read_unlock
();
...
...
@@ -619,8 +624,10 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)
hlist_for_each_entry_rcu
(
bucket
,
walk
,
head
,
hlist
)
{
orig_node
=
bucket
->
data
;
spin_lock_bh
(
&
orig_node
->
ogm_cnt_lock
);
ret
=
orig_node_del_if
(
orig_node
,
max_if_num
,
batman_if
->
if_num
);
spin_unlock_bh
(
&
orig_node
->
ogm_cnt_lock
);
if
(
ret
==
-
1
)
goto
err
;
...
...
net/batman-adv/routing.c
浏览文件 @
2ae2daf6
...
...
@@ -55,12 +55,14 @@ void slide_own_bcast_window(struct batman_if *batman_if)
rcu_read_lock
();
hlist_for_each_entry_rcu
(
bucket
,
walk
,
head
,
hlist
)
{
orig_node
=
bucket
->
data
;
spin_lock_bh
(
&
orig_node
->
ogm_cnt_lock
);
word_index
=
batman_if
->
if_num
*
NUM_WORDS
;
word
=
&
(
orig_node
->
bcast_own
[
word_index
]);
bit_get_packet
(
bat_priv
,
word
,
1
,
0
);
orig_node
->
bcast_own_sum
[
batman_if
->
if_num
]
=
bit_packet_count
(
word
);
spin_unlock_bh
(
&
orig_node
->
ogm_cnt_lock
);
}
rcu_read_unlock
();
}
...
...
@@ -278,8 +280,10 @@ static void update_orig(struct bat_priv *bat_priv,
char
is_duplicate
)
{
struct
neigh_node
*
neigh_node
=
NULL
,
*
tmp_neigh_node
=
NULL
;
struct
orig_node
*
orig_node_tmp
;
struct
hlist_node
*
node
;
int
tmp_hna_buff_len
;
uint8_t
bcast_own_sum_orig
,
bcast_own_sum_neigh
;
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
"update_originator(): "
"Searching and updating originator entry of received packet
\n
"
);
...
...
@@ -351,10 +355,22 @@ static void update_orig(struct bat_priv *bat_priv,
/* if the TQ is the same and the link not more symetric we
* won't consider it either */
if
((
orig_node
->
router
)
&&
((
neigh_node
->
tq_avg
==
orig_node
->
router
->
tq_avg
)
&&
(
orig_node
->
router
->
orig_node
->
bcast_own_sum
[
if_incoming
->
if_num
]
>=
neigh_node
->
orig_node
->
bcast_own_sum
[
if_incoming
->
if_num
])))
(
neigh_node
->
tq_avg
==
orig_node
->
router
->
tq_avg
))
{
orig_node_tmp
=
orig_node
->
router
->
orig_node
;
spin_lock_bh
(
&
orig_node_tmp
->
ogm_cnt_lock
);
bcast_own_sum_orig
=
orig_node_tmp
->
bcast_own_sum
[
if_incoming
->
if_num
];
spin_unlock_bh
(
&
orig_node_tmp
->
ogm_cnt_lock
);
orig_node_tmp
=
neigh_node
->
orig_node
;
spin_lock_bh
(
&
orig_node_tmp
->
ogm_cnt_lock
);
bcast_own_sum_neigh
=
orig_node_tmp
->
bcast_own_sum
[
if_incoming
->
if_num
];
spin_unlock_bh
(
&
orig_node_tmp
->
ogm_cnt_lock
);
if
(
bcast_own_sum_orig
>=
bcast_own_sum_neigh
)
goto
update_hna
;
}
update_routes
(
bat_priv
,
orig_node
,
neigh_node
,
hna_buff
,
tmp_hna_buff_len
);
...
...
@@ -705,10 +721,13 @@ void receive_bat_packet(struct ethhdr *ethhdr,
batman_packet
->
orig
)
&&
(
batman_packet
->
seqno
-
if_incoming_seqno
+
2
==
0
))
{
offset
=
if_incoming
->
if_num
*
NUM_WORDS
;
spin_lock_bh
(
&
orig_neigh_node
->
ogm_cnt_lock
);
word
=
&
(
orig_neigh_node
->
bcast_own
[
offset
]);
bit_mark
(
word
,
0
);
orig_neigh_node
->
bcast_own_sum
[
if_incoming
->
if_num
]
=
bit_packet_count
(
word
);
spin_unlock_bh
(
&
orig_neigh_node
->
ogm_cnt_lock
);
}
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
"Drop packet: "
...
...
net/batman-adv/types.h
浏览文件 @
2ae2daf6
...
...
@@ -89,6 +89,7 @@ struct orig_node {
struct
kref
refcount
;
struct
bat_priv
*
bat_priv
;
unsigned
long
last_frag_packet
;
spinlock_t
ogm_cnt_lock
;
/* protects ogm counter */
struct
{
uint8_t
candidates
;
struct
neigh_node
*
selected
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录