Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
b6d151bb
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b6d151bb
编写于
4月 30, 2012
作者:
D
David S. Miller
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'tipc_net-next' of
git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux
上级
1191cb83
617d3c7a
变更
34
展开全部
隐藏空白更改
内联
并排
Showing
34 changed file
with
58 addition
and
567 deletion
+58
-567
net/tipc/Makefile
net/tipc/Makefile
+0
-2
net/tipc/addr.c
net/tipc/addr.c
+0
-3
net/tipc/addr.h
net/tipc/addr.h
+0
-3
net/tipc/bcast.c
net/tipc/bcast.c
+0
-22
net/tipc/bcast.h
net/tipc/bcast.h
+0
-3
net/tipc/bearer.c
net/tipc/bearer.c
+1
-21
net/tipc/bearer.h
net/tipc/bearer.h
+0
-4
net/tipc/config.c
net/tipc/config.c
+17
-11
net/tipc/config.h
net/tipc/config.h
+1
-0
net/tipc/core.c
net/tipc/core.c
+2
-9
net/tipc/core.h
net/tipc/core.h
+0
-14
net/tipc/discover.c
net/tipc/discover.c
+0
-14
net/tipc/eth_media.c
net/tipc/eth_media.c
+0
-19
net/tipc/handler.c
net/tipc/handler.c
+0
-1
net/tipc/link.c
net/tipc/link.c
+5
-115
net/tipc/link.h
net/tipc/link.h
+0
-6
net/tipc/log.c
net/tipc/log.c
+0
-14
net/tipc/log.h
net/tipc/log.h
+0
-1
net/tipc/msg.c
net/tipc/msg.c
+0
-3
net/tipc/msg.h
net/tipc/msg.h
+0
-21
net/tipc/name_distr.c
net/tipc/name_distr.c
+0
-11
net/tipc/name_table.c
net/tipc/name_table.c
+25
-59
net/tipc/name_table.h
net/tipc/name_table.h
+0
-3
net/tipc/net.c
net/tipc/net.c
+1
-5
net/tipc/node.c
net/tipc/node.c
+0
-13
net/tipc/node.h
net/tipc/node.h
+0
-2
net/tipc/node_subscr.c
net/tipc/node_subscr.c
+0
-3
net/tipc/node_subscr.h
net/tipc/node_subscr.h
+0
-1
net/tipc/port.c
net/tipc/port.c
+2
-35
net/tipc/port.h
net/tipc/port.h
+0
-3
net/tipc/ref.c
net/tipc/ref.c
+0
-13
net/tipc/socket.c
net/tipc/socket.c
+4
-86
net/tipc/subscr.c
net/tipc/subscr.c
+0
-45
net/tipc/subscr.h
net/tipc/subscr.h
+0
-2
未找到文件。
net/tipc/Makefile
浏览文件 @
b6d151bb
...
@@ -9,5 +9,3 @@ tipc-y += addr.o bcast.o bearer.o config.o \
...
@@ -9,5 +9,3 @@ tipc-y += addr.o bcast.o bearer.o config.o \
name_distr.o subscr.o name_table.o net.o
\
name_distr.o subscr.o name_table.o net.o
\
netlink.o node.o node_subscr.o port.o ref.o
\
netlink.o node.o node_subscr.o port.o ref.o
\
socket.o log.o eth_media.o
socket.o log.o eth_media.o
# End of file
net/tipc/addr.c
浏览文件 @
b6d151bb
...
@@ -45,7 +45,6 @@
...
@@ -45,7 +45,6 @@
*
*
* Returns 1 if domain address is valid, otherwise 0
* Returns 1 if domain address is valid, otherwise 0
*/
*/
int
tipc_addr_domain_valid
(
u32
addr
)
int
tipc_addr_domain_valid
(
u32
addr
)
{
{
u32
n
=
tipc_node
(
addr
);
u32
n
=
tipc_node
(
addr
);
...
@@ -66,7 +65,6 @@ int tipc_addr_domain_valid(u32 addr)
...
@@ -66,7 +65,6 @@ int tipc_addr_domain_valid(u32 addr)
*
*
* Returns 1 if address can be used, otherwise 0
* Returns 1 if address can be used, otherwise 0
*/
*/
int
tipc_addr_node_valid
(
u32
addr
)
int
tipc_addr_node_valid
(
u32
addr
)
{
{
return
tipc_addr_domain_valid
(
addr
)
&&
tipc_node
(
addr
);
return
tipc_addr_domain_valid
(
addr
)
&&
tipc_node
(
addr
);
...
@@ -86,7 +84,6 @@ int tipc_in_scope(u32 domain, u32 addr)
...
@@ -86,7 +84,6 @@ int tipc_in_scope(u32 domain, u32 addr)
/**
/**
* tipc_addr_scope - convert message lookup domain to a 2-bit scope value
* tipc_addr_scope - convert message lookup domain to a 2-bit scope value
*/
*/
int
tipc_addr_scope
(
u32
domain
)
int
tipc_addr_scope
(
u32
domain
)
{
{
if
(
likely
(
!
domain
))
if
(
likely
(
!
domain
))
...
...
net/tipc/addr.h
浏览文件 @
b6d151bb
...
@@ -58,7 +58,6 @@ static inline int in_own_cluster_exact(u32 addr)
...
@@ -58,7 +58,6 @@ static inline int in_own_cluster_exact(u32 addr)
/**
/**
* in_own_node - test for node inclusion; <0.0.0> always matches
* in_own_node - test for node inclusion; <0.0.0> always matches
*/
*/
static
inline
int
in_own_node
(
u32
addr
)
static
inline
int
in_own_node
(
u32
addr
)
{
{
return
(
addr
==
tipc_own_addr
)
||
!
addr
;
return
(
addr
==
tipc_own_addr
)
||
!
addr
;
...
@@ -67,7 +66,6 @@ static inline int in_own_node(u32 addr)
...
@@ -67,7 +66,6 @@ static inline int in_own_node(u32 addr)
/**
/**
* in_own_cluster - test for cluster inclusion; <0.0.0> always matches
* in_own_cluster - test for cluster inclusion; <0.0.0> always matches
*/
*/
static
inline
int
in_own_cluster
(
u32
addr
)
static
inline
int
in_own_cluster
(
u32
addr
)
{
{
return
in_own_cluster_exact
(
addr
)
||
!
addr
;
return
in_own_cluster_exact
(
addr
)
||
!
addr
;
...
@@ -79,7 +77,6 @@ static inline int in_own_cluster(u32 addr)
...
@@ -79,7 +77,6 @@ static inline int in_own_cluster(u32 addr)
* Needed when address of a named message must be looked up a second time
* Needed when address of a named message must be looked up a second time
* after a network hop.
* after a network hop.
*/
*/
static
inline
u32
addr_domain
(
u32
sc
)
static
inline
u32
addr_domain
(
u32
sc
)
{
{
if
(
likely
(
sc
==
TIPC_NODE_SCOPE
))
if
(
likely
(
sc
==
TIPC_NODE_SCOPE
))
...
...
net/tipc/bcast.c
浏览文件 @
b6d151bb
...
@@ -73,7 +73,6 @@ struct tipc_bcbearer_pair {
...
@@ -73,7 +73,6 @@ struct tipc_bcbearer_pair {
* large local variables within multicast routines. Concurrent access is
* large local variables within multicast routines. Concurrent access is
* prevented through use of the spinlock "bc_lock".
* prevented through use of the spinlock "bc_lock".
*/
*/
struct
tipc_bcbearer
{
struct
tipc_bcbearer
{
struct
tipc_bearer
bearer
;
struct
tipc_bearer
bearer
;
struct
tipc_media
media
;
struct
tipc_media
media
;
...
@@ -92,7 +91,6 @@ struct tipc_bcbearer {
...
@@ -92,7 +91,6 @@ struct tipc_bcbearer {
*
*
* Handles sequence numbering, fragmentation, bundling, etc.
* Handles sequence numbering, fragmentation, bundling, etc.
*/
*/
struct
tipc_bclink
{
struct
tipc_bclink
{
struct
tipc_link
link
;
struct
tipc_link
link
;
struct
tipc_node
node
;
struct
tipc_node
node
;
...
@@ -169,7 +167,6 @@ static void bclink_update_last_sent(struct tipc_node *node, u32 seqno)
...
@@ -169,7 +167,6 @@ static void bclink_update_last_sent(struct tipc_node *node, u32 seqno)
*
*
* Called with bc_lock locked
* Called with bc_lock locked
*/
*/
struct
tipc_node
*
tipc_bclink_retransmit_to
(
void
)
struct
tipc_node
*
tipc_bclink_retransmit_to
(
void
)
{
{
return
bclink
->
retransmit_to
;
return
bclink
->
retransmit_to
;
...
@@ -182,7 +179,6 @@ struct tipc_node *tipc_bclink_retransmit_to(void)
...
@@ -182,7 +179,6 @@ struct tipc_node *tipc_bclink_retransmit_to(void)
*
*
* Called with bc_lock locked
* Called with bc_lock locked
*/
*/
static
void
bclink_retransmit_pkt
(
u32
after
,
u32
to
)
static
void
bclink_retransmit_pkt
(
u32
after
,
u32
to
)
{
{
struct
sk_buff
*
buf
;
struct
sk_buff
*
buf
;
...
@@ -200,7 +196,6 @@ static void bclink_retransmit_pkt(u32 after, u32 to)
...
@@ -200,7 +196,6 @@ static void bclink_retransmit_pkt(u32 after, u32 to)
*
*
* Node is locked, bc_lock unlocked.
* Node is locked, bc_lock unlocked.
*/
*/
void
tipc_bclink_acknowledge
(
struct
tipc_node
*
n_ptr
,
u32
acked
)
void
tipc_bclink_acknowledge
(
struct
tipc_node
*
n_ptr
,
u32
acked
)
{
{
struct
sk_buff
*
crs
;
struct
sk_buff
*
crs
;
...
@@ -280,7 +275,6 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked)
...
@@ -280,7 +275,6 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked)
*
*
* tipc_net_lock and node lock set
* tipc_net_lock and node lock set
*/
*/
void
tipc_bclink_update_link_state
(
struct
tipc_node
*
n_ptr
,
u32
last_sent
)
void
tipc_bclink_update_link_state
(
struct
tipc_node
*
n_ptr
,
u32
last_sent
)
{
{
struct
sk_buff
*
buf
;
struct
sk_buff
*
buf
;
...
@@ -344,7 +338,6 @@ void tipc_bclink_update_link_state(struct tipc_node *n_ptr, u32 last_sent)
...
@@ -344,7 +338,6 @@ void tipc_bclink_update_link_state(struct tipc_node *n_ptr, u32 last_sent)
*
*
* Only tipc_net_lock set.
* Only tipc_net_lock set.
*/
*/
static
void
bclink_peek_nack
(
struct
tipc_msg
*
msg
)
static
void
bclink_peek_nack
(
struct
tipc_msg
*
msg
)
{
{
struct
tipc_node
*
n_ptr
=
tipc_node_find
(
msg_destnode
(
msg
));
struct
tipc_node
*
n_ptr
=
tipc_node_find
(
msg_destnode
(
msg
));
...
@@ -365,7 +358,6 @@ static void bclink_peek_nack(struct tipc_msg *msg)
...
@@ -365,7 +358,6 @@ static void bclink_peek_nack(struct tipc_msg *msg)
/*
/*
* tipc_bclink_send_msg - broadcast a packet to all nodes in cluster
* tipc_bclink_send_msg - broadcast a packet to all nodes in cluster
*/
*/
int
tipc_bclink_send_msg
(
struct
sk_buff
*
buf
)
int
tipc_bclink_send_msg
(
struct
sk_buff
*
buf
)
{
{
int
res
;
int
res
;
...
@@ -394,7 +386,6 @@ int tipc_bclink_send_msg(struct sk_buff *buf)
...
@@ -394,7 +386,6 @@ int tipc_bclink_send_msg(struct sk_buff *buf)
*
*
* Called with both sending node's lock and bc_lock taken.
* Called with both sending node's lock and bc_lock taken.
*/
*/
static
void
bclink_accept_pkt
(
struct
tipc_node
*
node
,
u32
seqno
)
static
void
bclink_accept_pkt
(
struct
tipc_node
*
node
,
u32
seqno
)
{
{
bclink_update_last_sent
(
node
,
seqno
);
bclink_update_last_sent
(
node
,
seqno
);
...
@@ -420,7 +411,6 @@ static void bclink_accept_pkt(struct tipc_node *node, u32 seqno)
...
@@ -420,7 +411,6 @@ static void bclink_accept_pkt(struct tipc_node *node, u32 seqno)
*
*
* tipc_net_lock is read_locked, no other locks set
* tipc_net_lock is read_locked, no other locks set
*/
*/
void
tipc_bclink_recv_pkt
(
struct
sk_buff
*
buf
)
void
tipc_bclink_recv_pkt
(
struct
sk_buff
*
buf
)
{
{
struct
tipc_msg
*
msg
=
buf_msg
(
buf
);
struct
tipc_msg
*
msg
=
buf_msg
(
buf
);
...
@@ -588,7 +578,6 @@ u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr)
...
@@ -588,7 +578,6 @@ u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr)
* Returns 0 (packet sent successfully) under all circumstances,
* Returns 0 (packet sent successfully) under all circumstances,
* since the broadcast link's pseudo-bearer never blocks
* since the broadcast link's pseudo-bearer never blocks
*/
*/
static
int
tipc_bcbearer_send
(
struct
sk_buff
*
buf
,
static
int
tipc_bcbearer_send
(
struct
sk_buff
*
buf
,
struct
tipc_bearer
*
unused1
,
struct
tipc_bearer
*
unused1
,
struct
tipc_media_addr
*
unused2
)
struct
tipc_media_addr
*
unused2
)
...
@@ -601,7 +590,6 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
...
@@ -601,7 +590,6 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
* preparation is skipped for broadcast link protocol messages
* preparation is skipped for broadcast link protocol messages
* since they are sent in an unreliable manner and don't need it
* since they are sent in an unreliable manner and don't need it
*/
*/
if
(
likely
(
!
msg_non_seq
(
buf_msg
(
buf
))))
{
if
(
likely
(
!
msg_non_seq
(
buf_msg
(
buf
))))
{
struct
tipc_msg
*
msg
;
struct
tipc_msg
*
msg
;
...
@@ -618,7 +606,6 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
...
@@ -618,7 +606,6 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
}
}
/* Send buffer over bearers until all targets reached */
/* Send buffer over bearers until all targets reached */
bcbearer
->
remains
=
bclink
->
bcast_nodes
;
bcbearer
->
remains
=
bclink
->
bcast_nodes
;
for
(
bp_index
=
0
;
bp_index
<
MAX_BEARERS
;
bp_index
++
)
{
for
(
bp_index
=
0
;
bp_index
<
MAX_BEARERS
;
bp_index
++
)
{
...
@@ -660,7 +647,6 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
...
@@ -660,7 +647,6 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
/**
/**
* tipc_bcbearer_sort - create sets of bearer pairs used by broadcast bearer
* tipc_bcbearer_sort - create sets of bearer pairs used by broadcast bearer
*/
*/
void
tipc_bcbearer_sort
(
void
)
void
tipc_bcbearer_sort
(
void
)
{
{
struct
tipc_bcbearer_pair
*
bp_temp
=
bcbearer
->
bpairs_temp
;
struct
tipc_bcbearer_pair
*
bp_temp
=
bcbearer
->
bpairs_temp
;
...
@@ -671,7 +657,6 @@ void tipc_bcbearer_sort(void)
...
@@ -671,7 +657,6 @@ void tipc_bcbearer_sort(void)
spin_lock_bh
(
&
bc_lock
);
spin_lock_bh
(
&
bc_lock
);
/* Group bearers by priority (can assume max of two per priority) */
/* Group bearers by priority (can assume max of two per priority) */
memset
(
bp_temp
,
0
,
sizeof
(
bcbearer
->
bpairs_temp
));
memset
(
bp_temp
,
0
,
sizeof
(
bcbearer
->
bpairs_temp
));
for
(
b_index
=
0
;
b_index
<
MAX_BEARERS
;
b_index
++
)
{
for
(
b_index
=
0
;
b_index
<
MAX_BEARERS
;
b_index
++
)
{
...
@@ -687,7 +672,6 @@ void tipc_bcbearer_sort(void)
...
@@ -687,7 +672,6 @@ void tipc_bcbearer_sort(void)
}
}
/* Create array of bearer pairs for broadcasting */
/* Create array of bearer pairs for broadcasting */
bp_curr
=
bcbearer
->
bpairs
;
bp_curr
=
bcbearer
->
bpairs
;
memset
(
bcbearer
->
bpairs
,
0
,
sizeof
(
bcbearer
->
bpairs
));
memset
(
bcbearer
->
bpairs
,
0
,
sizeof
(
bcbearer
->
bpairs
));
...
@@ -817,7 +801,6 @@ void tipc_bclink_stop(void)
...
@@ -817,7 +801,6 @@ void tipc_bclink_stop(void)
/**
/**
* tipc_nmap_add - add a node to a node map
* tipc_nmap_add - add a node to a node map
*/
*/
void
tipc_nmap_add
(
struct
tipc_node_map
*
nm_ptr
,
u32
node
)
void
tipc_nmap_add
(
struct
tipc_node_map
*
nm_ptr
,
u32
node
)
{
{
int
n
=
tipc_node
(
node
);
int
n
=
tipc_node
(
node
);
...
@@ -833,7 +816,6 @@ void tipc_nmap_add(struct tipc_node_map *nm_ptr, u32 node)
...
@@ -833,7 +816,6 @@ void tipc_nmap_add(struct tipc_node_map *nm_ptr, u32 node)
/**
/**
* tipc_nmap_remove - remove a node from a node map
* tipc_nmap_remove - remove a node from a node map
*/
*/
void
tipc_nmap_remove
(
struct
tipc_node_map
*
nm_ptr
,
u32
node
)
void
tipc_nmap_remove
(
struct
tipc_node_map
*
nm_ptr
,
u32
node
)
{
{
int
n
=
tipc_node
(
node
);
int
n
=
tipc_node
(
node
);
...
@@ -852,7 +834,6 @@ void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node)
...
@@ -852,7 +834,6 @@ void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node)
* @nm_b: input node map B
* @nm_b: input node map B
* @nm_diff: output node map A-B (i.e. nodes of A that are not in B)
* @nm_diff: output node map A-B (i.e. nodes of A that are not in B)
*/
*/
static
void
tipc_nmap_diff
(
struct
tipc_node_map
*
nm_a
,
static
void
tipc_nmap_diff
(
struct
tipc_node_map
*
nm_a
,
struct
tipc_node_map
*
nm_b
,
struct
tipc_node_map
*
nm_b
,
struct
tipc_node_map
*
nm_diff
)
struct
tipc_node_map
*
nm_diff
)
...
@@ -878,7 +859,6 @@ static void tipc_nmap_diff(struct tipc_node_map *nm_a,
...
@@ -878,7 +859,6 @@ static void tipc_nmap_diff(struct tipc_node_map *nm_a,
/**
/**
* tipc_port_list_add - add a port to a port list, ensuring no duplicates
* tipc_port_list_add - add a port to a port list, ensuring no duplicates
*/
*/
void
tipc_port_list_add
(
struct
tipc_port_list
*
pl_ptr
,
u32
port
)
void
tipc_port_list_add
(
struct
tipc_port_list
*
pl_ptr
,
u32
port
)
{
{
struct
tipc_port_list
*
item
=
pl_ptr
;
struct
tipc_port_list
*
item
=
pl_ptr
;
...
@@ -912,7 +892,6 @@ void tipc_port_list_add(struct tipc_port_list *pl_ptr, u32 port)
...
@@ -912,7 +892,6 @@ void tipc_port_list_add(struct tipc_port_list *pl_ptr, u32 port)
* tipc_port_list_free - free dynamically created entries in port_list chain
* tipc_port_list_free - free dynamically created entries in port_list chain
*
*
*/
*/
void
tipc_port_list_free
(
struct
tipc_port_list
*
pl_ptr
)
void
tipc_port_list_free
(
struct
tipc_port_list
*
pl_ptr
)
{
{
struct
tipc_port_list
*
item
;
struct
tipc_port_list
*
item
;
...
@@ -923,4 +902,3 @@ void tipc_port_list_free(struct tipc_port_list *pl_ptr)
...
@@ -923,4 +902,3 @@ void tipc_port_list_free(struct tipc_port_list *pl_ptr)
kfree
(
item
);
kfree
(
item
);
}
}
}
}
net/tipc/bcast.h
浏览文件 @
b6d151bb
...
@@ -45,7 +45,6 @@
...
@@ -45,7 +45,6 @@
* @count: # of nodes in set
* @count: # of nodes in set
* @map: bitmap of node identifiers that are in the set
* @map: bitmap of node identifiers that are in the set
*/
*/
struct
tipc_node_map
{
struct
tipc_node_map
{
u32
count
;
u32
count
;
u32
map
[
MAX_NODES
/
WSIZE
];
u32
map
[
MAX_NODES
/
WSIZE
];
...
@@ -59,7 +58,6 @@ struct tipc_node_map {
...
@@ -59,7 +58,6 @@ struct tipc_node_map {
* @next: pointer to next entry in list
* @next: pointer to next entry in list
* @ports: array of port references
* @ports: array of port references
*/
*/
struct
tipc_port_list
{
struct
tipc_port_list
{
int
count
;
int
count
;
struct
tipc_port_list
*
next
;
struct
tipc_port_list
*
next
;
...
@@ -77,7 +75,6 @@ void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node);
...
@@ -77,7 +75,6 @@ void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node);
/**
/**
* tipc_nmap_equal - test for equality of node maps
* tipc_nmap_equal - test for equality of node maps
*/
*/
static
inline
int
tipc_nmap_equal
(
struct
tipc_node_map
*
nm_a
,
struct
tipc_node_map
*
nm_b
)
static
inline
int
tipc_nmap_equal
(
struct
tipc_node_map
*
nm_a
,
struct
tipc_node_map
*
nm_b
)
{
{
return
!
memcmp
(
nm_a
,
nm_b
,
sizeof
(
*
nm_a
));
return
!
memcmp
(
nm_a
,
nm_b
,
sizeof
(
*
nm_a
));
...
...
net/tipc/bearer.c
浏览文件 @
b6d151bb
...
@@ -53,7 +53,6 @@ static void bearer_disable(struct tipc_bearer *b_ptr);
...
@@ -53,7 +53,6 @@ static void bearer_disable(struct tipc_bearer *b_ptr);
*
*
* Returns 1 if media name is valid, otherwise 0.
* Returns 1 if media name is valid, otherwise 0.
*/
*/
static
int
media_name_valid
(
const
char
*
name
)
static
int
media_name_valid
(
const
char
*
name
)
{
{
u32
len
;
u32
len
;
...
@@ -67,7 +66,6 @@ static int media_name_valid(const char *name)
...
@@ -67,7 +66,6 @@ static int media_name_valid(const char *name)
/**
/**
* tipc_media_find - locates specified media object by name
* tipc_media_find - locates specified media object by name
*/
*/
struct
tipc_media
*
tipc_media_find
(
const
char
*
name
)
struct
tipc_media
*
tipc_media_find
(
const
char
*
name
)
{
{
u32
i
;
u32
i
;
...
@@ -82,7 +80,6 @@ struct tipc_media *tipc_media_find(const char *name)
...
@@ -82,7 +80,6 @@ struct tipc_media *tipc_media_find(const char *name)
/**
/**
* media_find_id - locates specified media object by type identifier
* media_find_id - locates specified media object by type identifier
*/
*/
static
struct
tipc_media
*
media_find_id
(
u8
type
)
static
struct
tipc_media
*
media_find_id
(
u8
type
)
{
{
u32
i
;
u32
i
;
...
@@ -99,7 +96,6 @@ static struct tipc_media *media_find_id(u8 type)
...
@@ -99,7 +96,6 @@ static struct tipc_media *media_find_id(u8 type)
*
*
* Bearers for this media type must be activated separately at a later stage.
* Bearers for this media type must be activated separately at a later stage.
*/
*/
int
tipc_register_media
(
struct
tipc_media
*
m_ptr
)
int
tipc_register_media
(
struct
tipc_media
*
m_ptr
)
{
{
int
res
=
-
EINVAL
;
int
res
=
-
EINVAL
;
...
@@ -134,7 +130,6 @@ int tipc_register_media(struct tipc_media *m_ptr)
...
@@ -134,7 +130,6 @@ int tipc_register_media(struct tipc_media *m_ptr)
/**
/**
* tipc_media_addr_printf - record media address in print buffer
* tipc_media_addr_printf - record media address in print buffer
*/
*/
void
tipc_media_addr_printf
(
struct
print_buf
*
pb
,
struct
tipc_media_addr
*
a
)
void
tipc_media_addr_printf
(
struct
print_buf
*
pb
,
struct
tipc_media_addr
*
a
)
{
{
char
addr_str
[
MAX_ADDR_STR
];
char
addr_str
[
MAX_ADDR_STR
];
...
@@ -156,7 +151,6 @@ void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a)
...
@@ -156,7 +151,6 @@ void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a)
/**
/**
* tipc_media_get_names - record names of registered media in buffer
* tipc_media_get_names - record names of registered media in buffer
*/
*/
struct
sk_buff
*
tipc_media_get_names
(
void
)
struct
sk_buff
*
tipc_media_get_names
(
void
)
{
{
struct
sk_buff
*
buf
;
struct
sk_buff
*
buf
;
...
@@ -183,7 +177,6 @@ struct sk_buff *tipc_media_get_names(void)
...
@@ -183,7 +177,6 @@ struct sk_buff *tipc_media_get_names(void)
*
*
* Returns 1 if bearer name is valid, otherwise 0.
* Returns 1 if bearer name is valid, otherwise 0.
*/
*/
static
int
bearer_name_validate
(
const
char
*
name
,
static
int
bearer_name_validate
(
const
char
*
name
,
struct
tipc_bearer_names
*
name_parts
)
struct
tipc_bearer_names
*
name_parts
)
{
{
...
@@ -194,7 +187,6 @@ static int bearer_name_validate(const char *name,
...
@@ -194,7 +187,6 @@ static int bearer_name_validate(const char *name,
u32
if_len
;
u32
if_len
;
/* copy bearer name & ensure length is OK */
/* copy bearer name & ensure length is OK */
name_copy
[
TIPC_MAX_BEARER_NAME
-
1
]
=
0
;
name_copy
[
TIPC_MAX_BEARER_NAME
-
1
]
=
0
;
/* need above in case non-Posix strncpy() doesn't pad with nulls */
/* need above in case non-Posix strncpy() doesn't pad with nulls */
strncpy
(
name_copy
,
name
,
TIPC_MAX_BEARER_NAME
);
strncpy
(
name_copy
,
name
,
TIPC_MAX_BEARER_NAME
);
...
@@ -202,7 +194,6 @@ static int bearer_name_validate(const char *name,
...
@@ -202,7 +194,6 @@ static int bearer_name_validate(const char *name,
return
0
;
return
0
;
/* ensure all component parts of bearer name are present */
/* ensure all component parts of bearer name are present */
media_name
=
name_copy
;
media_name
=
name_copy
;
if_name
=
strchr
(
media_name
,
':'
);
if_name
=
strchr
(
media_name
,
':'
);
if
(
if_name
==
NULL
)
if
(
if_name
==
NULL
)
...
@@ -212,7 +203,6 @@ static int bearer_name_validate(const char *name,
...
@@ -212,7 +203,6 @@ static int bearer_name_validate(const char *name,
if_len
=
strlen
(
if_name
)
+
1
;
if_len
=
strlen
(
if_name
)
+
1
;
/* validate component parts of bearer name */
/* validate component parts of bearer name */
if
((
media_len
<=
1
)
||
(
media_len
>
TIPC_MAX_MEDIA_NAME
)
||
if
((
media_len
<=
1
)
||
(
media_len
>
TIPC_MAX_MEDIA_NAME
)
||
(
if_len
<=
1
)
||
(
if_len
>
TIPC_MAX_IF_NAME
)
||
(
if_len
<=
1
)
||
(
if_len
>
TIPC_MAX_IF_NAME
)
||
(
strspn
(
media_name
,
tipc_alphabet
)
!=
(
media_len
-
1
))
||
(
strspn
(
media_name
,
tipc_alphabet
)
!=
(
media_len
-
1
))
||
...
@@ -220,7 +210,6 @@ static int bearer_name_validate(const char *name,
...
@@ -220,7 +210,6 @@ static int bearer_name_validate(const char *name,
return
0
;
return
0
;
/* return bearer name components, if necessary */
/* return bearer name components, if necessary */
if
(
name_parts
)
{
if
(
name_parts
)
{
strcpy
(
name_parts
->
media_name
,
media_name
);
strcpy
(
name_parts
->
media_name
,
media_name
);
strcpy
(
name_parts
->
if_name
,
if_name
);
strcpy
(
name_parts
->
if_name
,
if_name
);
...
@@ -231,7 +220,6 @@ static int bearer_name_validate(const char *name,
...
@@ -231,7 +220,6 @@ static int bearer_name_validate(const char *name,
/**
/**
* tipc_bearer_find - locates bearer object with matching bearer name
* tipc_bearer_find - locates bearer object with matching bearer name
*/
*/
struct
tipc_bearer
*
tipc_bearer_find
(
const
char
*
name
)
struct
tipc_bearer
*
tipc_bearer_find
(
const
char
*
name
)
{
{
struct
tipc_bearer
*
b_ptr
;
struct
tipc_bearer
*
b_ptr
;
...
@@ -247,7 +235,6 @@ struct tipc_bearer *tipc_bearer_find(const char *name)
...
@@ -247,7 +235,6 @@ struct tipc_bearer *tipc_bearer_find(const char *name)
/**
/**
* tipc_bearer_find_interface - locates bearer object with matching interface name
* tipc_bearer_find_interface - locates bearer object with matching interface name
*/
*/
struct
tipc_bearer
*
tipc_bearer_find_interface
(
const
char
*
if_name
)
struct
tipc_bearer
*
tipc_bearer_find_interface
(
const
char
*
if_name
)
{
{
struct
tipc_bearer
*
b_ptr
;
struct
tipc_bearer
*
b_ptr
;
...
@@ -267,7 +254,6 @@ struct tipc_bearer *tipc_bearer_find_interface(const char *if_name)
...
@@ -267,7 +254,6 @@ struct tipc_bearer *tipc_bearer_find_interface(const char *if_name)
/**
/**
* tipc_bearer_get_names - record names of bearers in buffer
* tipc_bearer_get_names - record names of bearers in buffer
*/
*/
struct
sk_buff
*
tipc_bearer_get_names
(
void
)
struct
sk_buff
*
tipc_bearer_get_names
(
void
)
{
{
struct
sk_buff
*
buf
;
struct
sk_buff
*
buf
;
...
@@ -363,7 +349,6 @@ void tipc_continue(struct tipc_bearer *b_ptr)
...
@@ -363,7 +349,6 @@ void tipc_continue(struct tipc_bearer *b_ptr)
* the bearer is congested. 'tipc_net_lock' is in read_lock here
* the bearer is congested. 'tipc_net_lock' is in read_lock here
* bearer.lock is busy
* bearer.lock is busy
*/
*/
static
void
tipc_bearer_schedule_unlocked
(
struct
tipc_bearer
*
b_ptr
,
static
void
tipc_bearer_schedule_unlocked
(
struct
tipc_bearer
*
b_ptr
,
struct
tipc_link
*
l_ptr
)
struct
tipc_link
*
l_ptr
)
{
{
...
@@ -377,7 +362,6 @@ static void tipc_bearer_schedule_unlocked(struct tipc_bearer *b_ptr,
...
@@ -377,7 +362,6 @@ static void tipc_bearer_schedule_unlocked(struct tipc_bearer *b_ptr,
* the bearer is congested. 'tipc_net_lock' is in read_lock here,
* the bearer is congested. 'tipc_net_lock' is in read_lock here,
* bearer.lock is free
* bearer.lock is free
*/
*/
void
tipc_bearer_schedule
(
struct
tipc_bearer
*
b_ptr
,
struct
tipc_link
*
l_ptr
)
void
tipc_bearer_schedule
(
struct
tipc_bearer
*
b_ptr
,
struct
tipc_link
*
l_ptr
)
{
{
spin_lock_bh
(
&
b_ptr
->
lock
);
spin_lock_bh
(
&
b_ptr
->
lock
);
...
@@ -410,7 +394,6 @@ int tipc_bearer_resolve_congestion(struct tipc_bearer *b_ptr,
...
@@ -410,7 +394,6 @@ int tipc_bearer_resolve_congestion(struct tipc_bearer *b_ptr,
/**
/**
* tipc_bearer_congested - determines if bearer is currently congested
* tipc_bearer_congested - determines if bearer is currently congested
*/
*/
int
tipc_bearer_congested
(
struct
tipc_bearer
*
b_ptr
,
struct
tipc_link
*
l_ptr
)
int
tipc_bearer_congested
(
struct
tipc_bearer
*
b_ptr
,
struct
tipc_link
*
l_ptr
)
{
{
if
(
unlikely
(
b_ptr
->
blocked
))
if
(
unlikely
(
b_ptr
->
blocked
))
...
@@ -423,7 +406,6 @@ int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct tipc_link *l_ptr)
...
@@ -423,7 +406,6 @@ int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct tipc_link *l_ptr)
/**
/**
* tipc_enable_bearer - enable bearer with the given name
* tipc_enable_bearer - enable bearer with the given name
*/
*/
int
tipc_enable_bearer
(
const
char
*
name
,
u32
disc_domain
,
u32
priority
)
int
tipc_enable_bearer
(
const
char
*
name
,
u32
disc_domain
,
u32
priority
)
{
{
struct
tipc_bearer
*
b_ptr
;
struct
tipc_bearer
*
b_ptr
;
...
@@ -541,7 +523,6 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
...
@@ -541,7 +523,6 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
* tipc_block_bearer(): Block the bearer with the given name,
* tipc_block_bearer(): Block the bearer with the given name,
* and reset all its links
* and reset all its links
*/
*/
int
tipc_block_bearer
(
const
char
*
name
)
int
tipc_block_bearer
(
const
char
*
name
)
{
{
struct
tipc_bearer
*
b_ptr
=
NULL
;
struct
tipc_bearer
*
b_ptr
=
NULL
;
...
@@ -573,11 +554,10 @@ int tipc_block_bearer(const char *name)
...
@@ -573,11 +554,10 @@ int tipc_block_bearer(const char *name)
}
}
/**
/**
* bearer_disable
-
* bearer_disable
*
*
* Note: This routine assumes caller holds tipc_net_lock.
* Note: This routine assumes caller holds tipc_net_lock.
*/
*/
static
void
bearer_disable
(
struct
tipc_bearer
*
b_ptr
)
static
void
bearer_disable
(
struct
tipc_bearer
*
b_ptr
)
{
{
struct
tipc_link
*
l_ptr
;
struct
tipc_link
*
l_ptr
;
...
...
net/tipc/bearer.h
浏览文件 @
b6d151bb
...
@@ -49,7 +49,6 @@
...
@@ -49,7 +49,6 @@
* - media type identifier located at offset 3
* - media type identifier located at offset 3
* - remaining bytes vary according to media type
* - remaining bytes vary according to media type
*/
*/
#define TIPC_MEDIA_ADDR_SIZE 20
#define TIPC_MEDIA_ADDR_SIZE 20
#define TIPC_MEDIA_TYPE_OFFSET 3
#define TIPC_MEDIA_TYPE_OFFSET 3
...
@@ -64,7 +63,6 @@
...
@@ -64,7 +63,6 @@
* @media_id: TIPC media type identifier
* @media_id: TIPC media type identifier
* @broadcast: non-zero if address is a broadcast address
* @broadcast: non-zero if address is a broadcast address
*/
*/
struct
tipc_media_addr
{
struct
tipc_media_addr
{
u8
value
[
TIPC_MEDIA_ADDR_SIZE
];
u8
value
[
TIPC_MEDIA_ADDR_SIZE
];
u8
media_id
;
u8
media_id
;
...
@@ -89,7 +87,6 @@ struct tipc_bearer;
...
@@ -89,7 +87,6 @@ struct tipc_bearer;
* @type_id: TIPC media identifier
* @type_id: TIPC media identifier
* @name: media name
* @name: media name
*/
*/
struct
tipc_media
{
struct
tipc_media
{
int
(
*
send_msg
)(
struct
sk_buff
*
buf
,
int
(
*
send_msg
)(
struct
sk_buff
*
buf
,
struct
tipc_bearer
*
b_ptr
,
struct
tipc_bearer
*
b_ptr
,
...
@@ -216,7 +213,6 @@ void tipc_bearer_lock_push(struct tipc_bearer *b_ptr);
...
@@ -216,7 +213,6 @@ void tipc_bearer_lock_push(struct tipc_bearer *b_ptr);
* send routine always returns success -- even if the buffer was not sent --
* send routine always returns success -- even if the buffer was not sent --
* and let TIPC's link code deal with the undelivered message.
* and let TIPC's link code deal with the undelivered message.
*/
*/
static
inline
int
tipc_bearer_send
(
struct
tipc_bearer
*
b_ptr
,
static
inline
int
tipc_bearer_send
(
struct
tipc_bearer
*
b_ptr
,
struct
sk_buff
*
buf
,
struct
sk_buff
*
buf
,
struct
tipc_media_addr
*
dest
)
struct
tipc_media_addr
*
dest
)
...
...
net/tipc/config.c
浏览文件 @
b6d151bb
...
@@ -131,7 +131,6 @@ static struct sk_buff *tipc_show_stats(void)
...
@@ -131,7 +131,6 @@ static struct sk_buff *tipc_show_stats(void)
tipc_printf
(
&
pb
,
"TIPC version "
TIPC_MOD_VER
"
\n
"
);
tipc_printf
(
&
pb
,
"TIPC version "
TIPC_MOD_VER
"
\n
"
);
/* Use additional tipc_printf()'s to return more info ... */
/* Use additional tipc_printf()'s to return more info ... */
str_len
=
tipc_printbuf_validate
(
&
pb
);
str_len
=
tipc_printbuf_validate
(
&
pb
);
skb_put
(
buf
,
TLV_SPACE
(
str_len
));
skb_put
(
buf
,
TLV_SPACE
(
str_len
));
TLV_SET
(
rep_tlv
,
TIPC_TLV_ULTRA_STRING
,
NULL
,
str_len
);
TLV_SET
(
rep_tlv
,
TIPC_TLV_ULTRA_STRING
,
NULL
,
str_len
);
...
@@ -191,7 +190,6 @@ static struct sk_buff *cfg_set_own_addr(void)
...
@@ -191,7 +190,6 @@ static struct sk_buff *cfg_set_own_addr(void)
* configuration commands can't be received until a local configuration
* configuration commands can't be received until a local configuration
* command to enable the first bearer is received and processed.
* command to enable the first bearer is received and processed.
*/
*/
spin_unlock_bh
(
&
config_lock
);
spin_unlock_bh
(
&
config_lock
);
tipc_core_start_net
(
addr
);
tipc_core_start_net
(
addr
);
spin_lock_bh
(
&
config_lock
);
spin_lock_bh
(
&
config_lock
);
...
@@ -283,13 +281,11 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
...
@@ -283,13 +281,11 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
spin_lock_bh
(
&
config_lock
);
spin_lock_bh
(
&
config_lock
);
/* Save request and reply details in a well-known location */
/* Save request and reply details in a well-known location */
req_tlv_area
=
request_area
;
req_tlv_area
=
request_area
;
req_tlv_space
=
request_space
;
req_tlv_space
=
request_space
;
rep_headroom
=
reply_headroom
;
rep_headroom
=
reply_headroom
;
/* Check command authorization */
/* Check command authorization */
if
(
likely
(
in_own_node
(
orig_node
)))
{
if
(
likely
(
in_own_node
(
orig_node
)))
{
/* command is permitted */
/* command is permitted */
}
else
if
(
cmd
>=
0x8000
)
{
}
else
if
(
cmd
>=
0x8000
)
{
...
@@ -310,7 +306,6 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
...
@@ -310,7 +306,6 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
}
}
/* Call appropriate processing routine */
/* Call appropriate processing routine */
switch
(
cmd
)
{
switch
(
cmd
)
{
case
TIPC_CMD_NOOP
:
case
TIPC_CMD_NOOP
:
rep_tlv_buf
=
tipc_cfg_reply_none
();
rep_tlv_buf
=
tipc_cfg_reply_none
();
...
@@ -433,7 +428,6 @@ static void cfg_named_msg_event(void *userdata,
...
@@ -433,7 +428,6 @@ static void cfg_named_msg_event(void *userdata,
struct
sk_buff
*
rep_buf
;
struct
sk_buff
*
rep_buf
;
/* Validate configuration message header (ignore invalid message) */
/* Validate configuration message header (ignore invalid message) */
req_hdr
=
(
struct
tipc_cfg_msg_hdr
*
)
msg
;
req_hdr
=
(
struct
tipc_cfg_msg_hdr
*
)
msg
;
if
((
size
<
sizeof
(
*
req_hdr
))
||
if
((
size
<
sizeof
(
*
req_hdr
))
||
(
size
!=
TCM_ALIGN
(
ntohl
(
req_hdr
->
tcm_len
)))
||
(
size
!=
TCM_ALIGN
(
ntohl
(
req_hdr
->
tcm_len
)))
||
...
@@ -443,7 +437,6 @@ static void cfg_named_msg_event(void *userdata,
...
@@ -443,7 +437,6 @@ static void cfg_named_msg_event(void *userdata,
}
}
/* Generate reply for request (if can't, return request) */
/* Generate reply for request (if can't, return request) */
rep_buf
=
tipc_cfg_do_cmd
(
orig
->
node
,
rep_buf
=
tipc_cfg_do_cmd
(
orig
->
node
,
ntohs
(
req_hdr
->
tcm_type
),
ntohs
(
req_hdr
->
tcm_type
),
msg
+
sizeof
(
*
req_hdr
),
msg
+
sizeof
(
*
req_hdr
),
...
@@ -489,10 +482,23 @@ int tipc_cfg_init(void)
...
@@ -489,10 +482,23 @@ int tipc_cfg_init(void)
return
res
;
return
res
;
}
}
void
tipc_cfg_reinit
(
void
)
{
struct
tipc_name_seq
seq
;
int
res
;
seq
.
type
=
TIPC_CFG_SRV
;
seq
.
lower
=
seq
.
upper
=
0
;
tipc_withdraw
(
config_port_ref
,
TIPC_ZONE_SCOPE
,
&
seq
);
seq
.
lower
=
seq
.
upper
=
tipc_own_addr
;
res
=
tipc_publish
(
config_port_ref
,
TIPC_ZONE_SCOPE
,
&
seq
);
if
(
res
)
err
(
"Unable to reinitialize configuration service
\n
"
);
}
void
tipc_cfg_stop
(
void
)
void
tipc_cfg_stop
(
void
)
{
{
if
(
config_port_ref
)
{
tipc_deleteport
(
config_port_ref
);
tipc_deleteport
(
config_port_ref
);
config_port_ref
=
0
;
config_port_ref
=
0
;
}
}
}
net/tipc/config.h
浏览文件 @
b6d151bb
...
@@ -66,6 +66,7 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd,
...
@@ -66,6 +66,7 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd,
int
headroom
);
int
headroom
);
int
tipc_cfg_init
(
void
);
int
tipc_cfg_init
(
void
);
void
tipc_cfg_reinit
(
void
);
void
tipc_cfg_stop
(
void
);
void
tipc_cfg_stop
(
void
);
#endif
#endif
net/tipc/core.c
浏览文件 @
b6d151bb
...
@@ -52,14 +52,12 @@
...
@@ -52,14 +52,12 @@
#endif
#endif
/* global variables used by multiple sub-systems within TIPC */
/* global variables used by multiple sub-systems within TIPC */
int
tipc_random
;
int
tipc_random
;
const
char
tipc_alphabet
[]
=
const
char
tipc_alphabet
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_."
;
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_."
;
/* configurable TIPC parameters */
/* configurable TIPC parameters */
u32
tipc_own_addr
;
u32
tipc_own_addr
;
int
tipc_max_ports
;
int
tipc_max_ports
;
int
tipc_max_subscriptions
;
int
tipc_max_subscriptions
;
...
@@ -77,7 +75,6 @@ int tipc_remote_management;
...
@@ -77,7 +75,6 @@ int tipc_remote_management;
* NOTE: Headroom is reserved to allow prepending of a data link header.
* NOTE: Headroom is reserved to allow prepending of a data link header.
* There may also be unrequested tailroom present at the buffer's end.
* There may also be unrequested tailroom present at the buffer's end.
*/
*/
struct
sk_buff
*
tipc_buf_acquire
(
u32
size
)
struct
sk_buff
*
tipc_buf_acquire
(
u32
size
)
{
{
struct
sk_buff
*
skb
;
struct
sk_buff
*
skb
;
...
@@ -95,7 +92,6 @@ struct sk_buff *tipc_buf_acquire(u32 size)
...
@@ -95,7 +92,6 @@ struct sk_buff *tipc_buf_acquire(u32 size)
/**
/**
* tipc_core_stop_net - shut down TIPC networking sub-systems
* tipc_core_stop_net - shut down TIPC networking sub-systems
*/
*/
static
void
tipc_core_stop_net
(
void
)
static
void
tipc_core_stop_net
(
void
)
{
{
tipc_net_stop
();
tipc_net_stop
();
...
@@ -105,7 +101,6 @@ static void tipc_core_stop_net(void)
...
@@ -105,7 +101,6 @@ static void tipc_core_stop_net(void)
/**
/**
* start_net - start TIPC networking sub-systems
* start_net - start TIPC networking sub-systems
*/
*/
int
tipc_core_start_net
(
unsigned
long
addr
)
int
tipc_core_start_net
(
unsigned
long
addr
)
{
{
int
res
;
int
res
;
...
@@ -121,7 +116,6 @@ int tipc_core_start_net(unsigned long addr)
...
@@ -121,7 +116,6 @@ int tipc_core_start_net(unsigned long addr)
/**
/**
* tipc_core_stop - switch TIPC from SINGLE NODE to NOT RUNNING mode
* tipc_core_stop - switch TIPC from SINGLE NODE to NOT RUNNING mode
*/
*/
static
void
tipc_core_stop
(
void
)
static
void
tipc_core_stop
(
void
)
{
{
tipc_netlink_stop
();
tipc_netlink_stop
();
...
@@ -137,7 +131,6 @@ static void tipc_core_stop(void)
...
@@ -137,7 +131,6 @@ static void tipc_core_stop(void)
/**
/**
* tipc_core_start - switch TIPC from NOT RUNNING to SINGLE NODE mode
* tipc_core_start - switch TIPC from NOT RUNNING to SINGLE NODE mode
*/
*/
static
int
tipc_core_start
(
void
)
static
int
tipc_core_start
(
void
)
{
{
int
res
;
int
res
;
...
@@ -150,9 +143,9 @@ static int tipc_core_start(void)
...
@@ -150,9 +143,9 @@ static int tipc_core_start(void)
if
(
!
res
)
if
(
!
res
)
res
=
tipc_nametbl_init
();
res
=
tipc_nametbl_init
();
if
(
!
res
)
if
(
!
res
)
res
=
tipc_
k_signal
((
Handler
)
tipc_subscr_start
,
0
);
res
=
tipc_
subscr_start
(
);
if
(
!
res
)
if
(
!
res
)
res
=
tipc_
k_signal
((
Handler
)
tipc_cfg_init
,
0
);
res
=
tipc_
cfg_init
(
);
if
(
!
res
)
if
(
!
res
)
res
=
tipc_netlink_start
();
res
=
tipc_netlink_start
();
if
(
!
res
)
if
(
!
res
)
...
...
net/tipc/core.h
浏览文件 @
b6d151bb
...
@@ -85,7 +85,6 @@ void tipc_printf(struct print_buf *, const char *fmt, ...);
...
@@ -85,7 +85,6 @@ void tipc_printf(struct print_buf *, const char *fmt, ...);
/*
/*
* TIPC_OUTPUT is the destination print buffer for system messages.
* TIPC_OUTPUT is the destination print buffer for system messages.
*/
*/
#ifndef TIPC_OUTPUT
#ifndef TIPC_OUTPUT
#define TIPC_OUTPUT TIPC_LOG
#define TIPC_OUTPUT TIPC_LOG
#endif
#endif
...
@@ -102,7 +101,6 @@ void tipc_printf(struct print_buf *, const char *fmt, ...);
...
@@ -102,7 +101,6 @@ void tipc_printf(struct print_buf *, const char *fmt, ...);
/*
/*
* DBG_OUTPUT is the destination print buffer for debug messages.
* DBG_OUTPUT is the destination print buffer for debug messages.
*/
*/
#ifndef DBG_OUTPUT
#ifndef DBG_OUTPUT
#define DBG_OUTPUT TIPC_LOG
#define DBG_OUTPUT TIPC_LOG
#endif
#endif
...
@@ -126,13 +124,11 @@ void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *);
...
@@ -126,13 +124,11 @@ void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *);
/*
/*
* TIPC-specific error codes
* TIPC-specific error codes
*/
*/
#define ELINKCONG EAGAIN
/* link congestion <=> resource unavailable */
#define ELINKCONG EAGAIN
/* link congestion <=> resource unavailable */
/*
/*
* Global configuration variables
* Global configuration variables
*/
*/
extern
u32
tipc_own_addr
;
extern
u32
tipc_own_addr
;
extern
int
tipc_max_ports
;
extern
int
tipc_max_ports
;
extern
int
tipc_max_subscriptions
;
extern
int
tipc_max_subscriptions
;
...
@@ -143,7 +139,6 @@ extern int tipc_remote_management;
...
@@ -143,7 +139,6 @@ extern int tipc_remote_management;
/*
/*
* Other global variables
* Other global variables
*/
*/
extern
int
tipc_random
;
extern
int
tipc_random
;
extern
const
char
tipc_alphabet
[];
extern
const
char
tipc_alphabet
[];
...
@@ -151,7 +146,6 @@ extern const char tipc_alphabet[];
...
@@ -151,7 +146,6 @@ extern const char tipc_alphabet[];
/*
/*
* Routines available to privileged subsystems
* Routines available to privileged subsystems
*/
*/
extern
int
tipc_core_start_net
(
unsigned
long
);
extern
int
tipc_core_start_net
(
unsigned
long
);
extern
int
tipc_handler_start
(
void
);
extern
int
tipc_handler_start
(
void
);
extern
void
tipc_handler_stop
(
void
);
extern
void
tipc_handler_stop
(
void
);
...
@@ -163,7 +157,6 @@ extern void tipc_socket_stop(void);
...
@@ -163,7 +157,6 @@ extern void tipc_socket_stop(void);
/*
/*
* TIPC timer and signal code
* TIPC timer and signal code
*/
*/
typedef
void
(
*
Handler
)
(
unsigned
long
);
typedef
void
(
*
Handler
)
(
unsigned
long
);
u32
tipc_k_signal
(
Handler
routine
,
unsigned
long
argument
);
u32
tipc_k_signal
(
Handler
routine
,
unsigned
long
argument
);
...
@@ -176,7 +169,6 @@ u32 tipc_k_signal(Handler routine, unsigned long argument);
...
@@ -176,7 +169,6 @@ u32 tipc_k_signal(Handler routine, unsigned long argument);
*
*
* Timer must be initialized before use (and terminated when no longer needed).
* Timer must be initialized before use (and terminated when no longer needed).
*/
*/
static
inline
void
k_init_timer
(
struct
timer_list
*
timer
,
Handler
routine
,
static
inline
void
k_init_timer
(
struct
timer_list
*
timer
,
Handler
routine
,
unsigned
long
argument
)
unsigned
long
argument
)
{
{
...
@@ -196,7 +188,6 @@ static inline void k_init_timer(struct timer_list *timer, Handler routine,
...
@@ -196,7 +188,6 @@ static inline void k_init_timer(struct timer_list *timer, Handler routine,
* then an additional jiffy is added to account for the fact that
* then an additional jiffy is added to account for the fact that
* the starting time may be in the middle of the current jiffy.
* the starting time may be in the middle of the current jiffy.
*/
*/
static
inline
void
k_start_timer
(
struct
timer_list
*
timer
,
unsigned
long
msec
)
static
inline
void
k_start_timer
(
struct
timer_list
*
timer
,
unsigned
long
msec
)
{
{
mod_timer
(
timer
,
jiffies
+
msecs_to_jiffies
(
msec
)
+
1
);
mod_timer
(
timer
,
jiffies
+
msecs_to_jiffies
(
msec
)
+
1
);
...
@@ -212,7 +203,6 @@ static inline void k_start_timer(struct timer_list *timer, unsigned long msec)
...
@@ -212,7 +203,6 @@ static inline void k_start_timer(struct timer_list *timer, unsigned long msec)
* WARNING: Must not be called when holding locks required by the timer's
* WARNING: Must not be called when holding locks required by the timer's
* timeout routine, otherwise deadlock can occur on SMP systems!
* timeout routine, otherwise deadlock can occur on SMP systems!
*/
*/
static
inline
void
k_cancel_timer
(
struct
timer_list
*
timer
)
static
inline
void
k_cancel_timer
(
struct
timer_list
*
timer
)
{
{
del_timer_sync
(
timer
);
del_timer_sync
(
timer
);
...
@@ -229,12 +219,10 @@ static inline void k_cancel_timer(struct timer_list *timer)
...
@@ -229,12 +219,10 @@ static inline void k_cancel_timer(struct timer_list *timer)
* (Do not "enhance" this routine to automatically cancel an active timer,
* (Do not "enhance" this routine to automatically cancel an active timer,
* otherwise deadlock can arise when a timeout routine calls k_term_timer.)
* otherwise deadlock can arise when a timeout routine calls k_term_timer.)
*/
*/
static
inline
void
k_term_timer
(
struct
timer_list
*
timer
)
static
inline
void
k_term_timer
(
struct
timer_list
*
timer
)
{
{
}
}
/*
/*
* TIPC message buffer code
* TIPC message buffer code
*
*
...
@@ -244,7 +232,6 @@ static inline void k_term_timer(struct timer_list *timer)
...
@@ -244,7 +232,6 @@ static inline void k_term_timer(struct timer_list *timer)
* Note: Headroom should be a multiple of 4 to ensure the TIPC header fields
* Note: Headroom should be a multiple of 4 to ensure the TIPC header fields
* are word aligned for quicker access
* are word aligned for quicker access
*/
*/
#define BUF_HEADROOM LL_MAX_HEADER
#define BUF_HEADROOM LL_MAX_HEADER
struct
tipc_skb_cb
{
struct
tipc_skb_cb
{
...
@@ -253,7 +240,6 @@ struct tipc_skb_cb {
...
@@ -253,7 +240,6 @@ struct tipc_skb_cb {
#define TIPC_SKB_CB(__skb) ((struct tipc_skb_cb *)&((__skb)->cb[0]))
#define TIPC_SKB_CB(__skb) ((struct tipc_skb_cb *)&((__skb)->cb[0]))
static
inline
struct
tipc_msg
*
buf_msg
(
struct
sk_buff
*
skb
)
static
inline
struct
tipc_msg
*
buf_msg
(
struct
sk_buff
*
skb
)
{
{
return
(
struct
tipc_msg
*
)
skb
->
data
;
return
(
struct
tipc_msg
*
)
skb
->
data
;
...
...
net/tipc/discover.c
浏览文件 @
b6d151bb
...
@@ -70,7 +70,6 @@ struct tipc_link_req {
...
@@ -70,7 +70,6 @@ struct tipc_link_req {
* @dest_domain: network domain of node(s) which should respond to message
* @dest_domain: network domain of node(s) which should respond to message
* @b_ptr: ptr to bearer issuing message
* @b_ptr: ptr to bearer issuing message
*/
*/
static
struct
sk_buff
*
tipc_disc_init_msg
(
u32
type
,
static
struct
sk_buff
*
tipc_disc_init_msg
(
u32
type
,
u32
dest_domain
,
u32
dest_domain
,
struct
tipc_bearer
*
b_ptr
)
struct
tipc_bearer
*
b_ptr
)
...
@@ -96,7 +95,6 @@ static struct sk_buff *tipc_disc_init_msg(u32 type,
...
@@ -96,7 +95,6 @@ static struct sk_buff *tipc_disc_init_msg(u32 type,
* @node_addr: duplicated node address
* @node_addr: duplicated node address
* @media_addr: media address advertised by duplicated node
* @media_addr: media address advertised by duplicated node
*/
*/
static
void
disc_dupl_alert
(
struct
tipc_bearer
*
b_ptr
,
u32
node_addr
,
static
void
disc_dupl_alert
(
struct
tipc_bearer
*
b_ptr
,
u32
node_addr
,
struct
tipc_media_addr
*
media_addr
)
struct
tipc_media_addr
*
media_addr
)
{
{
...
@@ -117,7 +115,6 @@ static void disc_dupl_alert(struct tipc_bearer *b_ptr, u32 node_addr,
...
@@ -117,7 +115,6 @@ static void disc_dupl_alert(struct tipc_bearer *b_ptr, u32 node_addr,
* @buf: buffer containing message
* @buf: buffer containing message
* @b_ptr: bearer that message arrived on
* @b_ptr: bearer that message arrived on
*/
*/
void
tipc_disc_recv_msg
(
struct
sk_buff
*
buf
,
struct
tipc_bearer
*
b_ptr
)
void
tipc_disc_recv_msg
(
struct
sk_buff
*
buf
,
struct
tipc_bearer
*
b_ptr
)
{
{
struct
tipc_node
*
n_ptr
;
struct
tipc_node
*
n_ptr
;
...
@@ -221,7 +218,6 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
...
@@ -221,7 +218,6 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
* the new media address and reset the link to ensure it starts up
* the new media address and reset the link to ensure it starts up
* cleanly.
* cleanly.
*/
*/
if
(
addr_mismatch
)
{
if
(
addr_mismatch
)
{
if
(
tipc_link_is_up
(
link
))
{
if
(
tipc_link_is_up
(
link
))
{
disc_dupl_alert
(
b_ptr
,
orig
,
&
media_addr
);
disc_dupl_alert
(
b_ptr
,
orig
,
&
media_addr
);
...
@@ -264,7 +260,6 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
...
@@ -264,7 +260,6 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
* Reinitiates discovery process if discovery object has no associated nodes
* Reinitiates discovery process if discovery object has no associated nodes
* and is either not currently searching or is searching at a slow rate
* and is either not currently searching or is searching at a slow rate
*/
*/
static
void
disc_update
(
struct
tipc_link_req
*
req
)
static
void
disc_update
(
struct
tipc_link_req
*
req
)
{
{
if
(
!
req
->
num_nodes
)
{
if
(
!
req
->
num_nodes
)
{
...
@@ -280,7 +275,6 @@ static void disc_update(struct tipc_link_req *req)
...
@@ -280,7 +275,6 @@ static void disc_update(struct tipc_link_req *req)
* tipc_disc_add_dest - increment set of discovered nodes
* tipc_disc_add_dest - increment set of discovered nodes
* @req: ptr to link request structure
* @req: ptr to link request structure
*/
*/
void
tipc_disc_add_dest
(
struct
tipc_link_req
*
req
)
void
tipc_disc_add_dest
(
struct
tipc_link_req
*
req
)
{
{
req
->
num_nodes
++
;
req
->
num_nodes
++
;
...
@@ -290,7 +284,6 @@ void tipc_disc_add_dest(struct tipc_link_req *req)
...
@@ -290,7 +284,6 @@ void tipc_disc_add_dest(struct tipc_link_req *req)
* tipc_disc_remove_dest - decrement set of discovered nodes
* tipc_disc_remove_dest - decrement set of discovered nodes
* @req: ptr to link request structure
* @req: ptr to link request structure
*/
*/
void
tipc_disc_remove_dest
(
struct
tipc_link_req
*
req
)
void
tipc_disc_remove_dest
(
struct
tipc_link_req
*
req
)
{
{
req
->
num_nodes
--
;
req
->
num_nodes
--
;
...
@@ -301,7 +294,6 @@ void tipc_disc_remove_dest(struct tipc_link_req *req)
...
@@ -301,7 +294,6 @@ void tipc_disc_remove_dest(struct tipc_link_req *req)
* disc_send_msg - send link setup request message
* disc_send_msg - send link setup request message
* @req: ptr to link request structure
* @req: ptr to link request structure
*/
*/
static
void
disc_send_msg
(
struct
tipc_link_req
*
req
)
static
void
disc_send_msg
(
struct
tipc_link_req
*
req
)
{
{
if
(
!
req
->
bearer
->
blocked
)
if
(
!
req
->
bearer
->
blocked
)
...
@@ -314,7 +306,6 @@ static void disc_send_msg(struct tipc_link_req *req)
...
@@ -314,7 +306,6 @@ static void disc_send_msg(struct tipc_link_req *req)
*
*
* Called whenever a link setup request timer associated with a bearer expires.
* Called whenever a link setup request timer associated with a bearer expires.
*/
*/
static
void
disc_timeout
(
struct
tipc_link_req
*
req
)
static
void
disc_timeout
(
struct
tipc_link_req
*
req
)
{
{
int
max_delay
;
int
max_delay
;
...
@@ -322,7 +313,6 @@ static void disc_timeout(struct tipc_link_req *req)
...
@@ -322,7 +313,6 @@ static void disc_timeout(struct tipc_link_req *req)
spin_lock_bh
(
&
req
->
bearer
->
lock
);
spin_lock_bh
(
&
req
->
bearer
->
lock
);
/* Stop searching if only desired node has been found */
/* Stop searching if only desired node has been found */
if
(
tipc_node
(
req
->
domain
)
&&
req
->
num_nodes
)
{
if
(
tipc_node
(
req
->
domain
)
&&
req
->
num_nodes
)
{
req
->
timer_intv
=
TIPC_LINK_REQ_INACTIVE
;
req
->
timer_intv
=
TIPC_LINK_REQ_INACTIVE
;
goto
exit
;
goto
exit
;
...
@@ -335,7 +325,6 @@ static void disc_timeout(struct tipc_link_req *req)
...
@@ -335,7 +325,6 @@ static void disc_timeout(struct tipc_link_req *req)
* hold at fast polling rate if don't have any associated nodes,
* hold at fast polling rate if don't have any associated nodes,
* otherwise hold at slow polling rate
* otherwise hold at slow polling rate
*/
*/
disc_send_msg
(
req
);
disc_send_msg
(
req
);
req
->
timer_intv
*=
2
;
req
->
timer_intv
*=
2
;
...
@@ -359,7 +348,6 @@ static void disc_timeout(struct tipc_link_req *req)
...
@@ -359,7 +348,6 @@ static void disc_timeout(struct tipc_link_req *req)
*
*
* Returns 0 if successful, otherwise -errno.
* Returns 0 if successful, otherwise -errno.
*/
*/
int
tipc_disc_create
(
struct
tipc_bearer
*
b_ptr
,
int
tipc_disc_create
(
struct
tipc_bearer
*
b_ptr
,
struct
tipc_media_addr
*
dest
,
u32
dest_domain
)
struct
tipc_media_addr
*
dest
,
u32
dest_domain
)
{
{
...
@@ -391,7 +379,6 @@ int tipc_disc_create(struct tipc_bearer *b_ptr,
...
@@ -391,7 +379,6 @@ int tipc_disc_create(struct tipc_bearer *b_ptr,
* tipc_disc_delete - destroy object sending periodic link setup requests
* tipc_disc_delete - destroy object sending periodic link setup requests
* @req: ptr to link request structure
* @req: ptr to link request structure
*/
*/
void
tipc_disc_delete
(
struct
tipc_link_req
*
req
)
void
tipc_disc_delete
(
struct
tipc_link_req
*
req
)
{
{
k_cancel_timer
(
&
req
->
timer
);
k_cancel_timer
(
&
req
->
timer
);
...
@@ -399,4 +386,3 @@ void tipc_disc_delete(struct tipc_link_req *req)
...
@@ -399,4 +386,3 @@ void tipc_disc_delete(struct tipc_link_req *req)
kfree_skb
(
req
->
buf
);
kfree_skb
(
req
->
buf
);
kfree
(
req
);
kfree
(
req
);
}
}
net/tipc/eth_media.c
浏览文件 @
b6d151bb
...
@@ -48,7 +48,6 @@
...
@@ -48,7 +48,6 @@
* @tipc_packet_type: used in binding TIPC to Ethernet driver
* @tipc_packet_type: used in binding TIPC to Ethernet driver
* @cleanup: work item used when disabling bearer
* @cleanup: work item used when disabling bearer
*/
*/
struct
eth_bearer
{
struct
eth_bearer
{
struct
tipc_bearer
*
bearer
;
struct
tipc_bearer
*
bearer
;
struct
net_device
*
dev
;
struct
net_device
*
dev
;
...
@@ -67,7 +66,6 @@ static struct notifier_block notifier;
...
@@ -67,7 +66,6 @@ static struct notifier_block notifier;
* Media-dependent "value" field stores MAC address in first 6 bytes
* Media-dependent "value" field stores MAC address in first 6 bytes
* and zeroes out the remaining bytes.
* and zeroes out the remaining bytes.
*/
*/
static
void
eth_media_addr_set
(
struct
tipc_media_addr
*
a
,
char
*
mac
)
static
void
eth_media_addr_set
(
struct
tipc_media_addr
*
a
,
char
*
mac
)
{
{
memcpy
(
a
->
value
,
mac
,
ETH_ALEN
);
memcpy
(
a
->
value
,
mac
,
ETH_ALEN
);
...
@@ -79,7 +77,6 @@ static void eth_media_addr_set(struct tipc_media_addr *a, char *mac)
...
@@ -79,7 +77,6 @@ static void eth_media_addr_set(struct tipc_media_addr *a, char *mac)
/**
/**
* send_msg - send a TIPC message out over an Ethernet interface
* send_msg - send a TIPC message out over an Ethernet interface
*/
*/
static
int
send_msg
(
struct
sk_buff
*
buf
,
struct
tipc_bearer
*
tb_ptr
,
static
int
send_msg
(
struct
sk_buff
*
buf
,
struct
tipc_bearer
*
tb_ptr
,
struct
tipc_media_addr
*
dest
)
struct
tipc_media_addr
*
dest
)
{
{
...
@@ -115,7 +112,6 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
...
@@ -115,7 +112,6 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
* ignores packets sent using Ethernet multicast, and traffic sent to other
* ignores packets sent using Ethernet multicast, and traffic sent to other
* nodes (which can happen if interface is running in promiscuous mode).
* nodes (which can happen if interface is running in promiscuous mode).
*/
*/
static
int
recv_msg
(
struct
sk_buff
*
buf
,
struct
net_device
*
dev
,
static
int
recv_msg
(
struct
sk_buff
*
buf
,
struct
net_device
*
dev
,
struct
packet_type
*
pt
,
struct
net_device
*
orig_dev
)
struct
packet_type
*
pt
,
struct
net_device
*
orig_dev
)
{
{
...
@@ -140,7 +136,6 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev,
...
@@ -140,7 +136,6 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev,
/**
/**
* enable_bearer - attach TIPC bearer to an Ethernet interface
* enable_bearer - attach TIPC bearer to an Ethernet interface
*/
*/
static
int
enable_bearer
(
struct
tipc_bearer
*
tb_ptr
)
static
int
enable_bearer
(
struct
tipc_bearer
*
tb_ptr
)
{
{
struct
net_device
*
dev
=
NULL
;
struct
net_device
*
dev
=
NULL
;
...
@@ -151,7 +146,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
...
@@ -151,7 +146,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
int
pending_dev
=
0
;
int
pending_dev
=
0
;
/* Find unused Ethernet bearer structure */
/* Find unused Ethernet bearer structure */
while
(
eb_ptr
->
dev
)
{
while
(
eb_ptr
->
dev
)
{
if
(
!
eb_ptr
->
bearer
)
if
(
!
eb_ptr
->
bearer
)
pending_dev
++
;
pending_dev
++
;
...
@@ -160,7 +154,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
...
@@ -160,7 +154,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
}
}
/* Find device with specified name */
/* Find device with specified name */
read_lock
(
&
dev_base_lock
);
read_lock
(
&
dev_base_lock
);
for_each_netdev
(
&
init_net
,
pdev
)
{
for_each_netdev
(
&
init_net
,
pdev
)
{
if
(
!
strncmp
(
pdev
->
name
,
driver_name
,
IFNAMSIZ
))
{
if
(
!
strncmp
(
pdev
->
name
,
driver_name
,
IFNAMSIZ
))
{
...
@@ -174,7 +167,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
...
@@ -174,7 +167,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
return
-
ENODEV
;
return
-
ENODEV
;
/* Create Ethernet bearer for device */
/* Create Ethernet bearer for device */
eb_ptr
->
dev
=
dev
;
eb_ptr
->
dev
=
dev
;
eb_ptr
->
tipc_packet_type
.
type
=
htons
(
ETH_P_TIPC
);
eb_ptr
->
tipc_packet_type
.
type
=
htons
(
ETH_P_TIPC
);
eb_ptr
->
tipc_packet_type
.
dev
=
dev
;
eb_ptr
->
tipc_packet_type
.
dev
=
dev
;
...
@@ -184,7 +176,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
...
@@ -184,7 +176,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
dev_add_pack
(
&
eb_ptr
->
tipc_packet_type
);
dev_add_pack
(
&
eb_ptr
->
tipc_packet_type
);
/* Associate TIPC bearer with Ethernet bearer */
/* Associate TIPC bearer with Ethernet bearer */
eb_ptr
->
bearer
=
tb_ptr
;
eb_ptr
->
bearer
=
tb_ptr
;
tb_ptr
->
usr_handle
=
(
void
*
)
eb_ptr
;
tb_ptr
->
usr_handle
=
(
void
*
)
eb_ptr
;
tb_ptr
->
mtu
=
dev
->
mtu
;
tb_ptr
->
mtu
=
dev
->
mtu
;
...
@@ -198,7 +189,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
...
@@ -198,7 +189,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
*
*
* This routine must be invoked from a work queue because it can sleep.
* This routine must be invoked from a work queue because it can sleep.
*/
*/
static
void
cleanup_bearer
(
struct
work_struct
*
work
)
static
void
cleanup_bearer
(
struct
work_struct
*
work
)
{
{
struct
eth_bearer
*
eb_ptr
=
struct
eth_bearer
*
eb_ptr
=
...
@@ -216,7 +206,6 @@ static void cleanup_bearer(struct work_struct *work)
...
@@ -216,7 +206,6 @@ static void cleanup_bearer(struct work_struct *work)
* then get worker thread to complete bearer cleanup. (Can't do cleanup
* then get worker thread to complete bearer cleanup. (Can't do cleanup
* here because cleanup code needs to sleep and caller holds spinlocks.)
* here because cleanup code needs to sleep and caller holds spinlocks.)
*/
*/
static
void
disable_bearer
(
struct
tipc_bearer
*
tb_ptr
)
static
void
disable_bearer
(
struct
tipc_bearer
*
tb_ptr
)
{
{
struct
eth_bearer
*
eb_ptr
=
(
struct
eth_bearer
*
)
tb_ptr
->
usr_handle
;
struct
eth_bearer
*
eb_ptr
=
(
struct
eth_bearer
*
)
tb_ptr
->
usr_handle
;
...
@@ -232,7 +221,6 @@ static void disable_bearer(struct tipc_bearer *tb_ptr)
...
@@ -232,7 +221,6 @@ static void disable_bearer(struct tipc_bearer *tb_ptr)
* Change the state of the Ethernet bearer (if any) associated with the
* Change the state of the Ethernet bearer (if any) associated with the
* specified device.
* specified device.
*/
*/
static
int
recv_notification
(
struct
notifier_block
*
nb
,
unsigned
long
evt
,
static
int
recv_notification
(
struct
notifier_block
*
nb
,
unsigned
long
evt
,
void
*
dv
)
void
*
dv
)
{
{
...
@@ -281,7 +269,6 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
...
@@ -281,7 +269,6 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
/**
/**
* eth_addr2str - convert Ethernet address to string
* eth_addr2str - convert Ethernet address to string
*/
*/
static
int
eth_addr2str
(
struct
tipc_media_addr
*
a
,
char
*
str_buf
,
int
str_size
)
static
int
eth_addr2str
(
struct
tipc_media_addr
*
a
,
char
*
str_buf
,
int
str_size
)
{
{
if
(
str_size
<
18
)
/* 18 = strlen("aa:bb:cc:dd:ee:ff\0") */
if
(
str_size
<
18
)
/* 18 = strlen("aa:bb:cc:dd:ee:ff\0") */
...
@@ -294,7 +281,6 @@ static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size)
...
@@ -294,7 +281,6 @@ static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size)
/**
/**
* eth_str2addr - convert string to Ethernet address
* eth_str2addr - convert string to Ethernet address
*/
*/
static
int
eth_str2addr
(
struct
tipc_media_addr
*
a
,
char
*
str_buf
)
static
int
eth_str2addr
(
struct
tipc_media_addr
*
a
,
char
*
str_buf
)
{
{
char
mac
[
ETH_ALEN
];
char
mac
[
ETH_ALEN
];
...
@@ -314,7 +300,6 @@ static int eth_str2addr(struct tipc_media_addr *a, char *str_buf)
...
@@ -314,7 +300,6 @@ static int eth_str2addr(struct tipc_media_addr *a, char *str_buf)
/**
/**
* eth_str2addr - convert Ethernet address format to message header format
* eth_str2addr - convert Ethernet address format to message header format
*/
*/
static
int
eth_addr2msg
(
struct
tipc_media_addr
*
a
,
char
*
msg_area
)
static
int
eth_addr2msg
(
struct
tipc_media_addr
*
a
,
char
*
msg_area
)
{
{
memset
(
msg_area
,
0
,
TIPC_MEDIA_ADDR_SIZE
);
memset
(
msg_area
,
0
,
TIPC_MEDIA_ADDR_SIZE
);
...
@@ -326,7 +311,6 @@ static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area)
...
@@ -326,7 +311,6 @@ static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area)
/**
/**
* eth_str2addr - convert message header address format to Ethernet format
* eth_str2addr - convert message header address format to Ethernet format
*/
*/
static
int
eth_msg2addr
(
struct
tipc_media_addr
*
a
,
char
*
msg_area
)
static
int
eth_msg2addr
(
struct
tipc_media_addr
*
a
,
char
*
msg_area
)
{
{
if
(
msg_area
[
TIPC_MEDIA_TYPE_OFFSET
]
!=
TIPC_MEDIA_TYPE_ETH
)
if
(
msg_area
[
TIPC_MEDIA_TYPE_OFFSET
]
!=
TIPC_MEDIA_TYPE_ETH
)
...
@@ -339,7 +323,6 @@ static int eth_msg2addr(struct tipc_media_addr *a, char *msg_area)
...
@@ -339,7 +323,6 @@ static int eth_msg2addr(struct tipc_media_addr *a, char *msg_area)
/*
/*
* Ethernet media registration info
* Ethernet media registration info
*/
*/
static
struct
tipc_media
eth_media_info
=
{
static
struct
tipc_media
eth_media_info
=
{
.
send_msg
=
send_msg
,
.
send_msg
=
send_msg
,
.
enable_bearer
=
enable_bearer
,
.
enable_bearer
=
enable_bearer
,
...
@@ -363,7 +346,6 @@ static struct tipc_media eth_media_info = {
...
@@ -363,7 +346,6 @@ static struct tipc_media eth_media_info = {
* Register Ethernet media type with TIPC bearer code. Also register
* Register Ethernet media type with TIPC bearer code. Also register
* with OS for notifications about device state changes.
* with OS for notifications about device state changes.
*/
*/
int
tipc_eth_media_start
(
void
)
int
tipc_eth_media_start
(
void
)
{
{
int
res
;
int
res
;
...
@@ -386,7 +368,6 @@ int tipc_eth_media_start(void)
...
@@ -386,7 +368,6 @@ int tipc_eth_media_start(void)
/**
/**
* tipc_eth_media_stop - deactivate Ethernet bearer support
* tipc_eth_media_stop - deactivate Ethernet bearer support
*/
*/
void
tipc_eth_media_stop
(
void
)
void
tipc_eth_media_stop
(
void
)
{
{
if
(
!
eth_started
)
if
(
!
eth_started
)
...
...
net/tipc/handler.c
浏览文件 @
b6d151bb
...
@@ -129,4 +129,3 @@ void tipc_handler_stop(void)
...
@@ -129,4 +129,3 @@ void tipc_handler_stop(void)
kmem_cache_destroy
(
tipc_queue_item_cache
);
kmem_cache_destroy
(
tipc_queue_item_cache
);
}
}
net/tipc/link.c
浏览文件 @
b6d151bb
此差异已折叠。
点击以展开。
net/tipc/link.h
浏览文件 @
b6d151bb
...
@@ -47,13 +47,11 @@
...
@@ -47,13 +47,11 @@
/*
/*
* Out-of-range value for link sequence numbers
* Out-of-range value for link sequence numbers
*/
*/
#define INVALID_LINK_SEQ 0x10000
#define INVALID_LINK_SEQ 0x10000
/*
/*
* Link states
* Link states
*/
*/
#define WORKING_WORKING 560810u
#define WORKING_WORKING 560810u
#define WORKING_UNKNOWN 560811u
#define WORKING_UNKNOWN 560811u
#define RESET_UNKNOWN 560812u
#define RESET_UNKNOWN 560812u
...
@@ -63,7 +61,6 @@
...
@@ -63,7 +61,6 @@
* Starting value for maximum packet size negotiation on unicast links
* Starting value for maximum packet size negotiation on unicast links
* (unless bearer MTU is less)
* (unless bearer MTU is less)
*/
*/
#define MAX_PKT_DEFAULT 1500
#define MAX_PKT_DEFAULT 1500
/**
/**
...
@@ -114,7 +111,6 @@
...
@@ -114,7 +111,6 @@
* @defragm_buf: list of partially reassembled inbound message fragments
* @defragm_buf: list of partially reassembled inbound message fragments
* @stats: collects statistics regarding link activity
* @stats: collects statistics regarding link activity
*/
*/
struct
tipc_link
{
struct
tipc_link
{
u32
addr
;
u32
addr
;
char
name
[
TIPC_MAX_LINK_NAME
];
char
name
[
TIPC_MAX_LINK_NAME
];
...
@@ -255,7 +251,6 @@ void tipc_link_retransmit(struct tipc_link *l_ptr,
...
@@ -255,7 +251,6 @@ void tipc_link_retransmit(struct tipc_link *l_ptr,
/*
/*
* Link sequence number manipulation routines (uses modulo 2**16 arithmetic)
* Link sequence number manipulation routines (uses modulo 2**16 arithmetic)
*/
*/
static
inline
u32
buf_seqno
(
struct
sk_buff
*
buf
)
static
inline
u32
buf_seqno
(
struct
sk_buff
*
buf
)
{
{
return
msg_seqno
(
buf_msg
(
buf
));
return
msg_seqno
(
buf_msg
(
buf
));
...
@@ -294,7 +289,6 @@ static inline u32 lesser(u32 left, u32 right)
...
@@ -294,7 +289,6 @@ static inline u32 lesser(u32 left, u32 right)
/*
/*
* Link status checking routines
* Link status checking routines
*/
*/
static
inline
int
link_working_working
(
struct
tipc_link
*
l_ptr
)
static
inline
int
link_working_working
(
struct
tipc_link
*
l_ptr
)
{
{
return
l_ptr
->
state
==
WORKING_WORKING
;
return
l_ptr
->
state
==
WORKING_WORKING
;
...
...
net/tipc/log.c
浏览文件 @
b6d151bb
...
@@ -47,7 +47,6 @@
...
@@ -47,7 +47,6 @@
*
*
* Additional user-defined print buffers are also permitted.
* Additional user-defined print buffers are also permitted.
*/
*/
static
struct
print_buf
null_buf
=
{
NULL
,
0
,
NULL
,
0
};
static
struct
print_buf
null_buf
=
{
NULL
,
0
,
NULL
,
0
};
struct
print_buf
*
const
TIPC_NULL
=
&
null_buf
;
struct
print_buf
*
const
TIPC_NULL
=
&
null_buf
;
...
@@ -72,7 +71,6 @@ struct print_buf *const TIPC_LOG = &log_buf;
...
@@ -72,7 +71,6 @@ struct print_buf *const TIPC_LOG = &log_buf;
* on the caller to prevent simultaneous use of the print buffer(s) being
* on the caller to prevent simultaneous use of the print buffer(s) being
* manipulated.
* manipulated.
*/
*/
static
char
print_string
[
TIPC_PB_MAX_STR
];
static
char
print_string
[
TIPC_PB_MAX_STR
];
static
DEFINE_SPINLOCK
(
print_lock
);
static
DEFINE_SPINLOCK
(
print_lock
);
...
@@ -97,7 +95,6 @@ static void tipc_printbuf_move(struct print_buf *pb_to,
...
@@ -97,7 +95,6 @@ static void tipc_printbuf_move(struct print_buf *pb_to,
* Note: If the character array is too small (or absent), the print buffer
* Note: If the character array is too small (or absent), the print buffer
* becomes a null device that discards anything written to it.
* becomes a null device that discards anything written to it.
*/
*/
void
tipc_printbuf_init
(
struct
print_buf
*
pb
,
char
*
raw
,
u32
size
)
void
tipc_printbuf_init
(
struct
print_buf
*
pb
,
char
*
raw
,
u32
size
)
{
{
pb
->
buf
=
raw
;
pb
->
buf
=
raw
;
...
@@ -117,7 +114,6 @@ void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 size)
...
@@ -117,7 +114,6 @@ void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 size)
* tipc_printbuf_reset - reinitialize print buffer to empty state
* tipc_printbuf_reset - reinitialize print buffer to empty state
* @pb: pointer to print buffer structure
* @pb: pointer to print buffer structure
*/
*/
static
void
tipc_printbuf_reset
(
struct
print_buf
*
pb
)
static
void
tipc_printbuf_reset
(
struct
print_buf
*
pb
)
{
{
if
(
pb
->
buf
)
{
if
(
pb
->
buf
)
{
...
@@ -133,7 +129,6 @@ static void tipc_printbuf_reset(struct print_buf *pb)
...
@@ -133,7 +129,6 @@ static void tipc_printbuf_reset(struct print_buf *pb)
*
*
* Returns non-zero if print buffer is empty.
* Returns non-zero if print buffer is empty.
*/
*/
static
int
tipc_printbuf_empty
(
struct
print_buf
*
pb
)
static
int
tipc_printbuf_empty
(
struct
print_buf
*
pb
)
{
{
return
!
pb
->
buf
||
(
pb
->
crs
==
pb
->
buf
);
return
!
pb
->
buf
||
(
pb
->
crs
==
pb
->
buf
);
...
@@ -148,7 +143,6 @@ static int tipc_printbuf_empty(struct print_buf *pb)
...
@@ -148,7 +143,6 @@ static int tipc_printbuf_empty(struct print_buf *pb)
*
*
* Returns length of print buffer data string (including trailing NUL)
* Returns length of print buffer data string (including trailing NUL)
*/
*/
int
tipc_printbuf_validate
(
struct
print_buf
*
pb
)
int
tipc_printbuf_validate
(
struct
print_buf
*
pb
)
{
{
char
*
err
=
"
\n\n
*** PRINT BUFFER OVERFLOW ***
\n\n
"
;
char
*
err
=
"
\n\n
*** PRINT BUFFER OVERFLOW ***
\n\n
"
;
...
@@ -182,14 +176,12 @@ int tipc_printbuf_validate(struct print_buf *pb)
...
@@ -182,14 +176,12 @@ int tipc_printbuf_validate(struct print_buf *pb)
* Current contents of destination print buffer (if any) are discarded.
* Current contents of destination print buffer (if any) are discarded.
* Source print buffer becomes empty if a successful move occurs.
* Source print buffer becomes empty if a successful move occurs.
*/
*/
static
void
tipc_printbuf_move
(
struct
print_buf
*
pb_to
,
static
void
tipc_printbuf_move
(
struct
print_buf
*
pb_to
,
struct
print_buf
*
pb_from
)
struct
print_buf
*
pb_from
)
{
{
int
len
;
int
len
;
/* Handle the cases where contents can't be moved */
/* Handle the cases where contents can't be moved */
if
(
!
pb_to
->
buf
)
if
(
!
pb_to
->
buf
)
return
;
return
;
...
@@ -206,7 +198,6 @@ static void tipc_printbuf_move(struct print_buf *pb_to,
...
@@ -206,7 +198,6 @@ static void tipc_printbuf_move(struct print_buf *pb_to,
}
}
/* Copy data from char after cursor to end (if used) */
/* Copy data from char after cursor to end (if used) */
len
=
pb_from
->
buf
+
pb_from
->
size
-
pb_from
->
crs
-
2
;
len
=
pb_from
->
buf
+
pb_from
->
size
-
pb_from
->
crs
-
2
;
if
((
pb_from
->
buf
[
pb_from
->
size
-
1
]
==
0
)
&&
(
len
>
0
))
{
if
((
pb_from
->
buf
[
pb_from
->
size
-
1
]
==
0
)
&&
(
len
>
0
))
{
strcpy
(
pb_to
->
buf
,
pb_from
->
crs
+
1
);
strcpy
(
pb_to
->
buf
,
pb_from
->
crs
+
1
);
...
@@ -215,7 +206,6 @@ static void tipc_printbuf_move(struct print_buf *pb_to,
...
@@ -215,7 +206,6 @@ static void tipc_printbuf_move(struct print_buf *pb_to,
pb_to
->
crs
=
pb_to
->
buf
;
pb_to
->
crs
=
pb_to
->
buf
;
/* Copy data from start to cursor (always) */
/* Copy data from start to cursor (always) */
len
=
pb_from
->
crs
-
pb_from
->
buf
;
len
=
pb_from
->
crs
-
pb_from
->
buf
;
strcpy
(
pb_to
->
crs
,
pb_from
->
buf
);
strcpy
(
pb_to
->
crs
,
pb_from
->
buf
);
pb_to
->
crs
+=
len
;
pb_to
->
crs
+=
len
;
...
@@ -228,7 +218,6 @@ static void tipc_printbuf_move(struct print_buf *pb_to,
...
@@ -228,7 +218,6 @@ static void tipc_printbuf_move(struct print_buf *pb_to,
* @pb: pointer to print buffer
* @pb: pointer to print buffer
* @fmt: formatted info to be printed
* @fmt: formatted info to be printed
*/
*/
void
tipc_printf
(
struct
print_buf
*
pb
,
const
char
*
fmt
,
...)
void
tipc_printf
(
struct
print_buf
*
pb
,
const
char
*
fmt
,
...)
{
{
int
chars_to_add
;
int
chars_to_add
;
...
@@ -270,7 +259,6 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...)
...
@@ -270,7 +259,6 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...)
* tipc_log_resize - change the size of the TIPC log buffer
* tipc_log_resize - change the size of the TIPC log buffer
* @log_size: print buffer size to use
* @log_size: print buffer size to use
*/
*/
int
tipc_log_resize
(
int
log_size
)
int
tipc_log_resize
(
int
log_size
)
{
{
int
res
=
0
;
int
res
=
0
;
...
@@ -295,7 +283,6 @@ int tipc_log_resize(int log_size)
...
@@ -295,7 +283,6 @@ int tipc_log_resize(int log_size)
/**
/**
* tipc_log_resize_cmd - reconfigure size of TIPC log buffer
* tipc_log_resize_cmd - reconfigure size of TIPC log buffer
*/
*/
struct
sk_buff
*
tipc_log_resize_cmd
(
const
void
*
req_tlv_area
,
int
req_tlv_space
)
struct
sk_buff
*
tipc_log_resize_cmd
(
const
void
*
req_tlv_area
,
int
req_tlv_space
)
{
{
u32
value
;
u32
value
;
...
@@ -316,7 +303,6 @@ struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area, int req_tlv_space)
...
@@ -316,7 +303,6 @@ struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area, int req_tlv_space)
/**
/**
* tipc_log_dump - capture TIPC log buffer contents in configuration message
* tipc_log_dump - capture TIPC log buffer contents in configuration message
*/
*/
struct
sk_buff
*
tipc_log_dump
(
void
)
struct
sk_buff
*
tipc_log_dump
(
void
)
{
{
struct
sk_buff
*
reply
;
struct
sk_buff
*
reply
;
...
...
net/tipc/log.h
浏览文件 @
b6d151bb
...
@@ -44,7 +44,6 @@
...
@@ -44,7 +44,6 @@
* @crs: pointer to first unused space in character array (i.e. final NUL)
* @crs: pointer to first unused space in character array (i.e. final NUL)
* @echo: echo output to system console if non-zero
* @echo: echo output to system console if non-zero
*/
*/
struct
print_buf
{
struct
print_buf
{
char
*
buf
;
char
*
buf
;
u32
size
;
u32
size
;
...
...
net/tipc/msg.c
浏览文件 @
b6d151bb
...
@@ -72,7 +72,6 @@ void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type,
...
@@ -72,7 +72,6 @@ void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type,
*
*
* Returns message data size or errno
* Returns message data size or errno
*/
*/
int
tipc_msg_build
(
struct
tipc_msg
*
hdr
,
struct
iovec
const
*
msg_sect
,
int
tipc_msg_build
(
struct
tipc_msg
*
hdr
,
struct
iovec
const
*
msg_sect
,
u32
num_sect
,
unsigned
int
total_len
,
u32
num_sect
,
unsigned
int
total_len
,
int
max_size
,
int
usrmem
,
struct
sk_buff
**
buf
)
int
max_size
,
int
usrmem
,
struct
sk_buff
**
buf
)
...
@@ -112,7 +111,6 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
...
@@ -112,7 +111,6 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
}
}
#ifdef CONFIG_TIPC_DEBUG
#ifdef CONFIG_TIPC_DEBUG
void
tipc_msg_dbg
(
struct
print_buf
*
buf
,
struct
tipc_msg
*
msg
,
const
char
*
str
)
void
tipc_msg_dbg
(
struct
print_buf
*
buf
,
struct
tipc_msg
*
msg
,
const
char
*
str
)
{
{
u32
usr
=
msg_user
(
msg
);
u32
usr
=
msg_user
(
msg
);
...
@@ -352,5 +350,4 @@ void tipc_msg_dbg(struct print_buf *buf, struct tipc_msg *msg, const char *str)
...
@@ -352,5 +350,4 @@ void tipc_msg_dbg(struct print_buf *buf, struct tipc_msg *msg, const char *str)
if
((
usr
==
MSG_FRAGMENTER
)
&&
(
msg_type
(
msg
)
==
FIRST_FRAGMENT
))
if
((
usr
==
MSG_FRAGMENTER
)
&&
(
msg_type
(
msg
)
==
FIRST_FRAGMENT
))
tipc_msg_dbg
(
buf
,
msg_get_wrapped
(
msg
),
" /"
);
tipc_msg_dbg
(
buf
,
msg_get_wrapped
(
msg
),
" /"
);
}
}
#endif
#endif
net/tipc/msg.h
浏览文件 @
b6d151bb
...
@@ -44,7 +44,6 @@
...
@@ -44,7 +44,6 @@
*
*
* Note: Some items are also used with TIPC internal message headers
* Note: Some items are also used with TIPC internal message headers
*/
*/
#define TIPC_VERSION 2
#define TIPC_VERSION 2
/*
/*
...
@@ -58,7 +57,6 @@
...
@@ -58,7 +57,6 @@
/*
/*
* Payload message types
* Payload message types
*/
*/
#define TIPC_CONN_MSG 0
#define TIPC_CONN_MSG 0
#define TIPC_MCAST_MSG 1
#define TIPC_MCAST_MSG 1
#define TIPC_NAMED_MSG 2
#define TIPC_NAMED_MSG 2
...
@@ -67,7 +65,6 @@
...
@@ -67,7 +65,6 @@
/*
/*
* Message header sizes
* Message header sizes
*/
*/
#define SHORT_H_SIZE 24
/* In-cluster basic payload message */
#define SHORT_H_SIZE 24
/* In-cluster basic payload message */
#define BASIC_H_SIZE 32
/* Basic payload message */
#define BASIC_H_SIZE 32
/* Basic payload message */
#define NAMED_H_SIZE 40
/* Named payload message */
#define NAMED_H_SIZE 40
/* Named payload message */
...
@@ -121,7 +118,6 @@ static inline void msg_swap_words(struct tipc_msg *msg, u32 a, u32 b)
...
@@ -121,7 +118,6 @@ static inline void msg_swap_words(struct tipc_msg *msg, u32 a, u32 b)
/*
/*
* Word 0
* Word 0
*/
*/
static
inline
u32
msg_version
(
struct
tipc_msg
*
m
)
static
inline
u32
msg_version
(
struct
tipc_msg
*
m
)
{
{
return
msg_bits
(
m
,
0
,
29
,
7
);
return
msg_bits
(
m
,
0
,
29
,
7
);
...
@@ -216,7 +212,6 @@ static inline void msg_set_size(struct tipc_msg *m, u32 sz)
...
@@ -216,7 +212,6 @@ static inline void msg_set_size(struct tipc_msg *m, u32 sz)
/*
/*
* Word 1
* Word 1
*/
*/
static
inline
u32
msg_type
(
struct
tipc_msg
*
m
)
static
inline
u32
msg_type
(
struct
tipc_msg
*
m
)
{
{
return
msg_bits
(
m
,
1
,
29
,
0x7
);
return
msg_bits
(
m
,
1
,
29
,
0x7
);
...
@@ -291,7 +286,6 @@ static inline void msg_set_bcast_ack(struct tipc_msg *m, u32 n)
...
@@ -291,7 +286,6 @@ static inline void msg_set_bcast_ack(struct tipc_msg *m, u32 n)
/*
/*
* Word 2
* Word 2
*/
*/
static
inline
u32
msg_ack
(
struct
tipc_msg
*
m
)
static
inline
u32
msg_ack
(
struct
tipc_msg
*
m
)
{
{
return
msg_bits
(
m
,
2
,
16
,
0xffff
);
return
msg_bits
(
m
,
2
,
16
,
0xffff
);
...
@@ -315,8 +309,6 @@ static inline void msg_set_seqno(struct tipc_msg *m, u32 n)
...
@@ -315,8 +309,6 @@ static inline void msg_set_seqno(struct tipc_msg *m, u32 n)
/*
/*
* Words 3-10
* Words 3-10
*/
*/
static
inline
u32
msg_prevnode
(
struct
tipc_msg
*
m
)
static
inline
u32
msg_prevnode
(
struct
tipc_msg
*
m
)
{
{
return
msg_word
(
m
,
3
);
return
msg_word
(
m
,
3
);
...
@@ -434,7 +426,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
...
@@ -434,7 +426,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
return
(
struct
tipc_msg
*
)
msg_data
(
m
);
return
(
struct
tipc_msg
*
)
msg_data
(
m
);
}
}
/*
/*
* Constants and routines used to read and write TIPC internal message headers
* Constants and routines used to read and write TIPC internal message headers
*/
*/
...
@@ -442,7 +433,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
...
@@ -442,7 +433,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
/*
/*
* Internal message users
* Internal message users
*/
*/
#define BCAST_PROTOCOL 5
#define BCAST_PROTOCOL 5
#define MSG_BUNDLER 6
#define MSG_BUNDLER 6
#define LINK_PROTOCOL 7
#define LINK_PROTOCOL 7
...
@@ -456,7 +446,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
...
@@ -456,7 +446,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
/*
/*
* Connection management protocol message types
* Connection management protocol message types
*/
*/
#define CONN_PROBE 0
#define CONN_PROBE 0
#define CONN_PROBE_REPLY 1
#define CONN_PROBE_REPLY 1
#define CONN_ACK 2
#define CONN_ACK 2
...
@@ -464,14 +453,12 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
...
@@ -464,14 +453,12 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
/*
/*
* Name distributor message types
* Name distributor message types
*/
*/
#define PUBLICATION 0
#define PUBLICATION 0
#define WITHDRAWAL 1
#define WITHDRAWAL 1
/*
/*
* Segmentation message types
* Segmentation message types
*/
*/
#define FIRST_FRAGMENT 0
#define FIRST_FRAGMENT 0
#define FRAGMENT 1
#define FRAGMENT 1
#define LAST_FRAGMENT 2
#define LAST_FRAGMENT 2
...
@@ -479,7 +466,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
...
@@ -479,7 +466,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
/*
/*
* Link management protocol message types
* Link management protocol message types
*/
*/
#define STATE_MSG 0
#define STATE_MSG 0
#define RESET_MSG 1
#define RESET_MSG 1
#define ACTIVATE_MSG 2
#define ACTIVATE_MSG 2
...
@@ -493,7 +479,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
...
@@ -493,7 +479,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
/*
/*
* Config protocol message types
* Config protocol message types
*/
*/
#define DSC_REQ_MSG 0
#define DSC_REQ_MSG 0
#define DSC_RESP_MSG 1
#define DSC_RESP_MSG 1
...
@@ -501,7 +486,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
...
@@ -501,7 +486,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
/*
/*
* Word 1
* Word 1
*/
*/
static
inline
u32
msg_seq_gap
(
struct
tipc_msg
*
m
)
static
inline
u32
msg_seq_gap
(
struct
tipc_msg
*
m
)
{
{
return
msg_bits
(
m
,
1
,
16
,
0x1fff
);
return
msg_bits
(
m
,
1
,
16
,
0x1fff
);
...
@@ -526,7 +510,6 @@ static inline void msg_set_node_sig(struct tipc_msg *m, u32 n)
...
@@ -526,7 +510,6 @@ static inline void msg_set_node_sig(struct tipc_msg *m, u32 n)
/*
/*
* Word 2
* Word 2
*/
*/
static
inline
u32
msg_dest_domain
(
struct
tipc_msg
*
m
)
static
inline
u32
msg_dest_domain
(
struct
tipc_msg
*
m
)
{
{
return
msg_word
(
m
,
2
);
return
msg_word
(
m
,
2
);
...
@@ -561,7 +544,6 @@ static inline void msg_set_bcgap_to(struct tipc_msg *m, u32 n)
...
@@ -561,7 +544,6 @@ static inline void msg_set_bcgap_to(struct tipc_msg *m, u32 n)
/*
/*
* Word 4
* Word 4
*/
*/
static
inline
u32
msg_last_bcast
(
struct
tipc_msg
*
m
)
static
inline
u32
msg_last_bcast
(
struct
tipc_msg
*
m
)
{
{
return
msg_bits
(
m
,
4
,
16
,
0xffff
);
return
msg_bits
(
m
,
4
,
16
,
0xffff
);
...
@@ -628,7 +610,6 @@ static inline void msg_set_link_selector(struct tipc_msg *m, u32 n)
...
@@ -628,7 +610,6 @@ static inline void msg_set_link_selector(struct tipc_msg *m, u32 n)
/*
/*
* Word 5
* Word 5
*/
*/
static
inline
u32
msg_session
(
struct
tipc_msg
*
m
)
static
inline
u32
msg_session
(
struct
tipc_msg
*
m
)
{
{
return
msg_bits
(
m
,
5
,
16
,
0xffff
);
return
msg_bits
(
m
,
5
,
16
,
0xffff
);
...
@@ -697,7 +678,6 @@ static inline char *msg_media_addr(struct tipc_msg *m)
...
@@ -697,7 +678,6 @@ static inline char *msg_media_addr(struct tipc_msg *m)
/*
/*
* Word 9
* Word 9
*/
*/
static
inline
u32
msg_msgcnt
(
struct
tipc_msg
*
m
)
static
inline
u32
msg_msgcnt
(
struct
tipc_msg
*
m
)
{
{
return
msg_bits
(
m
,
9
,
16
,
0xffff
);
return
msg_bits
(
m
,
9
,
16
,
0xffff
);
...
@@ -744,5 +724,4 @@ void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type,
...
@@ -744,5 +724,4 @@ void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type,
int
tipc_msg_build
(
struct
tipc_msg
*
hdr
,
struct
iovec
const
*
msg_sect
,
int
tipc_msg_build
(
struct
tipc_msg
*
hdr
,
struct
iovec
const
*
msg_sect
,
u32
num_sect
,
unsigned
int
total_len
,
u32
num_sect
,
unsigned
int
total_len
,
int
max_size
,
int
usrmem
,
struct
sk_buff
**
buf
);
int
max_size
,
int
usrmem
,
struct
sk_buff
**
buf
);
#endif
#endif
net/tipc/name_distr.c
浏览文件 @
b6d151bb
...
@@ -58,7 +58,6 @@
...
@@ -58,7 +58,6 @@
* Note: There is no field that identifies the publishing node because it is
* Note: There is no field that identifies the publishing node because it is
* the same for all items contained within a publication message.
* the same for all items contained within a publication message.
*/
*/
struct
distr_item
{
struct
distr_item
{
__be32
type
;
__be32
type
;
__be32
lower
;
__be32
lower
;
...
@@ -103,7 +102,6 @@ static struct publ_list *publ_lists[] = {
...
@@ -103,7 +102,6 @@ static struct publ_list *publ_lists[] = {
/**
/**
* publ_to_item - add publication info to a publication message
* publ_to_item - add publication info to a publication message
*/
*/
static
void
publ_to_item
(
struct
distr_item
*
i
,
struct
publication
*
p
)
static
void
publ_to_item
(
struct
distr_item
*
i
,
struct
publication
*
p
)
{
{
i
->
type
=
htonl
(
p
->
type
);
i
->
type
=
htonl
(
p
->
type
);
...
@@ -116,7 +114,6 @@ static void publ_to_item(struct distr_item *i, struct publication *p)
...
@@ -116,7 +114,6 @@ static void publ_to_item(struct distr_item *i, struct publication *p)
/**
/**
* named_prepare_buf - allocate & initialize a publication message
* named_prepare_buf - allocate & initialize a publication message
*/
*/
static
struct
sk_buff
*
named_prepare_buf
(
u32
type
,
u32
size
,
u32
dest
)
static
struct
sk_buff
*
named_prepare_buf
(
u32
type
,
u32
size
,
u32
dest
)
{
{
struct
sk_buff
*
buf
=
tipc_buf_acquire
(
INT_H_SIZE
+
size
);
struct
sk_buff
*
buf
=
tipc_buf_acquire
(
INT_H_SIZE
+
size
);
...
@@ -151,7 +148,6 @@ static void named_cluster_distribute(struct sk_buff *buf)
...
@@ -151,7 +148,6 @@ static void named_cluster_distribute(struct sk_buff *buf)
/**
/**
* tipc_named_publish - tell other nodes about a new publication by this node
* tipc_named_publish - tell other nodes about a new publication by this node
*/
*/
void
tipc_named_publish
(
struct
publication
*
publ
)
void
tipc_named_publish
(
struct
publication
*
publ
)
{
{
struct
sk_buff
*
buf
;
struct
sk_buff
*
buf
;
...
@@ -177,7 +173,6 @@ void tipc_named_publish(struct publication *publ)
...
@@ -177,7 +173,6 @@ void tipc_named_publish(struct publication *publ)
/**
/**
* tipc_named_withdraw - tell other nodes about a withdrawn publication by this node
* tipc_named_withdraw - tell other nodes about a withdrawn publication by this node
*/
*/
void
tipc_named_withdraw
(
struct
publication
*
publ
)
void
tipc_named_withdraw
(
struct
publication
*
publ
)
{
{
struct
sk_buff
*
buf
;
struct
sk_buff
*
buf
;
...
@@ -236,7 +231,6 @@ static void named_distribute(struct list_head *message_list, u32 node,
...
@@ -236,7 +231,6 @@ static void named_distribute(struct list_head *message_list, u32 node,
/**
/**
* tipc_named_node_up - tell specified node about all publications by this node
* tipc_named_node_up - tell specified node about all publications by this node
*/
*/
void
tipc_named_node_up
(
unsigned
long
nodearg
)
void
tipc_named_node_up
(
unsigned
long
nodearg
)
{
{
struct
tipc_node
*
n_ptr
;
struct
tipc_node
*
n_ptr
;
...
@@ -246,7 +240,6 @@ void tipc_named_node_up(unsigned long nodearg)
...
@@ -246,7 +240,6 @@ void tipc_named_node_up(unsigned long nodearg)
u32
max_item_buf
=
0
;
u32
max_item_buf
=
0
;
/* compute maximum amount of publication data to send per message */
/* compute maximum amount of publication data to send per message */
read_lock_bh
(
&
tipc_net_lock
);
read_lock_bh
(
&
tipc_net_lock
);
n_ptr
=
tipc_node_find
(
node
);
n_ptr
=
tipc_node_find
(
node
);
if
(
n_ptr
)
{
if
(
n_ptr
)
{
...
@@ -262,7 +255,6 @@ void tipc_named_node_up(unsigned long nodearg)
...
@@ -262,7 +255,6 @@ void tipc_named_node_up(unsigned long nodearg)
return
;
return
;
/* create list of publication messages, then send them as a unit */
/* create list of publication messages, then send them as a unit */
INIT_LIST_HEAD
(
&
message_list
);
INIT_LIST_HEAD
(
&
message_list
);
read_lock_bh
(
&
tipc_nametbl_lock
);
read_lock_bh
(
&
tipc_nametbl_lock
);
...
@@ -279,7 +271,6 @@ void tipc_named_node_up(unsigned long nodearg)
...
@@ -279,7 +271,6 @@ void tipc_named_node_up(unsigned long nodearg)
* Invoked for each publication issued by a newly failed node.
* Invoked for each publication issued by a newly failed node.
* Removes publication structure from name table & deletes it.
* Removes publication structure from name table & deletes it.
*/
*/
static
void
named_purge_publ
(
struct
publication
*
publ
)
static
void
named_purge_publ
(
struct
publication
*
publ
)
{
{
struct
publication
*
p
;
struct
publication
*
p
;
...
@@ -303,7 +294,6 @@ static void named_purge_publ(struct publication *publ)
...
@@ -303,7 +294,6 @@ static void named_purge_publ(struct publication *publ)
/**
/**
* tipc_named_recv - process name table update message sent by another node
* tipc_named_recv - process name table update message sent by another node
*/
*/
void
tipc_named_recv
(
struct
sk_buff
*
buf
)
void
tipc_named_recv
(
struct
sk_buff
*
buf
)
{
{
struct
publication
*
publ
;
struct
publication
*
publ
;
...
@@ -361,7 +351,6 @@ void tipc_named_recv(struct sk_buff *buf)
...
@@ -361,7 +351,6 @@ void tipc_named_recv(struct sk_buff *buf)
* All name table entries published by this node are updated to reflect
* All name table entries published by this node are updated to reflect
* the node's new network address.
* the node's new network address.
*/
*/
void
tipc_named_reinit
(
void
)
void
tipc_named_reinit
(
void
)
{
{
struct
publication
*
publ
;
struct
publication
*
publ
;
...
...
net/tipc/name_table.c
浏览文件 @
b6d151bb
...
@@ -56,7 +56,6 @@ static int tipc_nametbl_size = 1024; /* must be a power of 2 */
...
@@ -56,7 +56,6 @@ static int tipc_nametbl_size = 1024; /* must be a power of 2 */
* publications of the associated name sequence belong to it.
* publications of the associated name sequence belong to it.
* (The cluster and node lists may be empty.)
* (The cluster and node lists may be empty.)
*/
*/
struct
name_info
{
struct
name_info
{
struct
list_head
node_list
;
struct
list_head
node_list
;
struct
list_head
cluster_list
;
struct
list_head
cluster_list
;
...
@@ -72,7 +71,6 @@ struct name_info {
...
@@ -72,7 +71,6 @@ struct name_info {
* @upper: name sequence upper bound
* @upper: name sequence upper bound
* @info: pointer to name sequence publication info
* @info: pointer to name sequence publication info
*/
*/
struct
sub_seq
{
struct
sub_seq
{
u32
lower
;
u32
lower
;
u32
upper
;
u32
upper
;
...
@@ -90,7 +88,6 @@ struct sub_seq {
...
@@ -90,7 +88,6 @@ struct sub_seq {
* @subscriptions: list of subscriptions for this 'type'
* @subscriptions: list of subscriptions for this 'type'
* @lock: spinlock controlling access to publication lists of all sub-sequences
* @lock: spinlock controlling access to publication lists of all sub-sequences
*/
*/
struct
name_seq
{
struct
name_seq
{
u32
type
;
u32
type
;
struct
sub_seq
*
sseqs
;
struct
sub_seq
*
sseqs
;
...
@@ -107,7 +104,6 @@ struct name_seq {
...
@@ -107,7 +104,6 @@ struct name_seq {
* accessed via hashing on 'type'; name sequence lists are *not* sorted
* accessed via hashing on 'type'; name sequence lists are *not* sorted
* @local_publ_count: number of publications issued by this node
* @local_publ_count: number of publications issued by this node
*/
*/
struct
name_table
{
struct
name_table
{
struct
hlist_head
*
types
;
struct
hlist_head
*
types
;
u32
local_publ_count
;
u32
local_publ_count
;
...
@@ -124,7 +120,6 @@ static int hash(int x)
...
@@ -124,7 +120,6 @@ static int hash(int x)
/**
/**
* publ_create - create a publication structure
* publ_create - create a publication structure
*/
*/
static
struct
publication
*
publ_create
(
u32
type
,
u32
lower
,
u32
upper
,
static
struct
publication
*
publ_create
(
u32
type
,
u32
lower
,
u32
upper
,
u32
scope
,
u32
node
,
u32
port_ref
,
u32
scope
,
u32
node
,
u32
port_ref
,
u32
key
)
u32
key
)
...
@@ -151,7 +146,6 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper,
...
@@ -151,7 +146,6 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper,
/**
/**
* tipc_subseq_alloc - allocate a specified number of sub-sequence structures
* tipc_subseq_alloc - allocate a specified number of sub-sequence structures
*/
*/
static
struct
sub_seq
*
tipc_subseq_alloc
(
u32
cnt
)
static
struct
sub_seq
*
tipc_subseq_alloc
(
u32
cnt
)
{
{
struct
sub_seq
*
sseq
=
kcalloc
(
cnt
,
sizeof
(
struct
sub_seq
),
GFP_ATOMIC
);
struct
sub_seq
*
sseq
=
kcalloc
(
cnt
,
sizeof
(
struct
sub_seq
),
GFP_ATOMIC
);
...
@@ -163,7 +157,6 @@ static struct sub_seq *tipc_subseq_alloc(u32 cnt)
...
@@ -163,7 +157,6 @@ static struct sub_seq *tipc_subseq_alloc(u32 cnt)
*
*
* Allocates a single sub-sequence structure and sets it to all 0's.
* Allocates a single sub-sequence structure and sets it to all 0's.
*/
*/
static
struct
name_seq
*
tipc_nameseq_create
(
u32
type
,
struct
hlist_head
*
seq_head
)
static
struct
name_seq
*
tipc_nameseq_create
(
u32
type
,
struct
hlist_head
*
seq_head
)
{
{
struct
name_seq
*
nseq
=
kzalloc
(
sizeof
(
*
nseq
),
GFP_ATOMIC
);
struct
name_seq
*
nseq
=
kzalloc
(
sizeof
(
*
nseq
),
GFP_ATOMIC
);
...
@@ -186,12 +179,23 @@ static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_hea
...
@@ -186,12 +179,23 @@ static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_hea
return
nseq
;
return
nseq
;
}
}
/**
/*
* nameseq_delete_empty - deletes a name sequence structure if now unused
*/
static
void
nameseq_delete_empty
(
struct
name_seq
*
seq
)
{
if
(
!
seq
->
first_free
&&
list_empty
(
&
seq
->
subscriptions
))
{
hlist_del_init
(
&
seq
->
ns_list
);
kfree
(
seq
->
sseqs
);
kfree
(
seq
);
}
}
/*
* nameseq_find_subseq - find sub-sequence (if any) matching a name instance
* nameseq_find_subseq - find sub-sequence (if any) matching a name instance
*
*
* Very time-critical, so binary searches through sub-sequence array.
* Very time-critical, so binary searches through sub-sequence array.
*/
*/
static
struct
sub_seq
*
nameseq_find_subseq
(
struct
name_seq
*
nseq
,
static
struct
sub_seq
*
nameseq_find_subseq
(
struct
name_seq
*
nseq
,
u32
instance
)
u32
instance
)
{
{
...
@@ -221,7 +225,6 @@ static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq,
...
@@ -221,7 +225,6 @@ static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq,
*
*
* Note: Similar to binary search code for locating a sub-sequence.
* Note: Similar to binary search code for locating a sub-sequence.
*/
*/
static
u32
nameseq_locate_subseq
(
struct
name_seq
*
nseq
,
u32
instance
)
static
u32
nameseq_locate_subseq
(
struct
name_seq
*
nseq
,
u32
instance
)
{
{
struct
sub_seq
*
sseqs
=
nseq
->
sseqs
;
struct
sub_seq
*
sseqs
=
nseq
->
sseqs
;
...
@@ -242,9 +245,8 @@ static u32 nameseq_locate_subseq(struct name_seq *nseq, u32 instance)
...
@@ -242,9 +245,8 @@ static u32 nameseq_locate_subseq(struct name_seq *nseq, u32 instance)
}
}
/**
/**
* tipc_nameseq_insert_publ
-
* tipc_nameseq_insert_publ
*/
*/
static
struct
publication
*
tipc_nameseq_insert_publ
(
struct
name_seq
*
nseq
,
static
struct
publication
*
tipc_nameseq_insert_publ
(
struct
name_seq
*
nseq
,
u32
type
,
u32
lower
,
u32
upper
,
u32
type
,
u32
lower
,
u32
upper
,
u32
scope
,
u32
node
,
u32
port
,
u32
key
)
u32
scope
,
u32
node
,
u32
port
,
u32
key
)
...
@@ -260,7 +262,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
...
@@ -260,7 +262,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
if
(
sseq
)
{
if
(
sseq
)
{
/* Lower end overlaps existing entry => need an exact match */
/* Lower end overlaps existing entry => need an exact match */
if
((
sseq
->
lower
!=
lower
)
||
(
sseq
->
upper
!=
upper
))
{
if
((
sseq
->
lower
!=
lower
)
||
(
sseq
->
upper
!=
upper
))
{
warn
(
"Cannot publish {%u,%u,%u}, overlap error
\n
"
,
warn
(
"Cannot publish {%u,%u,%u}, overlap error
\n
"
,
type
,
lower
,
upper
);
type
,
lower
,
upper
);
...
@@ -280,11 +281,9 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
...
@@ -280,11 +281,9 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
struct
sub_seq
*
freesseq
;
struct
sub_seq
*
freesseq
;
/* Find where lower end should be inserted */
/* Find where lower end should be inserted */
inspos
=
nameseq_locate_subseq
(
nseq
,
lower
);
inspos
=
nameseq_locate_subseq
(
nseq
,
lower
);
/* Fail if upper end overlaps into an existing entry */
/* Fail if upper end overlaps into an existing entry */
if
((
inspos
<
nseq
->
first_free
)
&&
if
((
inspos
<
nseq
->
first_free
)
&&
(
upper
>=
nseq
->
sseqs
[
inspos
].
lower
))
{
(
upper
>=
nseq
->
sseqs
[
inspos
].
lower
))
{
warn
(
"Cannot publish {%u,%u,%u}, overlap error
\n
"
,
warn
(
"Cannot publish {%u,%u,%u}, overlap error
\n
"
,
...
@@ -293,7 +292,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
...
@@ -293,7 +292,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
}
}
/* Ensure there is space for new sub-sequence */
/* Ensure there is space for new sub-sequence */
if
(
nseq
->
first_free
==
nseq
->
alloc
)
{
if
(
nseq
->
first_free
==
nseq
->
alloc
)
{
struct
sub_seq
*
sseqs
=
tipc_subseq_alloc
(
nseq
->
alloc
*
2
);
struct
sub_seq
*
sseqs
=
tipc_subseq_alloc
(
nseq
->
alloc
*
2
);
...
@@ -321,7 +319,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
...
@@ -321,7 +319,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
INIT_LIST_HEAD
(
&
info
->
zone_list
);
INIT_LIST_HEAD
(
&
info
->
zone_list
);
/* Insert new sub-sequence */
/* Insert new sub-sequence */
sseq
=
&
nseq
->
sseqs
[
inspos
];
sseq
=
&
nseq
->
sseqs
[
inspos
];
freesseq
=
&
nseq
->
sseqs
[
nseq
->
first_free
];
freesseq
=
&
nseq
->
sseqs
[
nseq
->
first_free
];
memmove
(
sseq
+
1
,
sseq
,
(
freesseq
-
sseq
)
*
sizeof
(
*
sseq
));
memmove
(
sseq
+
1
,
sseq
,
(
freesseq
-
sseq
)
*
sizeof
(
*
sseq
));
...
@@ -333,8 +330,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
...
@@ -333,8 +330,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
created_subseq
=
1
;
created_subseq
=
1
;
}
}
/* Insert a publication: */
/* Insert a publication */
publ
=
publ_create
(
type
,
lower
,
upper
,
scope
,
node
,
port
,
key
);
publ
=
publ_create
(
type
,
lower
,
upper
,
scope
,
node
,
port
,
key
);
if
(
!
publ
)
if
(
!
publ
)
return
NULL
;
return
NULL
;
...
@@ -352,9 +348,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
...
@@ -352,9 +348,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
info
->
node_list_size
++
;
info
->
node_list_size
++
;
}
}
/*
/* Any subscriptions waiting for notification? */
* Any subscriptions waiting for notification?
*/
list_for_each_entry_safe
(
s
,
st
,
&
nseq
->
subscriptions
,
nameseq_list
)
{
list_for_each_entry_safe
(
s
,
st
,
&
nseq
->
subscriptions
,
nameseq_list
)
{
tipc_subscr_report_overlap
(
s
,
tipc_subscr_report_overlap
(
s
,
publ
->
lower
,
publ
->
lower
,
...
@@ -368,7 +362,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
...
@@ -368,7 +362,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
}
}
/**
/**
* tipc_nameseq_remove_publ
-
* tipc_nameseq_remove_publ
*
*
* NOTE: There may be cases where TIPC is asked to remove a publication
* NOTE: There may be cases where TIPC is asked to remove a publication
* that is not in the name table. For example, if another node issues a
* that is not in the name table. For example, if another node issues a
...
@@ -378,7 +372,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
...
@@ -378,7 +372,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
* A failed withdraw request simply returns a failure indication and lets the
* A failed withdraw request simply returns a failure indication and lets the
* caller issue any error or warning messages associated with such a problem.
* caller issue any error or warning messages associated with such a problem.
*/
*/
static
struct
publication
*
tipc_nameseq_remove_publ
(
struct
name_seq
*
nseq
,
u32
inst
,
static
struct
publication
*
tipc_nameseq_remove_publ
(
struct
name_seq
*
nseq
,
u32
inst
,
u32
node
,
u32
ref
,
u32
key
)
u32
node
,
u32
ref
,
u32
key
)
{
{
...
@@ -395,7 +388,6 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
...
@@ -395,7 +388,6 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
info
=
sseq
->
info
;
info
=
sseq
->
info
;
/* Locate publication, if it exists */
/* Locate publication, if it exists */
list_for_each_entry
(
publ
,
&
info
->
zone_list
,
zone_list
)
{
list_for_each_entry
(
publ
,
&
info
->
zone_list
,
zone_list
)
{
if
((
publ
->
key
==
key
)
&&
(
publ
->
ref
==
ref
)
&&
if
((
publ
->
key
==
key
)
&&
(
publ
->
ref
==
ref
)
&&
(
!
publ
->
node
||
(
publ
->
node
==
node
)))
(
!
publ
->
node
||
(
publ
->
node
==
node
)))
...
@@ -405,26 +397,22 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
...
@@ -405,26 +397,22 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
found:
found:
/* Remove publication from zone scope list */
/* Remove publication from zone scope list */
list_del
(
&
publ
->
zone_list
);
list_del
(
&
publ
->
zone_list
);
info
->
zone_list_size
--
;
info
->
zone_list_size
--
;
/* Remove publication from cluster scope list, if present */
/* Remove publication from cluster scope list, if present */
if
(
in_own_cluster
(
node
))
{
if
(
in_own_cluster
(
node
))
{
list_del
(
&
publ
->
cluster_list
);
list_del
(
&
publ
->
cluster_list
);
info
->
cluster_list_size
--
;
info
->
cluster_list_size
--
;
}
}
/* Remove publication from node scope list, if present */
/* Remove publication from node scope list, if present */
if
(
in_own_node
(
node
))
{
if
(
in_own_node
(
node
))
{
list_del
(
&
publ
->
node_list
);
list_del
(
&
publ
->
node_list
);
info
->
node_list_size
--
;
info
->
node_list_size
--
;
}
}
/* Contract subseq list if no more publications for that subseq */
/* Contract subseq list if no more publications for that subseq */
if
(
list_empty
(
&
info
->
zone_list
))
{
if
(
list_empty
(
&
info
->
zone_list
))
{
kfree
(
info
);
kfree
(
info
);
free
=
&
nseq
->
sseqs
[
nseq
->
first_free
--
];
free
=
&
nseq
->
sseqs
[
nseq
->
first_free
--
];
...
@@ -433,7 +421,6 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
...
@@ -433,7 +421,6 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
}
}
/* Notify any waiting subscriptions */
/* Notify any waiting subscriptions */
list_for_each_entry_safe
(
s
,
st
,
&
nseq
->
subscriptions
,
nameseq_list
)
{
list_for_each_entry_safe
(
s
,
st
,
&
nseq
->
subscriptions
,
nameseq_list
)
{
tipc_subscr_report_overlap
(
s
,
tipc_subscr_report_overlap
(
s
,
publ
->
lower
,
publ
->
lower
,
...
@@ -452,7 +439,6 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
...
@@ -452,7 +439,6 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
* the prescribed number of events if there is any sub-
* the prescribed number of events if there is any sub-
* sequence overlapping with the requested sequence
* sequence overlapping with the requested sequence
*/
*/
static
void
tipc_nameseq_subscribe
(
struct
name_seq
*
nseq
,
static
void
tipc_nameseq_subscribe
(
struct
name_seq
*
nseq
,
struct
tipc_subscription
*
s
)
struct
tipc_subscription
*
s
)
{
{
...
@@ -504,9 +490,10 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
...
@@ -504,9 +490,10 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
{
{
struct
name_seq
*
seq
=
nametbl_find_seq
(
type
);
struct
name_seq
*
seq
=
nametbl_find_seq
(
type
);
if
(
lower
>
upper
)
{
if
((
scope
<
TIPC_ZONE_SCOPE
)
||
(
scope
>
TIPC_NODE_SCOPE
)
||
warn
(
"Failed to publish illegal {%u,%u,%u}
\n
"
,
(
lower
>
upper
))
{
type
,
lower
,
upper
);
dbg
(
"Failed to publish illegal {%u,%u,%u} with scope %u
\n
"
,
type
,
lower
,
upper
,
scope
);
return
NULL
;
return
NULL
;
}
}
...
@@ -529,12 +516,7 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
...
@@ -529,12 +516,7 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
return
NULL
;
return
NULL
;
publ
=
tipc_nameseq_remove_publ
(
seq
,
lower
,
node
,
ref
,
key
);
publ
=
tipc_nameseq_remove_publ
(
seq
,
lower
,
node
,
ref
,
key
);
nameseq_delete_empty
(
seq
);
if
(
!
seq
->
first_free
&&
list_empty
(
&
seq
->
subscriptions
))
{
hlist_del_init
(
&
seq
->
ns_list
);
kfree
(
seq
->
sseqs
);
kfree
(
seq
);
}
return
publ
;
return
publ
;
}
}
...
@@ -551,7 +533,6 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
...
@@ -551,7 +533,6 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
* - if name translation is attempted and fails, sets 'destnode' to 0
* - if name translation is attempted and fails, sets 'destnode' to 0
* and returns 0
* and returns 0
*/
*/
u32
tipc_nametbl_translate
(
u32
type
,
u32
instance
,
u32
*
destnode
)
u32
tipc_nametbl_translate
(
u32
type
,
u32
instance
,
u32
*
destnode
)
{
{
struct
sub_seq
*
sseq
;
struct
sub_seq
*
sseq
;
...
@@ -574,7 +555,7 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
...
@@ -574,7 +555,7 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
spin_lock_bh
(
&
seq
->
lock
);
spin_lock_bh
(
&
seq
->
lock
);
info
=
sseq
->
info
;
info
=
sseq
->
info
;
/* Closest-First Algorithm
:
*/
/* Closest-First Algorithm */
if
(
likely
(
!*
destnode
))
{
if
(
likely
(
!*
destnode
))
{
if
(
!
list_empty
(
&
info
->
node_list
))
{
if
(
!
list_empty
(
&
info
->
node_list
))
{
publ
=
list_first_entry
(
&
info
->
node_list
,
publ
=
list_first_entry
(
&
info
->
node_list
,
...
@@ -597,7 +578,7 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
...
@@ -597,7 +578,7 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
}
}
}
}
/* Round-Robin Algorithm
:
*/
/* Round-Robin Algorithm */
else
if
(
*
destnode
==
tipc_own_addr
)
{
else
if
(
*
destnode
==
tipc_own_addr
)
{
if
(
list_empty
(
&
info
->
node_list
))
if
(
list_empty
(
&
info
->
node_list
))
goto
no_match
;
goto
no_match
;
...
@@ -638,7 +619,6 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
...
@@ -638,7 +619,6 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
*
*
* Returns non-zero if any off-node ports overlap
* Returns non-zero if any off-node ports overlap
*/
*/
int
tipc_nametbl_mc_translate
(
u32
type
,
u32
lower
,
u32
upper
,
u32
limit
,
int
tipc_nametbl_mc_translate
(
u32
type
,
u32
lower
,
u32
upper
,
u32
limit
,
struct
tipc_port_list
*
dports
)
struct
tipc_port_list
*
dports
)
{
{
...
@@ -682,7 +662,6 @@ int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
...
@@ -682,7 +662,6 @@ int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
/*
/*
* tipc_nametbl_publish - add name publication to network name tables
* tipc_nametbl_publish - add name publication to network name tables
*/
*/
struct
publication
*
tipc_nametbl_publish
(
u32
type
,
u32
lower
,
u32
upper
,
struct
publication
*
tipc_nametbl_publish
(
u32
type
,
u32
lower
,
u32
upper
,
u32
scope
,
u32
port_ref
,
u32
key
)
u32
scope
,
u32
port_ref
,
u32
key
)
{
{
...
@@ -708,7 +687,6 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper,
...
@@ -708,7 +687,6 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper,
/**
/**
* tipc_nametbl_withdraw - withdraw name publication from network name tables
* tipc_nametbl_withdraw - withdraw name publication from network name tables
*/
*/
int
tipc_nametbl_withdraw
(
u32
type
,
u32
lower
,
u32
ref
,
u32
key
)
int
tipc_nametbl_withdraw
(
u32
type
,
u32
lower
,
u32
ref
,
u32
key
)
{
{
struct
publication
*
publ
;
struct
publication
*
publ
;
...
@@ -733,7 +711,6 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key)
...
@@ -733,7 +711,6 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key)
/**
/**
* tipc_nametbl_subscribe - add a subscription object to the name table
* tipc_nametbl_subscribe - add a subscription object to the name table
*/
*/
void
tipc_nametbl_subscribe
(
struct
tipc_subscription
*
s
)
void
tipc_nametbl_subscribe
(
struct
tipc_subscription
*
s
)
{
{
u32
type
=
s
->
seq
.
type
;
u32
type
=
s
->
seq
.
type
;
...
@@ -757,7 +734,6 @@ void tipc_nametbl_subscribe(struct tipc_subscription *s)
...
@@ -757,7 +734,6 @@ void tipc_nametbl_subscribe(struct tipc_subscription *s)
/**
/**
* tipc_nametbl_unsubscribe - remove a subscription object from name table
* tipc_nametbl_unsubscribe - remove a subscription object from name table
*/
*/
void
tipc_nametbl_unsubscribe
(
struct
tipc_subscription
*
s
)
void
tipc_nametbl_unsubscribe
(
struct
tipc_subscription
*
s
)
{
{
struct
name_seq
*
seq
;
struct
name_seq
*
seq
;
...
@@ -768,11 +744,7 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s)
...
@@ -768,11 +744,7 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s)
spin_lock_bh
(
&
seq
->
lock
);
spin_lock_bh
(
&
seq
->
lock
);
list_del_init
(
&
s
->
nameseq_list
);
list_del_init
(
&
s
->
nameseq_list
);
spin_unlock_bh
(
&
seq
->
lock
);
spin_unlock_bh
(
&
seq
->
lock
);
if
((
seq
->
first_free
==
0
)
&&
list_empty
(
&
seq
->
subscriptions
))
{
nameseq_delete_empty
(
seq
);
hlist_del_init
(
&
seq
->
ns_list
);
kfree
(
seq
->
sseqs
);
kfree
(
seq
);
}
}
}
write_unlock_bh
(
&
tipc_nametbl_lock
);
write_unlock_bh
(
&
tipc_nametbl_lock
);
}
}
...
@@ -781,7 +753,6 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s)
...
@@ -781,7 +753,6 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s)
/**
/**
* subseq_list: print specified sub-sequence contents into the given buffer
* subseq_list: print specified sub-sequence contents into the given buffer
*/
*/
static
void
subseq_list
(
struct
sub_seq
*
sseq
,
struct
print_buf
*
buf
,
u32
depth
,
static
void
subseq_list
(
struct
sub_seq
*
sseq
,
struct
print_buf
*
buf
,
u32
depth
,
u32
index
)
u32
index
)
{
{
...
@@ -818,7 +789,6 @@ static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth,
...
@@ -818,7 +789,6 @@ static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth,
/**
/**
* nameseq_list: print specified name sequence contents into the given buffer
* nameseq_list: print specified name sequence contents into the given buffer
*/
*/
static
void
nameseq_list
(
struct
name_seq
*
seq
,
struct
print_buf
*
buf
,
u32
depth
,
static
void
nameseq_list
(
struct
name_seq
*
seq
,
struct
print_buf
*
buf
,
u32
depth
,
u32
type
,
u32
lowbound
,
u32
upbound
,
u32
index
)
u32
type
,
u32
lowbound
,
u32
upbound
,
u32
index
)
{
{
...
@@ -849,7 +819,6 @@ static void nameseq_list(struct name_seq *seq, struct print_buf *buf, u32 depth,
...
@@ -849,7 +819,6 @@ static void nameseq_list(struct name_seq *seq, struct print_buf *buf, u32 depth,
/**
/**
* nametbl_header - print name table header into the given buffer
* nametbl_header - print name table header into the given buffer
*/
*/
static
void
nametbl_header
(
struct
print_buf
*
buf
,
u32
depth
)
static
void
nametbl_header
(
struct
print_buf
*
buf
,
u32
depth
)
{
{
const
char
*
header
[]
=
{
const
char
*
header
[]
=
{
...
@@ -871,7 +840,6 @@ static void nametbl_header(struct print_buf *buf, u32 depth)
...
@@ -871,7 +840,6 @@ static void nametbl_header(struct print_buf *buf, u32 depth)
/**
/**
* nametbl_list - print specified name table contents into the given buffer
* nametbl_list - print specified name table contents into the given buffer
*/
*/
static
void
nametbl_list
(
struct
print_buf
*
buf
,
u32
depth_info
,
static
void
nametbl_list
(
struct
print_buf
*
buf
,
u32
depth_info
,
u32
type
,
u32
lowbound
,
u32
upbound
)
u32
type
,
u32
lowbound
,
u32
upbound
)
{
{
...
@@ -970,7 +938,6 @@ void tipc_nametbl_stop(void)
...
@@ -970,7 +938,6 @@ void tipc_nametbl_stop(void)
return
;
return
;
/* Verify name table is empty, then release it */
/* Verify name table is empty, then release it */
write_lock_bh
(
&
tipc_nametbl_lock
);
write_lock_bh
(
&
tipc_nametbl_lock
);
for
(
i
=
0
;
i
<
tipc_nametbl_size
;
i
++
)
{
for
(
i
=
0
;
i
<
tipc_nametbl_size
;
i
++
)
{
if
(
!
hlist_empty
(
&
table
.
types
[
i
]))
if
(
!
hlist_empty
(
&
table
.
types
[
i
]))
...
@@ -980,4 +947,3 @@ void tipc_nametbl_stop(void)
...
@@ -980,4 +947,3 @@ void tipc_nametbl_stop(void)
table
.
types
=
NULL
;
table
.
types
=
NULL
;
write_unlock_bh
(
&
tipc_nametbl_lock
);
write_unlock_bh
(
&
tipc_nametbl_lock
);
}
}
net/tipc/name_table.h
浏览文件 @
b6d151bb
...
@@ -45,10 +45,8 @@ struct tipc_port_list;
...
@@ -45,10 +45,8 @@ struct tipc_port_list;
/*
/*
* TIPC name types reserved for internal TIPC use (both current and planned)
* TIPC name types reserved for internal TIPC use (both current and planned)
*/
*/
#define TIPC_ZM_SRV 3
/* zone master service name type */
#define TIPC_ZM_SRV 3
/* zone master service name type */
/**
/**
* struct publication - info about a published (name or) name sequence
* struct publication - info about a published (name or) name sequence
* @type: name sequence type
* @type: name sequence type
...
@@ -67,7 +65,6 @@ struct tipc_port_list;
...
@@ -67,7 +65,6 @@ struct tipc_port_list;
*
*
* Note that the node list, cluster list, and zone list are circular lists.
* Note that the node list, cluster list, and zone list are circular lists.
*/
*/
struct
publication
{
struct
publication
{
u32
type
;
u32
type
;
u32
lower
;
u32
lower
;
...
...
net/tipc/net.c
浏览文件 @
b6d151bb
...
@@ -175,9 +175,6 @@ int tipc_net_start(u32 addr)
...
@@ -175,9 +175,6 @@ int tipc_net_start(u32 addr)
{
{
char
addr_string
[
16
];
char
addr_string
[
16
];
tipc_subscr_stop
();
tipc_cfg_stop
();
write_lock_bh
(
&
tipc_net_lock
);
write_lock_bh
(
&
tipc_net_lock
);
tipc_own_addr
=
addr
;
tipc_own_addr
=
addr
;
tipc_named_reinit
();
tipc_named_reinit
();
...
@@ -185,8 +182,7 @@ int tipc_net_start(u32 addr)
...
@@ -185,8 +182,7 @@ int tipc_net_start(u32 addr)
tipc_bclink_init
();
tipc_bclink_init
();
write_unlock_bh
(
&
tipc_net_lock
);
write_unlock_bh
(
&
tipc_net_lock
);
tipc_k_signal
((
Handler
)
tipc_subscr_start
,
0
);
tipc_cfg_reinit
();
tipc_k_signal
((
Handler
)
tipc_cfg_init
,
0
);
info
(
"Started in network mode
\n
"
);
info
(
"Started in network mode
\n
"
);
info
(
"Own node address %s, network identity %u
\n
"
,
info
(
"Own node address %s, network identity %u
\n
"
,
...
...
net/tipc/node.c
浏览文件 @
b6d151bb
...
@@ -66,7 +66,6 @@ static unsigned int tipc_hashfn(u32 addr)
...
@@ -66,7 +66,6 @@ static unsigned int tipc_hashfn(u32 addr)
/*
/*
* tipc_node_find - locate specified node object, if it exists
* tipc_node_find - locate specified node object, if it exists
*/
*/
struct
tipc_node
*
tipc_node_find
(
u32
addr
)
struct
tipc_node
*
tipc_node_find
(
u32
addr
)
{
{
struct
tipc_node
*
node
;
struct
tipc_node
*
node
;
...
@@ -91,7 +90,6 @@ struct tipc_node *tipc_node_find(u32 addr)
...
@@ -91,7 +90,6 @@ struct tipc_node *tipc_node_find(u32 addr)
* time. (It would be preferable to switch to holding net_lock in write mode,
* time. (It would be preferable to switch to holding net_lock in write mode,
* but this is a non-trivial change.)
* but this is a non-trivial change.)
*/
*/
struct
tipc_node
*
tipc_node_create
(
u32
addr
)
struct
tipc_node
*
tipc_node_create
(
u32
addr
)
{
{
struct
tipc_node
*
n_ptr
,
*
temp_node
;
struct
tipc_node
*
n_ptr
,
*
temp_node
;
...
@@ -142,13 +140,11 @@ void tipc_node_delete(struct tipc_node *n_ptr)
...
@@ -142,13 +140,11 @@ void tipc_node_delete(struct tipc_node *n_ptr)
tipc_num_nodes
--
;
tipc_num_nodes
--
;
}
}
/**
/**
* tipc_node_link_up - handle addition of link
* tipc_node_link_up - handle addition of link
*
*
* Link becomes active (alone or shared) or standby, depending on its priority.
* Link becomes active (alone or shared) or standby, depending on its priority.
*/
*/
void
tipc_node_link_up
(
struct
tipc_node
*
n_ptr
,
struct
tipc_link
*
l_ptr
)
void
tipc_node_link_up
(
struct
tipc_node
*
n_ptr
,
struct
tipc_link
*
l_ptr
)
{
{
struct
tipc_link
**
active
=
&
n_ptr
->
active_links
[
0
];
struct
tipc_link
**
active
=
&
n_ptr
->
active_links
[
0
];
...
@@ -181,7 +177,6 @@ void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
...
@@ -181,7 +177,6 @@ void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
/**
/**
* node_select_active_links - select active link
* node_select_active_links - select active link
*/
*/
static
void
node_select_active_links
(
struct
tipc_node
*
n_ptr
)
static
void
node_select_active_links
(
struct
tipc_node
*
n_ptr
)
{
{
struct
tipc_link
**
active
=
&
n_ptr
->
active_links
[
0
];
struct
tipc_link
**
active
=
&
n_ptr
->
active_links
[
0
];
...
@@ -209,7 +204,6 @@ static void node_select_active_links(struct tipc_node *n_ptr)
...
@@ -209,7 +204,6 @@ static void node_select_active_links(struct tipc_node *n_ptr)
/**
/**
* tipc_node_link_down - handle loss of link
* tipc_node_link_down - handle loss of link
*/
*/
void
tipc_node_link_down
(
struct
tipc_node
*
n_ptr
,
struct
tipc_link
*
l_ptr
)
void
tipc_node_link_down
(
struct
tipc_node
*
n_ptr
,
struct
tipc_link
*
l_ptr
)
{
{
struct
tipc_link
**
active
;
struct
tipc_link
**
active
;
...
@@ -300,7 +294,6 @@ static void node_lost_contact(struct tipc_node *n_ptr)
...
@@ -300,7 +294,6 @@ static void node_lost_contact(struct tipc_node *n_ptr)
tipc_addr_string_fill
(
addr_string
,
n_ptr
->
addr
));
tipc_addr_string_fill
(
addr_string
,
n_ptr
->
addr
));
/* Flush broadcast link info associated with lost node */
/* Flush broadcast link info associated with lost node */
if
(
n_ptr
->
bclink
.
supported
)
{
if
(
n_ptr
->
bclink
.
supported
)
{
while
(
n_ptr
->
bclink
.
deferred_head
)
{
while
(
n_ptr
->
bclink
.
deferred_head
)
{
struct
sk_buff
*
buf
=
n_ptr
->
bclink
.
deferred_head
;
struct
sk_buff
*
buf
=
n_ptr
->
bclink
.
deferred_head
;
...
@@ -334,7 +327,6 @@ static void node_lost_contact(struct tipc_node *n_ptr)
...
@@ -334,7 +327,6 @@ static void node_lost_contact(struct tipc_node *n_ptr)
tipc_nodesub_notify
(
n_ptr
);
tipc_nodesub_notify
(
n_ptr
);
/* Prevent re-contact with node until cleanup is done */
/* Prevent re-contact with node until cleanup is done */
n_ptr
->
block_setup
=
WAIT_PEER_DOWN
|
WAIT_NAMES_GONE
;
n_ptr
->
block_setup
=
WAIT_PEER_DOWN
|
WAIT_NAMES_GONE
;
tipc_k_signal
((
Handler
)
node_name_purge_complete
,
n_ptr
->
addr
);
tipc_k_signal
((
Handler
)
node_name_purge_complete
,
n_ptr
->
addr
);
}
}
...
@@ -362,7 +354,6 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
...
@@ -362,7 +354,6 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
}
}
/* For now, get space for all other nodes */
/* For now, get space for all other nodes */
payload_size
=
TLV_SPACE
(
sizeof
(
node_info
))
*
tipc_num_nodes
;
payload_size
=
TLV_SPACE
(
sizeof
(
node_info
))
*
tipc_num_nodes
;
if
(
payload_size
>
32768u
)
{
if
(
payload_size
>
32768u
)
{
read_unlock_bh
(
&
tipc_net_lock
);
read_unlock_bh
(
&
tipc_net_lock
);
...
@@ -376,7 +367,6 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
...
@@ -376,7 +367,6 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
}
}
/* Add TLVs for all nodes in scope */
/* Add TLVs for all nodes in scope */
list_for_each_entry
(
n_ptr
,
&
tipc_node_list
,
list
)
{
list_for_each_entry
(
n_ptr
,
&
tipc_node_list
,
list
)
{
if
(
!
tipc_in_scope
(
domain
,
n_ptr
->
addr
))
if
(
!
tipc_in_scope
(
domain
,
n_ptr
->
addr
))
continue
;
continue
;
...
@@ -412,7 +402,6 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
...
@@ -412,7 +402,6 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
read_lock_bh
(
&
tipc_net_lock
);
read_lock_bh
(
&
tipc_net_lock
);
/* Get space for all unicast links + broadcast link */
/* Get space for all unicast links + broadcast link */
payload_size
=
TLV_SPACE
(
sizeof
(
link_info
))
*
payload_size
=
TLV_SPACE
(
sizeof
(
link_info
))
*
(
atomic_read
(
&
tipc_num_links
)
+
1
);
(
atomic_read
(
&
tipc_num_links
)
+
1
);
if
(
payload_size
>
32768u
)
{
if
(
payload_size
>
32768u
)
{
...
@@ -427,14 +416,12 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
...
@@ -427,14 +416,12 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
}
}
/* Add TLV for broadcast link */
/* Add TLV for broadcast link */
link_info
.
dest
=
htonl
(
tipc_cluster_mask
(
tipc_own_addr
));
link_info
.
dest
=
htonl
(
tipc_cluster_mask
(
tipc_own_addr
));
link_info
.
up
=
htonl
(
1
);
link_info
.
up
=
htonl
(
1
);
strlcpy
(
link_info
.
str
,
tipc_bclink_name
,
TIPC_MAX_LINK_NAME
);
strlcpy
(
link_info
.
str
,
tipc_bclink_name
,
TIPC_MAX_LINK_NAME
);
tipc_cfg_append_tlv
(
buf
,
TIPC_TLV_LINK_INFO
,
&
link_info
,
sizeof
(
link_info
));
tipc_cfg_append_tlv
(
buf
,
TIPC_TLV_LINK_INFO
,
&
link_info
,
sizeof
(
link_info
));
/* Add TLVs for any other links in scope */
/* Add TLVs for any other links in scope */
list_for_each_entry
(
n_ptr
,
&
tipc_node_list
,
list
)
{
list_for_each_entry
(
n_ptr
,
&
tipc_node_list
,
list
)
{
u32
i
;
u32
i
;
...
...
net/tipc/node.h
浏览文件 @
b6d151bb
...
@@ -48,7 +48,6 @@
...
@@ -48,7 +48,6 @@
#define INVALID_NODE_SIG 0x10000
#define INVALID_NODE_SIG 0x10000
/* Flags used to block (re)establishment of contact with a neighboring node */
/* Flags used to block (re)establishment of contact with a neighboring node */
#define WAIT_PEER_DOWN 0x0001
/* wait to see that peer's links are down */
#define WAIT_PEER_DOWN 0x0001
/* wait to see that peer's links are down */
#define WAIT_NAMES_GONE 0x0002
/* wait for peer's publications to be purged */
#define WAIT_NAMES_GONE 0x0002
/* wait for peer's publications to be purged */
#define WAIT_NODE_DOWN 0x0004
/* wait until peer node is declared down */
#define WAIT_NODE_DOWN 0x0004
/* wait until peer node is declared down */
...
@@ -79,7 +78,6 @@
...
@@ -79,7 +78,6 @@
* @deferred_tail: newest OOS b'cast message received from node
* @deferred_tail: newest OOS b'cast message received from node
* @defragm: list of partially reassembled b'cast message fragments from node
* @defragm: list of partially reassembled b'cast message fragments from node
*/
*/
struct
tipc_node
{
struct
tipc_node
{
u32
addr
;
u32
addr
;
spinlock_t
lock
;
spinlock_t
lock
;
...
...
net/tipc/node_subscr.c
浏览文件 @
b6d151bb
...
@@ -41,7 +41,6 @@
...
@@ -41,7 +41,6 @@
/**
/**
* tipc_nodesub_subscribe - create "node down" subscription for specified node
* tipc_nodesub_subscribe - create "node down" subscription for specified node
*/
*/
void
tipc_nodesub_subscribe
(
struct
tipc_node_subscr
*
node_sub
,
u32
addr
,
void
tipc_nodesub_subscribe
(
struct
tipc_node_subscr
*
node_sub
,
u32
addr
,
void
*
usr_handle
,
net_ev_handler
handle_down
)
void
*
usr_handle
,
net_ev_handler
handle_down
)
{
{
...
@@ -66,7 +65,6 @@ void tipc_nodesub_subscribe(struct tipc_node_subscr *node_sub, u32 addr,
...
@@ -66,7 +65,6 @@ void tipc_nodesub_subscribe(struct tipc_node_subscr *node_sub, u32 addr,
/**
/**
* tipc_nodesub_unsubscribe - cancel "node down" subscription (if any)
* tipc_nodesub_unsubscribe - cancel "node down" subscription (if any)
*/
*/
void
tipc_nodesub_unsubscribe
(
struct
tipc_node_subscr
*
node_sub
)
void
tipc_nodesub_unsubscribe
(
struct
tipc_node_subscr
*
node_sub
)
{
{
if
(
!
node_sub
->
node
)
if
(
!
node_sub
->
node
)
...
@@ -82,7 +80,6 @@ void tipc_nodesub_unsubscribe(struct tipc_node_subscr *node_sub)
...
@@ -82,7 +80,6 @@ void tipc_nodesub_unsubscribe(struct tipc_node_subscr *node_sub)
*
*
* Note: node is locked by caller
* Note: node is locked by caller
*/
*/
void
tipc_nodesub_notify
(
struct
tipc_node
*
node
)
void
tipc_nodesub_notify
(
struct
tipc_node
*
node
)
{
{
struct
tipc_node_subscr
*
ns
;
struct
tipc_node_subscr
*
ns
;
...
...
net/tipc/node_subscr.h
浏览文件 @
b6d151bb
...
@@ -48,7 +48,6 @@ typedef void (*net_ev_handler) (void *usr_handle);
...
@@ -48,7 +48,6 @@ typedef void (*net_ev_handler) (void *usr_handle);
* @usr_handle: argument to pass to routine when node fails
* @usr_handle: argument to pass to routine when node fails
* @nodesub_list: adjacent entries in list of subscriptions for the node
* @nodesub_list: adjacent entries in list of subscriptions for the node
*/
*/
struct
tipc_node_subscr
{
struct
tipc_node_subscr
{
struct
tipc_node
*
node
;
struct
tipc_node
*
node
;
net_ev_handler
handle_node_down
;
net_ev_handler
handle_node_down
;
...
...
net/tipc/port.c
浏览文件 @
b6d151bb
...
@@ -75,7 +75,6 @@ static u32 port_peerport(struct tipc_port *p_ptr)
...
@@ -75,7 +75,6 @@ static u32 port_peerport(struct tipc_port *p_ptr)
* Handles cases where the node's network address has changed from
* Handles cases where the node's network address has changed from
* the default of <0.0.0> to its configured setting.
* the default of <0.0.0> to its configured setting.
*/
*/
int
tipc_port_peer_msg
(
struct
tipc_port
*
p_ptr
,
struct
tipc_msg
*
msg
)
int
tipc_port_peer_msg
(
struct
tipc_port
*
p_ptr
,
struct
tipc_msg
*
msg
)
{
{
u32
peernode
;
u32
peernode
;
...
@@ -94,7 +93,6 @@ int tipc_port_peer_msg(struct tipc_port *p_ptr, struct tipc_msg *msg)
...
@@ -94,7 +93,6 @@ int tipc_port_peer_msg(struct tipc_port *p_ptr, struct tipc_msg *msg)
/**
/**
* tipc_multicast - send a multicast message to local and remote destinations
* tipc_multicast - send a multicast message to local and remote destinations
*/
*/
int
tipc_multicast
(
u32
ref
,
struct
tipc_name_seq
const
*
seq
,
int
tipc_multicast
(
u32
ref
,
struct
tipc_name_seq
const
*
seq
,
u32
num_sect
,
struct
iovec
const
*
msg_sect
,
u32
num_sect
,
struct
iovec
const
*
msg_sect
,
unsigned
int
total_len
)
unsigned
int
total_len
)
...
@@ -111,7 +109,6 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
...
@@ -111,7 +109,6 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
return
-
EINVAL
;
return
-
EINVAL
;
/* Create multicast message */
/* Create multicast message */
hdr
=
&
oport
->
phdr
;
hdr
=
&
oport
->
phdr
;
msg_set_type
(
hdr
,
TIPC_MCAST_MSG
);
msg_set_type
(
hdr
,
TIPC_MCAST_MSG
);
msg_set_lookup_scope
(
hdr
,
TIPC_CLUSTER_SCOPE
);
msg_set_lookup_scope
(
hdr
,
TIPC_CLUSTER_SCOPE
);
...
@@ -127,12 +124,10 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
...
@@ -127,12 +124,10 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
return
res
;
return
res
;
/* Figure out where to send multicast message */
/* Figure out where to send multicast message */
ext_targets
=
tipc_nametbl_mc_translate
(
seq
->
type
,
seq
->
lower
,
seq
->
upper
,
ext_targets
=
tipc_nametbl_mc_translate
(
seq
->
type
,
seq
->
lower
,
seq
->
upper
,
TIPC_NODE_SCOPE
,
&
dports
);
TIPC_NODE_SCOPE
,
&
dports
);
/* Send message to destinations (duplicate it only if necessary) */
/* Send message to destinations (duplicate it only if necessary) */
if
(
ext_targets
)
{
if
(
ext_targets
)
{
if
(
dports
.
count
!=
0
)
{
if
(
dports
.
count
!=
0
)
{
ibuf
=
skb_copy
(
buf
,
GFP_ATOMIC
);
ibuf
=
skb_copy
(
buf
,
GFP_ATOMIC
);
...
@@ -163,7 +158,6 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
...
@@ -163,7 +158,6 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
*
*
* If there is no port list, perform a lookup to create one
* If there is no port list, perform a lookup to create one
*/
*/
void
tipc_port_recv_mcast
(
struct
sk_buff
*
buf
,
struct
tipc_port_list
*
dp
)
void
tipc_port_recv_mcast
(
struct
sk_buff
*
buf
,
struct
tipc_port_list
*
dp
)
{
{
struct
tipc_msg
*
msg
;
struct
tipc_msg
*
msg
;
...
@@ -174,7 +168,6 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp)
...
@@ -174,7 +168,6 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp)
msg
=
buf_msg
(
buf
);
msg
=
buf_msg
(
buf
);
/* Create destination port list, if one wasn't supplied */
/* Create destination port list, if one wasn't supplied */
if
(
dp
==
NULL
)
{
if
(
dp
==
NULL
)
{
tipc_nametbl_mc_translate
(
msg_nametype
(
msg
),
tipc_nametbl_mc_translate
(
msg_nametype
(
msg
),
msg_namelower
(
msg
),
msg_namelower
(
msg
),
...
@@ -185,7 +178,6 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp)
...
@@ -185,7 +178,6 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp)
}
}
/* Deliver a copy of message to each destination port */
/* Deliver a copy of message to each destination port */
if
(
dp
->
count
!=
0
)
{
if
(
dp
->
count
!=
0
)
{
msg_set_destnode
(
msg
,
tipc_own_addr
);
msg_set_destnode
(
msg
,
tipc_own_addr
);
if
(
dp
->
count
==
1
)
{
if
(
dp
->
count
==
1
)
{
...
@@ -218,7 +210,6 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp)
...
@@ -218,7 +210,6 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp)
*
*
* Returns pointer to (locked) TIPC port, or NULL if unable to create it
* Returns pointer to (locked) TIPC port, or NULL if unable to create it
*/
*/
struct
tipc_port
*
tipc_createport_raw
(
void
*
usr_handle
,
struct
tipc_port
*
tipc_createport_raw
(
void
*
usr_handle
,
u32
(
*
dispatcher
)(
struct
tipc_port
*
,
struct
sk_buff
*
),
u32
(
*
dispatcher
)(
struct
tipc_port
*
,
struct
sk_buff
*
),
void
(
*
wakeup
)(
struct
tipc_port
*
),
void
(
*
wakeup
)(
struct
tipc_port
*
),
...
@@ -257,7 +248,6 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,
...
@@ -257,7 +248,6 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,
* to ensure a change to node's own network address doesn't result
* to ensure a change to node's own network address doesn't result
* in template containing out-dated network address information
* in template containing out-dated network address information
*/
*/
spin_lock_bh
(
&
tipc_port_list_lock
);
spin_lock_bh
(
&
tipc_port_list_lock
);
msg
=
&
p_ptr
->
phdr
;
msg
=
&
p_ptr
->
phdr
;
tipc_msg_init
(
msg
,
importance
,
TIPC_NAMED_MSG
,
NAMED_H_SIZE
,
0
);
tipc_msg_init
(
msg
,
importance
,
TIPC_NAMED_MSG
,
NAMED_H_SIZE
,
0
);
...
@@ -390,7 +380,6 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
...
@@ -390,7 +380,6 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
u32
rmsg_sz
;
u32
rmsg_sz
;
/* discard rejected message if it shouldn't be returned to sender */
/* discard rejected message if it shouldn't be returned to sender */
if
(
WARN
(
!
msg_isdata
(
msg
),
if
(
WARN
(
!
msg_isdata
(
msg
),
"attempt to reject message with user=%u"
,
msg_user
(
msg
)))
{
"attempt to reject message with user=%u"
,
msg_user
(
msg
)))
{
dump_stack
();
dump_stack
();
...
@@ -403,7 +392,6 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
...
@@ -403,7 +392,6 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
* construct returned message by copying rejected message header and
* construct returned message by copying rejected message header and
* data (or subset), then updating header fields that need adjusting
* data (or subset), then updating header fields that need adjusting
*/
*/
hdr_sz
=
msg_hdr_sz
(
msg
);
hdr_sz
=
msg_hdr_sz
(
msg
);
rmsg_sz
=
hdr_sz
+
min_t
(
u32
,
data_sz
,
MAX_REJECT_SIZE
);
rmsg_sz
=
hdr_sz
+
min_t
(
u32
,
data_sz
,
MAX_REJECT_SIZE
);
...
@@ -442,7 +430,6 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
...
@@ -442,7 +430,6 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
}
}
/* send returned message & dispose of rejected message */
/* send returned message & dispose of rejected message */
src_node
=
msg_prevnode
(
msg
);
src_node
=
msg_prevnode
(
msg
);
if
(
in_own_node
(
src_node
))
if
(
in_own_node
(
src_node
))
tipc_port_recv_msg
(
rbuf
);
tipc_port_recv_msg
(
rbuf
);
...
@@ -552,7 +539,6 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
...
@@ -552,7 +539,6 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
int
wakeable
;
int
wakeable
;
/* Validate connection */
/* Validate connection */
p_ptr
=
tipc_port_lock
(
destport
);
p_ptr
=
tipc_port_lock
(
destport
);
if
(
!
p_ptr
||
!
p_ptr
->
connected
||
!
tipc_port_peer_msg
(
p_ptr
,
msg
))
{
if
(
!
p_ptr
||
!
p_ptr
->
connected
||
!
tipc_port_peer_msg
(
p_ptr
,
msg
))
{
r_buf
=
tipc_buf_acquire
(
BASIC_H_SIZE
);
r_buf
=
tipc_buf_acquire
(
BASIC_H_SIZE
);
...
@@ -570,7 +556,6 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
...
@@ -570,7 +556,6 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
}
}
/* Process protocol message sent by peer */
/* Process protocol message sent by peer */
switch
(
msg_type
(
msg
))
{
switch
(
msg_type
(
msg
))
{
case
CONN_ACK
:
case
CONN_ACK
:
wakeable
=
tipc_port_congested
(
p_ptr
)
&&
p_ptr
->
congested
&&
wakeable
=
tipc_port_congested
(
p_ptr
)
&&
p_ptr
->
congested
&&
...
@@ -682,7 +667,6 @@ void tipc_port_reinit(void)
...
@@ -682,7 +667,6 @@ void tipc_port_reinit(void)
* port_dispatcher_sigh(): Signal handler for messages destinated
* port_dispatcher_sigh(): Signal handler for messages destinated
* to the tipc_port interface.
* to the tipc_port interface.
*/
*/
static
void
port_dispatcher_sigh
(
void
*
dummy
)
static
void
port_dispatcher_sigh
(
void
*
dummy
)
{
{
struct
sk_buff
*
buf
;
struct
sk_buff
*
buf
;
...
@@ -843,7 +827,6 @@ static void port_dispatcher_sigh(void *dummy)
...
@@ -843,7 +827,6 @@ static void port_dispatcher_sigh(void *dummy)
* port_dispatcher(): Dispatcher for messages destinated
* port_dispatcher(): Dispatcher for messages destinated
* to the tipc_port interface. Called with port locked.
* to the tipc_port interface. Called with port locked.
*/
*/
static
u32
port_dispatcher
(
struct
tipc_port
*
dummy
,
struct
sk_buff
*
buf
)
static
u32
port_dispatcher
(
struct
tipc_port
*
dummy
,
struct
sk_buff
*
buf
)
{
{
buf
->
next
=
NULL
;
buf
->
next
=
NULL
;
...
@@ -860,10 +843,8 @@ static u32 port_dispatcher(struct tipc_port *dummy, struct sk_buff *buf)
...
@@ -860,10 +843,8 @@ static u32 port_dispatcher(struct tipc_port *dummy, struct sk_buff *buf)
}
}
/*
/*
* Wake up port after congestion: Called with port locked,
* Wake up port after congestion: Called with port locked
*
*/
*/
static
void
port_wakeup_sh
(
unsigned
long
ref
)
static
void
port_wakeup_sh
(
unsigned
long
ref
)
{
{
struct
tipc_port
*
p_ptr
;
struct
tipc_port
*
p_ptr
;
...
@@ -909,7 +890,6 @@ void tipc_acknowledge(u32 ref, u32 ack)
...
@@ -909,7 +890,6 @@ void tipc_acknowledge(u32 ref, u32 ack)
/*
/*
* tipc_createport(): user level call.
* tipc_createport(): user level call.
*/
*/
int
tipc_createport
(
void
*
usr_handle
,
int
tipc_createport
(
void
*
usr_handle
,
unsigned
int
importance
,
unsigned
int
importance
,
tipc_msg_err_event
error_cb
,
tipc_msg_err_event
error_cb
,
...
@@ -918,7 +898,7 @@ int tipc_createport(void *usr_handle,
...
@@ -918,7 +898,7 @@ int tipc_createport(void *usr_handle,
tipc_msg_event
msg_cb
,
tipc_msg_event
msg_cb
,
tipc_named_msg_event
named_msg_cb
,
tipc_named_msg_event
named_msg_cb
,
tipc_conn_msg_event
conn_msg_cb
,
tipc_conn_msg_event
conn_msg_cb
,
tipc_continue_event
continue_event_cb
,
/* May be zero */
tipc_continue_event
continue_event_cb
,
/* May be zero */
u32
*
portref
)
u32
*
portref
)
{
{
struct
user_port
*
up_ptr
;
struct
user_port
*
up_ptr
;
...
@@ -992,10 +972,6 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
...
@@ -992,10 +972,6 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
if
(
p_ptr
->
connected
)
if
(
p_ptr
->
connected
)
goto
exit
;
goto
exit
;
if
(
seq
->
lower
>
seq
->
upper
)
goto
exit
;
if
((
scope
<
TIPC_ZONE_SCOPE
)
||
(
scope
>
TIPC_NODE_SCOPE
))
goto
exit
;
key
=
ref
+
p_ptr
->
pub_count
+
1
;
key
=
ref
+
p_ptr
->
pub_count
+
1
;
if
(
key
==
ref
)
{
if
(
key
==
ref
)
{
res
=
-
EADDRINUSE
;
res
=
-
EADDRINUSE
;
...
@@ -1095,7 +1071,6 @@ int tipc_connect2port(u32 ref, struct tipc_portid const *peer)
...
@@ -1095,7 +1071,6 @@ int tipc_connect2port(u32 ref, struct tipc_portid const *peer)
*
*
* Port must be locked.
* Port must be locked.
*/
*/
int
tipc_disconnect_port
(
struct
tipc_port
*
tp_ptr
)
int
tipc_disconnect_port
(
struct
tipc_port
*
tp_ptr
)
{
{
int
res
;
int
res
;
...
@@ -1116,7 +1091,6 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr)
...
@@ -1116,7 +1091,6 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr)
* tipc_disconnect(): Disconnect port form peer.
* tipc_disconnect(): Disconnect port form peer.
* This is a node local operation.
* This is a node local operation.
*/
*/
int
tipc_disconnect
(
u32
ref
)
int
tipc_disconnect
(
u32
ref
)
{
{
struct
tipc_port
*
p_ptr
;
struct
tipc_port
*
p_ptr
;
...
@@ -1151,7 +1125,6 @@ int tipc_shutdown(u32 ref)
...
@@ -1151,7 +1125,6 @@ int tipc_shutdown(u32 ref)
/**
/**
* tipc_port_recv_msg - receive message from lower layer and deliver to port user
* tipc_port_recv_msg - receive message from lower layer and deliver to port user
*/
*/
int
tipc_port_recv_msg
(
struct
sk_buff
*
buf
)
int
tipc_port_recv_msg
(
struct
sk_buff
*
buf
)
{
{
struct
tipc_port
*
p_ptr
;
struct
tipc_port
*
p_ptr
;
...
@@ -1184,7 +1157,6 @@ int tipc_port_recv_msg(struct sk_buff *buf)
...
@@ -1184,7 +1157,6 @@ int tipc_port_recv_msg(struct sk_buff *buf)
* tipc_port_recv_sections(): Concatenate and deliver sectioned
* tipc_port_recv_sections(): Concatenate and deliver sectioned
* message for this node.
* message for this node.
*/
*/
static
int
tipc_port_recv_sections
(
struct
tipc_port
*
sender
,
unsigned
int
num_sect
,
static
int
tipc_port_recv_sections
(
struct
tipc_port
*
sender
,
unsigned
int
num_sect
,
struct
iovec
const
*
msg_sect
,
struct
iovec
const
*
msg_sect
,
unsigned
int
total_len
)
unsigned
int
total_len
)
...
@@ -1202,7 +1174,6 @@ static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_se
...
@@ -1202,7 +1174,6 @@ static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_se
/**
/**
* tipc_send - send message sections on connection
* tipc_send - send message sections on connection
*/
*/
int
tipc_send
(
u32
ref
,
unsigned
int
num_sect
,
struct
iovec
const
*
msg_sect
,
int
tipc_send
(
u32
ref
,
unsigned
int
num_sect
,
struct
iovec
const
*
msg_sect
,
unsigned
int
total_len
)
unsigned
int
total_len
)
{
{
...
@@ -1241,7 +1212,6 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect,
...
@@ -1241,7 +1212,6 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect,
/**
/**
* tipc_send2name - send message sections to port name
* tipc_send2name - send message sections to port name
*/
*/
int
tipc_send2name
(
u32
ref
,
struct
tipc_name
const
*
name
,
unsigned
int
domain
,
int
tipc_send2name
(
u32
ref
,
struct
tipc_name
const
*
name
,
unsigned
int
domain
,
unsigned
int
num_sect
,
struct
iovec
const
*
msg_sect
,
unsigned
int
num_sect
,
struct
iovec
const
*
msg_sect
,
unsigned
int
total_len
)
unsigned
int
total_len
)
...
@@ -1295,7 +1265,6 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain,
...
@@ -1295,7 +1265,6 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain,
/**
/**
* tipc_send2port - send message sections to port identity
* tipc_send2port - send message sections to port identity
*/
*/
int
tipc_send2port
(
u32
ref
,
struct
tipc_portid
const
*
dest
,
int
tipc_send2port
(
u32
ref
,
struct
tipc_portid
const
*
dest
,
unsigned
int
num_sect
,
struct
iovec
const
*
msg_sect
,
unsigned
int
num_sect
,
struct
iovec
const
*
msg_sect
,
unsigned
int
total_len
)
unsigned
int
total_len
)
...
@@ -1338,7 +1307,6 @@ int tipc_send2port(u32 ref, struct tipc_portid const *dest,
...
@@ -1338,7 +1307,6 @@ int tipc_send2port(u32 ref, struct tipc_portid const *dest,
/**
/**
* tipc_send_buf2port - send message buffer to port identity
* tipc_send_buf2port - send message buffer to port identity
*/
*/
int
tipc_send_buf2port
(
u32
ref
,
struct
tipc_portid
const
*
dest
,
int
tipc_send_buf2port
(
u32
ref
,
struct
tipc_portid
const
*
dest
,
struct
sk_buff
*
buf
,
unsigned
int
dsz
)
struct
sk_buff
*
buf
,
unsigned
int
dsz
)
{
{
...
@@ -1375,4 +1343,3 @@ int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest,
...
@@ -1375,4 +1343,3 @@ int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest,
return
dsz
;
return
dsz
;
return
-
ELINKCONG
;
return
-
ELINKCONG
;
}
}
net/tipc/port.h
浏览文件 @
b6d151bb
...
@@ -81,7 +81,6 @@ typedef void (*tipc_continue_event) (void *usr_handle, u32 portref);
...
@@ -81,7 +81,6 @@ typedef void (*tipc_continue_event) (void *usr_handle, u32 portref);
* @ref: object reference to associated TIPC port
* @ref: object reference to associated TIPC port
* <various callback routines>
* <various callback routines>
*/
*/
struct
user_port
{
struct
user_port
{
void
*
usr_handle
;
void
*
usr_handle
;
u32
ref
;
u32
ref
;
...
@@ -236,7 +235,6 @@ void tipc_port_reinit(void);
...
@@ -236,7 +235,6 @@ void tipc_port_reinit(void);
/**
/**
* tipc_port_lock - lock port instance referred to and return its pointer
* tipc_port_lock - lock port instance referred to and return its pointer
*/
*/
static
inline
struct
tipc_port
*
tipc_port_lock
(
u32
ref
)
static
inline
struct
tipc_port
*
tipc_port_lock
(
u32
ref
)
{
{
return
(
struct
tipc_port
*
)
tipc_ref_lock
(
ref
);
return
(
struct
tipc_port
*
)
tipc_ref_lock
(
ref
);
...
@@ -247,7 +245,6 @@ static inline struct tipc_port *tipc_port_lock(u32 ref)
...
@@ -247,7 +245,6 @@ static inline struct tipc_port *tipc_port_lock(u32 ref)
*
*
* Can use pointer instead of tipc_ref_unlock() since port is already locked.
* Can use pointer instead of tipc_ref_unlock() since port is already locked.
*/
*/
static
inline
void
tipc_port_unlock
(
struct
tipc_port
*
p_ptr
)
static
inline
void
tipc_port_unlock
(
struct
tipc_port
*
p_ptr
)
{
{
spin_unlock_bh
(
p_ptr
->
lock
);
spin_unlock_bh
(
p_ptr
->
lock
);
...
...
net/tipc/ref.c
浏览文件 @
b6d151bb
...
@@ -43,7 +43,6 @@
...
@@ -43,7 +43,6 @@
* @lock: spinlock controlling access to object
* @lock: spinlock controlling access to object
* @ref: reference value for object (combines instance & array index info)
* @ref: reference value for object (combines instance & array index info)
*/
*/
struct
reference
{
struct
reference
{
void
*
object
;
void
*
object
;
spinlock_t
lock
;
spinlock_t
lock
;
...
@@ -60,7 +59,6 @@ struct reference {
...
@@ -60,7 +59,6 @@ struct reference {
* @index_mask: bitmask for array index portion of reference values
* @index_mask: bitmask for array index portion of reference values
* @start_mask: initial value for instance value portion of reference values
* @start_mask: initial value for instance value portion of reference values
*/
*/
struct
ref_table
{
struct
ref_table
{
struct
reference
*
entries
;
struct
reference
*
entries
;
u32
capacity
;
u32
capacity
;
...
@@ -96,7 +94,6 @@ static DEFINE_RWLOCK(ref_table_lock);
...
@@ -96,7 +94,6 @@ static DEFINE_RWLOCK(ref_table_lock);
/**
/**
* tipc_ref_table_init - create reference table for objects
* tipc_ref_table_init - create reference table for objects
*/
*/
int
tipc_ref_table_init
(
u32
requested_size
,
u32
start
)
int
tipc_ref_table_init
(
u32
requested_size
,
u32
start
)
{
{
struct
reference
*
table
;
struct
reference
*
table
;
...
@@ -109,7 +106,6 @@ int tipc_ref_table_init(u32 requested_size, u32 start)
...
@@ -109,7 +106,6 @@ int tipc_ref_table_init(u32 requested_size, u32 start)
/* do nothing */
;
/* do nothing */
;
/* allocate table & mark all entries as uninitialized */
/* allocate table & mark all entries as uninitialized */
table
=
vzalloc
(
actual_size
*
sizeof
(
struct
reference
));
table
=
vzalloc
(
actual_size
*
sizeof
(
struct
reference
));
if
(
table
==
NULL
)
if
(
table
==
NULL
)
return
-
ENOMEM
;
return
-
ENOMEM
;
...
@@ -128,7 +124,6 @@ int tipc_ref_table_init(u32 requested_size, u32 start)
...
@@ -128,7 +124,6 @@ int tipc_ref_table_init(u32 requested_size, u32 start)
/**
/**
* tipc_ref_table_stop - destroy reference table for objects
* tipc_ref_table_stop - destroy reference table for objects
*/
*/
void
tipc_ref_table_stop
(
void
)
void
tipc_ref_table_stop
(
void
)
{
{
if
(
!
tipc_ref_table
.
entries
)
if
(
!
tipc_ref_table
.
entries
)
...
@@ -149,7 +144,6 @@ void tipc_ref_table_stop(void)
...
@@ -149,7 +144,6 @@ void tipc_ref_table_stop(void)
* register a partially initialized object, without running the risk that
* register a partially initialized object, without running the risk that
* the object will be accessed before initialization is complete.
* the object will be accessed before initialization is complete.
*/
*/
u32
tipc_ref_acquire
(
void
*
object
,
spinlock_t
**
lock
)
u32
tipc_ref_acquire
(
void
*
object
,
spinlock_t
**
lock
)
{
{
u32
index
;
u32
index
;
...
@@ -168,7 +162,6 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
...
@@ -168,7 +162,6 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
}
}
/* take a free entry, if available; otherwise initialize a new entry */
/* take a free entry, if available; otherwise initialize a new entry */
write_lock_bh
(
&
ref_table_lock
);
write_lock_bh
(
&
ref_table_lock
);
if
(
tipc_ref_table
.
first_free
)
{
if
(
tipc_ref_table
.
first_free
)
{
index
=
tipc_ref_table
.
first_free
;
index
=
tipc_ref_table
.
first_free
;
...
@@ -211,7 +204,6 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
...
@@ -211,7 +204,6 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
* Disallow future references to an object and free up the entry for re-use.
* Disallow future references to an object and free up the entry for re-use.
* Note: The entry's spin_lock may still be busy after discard
* Note: The entry's spin_lock may still be busy after discard
*/
*/
void
tipc_ref_discard
(
u32
ref
)
void
tipc_ref_discard
(
u32
ref
)
{
{
struct
reference
*
entry
;
struct
reference
*
entry
;
...
@@ -242,12 +234,10 @@ void tipc_ref_discard(u32 ref)
...
@@ -242,12 +234,10 @@ void tipc_ref_discard(u32 ref)
* mark entry as unused; increment instance part of entry's reference
* mark entry as unused; increment instance part of entry's reference
* to invalidate any subsequent references
* to invalidate any subsequent references
*/
*/
entry
->
object
=
NULL
;
entry
->
object
=
NULL
;
entry
->
ref
=
(
ref
&
~
index_mask
)
+
(
index_mask
+
1
);
entry
->
ref
=
(
ref
&
~
index_mask
)
+
(
index_mask
+
1
);
/* append entry to free entry list */
/* append entry to free entry list */
if
(
tipc_ref_table
.
first_free
==
0
)
if
(
tipc_ref_table
.
first_free
==
0
)
tipc_ref_table
.
first_free
=
index
;
tipc_ref_table
.
first_free
=
index
;
else
else
...
@@ -261,7 +251,6 @@ void tipc_ref_discard(u32 ref)
...
@@ -261,7 +251,6 @@ void tipc_ref_discard(u32 ref)
/**
/**
* tipc_ref_lock - lock referenced object and return pointer to it
* tipc_ref_lock - lock referenced object and return pointer to it
*/
*/
void
*
tipc_ref_lock
(
u32
ref
)
void
*
tipc_ref_lock
(
u32
ref
)
{
{
if
(
likely
(
tipc_ref_table
.
entries
))
{
if
(
likely
(
tipc_ref_table
.
entries
))
{
...
@@ -283,7 +272,6 @@ void *tipc_ref_lock(u32 ref)
...
@@ -283,7 +272,6 @@ void *tipc_ref_lock(u32 ref)
/**
/**
* tipc_ref_deref - return pointer referenced object (without locking it)
* tipc_ref_deref - return pointer referenced object (without locking it)
*/
*/
void
*
tipc_ref_deref
(
u32
ref
)
void
*
tipc_ref_deref
(
u32
ref
)
{
{
if
(
likely
(
tipc_ref_table
.
entries
))
{
if
(
likely
(
tipc_ref_table
.
entries
))
{
...
@@ -296,4 +284,3 @@ void *tipc_ref_deref(u32 ref)
...
@@ -296,4 +284,3 @@ void *tipc_ref_deref(u32 ref)
}
}
return
NULL
;
return
NULL
;
}
}
net/tipc/socket.c
浏览文件 @
b6d151bb
...
@@ -123,7 +123,6 @@ static atomic_t tipc_queue_size = ATOMIC_INIT(0);
...
@@ -123,7 +123,6 @@ static atomic_t tipc_queue_size = ATOMIC_INIT(0);
*
*
* Caller must hold socket lock
* Caller must hold socket lock
*/
*/
static
void
advance_rx_queue
(
struct
sock
*
sk
)
static
void
advance_rx_queue
(
struct
sock
*
sk
)
{
{
kfree_skb
(
__skb_dequeue
(
&
sk
->
sk_receive_queue
));
kfree_skb
(
__skb_dequeue
(
&
sk
->
sk_receive_queue
));
...
@@ -135,7 +134,6 @@ static void advance_rx_queue(struct sock *sk)
...
@@ -135,7 +134,6 @@ static void advance_rx_queue(struct sock *sk)
*
*
* Caller must hold socket lock
* Caller must hold socket lock
*/
*/
static
void
discard_rx_queue
(
struct
sock
*
sk
)
static
void
discard_rx_queue
(
struct
sock
*
sk
)
{
{
struct
sk_buff
*
buf
;
struct
sk_buff
*
buf
;
...
@@ -151,7 +149,6 @@ static void discard_rx_queue(struct sock *sk)
...
@@ -151,7 +149,6 @@ static void discard_rx_queue(struct sock *sk)
*
*
* Caller must hold socket lock
* Caller must hold socket lock
*/
*/
static
void
reject_rx_queue
(
struct
sock
*
sk
)
static
void
reject_rx_queue
(
struct
sock
*
sk
)
{
{
struct
sk_buff
*
buf
;
struct
sk_buff
*
buf
;
...
@@ -174,7 +171,6 @@ static void reject_rx_queue(struct sock *sk)
...
@@ -174,7 +171,6 @@ static void reject_rx_queue(struct sock *sk)
*
*
* Returns 0 on success, errno otherwise
* Returns 0 on success, errno otherwise
*/
*/
static
int
tipc_create
(
struct
net
*
net
,
struct
socket
*
sock
,
int
protocol
,
static
int
tipc_create
(
struct
net
*
net
,
struct
socket
*
sock
,
int
protocol
,
int
kern
)
int
kern
)
{
{
...
@@ -184,7 +180,6 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
...
@@ -184,7 +180,6 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
struct
tipc_port
*
tp_ptr
;
struct
tipc_port
*
tp_ptr
;
/* Validate arguments */
/* Validate arguments */
if
(
unlikely
(
protocol
!=
0
))
if
(
unlikely
(
protocol
!=
0
))
return
-
EPROTONOSUPPORT
;
return
-
EPROTONOSUPPORT
;
...
@@ -207,13 +202,11 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
...
@@ -207,13 +202,11 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
}
}
/* Allocate socket's protocol area */
/* Allocate socket's protocol area */
sk
=
sk_alloc
(
net
,
AF_TIPC
,
GFP_KERNEL
,
&
tipc_proto
);
sk
=
sk_alloc
(
net
,
AF_TIPC
,
GFP_KERNEL
,
&
tipc_proto
);
if
(
sk
==
NULL
)
if
(
sk
==
NULL
)
return
-
ENOMEM
;
return
-
ENOMEM
;
/* Allocate TIPC port for socket to use */
/* Allocate TIPC port for socket to use */
tp_ptr
=
tipc_createport_raw
(
sk
,
&
dispatch
,
&
wakeupdispatch
,
tp_ptr
=
tipc_createport_raw
(
sk
,
&
dispatch
,
&
wakeupdispatch
,
TIPC_LOW_IMPORTANCE
);
TIPC_LOW_IMPORTANCE
);
if
(
unlikely
(
!
tp_ptr
))
{
if
(
unlikely
(
!
tp_ptr
))
{
...
@@ -222,7 +215,6 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
...
@@ -222,7 +215,6 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
}
}
/* Finish initializing socket data structures */
/* Finish initializing socket data structures */
sock
->
ops
=
ops
;
sock
->
ops
=
ops
;
sock
->
state
=
state
;
sock
->
state
=
state
;
...
@@ -258,7 +250,6 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
...
@@ -258,7 +250,6 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
*
*
* Returns 0 on success, errno otherwise
* Returns 0 on success, errno otherwise
*/
*/
static
int
release
(
struct
socket
*
sock
)
static
int
release
(
struct
socket
*
sock
)
{
{
struct
sock
*
sk
=
sock
->
sk
;
struct
sock
*
sk
=
sock
->
sk
;
...
@@ -270,7 +261,6 @@ static int release(struct socket *sock)
...
@@ -270,7 +261,6 @@ static int release(struct socket *sock)
* Exit if socket isn't fully initialized (occurs when a failed accept()
* Exit if socket isn't fully initialized (occurs when a failed accept()
* releases a pre-allocated child socket that was never used)
* releases a pre-allocated child socket that was never used)
*/
*/
if
(
sk
==
NULL
)
if
(
sk
==
NULL
)
return
0
;
return
0
;
...
@@ -281,7 +271,6 @@ static int release(struct socket *sock)
...
@@ -281,7 +271,6 @@ static int release(struct socket *sock)
* Reject all unreceived messages, except on an active connection
* Reject all unreceived messages, except on an active connection
* (which disconnects locally & sends a 'FIN+' to peer)
* (which disconnects locally & sends a 'FIN+' to peer)
*/
*/
while
(
sock
->
state
!=
SS_DISCONNECTING
)
{
while
(
sock
->
state
!=
SS_DISCONNECTING
)
{
buf
=
__skb_dequeue
(
&
sk
->
sk_receive_queue
);
buf
=
__skb_dequeue
(
&
sk
->
sk_receive_queue
);
if
(
buf
==
NULL
)
if
(
buf
==
NULL
)
...
@@ -303,15 +292,12 @@ static int release(struct socket *sock)
...
@@ -303,15 +292,12 @@ static int release(struct socket *sock)
* Delete TIPC port; this ensures no more messages are queued
* Delete TIPC port; this ensures no more messages are queued
* (also disconnects an active connection & sends a 'FIN-' to peer)
* (also disconnects an active connection & sends a 'FIN-' to peer)
*/
*/
res
=
tipc_deleteport
(
tport
->
ref
);
res
=
tipc_deleteport
(
tport
->
ref
);
/* Discard any remaining (connection-based) messages in receive queue */
/* Discard any remaining (connection-based) messages in receive queue */
discard_rx_queue
(
sk
);
discard_rx_queue
(
sk
);
/* Reject any messages that accumulated in backlog queue */
/* Reject any messages that accumulated in backlog queue */
sock
->
state
=
SS_DISCONNECTING
;
sock
->
state
=
SS_DISCONNECTING
;
release_sock
(
sk
);
release_sock
(
sk
);
...
@@ -336,7 +322,6 @@ static int release(struct socket *sock)
...
@@ -336,7 +322,6 @@ static int release(struct socket *sock)
* NOTE: This routine doesn't need to take the socket lock since it doesn't
* NOTE: This routine doesn't need to take the socket lock since it doesn't
* access any non-constant socket information.
* access any non-constant socket information.
*/
*/
static
int
bind
(
struct
socket
*
sock
,
struct
sockaddr
*
uaddr
,
int
uaddr_len
)
static
int
bind
(
struct
socket
*
sock
,
struct
sockaddr
*
uaddr
,
int
uaddr_len
)
{
{
struct
sockaddr_tipc
*
addr
=
(
struct
sockaddr_tipc
*
)
uaddr
;
struct
sockaddr_tipc
*
addr
=
(
struct
sockaddr_tipc
*
)
uaddr
;
...
@@ -376,7 +361,6 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len)
...
@@ -376,7 +361,6 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len)
* accesses socket information that is unchanging (or which changes in
* accesses socket information that is unchanging (or which changes in
* a completely predictable manner).
* a completely predictable manner).
*/
*/
static
int
get_name
(
struct
socket
*
sock
,
struct
sockaddr
*
uaddr
,
static
int
get_name
(
struct
socket
*
sock
,
struct
sockaddr
*
uaddr
,
int
*
uaddr_len
,
int
peer
)
int
*
uaddr_len
,
int
peer
)
{
{
...
@@ -444,7 +428,6 @@ static int get_name(struct socket *sock, struct sockaddr *uaddr,
...
@@ -444,7 +428,6 @@ static int get_name(struct socket *sock, struct sockaddr *uaddr,
* imply that the operation will succeed, merely that it should be performed
* imply that the operation will succeed, merely that it should be performed
* and will not block.
* and will not block.
*/
*/
static
unsigned
int
poll
(
struct
file
*
file
,
struct
socket
*
sock
,
static
unsigned
int
poll
(
struct
file
*
file
,
struct
socket
*
sock
,
poll_table
*
wait
)
poll_table
*
wait
)
{
{
...
@@ -482,7 +465,6 @@ static unsigned int poll(struct file *file, struct socket *sock,
...
@@ -482,7 +465,6 @@ static unsigned int poll(struct file *file, struct socket *sock,
*
*
* Returns 0 if permission is granted, otherwise errno
* Returns 0 if permission is granted, otherwise errno
*/
*/
static
int
dest_name_check
(
struct
sockaddr_tipc
*
dest
,
struct
msghdr
*
m
)
static
int
dest_name_check
(
struct
sockaddr_tipc
*
dest
,
struct
msghdr
*
m
)
{
{
struct
tipc_cfg_msg_hdr
hdr
;
struct
tipc_cfg_msg_hdr
hdr
;
...
@@ -518,7 +500,6 @@ static int dest_name_check(struct sockaddr_tipc *dest, struct msghdr *m)
...
@@ -518,7 +500,6 @@ static int dest_name_check(struct sockaddr_tipc *dest, struct msghdr *m)
*
*
* Returns the number of bytes sent on success, or errno otherwise
* Returns the number of bytes sent on success, or errno otherwise
*/
*/
static
int
send_msg
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
static
int
send_msg
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
struct
msghdr
*
m
,
size_t
total_len
)
struct
msghdr
*
m
,
size_t
total_len
)
{
{
...
@@ -562,7 +543,6 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
...
@@ -562,7 +543,6 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
}
}
/* Abort any pending connection attempts (very unlikely) */
/* Abort any pending connection attempts (very unlikely) */
reject_rx_queue
(
sk
);
reject_rx_queue
(
sk
);
}
}
...
@@ -631,7 +611,6 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
...
@@ -631,7 +611,6 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
*
*
* Returns the number of bytes sent on success, or errno otherwise
* Returns the number of bytes sent on success, or errno otherwise
*/
*/
static
int
send_packet
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
static
int
send_packet
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
struct
msghdr
*
m
,
size_t
total_len
)
struct
msghdr
*
m
,
size_t
total_len
)
{
{
...
@@ -642,7 +621,6 @@ static int send_packet(struct kiocb *iocb, struct socket *sock,
...
@@ -642,7 +621,6 @@ static int send_packet(struct kiocb *iocb, struct socket *sock,
int
res
;
int
res
;
/* Handle implied connection establishment */
/* Handle implied connection establishment */
if
(
unlikely
(
dest
))
if
(
unlikely
(
dest
))
return
send_msg
(
iocb
,
sock
,
m
,
total_len
);
return
send_msg
(
iocb
,
sock
,
m
,
total_len
);
...
@@ -695,7 +673,6 @@ static int send_packet(struct kiocb *iocb, struct socket *sock,
...
@@ -695,7 +673,6 @@ static int send_packet(struct kiocb *iocb, struct socket *sock,
* Returns the number of bytes sent on success (or partial success),
* Returns the number of bytes sent on success (or partial success),
* or errno if no data sent
* or errno if no data sent
*/
*/
static
int
send_stream
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
static
int
send_stream
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
struct
msghdr
*
m
,
size_t
total_len
)
struct
msghdr
*
m
,
size_t
total_len
)
{
{
...
@@ -715,7 +692,6 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
...
@@ -715,7 +692,6 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
lock_sock
(
sk
);
lock_sock
(
sk
);
/* Handle special cases where there is no connection */
/* Handle special cases where there is no connection */
if
(
unlikely
(
sock
->
state
!=
SS_CONNECTED
))
{
if
(
unlikely
(
sock
->
state
!=
SS_CONNECTED
))
{
if
(
sock
->
state
==
SS_UNCONNECTED
)
{
if
(
sock
->
state
==
SS_UNCONNECTED
)
{
res
=
send_packet
(
NULL
,
sock
,
m
,
total_len
);
res
=
send_packet
(
NULL
,
sock
,
m
,
total_len
);
...
@@ -747,7 +723,6 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
...
@@ -747,7 +723,6 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
* (i.e. one large iovec entry), but could be improved to pass sets
* (i.e. one large iovec entry), but could be improved to pass sets
* of small iovec entries into send_packet().
* of small iovec entries into send_packet().
*/
*/
curr_iov
=
m
->
msg_iov
;
curr_iov
=
m
->
msg_iov
;
curr_iovlen
=
m
->
msg_iovlen
;
curr_iovlen
=
m
->
msg_iovlen
;
my_msg
.
msg_iov
=
&
my_iov
;
my_msg
.
msg_iov
=
&
my_iov
;
...
@@ -796,7 +771,6 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
...
@@ -796,7 +771,6 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
*
*
* Returns 0 on success, errno otherwise
* Returns 0 on success, errno otherwise
*/
*/
static
int
auto_connect
(
struct
socket
*
sock
,
struct
tipc_msg
*
msg
)
static
int
auto_connect
(
struct
socket
*
sock
,
struct
tipc_msg
*
msg
)
{
{
struct
tipc_sock
*
tsock
=
tipc_sk
(
sock
->
sk
);
struct
tipc_sock
*
tsock
=
tipc_sk
(
sock
->
sk
);
...
@@ -821,7 +795,6 @@ static int auto_connect(struct socket *sock, struct tipc_msg *msg)
...
@@ -821,7 +795,6 @@ static int auto_connect(struct socket *sock, struct tipc_msg *msg)
*
*
* Note: Address is not captured if not requested by receiver.
* Note: Address is not captured if not requested by receiver.
*/
*/
static
void
set_orig_addr
(
struct
msghdr
*
m
,
struct
tipc_msg
*
msg
)
static
void
set_orig_addr
(
struct
msghdr
*
m
,
struct
tipc_msg
*
msg
)
{
{
struct
sockaddr_tipc
*
addr
=
(
struct
sockaddr_tipc
*
)
m
->
msg_name
;
struct
sockaddr_tipc
*
addr
=
(
struct
sockaddr_tipc
*
)
m
->
msg_name
;
...
@@ -847,7 +820,6 @@ static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg)
...
@@ -847,7 +820,6 @@ static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg)
*
*
* Returns 0 if successful, otherwise errno
* Returns 0 if successful, otherwise errno
*/
*/
static
int
anc_data_recv
(
struct
msghdr
*
m
,
struct
tipc_msg
*
msg
,
static
int
anc_data_recv
(
struct
msghdr
*
m
,
struct
tipc_msg
*
msg
,
struct
tipc_port
*
tport
)
struct
tipc_port
*
tport
)
{
{
...
@@ -861,7 +833,6 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg,
...
@@ -861,7 +833,6 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg,
return
0
;
return
0
;
/* Optionally capture errored message object(s) */
/* Optionally capture errored message object(s) */
err
=
msg
?
msg_errcode
(
msg
)
:
0
;
err
=
msg
?
msg_errcode
(
msg
)
:
0
;
if
(
unlikely
(
err
))
{
if
(
unlikely
(
err
))
{
anc_data
[
0
]
=
err
;
anc_data
[
0
]
=
err
;
...
@@ -878,7 +849,6 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg,
...
@@ -878,7 +849,6 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg,
}
}
/* Optionally capture message destination object */
/* Optionally capture message destination object */
dest_type
=
msg
?
msg_type
(
msg
)
:
TIPC_DIRECT_MSG
;
dest_type
=
msg
?
msg_type
(
msg
)
:
TIPC_DIRECT_MSG
;
switch
(
dest_type
)
{
switch
(
dest_type
)
{
case
TIPC_NAMED_MSG
:
case
TIPC_NAMED_MSG
:
...
@@ -923,7 +893,6 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg,
...
@@ -923,7 +893,6 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg,
*
*
* Returns size of returned message data, errno otherwise
* Returns size of returned message data, errno otherwise
*/
*/
static
int
recv_msg
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
static
int
recv_msg
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
struct
msghdr
*
m
,
size_t
buf_len
,
int
flags
)
struct
msghdr
*
m
,
size_t
buf_len
,
int
flags
)
{
{
...
@@ -937,7 +906,6 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
...
@@ -937,7 +906,6 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
int
res
;
int
res
;
/* Catch invalid receive requests */
/* Catch invalid receive requests */
if
(
unlikely
(
!
buf_len
))
if
(
unlikely
(
!
buf_len
))
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -952,7 +920,6 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
...
@@ -952,7 +920,6 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
restart:
restart:
/* Look for a message in receive queue; wait if necessary */
/* Look for a message in receive queue; wait if necessary */
while
(
skb_queue_empty
(
&
sk
->
sk_receive_queue
))
{
while
(
skb_queue_empty
(
&
sk
->
sk_receive_queue
))
{
if
(
sock
->
state
==
SS_DISCONNECTING
)
{
if
(
sock
->
state
==
SS_DISCONNECTING
)
{
res
=
-
ENOTCONN
;
res
=
-
ENOTCONN
;
...
@@ -970,14 +937,12 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
...
@@ -970,14 +937,12 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
}
}
/* Look at first message in receive queue */
/* Look at first message in receive queue */
buf
=
skb_peek
(
&
sk
->
sk_receive_queue
);
buf
=
skb_peek
(
&
sk
->
sk_receive_queue
);
msg
=
buf_msg
(
buf
);
msg
=
buf_msg
(
buf
);
sz
=
msg_data_sz
(
msg
);
sz
=
msg_data_sz
(
msg
);
err
=
msg_errcode
(
msg
);
err
=
msg_errcode
(
msg
);
/* Complete connection setup for an implied connect */
/* Complete connection setup for an implied connect */
if
(
unlikely
(
sock
->
state
==
SS_CONNECTING
))
{
if
(
unlikely
(
sock
->
state
==
SS_CONNECTING
))
{
res
=
auto_connect
(
sock
,
msg
);
res
=
auto_connect
(
sock
,
msg
);
if
(
res
)
if
(
res
)
...
@@ -985,24 +950,20 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
...
@@ -985,24 +950,20 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
}
}
/* Discard an empty non-errored message & try again */
/* Discard an empty non-errored message & try again */
if
((
!
sz
)
&&
(
!
err
))
{
if
((
!
sz
)
&&
(
!
err
))
{
advance_rx_queue
(
sk
);
advance_rx_queue
(
sk
);
goto
restart
;
goto
restart
;
}
}
/* Capture sender's address (optional) */
/* Capture sender's address (optional) */
set_orig_addr
(
m
,
msg
);
set_orig_addr
(
m
,
msg
);
/* Capture ancillary data (optional) */
/* Capture ancillary data (optional) */
res
=
anc_data_recv
(
m
,
msg
,
tport
);
res
=
anc_data_recv
(
m
,
msg
,
tport
);
if
(
res
)
if
(
res
)
goto
exit
;
goto
exit
;
/* Capture message data (if valid) & compute return value (always) */
/* Capture message data (if valid) & compute return value (always) */
if
(
!
err
)
{
if
(
!
err
)
{
if
(
unlikely
(
buf_len
<
sz
))
{
if
(
unlikely
(
buf_len
<
sz
))
{
sz
=
buf_len
;
sz
=
buf_len
;
...
@@ -1022,7 +983,6 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
...
@@ -1022,7 +983,6 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
}
}
/* Consume received message (optional) */
/* Consume received message (optional) */
if
(
likely
(
!
(
flags
&
MSG_PEEK
)))
{
if
(
likely
(
!
(
flags
&
MSG_PEEK
)))
{
if
((
sock
->
state
!=
SS_READY
)
&&
if
((
sock
->
state
!=
SS_READY
)
&&
(
++
tport
->
conn_unacked
>=
TIPC_FLOW_CONTROL_WIN
))
(
++
tport
->
conn_unacked
>=
TIPC_FLOW_CONTROL_WIN
))
...
@@ -1046,7 +1006,6 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
...
@@ -1046,7 +1006,6 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
*
*
* Returns size of returned message data, errno otherwise
* Returns size of returned message data, errno otherwise
*/
*/
static
int
recv_stream
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
static
int
recv_stream
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
struct
msghdr
*
m
,
size_t
buf_len
,
int
flags
)
struct
msghdr
*
m
,
size_t
buf_len
,
int
flags
)
{
{
...
@@ -1062,7 +1021,6 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
...
@@ -1062,7 +1021,6 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
int
res
=
0
;
int
res
=
0
;
/* Catch invalid receive attempts */
/* Catch invalid receive attempts */
if
(
unlikely
(
!
buf_len
))
if
(
unlikely
(
!
buf_len
))
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -1076,10 +1034,9 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
...
@@ -1076,10 +1034,9 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
target
=
sock_rcvlowat
(
sk
,
flags
&
MSG_WAITALL
,
buf_len
);
target
=
sock_rcvlowat
(
sk
,
flags
&
MSG_WAITALL
,
buf_len
);
timeout
=
sock_rcvtimeo
(
sk
,
flags
&
MSG_DONTWAIT
);
timeout
=
sock_rcvtimeo
(
sk
,
flags
&
MSG_DONTWAIT
);
restart:
restart:
/* Look for a message in receive queue; wait if necessary */
/* Look for a message in receive queue; wait if necessary */
while
(
skb_queue_empty
(
&
sk
->
sk_receive_queue
))
{
while
(
skb_queue_empty
(
&
sk
->
sk_receive_queue
))
{
if
(
sock
->
state
==
SS_DISCONNECTING
)
{
if
(
sock
->
state
==
SS_DISCONNECTING
)
{
res
=
-
ENOTCONN
;
res
=
-
ENOTCONN
;
...
@@ -1097,21 +1054,18 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
...
@@ -1097,21 +1054,18 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
}
}
/* Look at first message in receive queue */
/* Look at first message in receive queue */
buf
=
skb_peek
(
&
sk
->
sk_receive_queue
);
buf
=
skb_peek
(
&
sk
->
sk_receive_queue
);
msg
=
buf_msg
(
buf
);
msg
=
buf_msg
(
buf
);
sz
=
msg_data_sz
(
msg
);
sz
=
msg_data_sz
(
msg
);
err
=
msg_errcode
(
msg
);
err
=
msg_errcode
(
msg
);
/* Discard an empty non-errored message & try again */
/* Discard an empty non-errored message & try again */
if
((
!
sz
)
&&
(
!
err
))
{
if
((
!
sz
)
&&
(
!
err
))
{
advance_rx_queue
(
sk
);
advance_rx_queue
(
sk
);
goto
restart
;
goto
restart
;
}
}
/* Optionally capture sender's address & ancillary data of first msg */
/* Optionally capture sender's address & ancillary data of first msg */
if
(
sz_copied
==
0
)
{
if
(
sz_copied
==
0
)
{
set_orig_addr
(
m
,
msg
);
set_orig_addr
(
m
,
msg
);
res
=
anc_data_recv
(
m
,
msg
,
tport
);
res
=
anc_data_recv
(
m
,
msg
,
tport
);
...
@@ -1120,7 +1074,6 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
...
@@ -1120,7 +1074,6 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
}
}
/* Capture message data (if valid) & compute return value (always) */
/* Capture message data (if valid) & compute return value (always) */
if
(
!
err
)
{
if
(
!
err
)
{
u32
offset
=
(
u32
)(
unsigned
long
)(
TIPC_SKB_CB
(
buf
)
->
handle
);
u32
offset
=
(
u32
)(
unsigned
long
)(
TIPC_SKB_CB
(
buf
)
->
handle
);
...
@@ -1152,7 +1105,6 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
...
@@ -1152,7 +1105,6 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
}
}
/* Consume received message (optional) */
/* Consume received message (optional) */
if
(
likely
(
!
(
flags
&
MSG_PEEK
)))
{
if
(
likely
(
!
(
flags
&
MSG_PEEK
)))
{
if
(
unlikely
(
++
tport
->
conn_unacked
>=
TIPC_FLOW_CONTROL_WIN
))
if
(
unlikely
(
++
tport
->
conn_unacked
>=
TIPC_FLOW_CONTROL_WIN
))
tipc_acknowledge
(
tport
->
ref
,
tport
->
conn_unacked
);
tipc_acknowledge
(
tport
->
ref
,
tport
->
conn_unacked
);
...
@@ -1160,7 +1112,6 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
...
@@ -1160,7 +1112,6 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
}
}
/* Loop around if more data is required */
/* Loop around if more data is required */
if
((
sz_copied
<
buf_len
)
&&
/* didn't get all requested data */
if
((
sz_copied
<
buf_len
)
&&
/* didn't get all requested data */
(
!
skb_queue_empty
(
&
sk
->
sk_receive_queue
)
||
(
!
skb_queue_empty
(
&
sk
->
sk_receive_queue
)
||
(
sz_copied
<
target
))
&&
/* and more is ready or required */
(
sz_copied
<
target
))
&&
/* and more is ready or required */
...
@@ -1181,7 +1132,6 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
...
@@ -1181,7 +1132,6 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
*
*
* Returns 1 if queue is unable to accept message, 0 otherwise
* Returns 1 if queue is unable to accept message, 0 otherwise
*/
*/
static
int
rx_queue_full
(
struct
tipc_msg
*
msg
,
u32
queue_size
,
u32
base
)
static
int
rx_queue_full
(
struct
tipc_msg
*
msg
,
u32
queue_size
,
u32
base
)
{
{
u32
threshold
;
u32
threshold
;
...
@@ -1214,7 +1164,6 @@ static int rx_queue_full(struct tipc_msg *msg, u32 queue_size, u32 base)
...
@@ -1214,7 +1164,6 @@ static int rx_queue_full(struct tipc_msg *msg, u32 queue_size, u32 base)
*
*
* Returns TIPC error status code (TIPC_OK if message is not to be rejected)
* Returns TIPC error status code (TIPC_OK if message is not to be rejected)
*/
*/
static
u32
filter_rcv
(
struct
sock
*
sk
,
struct
sk_buff
*
buf
)
static
u32
filter_rcv
(
struct
sock
*
sk
,
struct
sk_buff
*
buf
)
{
{
struct
socket
*
sock
=
sk
->
sk_socket
;
struct
socket
*
sock
=
sk
->
sk_socket
;
...
@@ -1222,12 +1171,8 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf)
...
@@ -1222,12 +1171,8 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf)
u32
recv_q_len
;
u32
recv_q_len
;
/* Reject message if it is wrong sort of message for socket */
/* Reject message if it is wrong sort of message for socket */
if
(
msg_type
(
msg
)
>
TIPC_DIRECT_MSG
)
/*
return
TIPC_ERR_NO_PORT
;
* WOULD IT BE BETTER TO JUST DISCARD THESE MESSAGES INSTEAD?
* "NO PORT" ISN'T REALLY THE RIGHT ERROR CODE, AND THERE MAY
* BE SECURITY IMPLICATIONS INHERENT IN REJECTING INVALID TRAFFIC
*/
if
(
sock
->
state
==
SS_READY
)
{
if
(
sock
->
state
==
SS_READY
)
{
if
(
msg_connected
(
msg
))
if
(
msg_connected
(
msg
))
...
@@ -1254,7 +1199,6 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf)
...
@@ -1254,7 +1199,6 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf)
}
}
/* Reject message if there isn't room to queue it */
/* Reject message if there isn't room to queue it */
recv_q_len
=
(
u32
)
atomic_read
(
&
tipc_queue_size
);
recv_q_len
=
(
u32
)
atomic_read
(
&
tipc_queue_size
);
if
(
unlikely
(
recv_q_len
>=
OVERLOAD_LIMIT_BASE
))
{
if
(
unlikely
(
recv_q_len
>=
OVERLOAD_LIMIT_BASE
))
{
if
(
rx_queue_full
(
msg
,
recv_q_len
,
OVERLOAD_LIMIT_BASE
))
if
(
rx_queue_full
(
msg
,
recv_q_len
,
OVERLOAD_LIMIT_BASE
))
...
@@ -1267,13 +1211,11 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf)
...
@@ -1267,13 +1211,11 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf)
}
}
/* Enqueue message (finally!) */
/* Enqueue message (finally!) */
TIPC_SKB_CB
(
buf
)
->
handle
=
0
;
TIPC_SKB_CB
(
buf
)
->
handle
=
0
;
atomic_inc
(
&
tipc_queue_size
);
atomic_inc
(
&
tipc_queue_size
);
__skb_queue_tail
(
&
sk
->
sk_receive_queue
,
buf
);
__skb_queue_tail
(
&
sk
->
sk_receive_queue
,
buf
);
/* Initiate connection termination for an incoming 'FIN' */
/* Initiate connection termination for an incoming 'FIN' */
if
(
unlikely
(
msg_errcode
(
msg
)
&&
(
sock
->
state
==
SS_CONNECTED
)))
{
if
(
unlikely
(
msg_errcode
(
msg
)
&&
(
sock
->
state
==
SS_CONNECTED
)))
{
sock
->
state
=
SS_DISCONNECTING
;
sock
->
state
=
SS_DISCONNECTING
;
tipc_disconnect_port
(
tipc_sk_port
(
sk
));
tipc_disconnect_port
(
tipc_sk_port
(
sk
));
...
@@ -1293,7 +1235,6 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf)
...
@@ -1293,7 +1235,6 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf)
*
*
* Returns 0
* Returns 0
*/
*/
static
int
backlog_rcv
(
struct
sock
*
sk
,
struct
sk_buff
*
buf
)
static
int
backlog_rcv
(
struct
sock
*
sk
,
struct
sk_buff
*
buf
)
{
{
u32
res
;
u32
res
;
...
@@ -1313,7 +1254,6 @@ static int backlog_rcv(struct sock *sk, struct sk_buff *buf)
...
@@ -1313,7 +1254,6 @@ static int backlog_rcv(struct sock *sk, struct sk_buff *buf)
*
*
* Returns TIPC error status code (TIPC_OK if message is not to be rejected)
* Returns TIPC error status code (TIPC_OK if message is not to be rejected)
*/
*/
static
u32
dispatch
(
struct
tipc_port
*
tport
,
struct
sk_buff
*
buf
)
static
u32
dispatch
(
struct
tipc_port
*
tport
,
struct
sk_buff
*
buf
)
{
{
struct
sock
*
sk
=
(
struct
sock
*
)
tport
->
usr_handle
;
struct
sock
*
sk
=
(
struct
sock
*
)
tport
->
usr_handle
;
...
@@ -1325,7 +1265,6 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
...
@@ -1325,7 +1265,6 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
* This code is based on sk_receive_skb(), but must be distinct from it
* This code is based on sk_receive_skb(), but must be distinct from it
* since a TIPC-specific filter/reject mechanism is utilized
* since a TIPC-specific filter/reject mechanism is utilized
*/
*/
bh_lock_sock
(
sk
);
bh_lock_sock
(
sk
);
if
(
!
sock_owned_by_user
(
sk
))
{
if
(
!
sock_owned_by_user
(
sk
))
{
res
=
filter_rcv
(
sk
,
buf
);
res
=
filter_rcv
(
sk
,
buf
);
...
@@ -1346,7 +1285,6 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
...
@@ -1346,7 +1285,6 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
*
*
* Called with port lock already taken.
* Called with port lock already taken.
*/
*/
static
void
wakeupdispatch
(
struct
tipc_port
*
tport
)
static
void
wakeupdispatch
(
struct
tipc_port
*
tport
)
{
{
struct
sock
*
sk
=
(
struct
sock
*
)
tport
->
usr_handle
;
struct
sock
*
sk
=
(
struct
sock
*
)
tport
->
usr_handle
;
...
@@ -1364,7 +1302,6 @@ static void wakeupdispatch(struct tipc_port *tport)
...
@@ -1364,7 +1302,6 @@ static void wakeupdispatch(struct tipc_port *tport)
*
*
* Returns 0 on success, errno otherwise
* Returns 0 on success, errno otherwise
*/
*/
static
int
connect
(
struct
socket
*
sock
,
struct
sockaddr
*
dest
,
int
destlen
,
static
int
connect
(
struct
socket
*
sock
,
struct
sockaddr
*
dest
,
int
destlen
,
int
flags
)
int
flags
)
{
{
...
@@ -1379,21 +1316,18 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
...
@@ -1379,21 +1316,18 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
lock_sock
(
sk
);
lock_sock
(
sk
);
/* For now, TIPC does not allow use of connect() with DGRAM/RDM types */
/* For now, TIPC does not allow use of connect() with DGRAM/RDM types */
if
(
sock
->
state
==
SS_READY
)
{
if
(
sock
->
state
==
SS_READY
)
{
res
=
-
EOPNOTSUPP
;
res
=
-
EOPNOTSUPP
;
goto
exit
;
goto
exit
;
}
}
/* For now, TIPC does not support the non-blocking form of connect() */
/* For now, TIPC does not support the non-blocking form of connect() */
if
(
flags
&
O_NONBLOCK
)
{
if
(
flags
&
O_NONBLOCK
)
{
res
=
-
EOPNOTSUPP
;
res
=
-
EOPNOTSUPP
;
goto
exit
;
goto
exit
;
}
}
/* Issue Posix-compliant error code if socket is in the wrong state */
/* Issue Posix-compliant error code if socket is in the wrong state */
if
(
sock
->
state
==
SS_LISTENING
)
{
if
(
sock
->
state
==
SS_LISTENING
)
{
res
=
-
EOPNOTSUPP
;
res
=
-
EOPNOTSUPP
;
goto
exit
;
goto
exit
;
...
@@ -1413,18 +1347,15 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
...
@@ -1413,18 +1347,15 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
* Note: send_msg() validates the rest of the address fields,
* Note: send_msg() validates the rest of the address fields,
* so there's no need to do it here
* so there's no need to do it here
*/
*/
if
(
dst
->
addrtype
==
TIPC_ADDR_MCAST
)
{
if
(
dst
->
addrtype
==
TIPC_ADDR_MCAST
)
{
res
=
-
EINVAL
;
res
=
-
EINVAL
;
goto
exit
;
goto
exit
;
}
}
/* Reject any messages already in receive queue (very unlikely) */
/* Reject any messages already in receive queue (very unlikely) */
reject_rx_queue
(
sk
);
reject_rx_queue
(
sk
);
/* Send a 'SYN-' to destination */
/* Send a 'SYN-' to destination */
m
.
msg_name
=
dest
;
m
.
msg_name
=
dest
;
m
.
msg_namelen
=
destlen
;
m
.
msg_namelen
=
destlen
;
res
=
send_msg
(
NULL
,
sock
,
&
m
,
0
);
res
=
send_msg
(
NULL
,
sock
,
&
m
,
0
);
...
@@ -1432,7 +1363,6 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
...
@@ -1432,7 +1363,6 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
goto
exit
;
goto
exit
;
/* Wait until an 'ACK' or 'RST' arrives, or a timeout occurs */
/* Wait until an 'ACK' or 'RST' arrives, or a timeout occurs */
timeout
=
tipc_sk
(
sk
)
->
conn_timeout
;
timeout
=
tipc_sk
(
sk
)
->
conn_timeout
;
release_sock
(
sk
);
release_sock
(
sk
);
res
=
wait_event_interruptible_timeout
(
*
sk_sleep
(
sk
),
res
=
wait_event_interruptible_timeout
(
*
sk_sleep
(
sk
),
...
@@ -1477,7 +1407,6 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
...
@@ -1477,7 +1407,6 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
*
*
* Returns 0 on success, errno otherwise
* Returns 0 on success, errno otherwise
*/
*/
static
int
listen
(
struct
socket
*
sock
,
int
len
)
static
int
listen
(
struct
socket
*
sock
,
int
len
)
{
{
struct
sock
*
sk
=
sock
->
sk
;
struct
sock
*
sk
=
sock
->
sk
;
...
@@ -1504,7 +1433,6 @@ static int listen(struct socket *sock, int len)
...
@@ -1504,7 +1433,6 @@ static int listen(struct socket *sock, int len)
*
*
* Returns 0 on success, errno otherwise
* Returns 0 on success, errno otherwise
*/
*/
static
int
accept
(
struct
socket
*
sock
,
struct
socket
*
new_sock
,
int
flags
)
static
int
accept
(
struct
socket
*
sock
,
struct
socket
*
new_sock
,
int
flags
)
{
{
struct
sock
*
sk
=
sock
->
sk
;
struct
sock
*
sk
=
sock
->
sk
;
...
@@ -1547,11 +1475,9 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags)
...
@@ -1547,11 +1475,9 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags)
* Reject any stray messages received by new socket
* Reject any stray messages received by new socket
* before the socket lock was taken (very, very unlikely)
* before the socket lock was taken (very, very unlikely)
*/
*/
reject_rx_queue
(
new_sk
);
reject_rx_queue
(
new_sk
);
/* Connect new socket to it's peer */
/* Connect new socket to it's peer */
new_tsock
->
peer_name
.
ref
=
msg_origport
(
msg
);
new_tsock
->
peer_name
.
ref
=
msg_origport
(
msg
);
new_tsock
->
peer_name
.
node
=
msg_orignode
(
msg
);
new_tsock
->
peer_name
.
node
=
msg_orignode
(
msg
);
tipc_connect2port
(
new_ref
,
&
new_tsock
->
peer_name
);
tipc_connect2port
(
new_ref
,
&
new_tsock
->
peer_name
);
...
@@ -1567,7 +1493,6 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags)
...
@@ -1567,7 +1493,6 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags)
* Respond to 'SYN-' by discarding it & returning 'ACK'-.
* Respond to 'SYN-' by discarding it & returning 'ACK'-.
* Respond to 'SYN+' by queuing it on new socket.
* Respond to 'SYN+' by queuing it on new socket.
*/
*/
if
(
!
msg_data_sz
(
msg
))
{
if
(
!
msg_data_sz
(
msg
))
{
struct
msghdr
m
=
{
NULL
,};
struct
msghdr
m
=
{
NULL
,};
...
@@ -1593,7 +1518,6 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags)
...
@@ -1593,7 +1518,6 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags)
*
*
* Returns 0 on success, errno otherwise
* Returns 0 on success, errno otherwise
*/
*/
static
int
shutdown
(
struct
socket
*
sock
,
int
how
)
static
int
shutdown
(
struct
socket
*
sock
,
int
how
)
{
{
struct
sock
*
sk
=
sock
->
sk
;
struct
sock
*
sk
=
sock
->
sk
;
...
@@ -1610,8 +1534,8 @@ static int shutdown(struct socket *sock, int how)
...
@@ -1610,8 +1534,8 @@ static int shutdown(struct socket *sock, int how)
case
SS_CONNECTING
:
case
SS_CONNECTING
:
case
SS_CONNECTED
:
case
SS_CONNECTED
:
/* Disconnect and send a 'FIN+' or 'FIN-' message to peer */
restart:
restart:
/* Disconnect and send a 'FIN+' or 'FIN-' message to peer */
buf
=
__skb_dequeue
(
&
sk
->
sk_receive_queue
);
buf
=
__skb_dequeue
(
&
sk
->
sk_receive_queue
);
if
(
buf
)
{
if
(
buf
)
{
atomic_dec
(
&
tipc_queue_size
);
atomic_dec
(
&
tipc_queue_size
);
...
@@ -1632,7 +1556,6 @@ static int shutdown(struct socket *sock, int how)
...
@@ -1632,7 +1556,6 @@ static int shutdown(struct socket *sock, int how)
case
SS_DISCONNECTING
:
case
SS_DISCONNECTING
:
/* Discard any unreceived messages; wake up sleeping tasks */
/* Discard any unreceived messages; wake up sleeping tasks */
discard_rx_queue
(
sk
);
discard_rx_queue
(
sk
);
if
(
waitqueue_active
(
sk_sleep
(
sk
)))
if
(
waitqueue_active
(
sk_sleep
(
sk
)))
wake_up_interruptible
(
sk_sleep
(
sk
));
wake_up_interruptible
(
sk_sleep
(
sk
));
...
@@ -1660,7 +1583,6 @@ static int shutdown(struct socket *sock, int how)
...
@@ -1660,7 +1583,6 @@ static int shutdown(struct socket *sock, int how)
*
*
* Returns 0 on success, errno otherwise
* Returns 0 on success, errno otherwise
*/
*/
static
int
setsockopt
(
struct
socket
*
sock
,
static
int
setsockopt
(
struct
socket
*
sock
,
int
lvl
,
int
opt
,
char
__user
*
ov
,
unsigned
int
ol
)
int
lvl
,
int
opt
,
char
__user
*
ov
,
unsigned
int
ol
)
{
{
...
@@ -1720,7 +1642,6 @@ static int setsockopt(struct socket *sock,
...
@@ -1720,7 +1642,6 @@ static int setsockopt(struct socket *sock,
*
*
* Returns 0 on success, errno otherwise
* Returns 0 on success, errno otherwise
*/
*/
static
int
getsockopt
(
struct
socket
*
sock
,
static
int
getsockopt
(
struct
socket
*
sock
,
int
lvl
,
int
opt
,
char
__user
*
ov
,
int
__user
*
ol
)
int
lvl
,
int
opt
,
char
__user
*
ov
,
int
__user
*
ol
)
{
{
...
@@ -1781,7 +1702,6 @@ static int getsockopt(struct socket *sock,
...
@@ -1781,7 +1702,6 @@ static int getsockopt(struct socket *sock,
/**
/**
* Protocol switches for the various types of TIPC sockets
* Protocol switches for the various types of TIPC sockets
*/
*/
static
const
struct
proto_ops
msg_ops
=
{
static
const
struct
proto_ops
msg_ops
=
{
.
owner
=
THIS_MODULE
,
.
owner
=
THIS_MODULE
,
.
family
=
AF_TIPC
,
.
family
=
AF_TIPC
,
...
@@ -1887,7 +1807,6 @@ int tipc_socket_init(void)
...
@@ -1887,7 +1807,6 @@ int tipc_socket_init(void)
/**
/**
* tipc_socket_stop - stop TIPC socket interface
* tipc_socket_stop - stop TIPC socket interface
*/
*/
void
tipc_socket_stop
(
void
)
void
tipc_socket_stop
(
void
)
{
{
if
(
!
sockets_enabled
)
if
(
!
sockets_enabled
)
...
@@ -1897,4 +1816,3 @@ void tipc_socket_stop(void)
...
@@ -1897,4 +1816,3 @@ void tipc_socket_stop(void)
sock_unregister
(
tipc_family_ops
.
family
);
sock_unregister
(
tipc_family_ops
.
family
);
proto_unregister
(
&
tipc_proto
);
proto_unregister
(
&
tipc_proto
);
}
}
net/tipc/subscr.c
浏览文件 @
b6d151bb
...
@@ -46,7 +46,6 @@
...
@@ -46,7 +46,6 @@
* @subscriber_list: adjacent subscribers in top. server's list of subscribers
* @subscriber_list: adjacent subscribers in top. server's list of subscribers
* @subscription_list: list of subscription objects for this subscriber
* @subscription_list: list of subscription objects for this subscriber
*/
*/
struct
tipc_subscriber
{
struct
tipc_subscriber
{
u32
port_ref
;
u32
port_ref
;
spinlock_t
*
lock
;
spinlock_t
*
lock
;
...
@@ -56,13 +55,11 @@ struct tipc_subscriber {
...
@@ -56,13 +55,11 @@ struct tipc_subscriber {
/**
/**
* struct top_srv - TIPC network topology subscription service
* struct top_srv - TIPC network topology subscription service
* @user_ref: TIPC userid of subscription service
* @setup_port: reference to TIPC port that handles subscription requests
* @setup_port: reference to TIPC port that handles subscription requests
* @subscription_count: number of active subscriptions (not subscribers!)
* @subscription_count: number of active subscriptions (not subscribers!)
* @subscriber_list: list of ports subscribing to service
* @subscriber_list: list of ports subscribing to service
* @lock: spinlock govering access to subscriber list
* @lock: spinlock govering access to subscriber list
*/
*/
struct
top_srv
{
struct
top_srv
{
u32
setup_port
;
u32
setup_port
;
atomic_t
subscription_count
;
atomic_t
subscription_count
;
...
@@ -79,7 +76,6 @@ static struct top_srv topsrv;
...
@@ -79,7 +76,6 @@ static struct top_srv topsrv;
*
*
* Returns converted value
* Returns converted value
*/
*/
static
u32
htohl
(
u32
in
,
int
swap
)
static
u32
htohl
(
u32
in
,
int
swap
)
{
{
return
swap
?
swab32
(
in
)
:
in
;
return
swap
?
swab32
(
in
)
:
in
;
...
@@ -91,7 +87,6 @@ static u32 htohl(u32 in, int swap)
...
@@ -91,7 +87,6 @@ static u32 htohl(u32 in, int swap)
* Note: Must not hold subscriber's server port lock, since tipc_send() will
* Note: Must not hold subscriber's server port lock, since tipc_send() will
* try to take the lock if the message is rejected and returned!
* try to take the lock if the message is rejected and returned!
*/
*/
static
void
subscr_send_event
(
struct
tipc_subscription
*
sub
,
static
void
subscr_send_event
(
struct
tipc_subscription
*
sub
,
u32
found_lower
,
u32
found_lower
,
u32
found_upper
,
u32
found_upper
,
...
@@ -117,7 +112,6 @@ static void subscr_send_event(struct tipc_subscription *sub,
...
@@ -117,7 +112,6 @@ static void subscr_send_event(struct tipc_subscription *sub,
*
*
* Returns 1 if there is overlap, otherwise 0.
* Returns 1 if there is overlap, otherwise 0.
*/
*/
int
tipc_subscr_overlap
(
struct
tipc_subscription
*
sub
,
int
tipc_subscr_overlap
(
struct
tipc_subscription
*
sub
,
u32
found_lower
,
u32
found_lower
,
u32
found_upper
)
u32
found_upper
)
...
@@ -137,7 +131,6 @@ int tipc_subscr_overlap(struct tipc_subscription *sub,
...
@@ -137,7 +131,6 @@ int tipc_subscr_overlap(struct tipc_subscription *sub,
*
*
* Protected by nameseq.lock in name_table.c
* Protected by nameseq.lock in name_table.c
*/
*/
void
tipc_subscr_report_overlap
(
struct
tipc_subscription
*
sub
,
void
tipc_subscr_report_overlap
(
struct
tipc_subscription
*
sub
,
u32
found_lower
,
u32
found_lower
,
u32
found_upper
,
u32
found_upper
,
...
@@ -157,43 +150,35 @@ void tipc_subscr_report_overlap(struct tipc_subscription *sub,
...
@@ -157,43 +150,35 @@ void tipc_subscr_report_overlap(struct tipc_subscription *sub,
/**
/**
* subscr_timeout - subscription timeout has occurred
* subscr_timeout - subscription timeout has occurred
*/
*/
static
void
subscr_timeout
(
struct
tipc_subscription
*
sub
)
static
void
subscr_timeout
(
struct
tipc_subscription
*
sub
)
{
{
struct
tipc_port
*
server_port
;
struct
tipc_port
*
server_port
;
/* Validate server port reference (in case subscriber is terminating) */
/* Validate server port reference (in case subscriber is terminating) */
server_port
=
tipc_port_lock
(
sub
->
server_ref
);
server_port
=
tipc_port_lock
(
sub
->
server_ref
);
if
(
server_port
==
NULL
)
if
(
server_port
==
NULL
)
return
;
return
;
/* Validate timeout (in case subscription is being cancelled) */
/* Validate timeout (in case subscription is being cancelled) */
if
(
sub
->
timeout
==
TIPC_WAIT_FOREVER
)
{
if
(
sub
->
timeout
==
TIPC_WAIT_FOREVER
)
{
tipc_port_unlock
(
server_port
);
tipc_port_unlock
(
server_port
);
return
;
return
;
}
}
/* Unlink subscription from name table */
/* Unlink subscription from name table */
tipc_nametbl_unsubscribe
(
sub
);
tipc_nametbl_unsubscribe
(
sub
);
/* Unlink subscription from subscriber */
/* Unlink subscription from subscriber */
list_del
(
&
sub
->
subscription_list
);
list_del
(
&
sub
->
subscription_list
);
/* Release subscriber's server port */
/* Release subscriber's server port */
tipc_port_unlock
(
server_port
);
tipc_port_unlock
(
server_port
);
/* Notify subscriber of timeout */
/* Notify subscriber of timeout */
subscr_send_event
(
sub
,
sub
->
evt
.
s
.
seq
.
lower
,
sub
->
evt
.
s
.
seq
.
upper
,
subscr_send_event
(
sub
,
sub
->
evt
.
s
.
seq
.
lower
,
sub
->
evt
.
s
.
seq
.
upper
,
TIPC_SUBSCR_TIMEOUT
,
0
,
0
);
TIPC_SUBSCR_TIMEOUT
,
0
,
0
);
/* Now destroy subscription */
/* Now destroy subscription */
k_term_timer
(
&
sub
->
timer
);
k_term_timer
(
&
sub
->
timer
);
kfree
(
sub
);
kfree
(
sub
);
atomic_dec
(
&
topsrv
.
subscription_count
);
atomic_dec
(
&
topsrv
.
subscription_count
);
...
@@ -204,7 +189,6 @@ static void subscr_timeout(struct tipc_subscription *sub)
...
@@ -204,7 +189,6 @@ static void subscr_timeout(struct tipc_subscription *sub)
*
*
* Called with subscriber port locked.
* Called with subscriber port locked.
*/
*/
static
void
subscr_del
(
struct
tipc_subscription
*
sub
)
static
void
subscr_del
(
struct
tipc_subscription
*
sub
)
{
{
tipc_nametbl_unsubscribe
(
sub
);
tipc_nametbl_unsubscribe
(
sub
);
...
@@ -223,7 +207,6 @@ static void subscr_del(struct tipc_subscription *sub)
...
@@ -223,7 +207,6 @@ static void subscr_del(struct tipc_subscription *sub)
* a new object reference in the interim that uses this lock; this routine will
* a new object reference in the interim that uses this lock; this routine will
* simply wait for it to be released, then claim it.)
* simply wait for it to be released, then claim it.)
*/
*/
static
void
subscr_terminate
(
struct
tipc_subscriber
*
subscriber
)
static
void
subscr_terminate
(
struct
tipc_subscriber
*
subscriber
)
{
{
u32
port_ref
;
u32
port_ref
;
...
@@ -231,18 +214,15 @@ static void subscr_terminate(struct tipc_subscriber *subscriber)
...
@@ -231,18 +214,15 @@ static void subscr_terminate(struct tipc_subscriber *subscriber)
struct
tipc_subscription
*
sub_temp
;
struct
tipc_subscription
*
sub_temp
;
/* Invalidate subscriber reference */
/* Invalidate subscriber reference */
port_ref
=
subscriber
->
port_ref
;
port_ref
=
subscriber
->
port_ref
;
subscriber
->
port_ref
=
0
;
subscriber
->
port_ref
=
0
;
spin_unlock_bh
(
subscriber
->
lock
);
spin_unlock_bh
(
subscriber
->
lock
);
/* Sever connection to subscriber */
/* Sever connection to subscriber */
tipc_shutdown
(
port_ref
);
tipc_shutdown
(
port_ref
);
tipc_deleteport
(
port_ref
);
tipc_deleteport
(
port_ref
);
/* Destroy any existing subscriptions for subscriber */
/* Destroy any existing subscriptions for subscriber */
list_for_each_entry_safe
(
sub
,
sub_temp
,
&
subscriber
->
subscription_list
,
list_for_each_entry_safe
(
sub
,
sub_temp
,
&
subscriber
->
subscription_list
,
subscription_list
)
{
subscription_list
)
{
if
(
sub
->
timeout
!=
TIPC_WAIT_FOREVER
)
{
if
(
sub
->
timeout
!=
TIPC_WAIT_FOREVER
)
{
...
@@ -253,17 +233,14 @@ static void subscr_terminate(struct tipc_subscriber *subscriber)
...
@@ -253,17 +233,14 @@ static void subscr_terminate(struct tipc_subscriber *subscriber)
}
}
/* Remove subscriber from topology server's subscriber list */
/* Remove subscriber from topology server's subscriber list */
spin_lock_bh
(
&
topsrv
.
lock
);
spin_lock_bh
(
&
topsrv
.
lock
);
list_del
(
&
subscriber
->
subscriber_list
);
list_del
(
&
subscriber
->
subscriber_list
);
spin_unlock_bh
(
&
topsrv
.
lock
);
spin_unlock_bh
(
&
topsrv
.
lock
);
/* Reclaim subscriber lock */
/* Reclaim subscriber lock */
spin_lock_bh
(
subscriber
->
lock
);
spin_lock_bh
(
subscriber
->
lock
);
/* Now destroy subscriber */
/* Now destroy subscriber */
kfree
(
subscriber
);
kfree
(
subscriber
);
}
}
...
@@ -276,7 +253,6 @@ static void subscr_terminate(struct tipc_subscriber *subscriber)
...
@@ -276,7 +253,6 @@ static void subscr_terminate(struct tipc_subscriber *subscriber)
*
*
* Note that fields of 's' use subscriber's endianness!
* Note that fields of 's' use subscriber's endianness!
*/
*/
static
void
subscr_cancel
(
struct
tipc_subscr
*
s
,
static
void
subscr_cancel
(
struct
tipc_subscr
*
s
,
struct
tipc_subscriber
*
subscriber
)
struct
tipc_subscriber
*
subscriber
)
{
{
...
@@ -285,7 +261,6 @@ static void subscr_cancel(struct tipc_subscr *s,
...
@@ -285,7 +261,6 @@ static void subscr_cancel(struct tipc_subscr *s,
int
found
=
0
;
int
found
=
0
;
/* Find first matching subscription, exit if not found */
/* Find first matching subscription, exit if not found */
list_for_each_entry_safe
(
sub
,
sub_temp
,
&
subscriber
->
subscription_list
,
list_for_each_entry_safe
(
sub
,
sub_temp
,
&
subscriber
->
subscription_list
,
subscription_list
)
{
subscription_list
)
{
if
(
!
memcmp
(
s
,
&
sub
->
evt
.
s
,
sizeof
(
struct
tipc_subscr
)))
{
if
(
!
memcmp
(
s
,
&
sub
->
evt
.
s
,
sizeof
(
struct
tipc_subscr
)))
{
...
@@ -297,7 +272,6 @@ static void subscr_cancel(struct tipc_subscr *s,
...
@@ -297,7 +272,6 @@ static void subscr_cancel(struct tipc_subscr *s,
return
;
return
;
/* Cancel subscription timer (if used), then delete subscription */
/* Cancel subscription timer (if used), then delete subscription */
if
(
sub
->
timeout
!=
TIPC_WAIT_FOREVER
)
{
if
(
sub
->
timeout
!=
TIPC_WAIT_FOREVER
)
{
sub
->
timeout
=
TIPC_WAIT_FOREVER
;
sub
->
timeout
=
TIPC_WAIT_FOREVER
;
spin_unlock_bh
(
subscriber
->
lock
);
spin_unlock_bh
(
subscriber
->
lock
);
...
@@ -313,7 +287,6 @@ static void subscr_cancel(struct tipc_subscr *s,
...
@@ -313,7 +287,6 @@ static void subscr_cancel(struct tipc_subscr *s,
*
*
* Called with subscriber port locked.
* Called with subscriber port locked.
*/
*/
static
struct
tipc_subscription
*
subscr_subscribe
(
struct
tipc_subscr
*
s
,
static
struct
tipc_subscription
*
subscr_subscribe
(
struct
tipc_subscr
*
s
,
struct
tipc_subscriber
*
subscriber
)
struct
tipc_subscriber
*
subscriber
)
{
{
...
@@ -321,11 +294,9 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s,
...
@@ -321,11 +294,9 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s,
int
swap
;
int
swap
;
/* Determine subscriber's endianness */
/* Determine subscriber's endianness */
swap
=
!
(
s
->
filter
&
(
TIPC_SUB_PORTS
|
TIPC_SUB_SERVICE
));
swap
=
!
(
s
->
filter
&
(
TIPC_SUB_PORTS
|
TIPC_SUB_SERVICE
));
/* Detect & process a subscription cancellation request */
/* Detect & process a subscription cancellation request */
if
(
s
->
filter
&
htohl
(
TIPC_SUB_CANCEL
,
swap
))
{
if
(
s
->
filter
&
htohl
(
TIPC_SUB_CANCEL
,
swap
))
{
s
->
filter
&=
~
htohl
(
TIPC_SUB_CANCEL
,
swap
);
s
->
filter
&=
~
htohl
(
TIPC_SUB_CANCEL
,
swap
);
subscr_cancel
(
s
,
subscriber
);
subscr_cancel
(
s
,
subscriber
);
...
@@ -333,7 +304,6 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s,
...
@@ -333,7 +304,6 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s,
}
}
/* Refuse subscription if global limit exceeded */
/* Refuse subscription if global limit exceeded */
if
(
atomic_read
(
&
topsrv
.
subscription_count
)
>=
tipc_max_subscriptions
)
{
if
(
atomic_read
(
&
topsrv
.
subscription_count
)
>=
tipc_max_subscriptions
)
{
warn
(
"Subscription rejected, subscription limit reached (%u)
\n
"
,
warn
(
"Subscription rejected, subscription limit reached (%u)
\n
"
,
tipc_max_subscriptions
);
tipc_max_subscriptions
);
...
@@ -342,7 +312,6 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s,
...
@@ -342,7 +312,6 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s,
}
}
/* Allocate subscription object */
/* Allocate subscription object */
sub
=
kmalloc
(
sizeof
(
*
sub
),
GFP_ATOMIC
);
sub
=
kmalloc
(
sizeof
(
*
sub
),
GFP_ATOMIC
);
if
(
!
sub
)
{
if
(
!
sub
)
{
warn
(
"Subscription rejected, no memory
\n
"
);
warn
(
"Subscription rejected, no memory
\n
"
);
...
@@ -351,7 +320,6 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s,
...
@@ -351,7 +320,6 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s,
}
}
/* Initialize subscription object */
/* Initialize subscription object */
sub
->
seq
.
type
=
htohl
(
s
->
seq
.
type
,
swap
);
sub
->
seq
.
type
=
htohl
(
s
->
seq
.
type
,
swap
);
sub
->
seq
.
lower
=
htohl
(
s
->
seq
.
lower
,
swap
);
sub
->
seq
.
lower
=
htohl
(
s
->
seq
.
lower
,
swap
);
sub
->
seq
.
upper
=
htohl
(
s
->
seq
.
upper
,
swap
);
sub
->
seq
.
upper
=
htohl
(
s
->
seq
.
upper
,
swap
);
...
@@ -385,7 +353,6 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s,
...
@@ -385,7 +353,6 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s,
*
*
* Called with subscriber's server port unlocked.
* Called with subscriber's server port unlocked.
*/
*/
static
void
subscr_conn_shutdown_event
(
void
*
usr_handle
,
static
void
subscr_conn_shutdown_event
(
void
*
usr_handle
,
u32
port_ref
,
u32
port_ref
,
struct
sk_buff
**
buf
,
struct
sk_buff
**
buf
,
...
@@ -409,7 +376,6 @@ static void subscr_conn_shutdown_event(void *usr_handle,
...
@@ -409,7 +376,6 @@ static void subscr_conn_shutdown_event(void *usr_handle,
*
*
* Called with subscriber's server port unlocked.
* Called with subscriber's server port unlocked.
*/
*/
static
void
subscr_conn_msg_event
(
void
*
usr_handle
,
static
void
subscr_conn_msg_event
(
void
*
usr_handle
,
u32
port_ref
,
u32
port_ref
,
struct
sk_buff
**
buf
,
struct
sk_buff
**
buf
,
...
@@ -424,7 +390,6 @@ static void subscr_conn_msg_event(void *usr_handle,
...
@@ -424,7 +390,6 @@ static void subscr_conn_msg_event(void *usr_handle,
* Lock subscriber's server port (& make a local copy of lock pointer,
* Lock subscriber's server port (& make a local copy of lock pointer,
* in case subscriber is deleted while processing subscription request)
* in case subscriber is deleted while processing subscription request)
*/
*/
if
(
tipc_port_lock
(
port_ref
)
==
NULL
)
if
(
tipc_port_lock
(
port_ref
)
==
NULL
)
return
;
return
;
...
@@ -452,7 +417,6 @@ static void subscr_conn_msg_event(void *usr_handle,
...
@@ -452,7 +417,6 @@ static void subscr_conn_msg_event(void *usr_handle,
* timeout code cannot delete the subscription,
* timeout code cannot delete the subscription,
* so the subscription object is still protected.
* so the subscription object is still protected.
*/
*/
tipc_nametbl_subscribe
(
sub
);
tipc_nametbl_subscribe
(
sub
);
}
}
}
}
...
@@ -461,7 +425,6 @@ static void subscr_conn_msg_event(void *usr_handle,
...
@@ -461,7 +425,6 @@ static void subscr_conn_msg_event(void *usr_handle,
/**
/**
* subscr_named_msg_event - handle request to establish a new subscriber
* subscr_named_msg_event - handle request to establish a new subscriber
*/
*/
static
void
subscr_named_msg_event
(
void
*
usr_handle
,
static
void
subscr_named_msg_event
(
void
*
usr_handle
,
u32
port_ref
,
u32
port_ref
,
struct
sk_buff
**
buf
,
struct
sk_buff
**
buf
,
...
@@ -475,7 +438,6 @@ static void subscr_named_msg_event(void *usr_handle,
...
@@ -475,7 +438,6 @@ static void subscr_named_msg_event(void *usr_handle,
u32
server_port_ref
;
u32
server_port_ref
;
/* Create subscriber object */
/* Create subscriber object */
subscriber
=
kzalloc
(
sizeof
(
struct
tipc_subscriber
),
GFP_ATOMIC
);
subscriber
=
kzalloc
(
sizeof
(
struct
tipc_subscriber
),
GFP_ATOMIC
);
if
(
subscriber
==
NULL
)
{
if
(
subscriber
==
NULL
)
{
warn
(
"Subscriber rejected, no memory
\n
"
);
warn
(
"Subscriber rejected, no memory
\n
"
);
...
@@ -485,7 +447,6 @@ static void subscr_named_msg_event(void *usr_handle,
...
@@ -485,7 +447,6 @@ static void subscr_named_msg_event(void *usr_handle,
INIT_LIST_HEAD
(
&
subscriber
->
subscriber_list
);
INIT_LIST_HEAD
(
&
subscriber
->
subscriber_list
);
/* Create server port & establish connection to subscriber */
/* Create server port & establish connection to subscriber */
tipc_createport
(
subscriber
,
tipc_createport
(
subscriber
,
importance
,
importance
,
NULL
,
NULL
,
...
@@ -504,26 +465,21 @@ static void subscr_named_msg_event(void *usr_handle,
...
@@ -504,26 +465,21 @@ static void subscr_named_msg_event(void *usr_handle,
tipc_connect2port
(
subscriber
->
port_ref
,
orig
);
tipc_connect2port
(
subscriber
->
port_ref
,
orig
);
/* Lock server port (& save lock address for future use) */
/* Lock server port (& save lock address for future use) */
subscriber
->
lock
=
tipc_port_lock
(
subscriber
->
port_ref
)
->
lock
;
subscriber
->
lock
=
tipc_port_lock
(
subscriber
->
port_ref
)
->
lock
;
/* Add subscriber to topology server's subscriber list */
/* Add subscriber to topology server's subscriber list */
spin_lock_bh
(
&
topsrv
.
lock
);
spin_lock_bh
(
&
topsrv
.
lock
);
list_add
(
&
subscriber
->
subscriber_list
,
&
topsrv
.
subscriber_list
);
list_add
(
&
subscriber
->
subscriber_list
,
&
topsrv
.
subscriber_list
);
spin_unlock_bh
(
&
topsrv
.
lock
);
spin_unlock_bh
(
&
topsrv
.
lock
);
/* Unlock server port */
/* Unlock server port */
server_port_ref
=
subscriber
->
port_ref
;
server_port_ref
=
subscriber
->
port_ref
;
spin_unlock_bh
(
subscriber
->
lock
);
spin_unlock_bh
(
subscriber
->
lock
);
/* Send an ACK- to complete connection handshaking */
/* Send an ACK- to complete connection handshaking */
tipc_send
(
server_port_ref
,
0
,
NULL
,
0
);
tipc_send
(
server_port_ref
,
0
,
NULL
,
0
);
/* Handle optional subscription request */
/* Handle optional subscription request */
if
(
size
!=
0
)
{
if
(
size
!=
0
)
{
subscr_conn_msg_event
(
subscriber
,
server_port_ref
,
subscr_conn_msg_event
(
subscriber
,
server_port_ref
,
buf
,
data
,
size
);
buf
,
data
,
size
);
...
@@ -535,7 +491,6 @@ int tipc_subscr_start(void)
...
@@ -535,7 +491,6 @@ int tipc_subscr_start(void)
struct
tipc_name_seq
seq
=
{
TIPC_TOP_SRV
,
TIPC_TOP_SRV
,
TIPC_TOP_SRV
};
struct
tipc_name_seq
seq
=
{
TIPC_TOP_SRV
,
TIPC_TOP_SRV
,
TIPC_TOP_SRV
};
int
res
;
int
res
;
memset
(
&
topsrv
,
0
,
sizeof
(
topsrv
));
spin_lock_init
(
&
topsrv
.
lock
);
spin_lock_init
(
&
topsrv
.
lock
);
INIT_LIST_HEAD
(
&
topsrv
.
subscriber_list
);
INIT_LIST_HEAD
(
&
topsrv
.
subscriber_list
);
...
...
net/tipc/subscr.h
浏览文件 @
b6d151bb
...
@@ -51,7 +51,6 @@ struct tipc_subscription;
...
@@ -51,7 +51,6 @@ struct tipc_subscription;
* @swap: indicates if subscriber uses opposite endianness in its messages
* @swap: indicates if subscriber uses opposite endianness in its messages
* @evt: template for events generated by subscription
* @evt: template for events generated by subscription
*/
*/
struct
tipc_subscription
{
struct
tipc_subscription
{
struct
tipc_name_seq
seq
;
struct
tipc_name_seq
seq
;
u32
timeout
;
u32
timeout
;
...
@@ -80,5 +79,4 @@ int tipc_subscr_start(void);
...
@@ -80,5 +79,4 @@ int tipc_subscr_start(void);
void
tipc_subscr_stop
(
void
);
void
tipc_subscr_stop
(
void
);
#endif
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录