Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
27a7b041
K
Kernel
项目概览
openeuler
/
Kernel
接近 2 年 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
27a7b041
编写于
1月 18, 2006
作者:
D
David S. Miller
浏览文件
操作
浏览文件
下载
差异文件
Merge
git://tipc.cslab.ericsson.net/pub/git/tipc
上级
ad12583f
4323add6
变更
49
展开全部
显示空白变更内容
内联
并排
Showing
49 changed file
with
1702 addition
and
1705 deletion
+1702
-1705
MAINTAINERS
MAINTAINERS
+3
-3
include/linux/if_ether.h
include/linux/if_ether.h
+1
-0
include/linux/tipc_config.h
include/linux/tipc_config.h
+5
-2
net/Kconfig
net/Kconfig
+1
-1
net/tipc/Kconfig
net/tipc/Kconfig
+6
-1
net/tipc/addr.c
net/tipc/addr.c
+5
-5
net/tipc/addr.h
net/tipc/addr.h
+2
-2
net/tipc/bcast.c
net/tipc/bcast.c
+83
-83
net/tipc/bcast.h
net/tipc/bcast.h
+22
-22
net/tipc/bearer.c
net/tipc/bearer.c
+98
-91
net/tipc/bearer.h
net/tipc/bearer.h
+19
-21
net/tipc/cluster.c
net/tipc/cluster.c
+77
-77
net/tipc/cluster.h
net/tipc/cluster.h
+20
-20
net/tipc/config.c
net/tipc/config.c
+109
-109
net/tipc/config.h
net/tipc/config.h
+20
-21
net/tipc/core.c
net/tipc/core.c
+43
-44
net/tipc/core.h
net/tipc/core.h
+20
-15
net/tipc/dbg.c
net/tipc/dbg.c
+56
-56
net/tipc/dbg.h
net/tipc/dbg.h
+9
-9
net/tipc/discover.c
net/tipc/discover.c
+26
-26
net/tipc/discover.h
net/tipc/discover.h
+9
-9
net/tipc/eth_media.c
net/tipc/eth_media.c
+9
-11
net/tipc/handler.c
net/tipc/handler.c
+3
-3
net/tipc/link.c
net/tipc/link.c
+302
-303
net/tipc/link.h
net/tipc/link.h
+36
-37
net/tipc/msg.c
net/tipc/msg.c
+4
-15
net/tipc/msg.h
net/tipc/msg.h
+9
-9
net/tipc/name_distr.c
net/tipc/name_distr.c
+46
-46
net/tipc/name_distr.h
net/tipc/name_distr.h
+5
-5
net/tipc/name_table.c
net/tipc/name_table.c
+103
-103
net/tipc/name_table.h
net/tipc/name_table.h
+13
-13
net/tipc/net.c
net/tipc/net.c
+63
-63
net/tipc/net.h
net/tipc/net.h
+9
-11
net/tipc/netlink.c
net/tipc/netlink.c
+8
-8
net/tipc/node.c
net/tipc/node.c
+107
-108
net/tipc/node.h
net/tipc/node.h
+25
-25
net/tipc/node_subscr.c
net/tipc/node_subscr.c
+10
-10
net/tipc/node_subscr.h
net/tipc/node_subscr.h
+3
-3
net/tipc/port.c
net/tipc/port.c
+137
-137
net/tipc/port.h
net/tipc/port.h
+30
-30
net/tipc/ref.c
net/tipc/ref.c
+36
-36
net/tipc/ref.h
net/tipc/ref.h
+19
-19
net/tipc/socket.c
net/tipc/socket.c
+5
-7
net/tipc/subscr.c
net/tipc/subscr.c
+29
-29
net/tipc/subscr.h
net/tipc/subscr.h
+12
-12
net/tipc/user_reg.c
net/tipc/user_reg.c
+11
-11
net/tipc/user_reg.h
net/tipc/user_reg.h
+4
-4
net/tipc/zone.c
net/tipc/zone.c
+20
-20
net/tipc/zone.h
net/tipc/zone.h
+10
-10
未找到文件。
MAINTAINERS
浏览文件 @
27a7b041
...
...
@@ -2536,11 +2536,11 @@ S: Maintained
TIPC NETWORK LAYER
P: Per Liden
M: per.liden@
nospam.
ericsson.com
M: per.liden@ericsson.com
P: Jon Maloy
M: jon.maloy@
nospam.
ericsson.com
M: jon.maloy@ericsson.com
P: Allan Stephens
M: allan.stephens@
nospam.
windriver.com
M: allan.stephens@windriver.com
L: tipc-discussion@lists.sourceforge.net
W: http://tipc.sourceforge.net/
W: http://tipc.cslab.ericsson.net/
...
...
include/linux/if_ether.h
浏览文件 @
27a7b041
...
...
@@ -72,6 +72,7 @@
* over Ethernet
*/
#define ETH_P_AOE 0x88A2
/* ATA over Ethernet */
#define ETH_P_TIPC 0x88CA
/* TIPC */
/*
* Non DIX types. Won't clash for 1500 types.
...
...
include/linux/tipc_config.h
浏览文件 @
27a7b041
...
...
@@ -168,10 +168,13 @@
#define TIPC_MAX_LINK_NAME 60
/* format = Z.C.N:interface-Z.C.N:interface */
/*
* Link priority limits (
range from 0 to # priorities - 1
)
* Link priority limits (
min, default, max, media default
)
*/
#define TIPC_NUM_LINK_PRI 32
#define TIPC_MIN_LINK_PRI 0
#define TIPC_DEF_LINK_PRI 10
#define TIPC_MAX_LINK_PRI 31
#define TIPC_MEDIA_LINK_PRI (TIPC_MAX_LINK_PRI + 1)
/*
* Link tolerance limits (min, default, max), in ms
...
...
net/Kconfig
浏览文件 @
27a7b041
...
...
@@ -150,6 +150,7 @@ endif
source "net/dccp/Kconfig"
source "net/sctp/Kconfig"
source "net/tipc/Kconfig"
source "net/atm/Kconfig"
source "net/bridge/Kconfig"
source "net/8021q/Kconfig"
...
...
@@ -159,7 +160,6 @@ source "net/ipx/Kconfig"
source "drivers/net/appletalk/Kconfig"
source "net/x25/Kconfig"
source "net/lapb/Kconfig"
source "net/tipc/Kconfig"
config NET_DIVERT
bool "Frame Diverter (EXPERIMENTAL)"
...
...
net/tipc/Kconfig
浏览文件 @
27a7b041
...
...
@@ -8,7 +8,12 @@ menu "TIPC Configuration (EXPERIMENTAL)"
config TIPC
tristate "The TIPC Protocol (EXPERIMENTAL)"
---help---
TBD.
The Transparent Inter Process Communication (TIPC) protocol is
specially designed for intra cluster communication. This protocol
originates from Ericsson where it has been used in carrier grade
cluster applications for many years.
For more information about TIPC, see http://tipc.sourceforge.net.
This protocol support is also available as a module ( = code which
can be inserted in and removed from the running kernel whenever you
...
...
net/tipc/addr.c
浏览文件 @
27a7b041
...
...
@@ -47,7 +47,7 @@ u32 tipc_get_addr(void)
}
/**
* addr_domain_valid - validates a network domain address
*
tipc_
addr_domain_valid - validates a network domain address
*
* Accepts <Z.C.N>, <Z.C.0>, <Z.0.0>, and <0.0.0>,
* where Z, C, and N are non-zero and do not exceed the configured limits.
...
...
@@ -55,7 +55,7 @@ u32 tipc_get_addr(void)
* Returns 1 if domain address is valid, otherwise 0
*/
int
addr_domain_valid
(
u32
addr
)
int
tipc_
addr_domain_valid
(
u32
addr
)
{
u32
n
=
tipc_node
(
addr
);
u32
c
=
tipc_cluster
(
addr
);
...
...
@@ -79,7 +79,7 @@ int addr_domain_valid(u32 addr)
}
/**
* addr_node_valid - validates a proposed network address for this node
*
tipc_
addr_node_valid - validates a proposed network address for this node
*
* Accepts <Z.C.N>, where Z, C, and N are non-zero and do not exceed
* the configured limits.
...
...
@@ -87,8 +87,8 @@ int addr_domain_valid(u32 addr)
* Returns 1 if address can be used, otherwise 0
*/
int
addr_node_valid
(
u32
addr
)
int
tipc_
addr_node_valid
(
u32
addr
)
{
return
(
addr_domain_valid
(
addr
)
&&
tipc_node
(
addr
));
return
(
tipc_
addr_domain_valid
(
addr
)
&&
tipc_node
(
addr
));
}
net/tipc/addr.h
浏览文件 @
27a7b041
...
...
@@ -122,7 +122,7 @@ static inline char *addr_string_fill(char *string, u32 addr)
return
string
;
}
int
addr_domain_valid
(
u32
);
int
addr_node_valid
(
u32
addr
);
int
tipc_
addr_domain_valid
(
u32
);
int
tipc_
addr_node_valid
(
u32
addr
);
#endif
net/tipc/bcast.c
浏览文件 @
27a7b041
...
...
@@ -82,7 +82,7 @@ struct bcbearer {
struct
bearer
bearer
;
struct
media
media
;
struct
bcbearer_pair
bpairs
[
MAX_BEARERS
];
struct
bcbearer_pair
bpairs_temp
[
TIPC_
NUM_LINK_PRI
];
struct
bcbearer_pair
bpairs_temp
[
TIPC_
MAX_LINK_PRI
+
1
];
};
/**
...
...
@@ -104,7 +104,7 @@ static struct bclink *bclink = NULL;
static
struct
link
*
bcl
=
NULL
;
static
spinlock_t
bc_lock
=
SPIN_LOCK_UNLOCKED
;
char
bc_
link_name
[]
=
"multicast-link"
;
char
tipc_bc
link_name
[]
=
"multicast-link"
;
static
inline
u32
buf_seqno
(
struct
sk_buff
*
buf
)
...
...
@@ -178,19 +178,19 @@ static void bclink_retransmit_pkt(u32 after, u32 to)
buf
=
buf
->
next
;
}
if
(
buf
!=
NULL
)
link_retransmit
(
bcl
,
buf
,
mod
(
to
-
after
));
tipc_
link_retransmit
(
bcl
,
buf
,
mod
(
to
-
after
));
spin_unlock_bh
(
&
bc_lock
);
}
/**
* bclink_acknowledge - handle acknowledgement of broadcast packets
*
tipc_
bclink_acknowledge - handle acknowledgement of broadcast packets
* @n_ptr: node that sent acknowledgement info
* @acked: broadcast sequence # that has been acknowledged
*
* Node is locked, bc_lock unlocked.
*/
void
bclink_acknowledge
(
struct
node
*
n_ptr
,
u32
acked
)
void
tipc_
bclink_acknowledge
(
struct
node
*
n_ptr
,
u32
acked
)
{
struct
sk_buff
*
crs
;
struct
sk_buff
*
next
;
...
...
@@ -226,16 +226,16 @@ void bclink_acknowledge(struct node *n_ptr, u32 acked)
/* Try resolving broadcast link congestion, if necessary */
if
(
unlikely
(
bcl
->
next_out
))
link_push_queue
(
bcl
);
tipc_
link_push_queue
(
bcl
);
if
(
unlikely
(
released
&&
!
list_empty
(
&
bcl
->
waiting_ports
)))
link_wakeup_ports
(
bcl
,
0
);
tipc_
link_wakeup_ports
(
bcl
,
0
);
spin_unlock_bh
(
&
bc_lock
);
}
/**
* bclink_send_ack - unicast an ACK msg
*
* net_lock and node lock set
*
tipc_
net_lock and node lock set
*/
static
void
bclink_send_ack
(
struct
node
*
n_ptr
)
...
...
@@ -243,13 +243,13 @@ static void bclink_send_ack(struct node *n_ptr)
struct
link
*
l_ptr
=
n_ptr
->
active_links
[
n_ptr
->
addr
&
1
];
if
(
l_ptr
!=
NULL
)
link_send_proto_msg
(
l_ptr
,
STATE_MSG
,
0
,
0
,
0
,
0
,
0
);
tipc_
link_send_proto_msg
(
l_ptr
,
STATE_MSG
,
0
,
0
,
0
,
0
,
0
);
}
/**
* bclink_send_nack- broadcast a NACK msg
*
* net_lock and node lock set
*
tipc_
net_lock and node lock set
*/
static
void
bclink_send_nack
(
struct
node
*
n_ptr
)
...
...
@@ -271,11 +271,11 @@ static void bclink_send_nack(struct node *n_ptr)
msg_set_bcgap_to
(
msg
,
n_ptr
->
bclink
.
gap_to
);
msg_set_bcast_tag
(
msg
,
tipc_own_tag
);
if
(
bearer_send
(
&
bcbearer
->
bearer
,
buf
,
0
))
{
if
(
tipc_
bearer_send
(
&
bcbearer
->
bearer
,
buf
,
0
))
{
bcl
->
stats
.
sent_nacks
++
;
buf_discard
(
buf
);
}
else
{
bearer_schedule
(
bcl
->
b_ptr
,
bcl
);
tipc_
bearer_schedule
(
bcl
->
b_ptr
,
bcl
);
bcl
->
proto_msg_queue
=
buf
;
bcl
->
stats
.
bearer_congs
++
;
}
...
...
@@ -291,12 +291,12 @@ static void bclink_send_nack(struct node *n_ptr)
}
/**
* bclink_check_gap - send a NACK if a sequence gap exists
*
tipc_
bclink_check_gap - send a NACK if a sequence gap exists
*
* net_lock and node lock set
*
tipc_
net_lock and node lock set
*/
void
bclink_check_gap
(
struct
node
*
n_ptr
,
u32
last_sent
)
void
tipc_
bclink_check_gap
(
struct
node
*
n_ptr
,
u32
last_sent
)
{
if
(
!
n_ptr
->
bclink
.
supported
||
less_eq
(
last_sent
,
mod
(
n_ptr
->
bclink
.
last_in
)))
...
...
@@ -309,19 +309,19 @@ void bclink_check_gap(struct node *n_ptr, u32 last_sent)
}
/**
* bclink_peek_nack - process a NACK msg meant for another node
*
tipc_
bclink_peek_nack - process a NACK msg meant for another node
*
* Only net_lock set.
* Only
tipc_
net_lock set.
*/
void
bclink_peek_nack
(
u32
dest
,
u32
sender_tag
,
u32
gap_after
,
u32
gap_to
)
void
tipc_
bclink_peek_nack
(
u32
dest
,
u32
sender_tag
,
u32
gap_after
,
u32
gap_to
)
{
struct
node
*
n_ptr
=
node_find
(
dest
);
struct
node
*
n_ptr
=
tipc_
node_find
(
dest
);
u32
my_after
,
my_to
;
if
(
unlikely
(
!
n_ptr
||
!
node_is_up
(
n_ptr
)))
if
(
unlikely
(
!
n_ptr
||
!
tipc_
node_is_up
(
n_ptr
)))
return
;
node_lock
(
n_ptr
);
tipc_
node_lock
(
n_ptr
);
/*
* Modify gap to suppress unnecessary NACKs from this node
*/
...
...
@@ -364,20 +364,20 @@ void bclink_peek_nack(u32 dest, u32 sender_tag, u32 gap_after, u32 gap_to)
bclink_set_gap
(
n_ptr
);
}
}
node_unlock
(
n_ptr
);
tipc_
node_unlock
(
n_ptr
);
}
/**
* bclink_send_msg - broadcast a packet to all nodes in cluster
*
tipc_
bclink_send_msg - broadcast a packet to all nodes in cluster
*/
int
bclink_send_msg
(
struct
sk_buff
*
buf
)
int
tipc_
bclink_send_msg
(
struct
sk_buff
*
buf
)
{
int
res
;
spin_lock_bh
(
&
bc_lock
);
res
=
link_send_buf
(
bcl
,
buf
);
res
=
tipc_
link_send_buf
(
bcl
,
buf
);
if
(
unlikely
(
res
==
-
ELINKCONG
))
buf_discard
(
buf
);
else
...
...
@@ -393,22 +393,22 @@ int bclink_send_msg(struct sk_buff *buf)
}
/**
* bclink_recv_pkt - receive a broadcast packet, and deliver upwards
*
tipc_
bclink_recv_pkt - receive a broadcast packet, and deliver upwards
*
* net_lock is read_locked, no other locks set
*
tipc_
net_lock is read_locked, no other locks set
*/
void
bclink_recv_pkt
(
struct
sk_buff
*
buf
)
void
tipc_
bclink_recv_pkt
(
struct
sk_buff
*
buf
)
{
struct
tipc_msg
*
msg
=
buf_msg
(
buf
);
struct
node
*
node
=
node_find
(
msg_prevnode
(
msg
));
struct
node
*
node
=
tipc_
node_find
(
msg_prevnode
(
msg
));
u32
next_in
;
u32
seqno
;
struct
sk_buff
*
deferred
;
msg_dbg
(
msg
,
"<BC<<<"
);
if
(
unlikely
(
!
node
||
!
node_is_up
(
node
)
||
!
node
->
bclink
.
supported
||
if
(
unlikely
(
!
node
||
!
tipc_
node_is_up
(
node
)
||
!
node
->
bclink
.
supported
||
(
msg_mc_netid
(
msg
)
!=
tipc_net_id
)))
{
buf_discard
(
buf
);
return
;
...
...
@@ -417,14 +417,14 @@ void bclink_recv_pkt(struct sk_buff *buf)
if
(
unlikely
(
msg_user
(
msg
)
==
BCAST_PROTOCOL
))
{
msg_dbg
(
msg
,
"<BCNACK<<<"
);
if
(
msg_destnode
(
msg
)
==
tipc_own_addr
)
{
node_lock
(
node
);
bclink_acknowledge
(
node
,
msg_bcast_ack
(
msg
));
node_unlock
(
node
);
tipc_
node_lock
(
node
);
tipc_
bclink_acknowledge
(
node
,
msg_bcast_ack
(
msg
));
tipc_
node_unlock
(
node
);
bcl
->
stats
.
recv_nacks
++
;
bclink_retransmit_pkt
(
msg_bcgap_after
(
msg
),
msg_bcgap_to
(
msg
));
}
else
{
bclink_peek_nack
(
msg_destnode
(
msg
),
tipc_
bclink_peek_nack
(
msg_destnode
(
msg
),
msg_bcast_tag
(
msg
),
msg_bcgap_after
(
msg
),
msg_bcgap_to
(
msg
));
...
...
@@ -433,7 +433,7 @@ void bclink_recv_pkt(struct sk_buff *buf)
return
;
}
node_lock
(
node
);
tipc_
node_lock
(
node
);
receive:
deferred
=
node
->
bclink
.
deferred_head
;
next_in
=
mod
(
node
->
bclink
.
last_in
+
1
);
...
...
@@ -448,26 +448,26 @@ void bclink_recv_pkt(struct sk_buff *buf)
bcl
->
stats
.
sent_acks
++
;
}
if
(
likely
(
msg_isdata
(
msg
)))
{
node_unlock
(
node
);
port_recv_mcast
(
buf
,
NULL
);
tipc_
node_unlock
(
node
);
tipc_
port_recv_mcast
(
buf
,
NULL
);
}
else
if
(
msg_user
(
msg
)
==
MSG_BUNDLER
)
{
bcl
->
stats
.
recv_bundles
++
;
bcl
->
stats
.
recv_bundled
+=
msg_msgcnt
(
msg
);
node_unlock
(
node
);
link_recv_bundle
(
buf
);
tipc_
node_unlock
(
node
);
tipc_
link_recv_bundle
(
buf
);
}
else
if
(
msg_user
(
msg
)
==
MSG_FRAGMENTER
)
{
bcl
->
stats
.
recv_fragments
++
;
if
(
link_recv_fragment
(
&
node
->
bclink
.
defragm
,
if
(
tipc_
link_recv_fragment
(
&
node
->
bclink
.
defragm
,
&
buf
,
&
msg
))
bcl
->
stats
.
recv_fragmented
++
;
node_unlock
(
node
);
net_route_msg
(
buf
);
tipc_
node_unlock
(
node
);
tipc_
net_route_msg
(
buf
);
}
else
{
node_unlock
(
node
);
net_route_msg
(
buf
);
tipc_
node_unlock
(
node
);
tipc_
net_route_msg
(
buf
);
}
if
(
deferred
&&
(
buf_seqno
(
deferred
)
==
mod
(
next_in
+
1
)))
{
node_lock
(
node
);
tipc_
node_lock
(
node
);
buf
=
deferred
;
msg
=
buf_msg
(
buf
);
node
->
bclink
.
deferred_head
=
deferred
->
next
;
...
...
@@ -478,7 +478,7 @@ void bclink_recv_pkt(struct sk_buff *buf)
u32
gap_after
=
node
->
bclink
.
gap_after
;
u32
gap_to
=
node
->
bclink
.
gap_to
;
if
(
link_defer_pkt
(
&
node
->
bclink
.
deferred_head
,
if
(
tipc_
link_defer_pkt
(
&
node
->
bclink
.
deferred_head
,
&
node
->
bclink
.
deferred_tail
,
buf
))
{
node
->
bclink
.
nack_sync
++
;
...
...
@@ -497,10 +497,10 @@ void bclink_recv_pkt(struct sk_buff *buf)
bcl
->
stats
.
duplicates
++
;
buf_discard
(
buf
);
}
node_unlock
(
node
);
tipc_
node_unlock
(
node
);
}
u32
bclink_get_last_sent
(
void
)
u32
tipc_
bclink_get_last_sent
(
void
)
{
u32
last_sent
=
mod
(
bcl
->
next_out_no
-
1
);
...
...
@@ -509,15 +509,15 @@ u32 bclink_get_last_sent(void)
return
last_sent
;
}
u32
bclink_acks_missing
(
struct
node
*
n_ptr
)
u32
tipc_
bclink_acks_missing
(
struct
node
*
n_ptr
)
{
return
(
n_ptr
->
bclink
.
supported
&&
(
bclink_get_last_sent
()
!=
n_ptr
->
bclink
.
acked
));
(
tipc_
bclink_get_last_sent
()
!=
n_ptr
->
bclink
.
acked
));
}
/**
* bcbearer_send - send a packet through the broadcast pseudo-bearer
*
tipc_
bcbearer_send - send a packet through the broadcast pseudo-bearer
*
* Send through as many bearers as necessary to reach all nodes
* that support TIPC multicasting.
...
...
@@ -525,7 +525,7 @@ u32 bclink_acks_missing(struct node *n_ptr)
* Returns 0 if packet sent successfully, non-zero if not
*/
int
bcbearer_send
(
struct
sk_buff
*
buf
,
int
tipc_
bcbearer_send
(
struct
sk_buff
*
buf
,
struct
tipc_bearer
*
unused1
,
struct
tipc_media_addr
*
unused2
)
{
...
...
@@ -541,8 +541,8 @@ int bcbearer_send(struct sk_buff *buf,
if
(
likely
(
!
msg_non_seq
(
buf_msg
(
buf
))))
{
struct
tipc_msg
*
msg
;
assert
(
cluste
r_bcast_nodes
.
count
!=
0
);
bcbuf_set_acks
(
buf
,
cluste
r_bcast_nodes
.
count
);
assert
(
tipc_clt
r_bcast_nodes
.
count
!=
0
);
bcbuf_set_acks
(
buf
,
tipc_clt
r_bcast_nodes
.
count
);
msg
=
buf_msg
(
buf
);
msg_set_non_seq
(
msg
);
msg_set_mc_netid
(
msg
,
tipc_net_id
);
...
...
@@ -555,7 +555,7 @@ int bcbearer_send(struct sk_buff *buf,
/* Send buffer over bearers until all targets reached */
remains
=
cluste
r_bcast_nodes
;
remains
=
tipc_clt
r_bcast_nodes
;
for
(
bp_index
=
0
;
bp_index
<
MAX_BEARERS
;
bp_index
++
)
{
struct
bearer
*
p
=
bcbearer
->
bpairs
[
bp_index
].
primary
;
...
...
@@ -564,7 +564,7 @@ int bcbearer_send(struct sk_buff *buf,
if
(
!
p
)
break
;
/* no more bearers to try */
nmap_diff
(
&
remains
,
&
p
->
nodes
,
&
remains_new
);
tipc_
nmap_diff
(
&
remains
,
&
p
->
nodes
,
&
remains_new
);
if
(
remains_new
.
count
==
remains
.
count
)
continue
;
/* bearer pair doesn't add anything */
...
...
@@ -597,10 +597,10 @@ int bcbearer_send(struct sk_buff *buf,
}
/**
* bcbearer_sort - create sets of bearer pairs used by broadcast bearer
*
tipc_
bcbearer_sort - create sets of bearer pairs used by broadcast bearer
*/
void
bcbearer_sort
(
void
)
void
tipc_
bcbearer_sort
(
void
)
{
struct
bcbearer_pair
*
bp_temp
=
bcbearer
->
bpairs_temp
;
struct
bcbearer_pair
*
bp_curr
;
...
...
@@ -614,7 +614,7 @@ void bcbearer_sort(void)
memset
(
bp_temp
,
0
,
sizeof
(
bcbearer
->
bpairs_temp
));
for
(
b_index
=
0
;
b_index
<
MAX_BEARERS
;
b_index
++
)
{
struct
bearer
*
b
=
&
bearers
[
b_index
];
struct
bearer
*
b
=
&
tipc_
bearers
[
b_index
];
if
(
!
b
->
active
||
!
b
->
nodes
.
count
)
continue
;
...
...
@@ -630,7 +630,7 @@ void bcbearer_sort(void)
bp_curr
=
bcbearer
->
bpairs
;
memset
(
bcbearer
->
bpairs
,
0
,
sizeof
(
bcbearer
->
bpairs
));
for
(
pri
=
(
TIPC_NUM_LINK_PRI
-
1
)
;
pri
>=
0
;
pri
--
)
{
for
(
pri
=
TIPC_MAX_LINK_PRI
;
pri
>=
0
;
pri
--
)
{
if
(
!
bp_temp
[
pri
].
primary
)
continue
;
...
...
@@ -638,7 +638,7 @@ void bcbearer_sort(void)
bp_curr
->
primary
=
bp_temp
[
pri
].
primary
;
if
(
bp_temp
[
pri
].
secondary
)
{
if
(
nmap_equal
(
&
bp_temp
[
pri
].
primary
->
nodes
,
if
(
tipc_
nmap_equal
(
&
bp_temp
[
pri
].
primary
->
nodes
,
&
bp_temp
[
pri
].
secondary
->
nodes
))
{
bp_curr
->
secondary
=
bp_temp
[
pri
].
secondary
;
}
else
{
...
...
@@ -654,14 +654,14 @@ void bcbearer_sort(void)
}
/**
* bcbearer_push - resolve bearer congestion
*
tipc_
bcbearer_push - resolve bearer congestion
*
* Forces bclink to push out any unsent packets, until all packets are gone
* or congestion reoccurs.
* No locks set when function called
*/
void
bcbearer_push
(
void
)
void
tipc_
bcbearer_push
(
void
)
{
struct
bearer
*
b_ptr
;
...
...
@@ -669,20 +669,20 @@ void bcbearer_push(void)
b_ptr
=
&
bcbearer
->
bearer
;
if
(
b_ptr
->
publ
.
blocked
)
{
b_ptr
->
publ
.
blocked
=
0
;
bearer_lock_push
(
b_ptr
);
tipc_
bearer_lock_push
(
b_ptr
);
}
spin_unlock_bh
(
&
bc_lock
);
}
int
bclink_stats
(
char
*
buf
,
const
u32
buf_size
)
int
tipc_
bclink_stats
(
char
*
buf
,
const
u32
buf_size
)
{
struct
print_buf
pb
;
if
(
!
bcl
)
return
0
;
printbuf_init
(
&
pb
,
buf
,
buf_size
);
tipc_
printbuf_init
(
&
pb
,
buf
,
buf_size
);
spin_lock_bh
(
&
bc_lock
);
...
...
@@ -718,10 +718,10 @@ int bclink_stats(char *buf, const u32 buf_size)
:
0
);
spin_unlock_bh
(
&
bc_lock
);
return
printbuf_validate
(
&
pb
);
return
tipc_
printbuf_validate
(
&
pb
);
}
int
bclink_reset_stats
(
void
)
int
tipc_
bclink_reset_stats
(
void
)
{
if
(
!
bcl
)
return
-
ENOPROTOOPT
;
...
...
@@ -732,7 +732,7 @@ int bclink_reset_stats(void)
return
TIPC_OK
;
}
int
bclink_set_queue_limits
(
u32
limit
)
int
tipc_
bclink_set_queue_limits
(
u32
limit
)
{
if
(
!
bcl
)
return
-
ENOPROTOOPT
;
...
...
@@ -740,12 +740,12 @@ int bclink_set_queue_limits(u32 limit)
return
-
EINVAL
;
spin_lock_bh
(
&
bc_lock
);
link_set_queue_limits
(
bcl
,
limit
);
tipc_
link_set_queue_limits
(
bcl
,
limit
);
spin_unlock_bh
(
&
bc_lock
);
return
TIPC_OK
;
}
int
bclink_init
(
void
)
int
tipc_
bclink_init
(
void
)
{
bcbearer
=
kmalloc
(
sizeof
(
*
bcbearer
),
GFP_ATOMIC
);
bclink
=
kmalloc
(
sizeof
(
*
bclink
),
GFP_ATOMIC
);
...
...
@@ -762,7 +762,7 @@ int bclink_init(void)
memset
(
bcbearer
,
0
,
sizeof
(
struct
bcbearer
));
INIT_LIST_HEAD
(
&
bcbearer
->
bearer
.
cong_links
);
bcbearer
->
bearer
.
media
=
&
bcbearer
->
media
;
bcbearer
->
media
.
send_msg
=
bcbearer_send
;
bcbearer
->
media
.
send_msg
=
tipc_
bcbearer_send
;
sprintf
(
bcbearer
->
media
.
name
,
"tipc-multicast"
);
bcl
=
&
bclink
->
link
;
...
...
@@ -772,27 +772,27 @@ int bclink_init(void)
bclink
->
node
.
lock
=
SPIN_LOCK_UNLOCKED
;
bcl
->
owner
=
&
bclink
->
node
;
bcl
->
max_pkt
=
MAX_PKT_DEFAULT_MCAST
;
link_set_queue_limits
(
bcl
,
BCLINK_WIN_DEFAULT
);
tipc_
link_set_queue_limits
(
bcl
,
BCLINK_WIN_DEFAULT
);
bcl
->
b_ptr
=
&
bcbearer
->
bearer
;
bcl
->
state
=
WORKING_WORKING
;
sprintf
(
bcl
->
name
,
bc_
link_name
);
sprintf
(
bcl
->
name
,
tipc_bc
link_name
);
if
(
BCLINK_LOG_BUF_SIZE
)
{
char
*
pb
=
kmalloc
(
BCLINK_LOG_BUF_SIZE
,
GFP_ATOMIC
);
if
(
!
pb
)
goto
nomem
;
printbuf_init
(
&
bcl
->
print_buf
,
pb
,
BCLINK_LOG_BUF_SIZE
);
tipc_
printbuf_init
(
&
bcl
->
print_buf
,
pb
,
BCLINK_LOG_BUF_SIZE
);
}
return
TIPC_OK
;
}
void
bclink_stop
(
void
)
void
tipc_
bclink_stop
(
void
)
{
spin_lock_bh
(
&
bc_lock
);
if
(
bcbearer
)
{
link_stop
(
bcl
);
tipc_
link_stop
(
bcl
);
if
(
BCLINK_LOG_BUF_SIZE
)
kfree
(
bcl
->
print_buf
.
buf
);
bcl
=
NULL
;
...
...
net/tipc/bcast.h
浏览文件 @
27a7b041
...
...
@@ -70,14 +70,14 @@ struct port_list {
struct
node
;
extern
char
bc_
link_name
[];
extern
char
tipc_bc
link_name
[];
/**
* nmap_get - determine if node exists in a node map
*/
static
inline
int
nmap_get
(
struct
node_map
*
nm_ptr
,
u32
node
)
static
inline
int
tipc_
nmap_get
(
struct
node_map
*
nm_ptr
,
u32
node
)
{
int
n
=
tipc_node
(
node
);
int
w
=
n
/
WSIZE
;
...
...
@@ -90,7 +90,7 @@ static inline int nmap_get(struct node_map *nm_ptr, u32 node)
* nmap_add - add a node to a node map
*/
static
inline
void
nmap_add
(
struct
node_map
*
nm_ptr
,
u32
node
)
static
inline
void
tipc_
nmap_add
(
struct
node_map
*
nm_ptr
,
u32
node
)
{
int
n
=
tipc_node
(
node
);
int
w
=
n
/
WSIZE
;
...
...
@@ -106,7 +106,7 @@ static inline void nmap_add(struct node_map *nm_ptr, u32 node)
* nmap_remove - remove a node from a node map
*/
static
inline
void
nmap_remove
(
struct
node_map
*
nm_ptr
,
u32
node
)
static
inline
void
tipc_
nmap_remove
(
struct
node_map
*
nm_ptr
,
u32
node
)
{
int
n
=
tipc_node
(
node
);
int
w
=
n
/
WSIZE
;
...
...
@@ -122,7 +122,7 @@ static inline void nmap_remove(struct node_map *nm_ptr, u32 node)
* nmap_equal - test for equality of node maps
*/
static
inline
int
nmap_equal
(
struct
node_map
*
nm_a
,
struct
node_map
*
nm_b
)
static
inline
int
tipc_
nmap_equal
(
struct
node_map
*
nm_a
,
struct
node_map
*
nm_b
)
{
return
!
memcmp
(
nm_a
,
nm_b
,
sizeof
(
*
nm_a
));
}
...
...
@@ -134,7 +134,7 @@ static inline int nmap_equal(struct node_map *nm_a, struct node_map *nm_b)
* @nm_diff: output node map A-B (i.e. nodes of A that are not in B)
*/
static
inline
void
nmap_diff
(
struct
node_map
*
nm_a
,
struct
node_map
*
nm_b
,
static
inline
void
tipc_
nmap_diff
(
struct
node_map
*
nm_a
,
struct
node_map
*
nm_b
,
struct
node_map
*
nm_diff
)
{
int
stop
=
sizeof
(
nm_a
->
map
)
/
sizeof
(
u32
);
...
...
@@ -159,7 +159,7 @@ static inline void nmap_diff(struct node_map *nm_a, struct node_map *nm_b,
* port_list_add - add a port to a port list, ensuring no duplicates
*/
static
inline
void
port_list_add
(
struct
port_list
*
pl_ptr
,
u32
port
)
static
inline
void
tipc_
port_list_add
(
struct
port_list
*
pl_ptr
,
u32
port
)
{
struct
port_list
*
item
=
pl_ptr
;
int
i
;
...
...
@@ -194,7 +194,7 @@ static inline void port_list_add(struct port_list *pl_ptr, u32 port)
* Note: First item is on stack, so it doesn't need to be released
*/
static
inline
void
port_list_free
(
struct
port_list
*
pl_ptr
)
static
inline
void
tipc_
port_list_free
(
struct
port_list
*
pl_ptr
)
{
struct
port_list
*
item
;
struct
port_list
*
next
;
...
...
@@ -206,18 +206,18 @@ static inline void port_list_free(struct port_list *pl_ptr)
}
int
bclink_init
(
void
);
void
bclink_stop
(
void
);
void
bclink_acknowledge
(
struct
node
*
n_ptr
,
u32
acked
);
int
bclink_send_msg
(
struct
sk_buff
*
buf
);
void
bclink_recv_pkt
(
struct
sk_buff
*
buf
);
u32
bclink_get_last_sent
(
void
);
u32
bclink_acks_missing
(
struct
node
*
n_ptr
);
void
bclink_check_gap
(
struct
node
*
n_ptr
,
u32
seqno
);
int
bclink_stats
(
char
*
stats_buf
,
const
u32
buf_size
);
int
bclink_reset_stats
(
void
);
int
bclink_set_queue_limits
(
u32
limit
);
void
bcbearer_sort
(
void
);
void
bcbearer_push
(
void
);
int
tipc_
bclink_init
(
void
);
void
tipc_
bclink_stop
(
void
);
void
tipc_
bclink_acknowledge
(
struct
node
*
n_ptr
,
u32
acked
);
int
tipc_
bclink_send_msg
(
struct
sk_buff
*
buf
);
void
tipc_
bclink_recv_pkt
(
struct
sk_buff
*
buf
);
u32
tipc_
bclink_get_last_sent
(
void
);
u32
tipc_
bclink_acks_missing
(
struct
node
*
n_ptr
);
void
tipc_
bclink_check_gap
(
struct
node
*
n_ptr
,
u32
seqno
);
int
tipc_
bclink_stats
(
char
*
stats_buf
,
const
u32
buf_size
);
int
tipc_
bclink_reset_stats
(
void
);
int
tipc_
bclink_set_queue_limits
(
u32
limit
);
void
tipc_
bcbearer_sort
(
void
);
void
tipc_
bcbearer_push
(
void
);
#endif
net/tipc/bearer.c
浏览文件 @
27a7b041
...
...
@@ -48,7 +48,7 @@
static
struct
media
*
media_list
=
0
;
static
u32
media_count
=
0
;
struct
bearer
*
bearers
=
0
;
struct
bearer
*
tipc_
bearers
=
0
;
/**
* media_name_valid - validate media name
...
...
@@ -107,7 +107,7 @@ int tipc_register_media(u32 media_type,
u32
i
;
int
res
=
-
EINVAL
;
write_lock_bh
(
&
net_lock
);
write_lock_bh
(
&
tipc_
net_lock
);
if
(
!
media_list
)
goto
exit
;
...
...
@@ -119,7 +119,8 @@ int tipc_register_media(u32 media_type,
warn
(
"Media registration error: no broadcast address supplied
\n
"
);
goto
exit
;
}
if
(
bearer_priority
>=
TIPC_NUM_LINK_PRI
)
{
if
((
bearer_priority
<
TIPC_MIN_LINK_PRI
)
&&
(
bearer_priority
>
TIPC_MAX_LINK_PRI
))
{
warn
(
"Media registration error: priority %u
\n
"
,
bearer_priority
);
goto
exit
;
}
...
...
@@ -164,15 +165,15 @@ int tipc_register_media(u32 media_type,
dbg
(
"Media <%s> registered
\n
"
,
name
);
res
=
0
;
exit:
write_unlock_bh
(
&
net_lock
);
write_unlock_bh
(
&
tipc_
net_lock
);
return
res
;
}
/**
* media_addr_printf - record media address in print buffer
*
tipc_
media_addr_printf - record media address in print buffer
*/
void
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
)
{
struct
media
*
m_ptr
;
u32
media_type
;
...
...
@@ -200,25 +201,25 @@ void media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a)
}
/**
* media_get_names - record names of registered media in buffer
*
tipc_
media_get_names - record names of registered media in buffer
*/
struct
sk_buff
*
media_get_names
(
void
)
struct
sk_buff
*
tipc_
media_get_names
(
void
)
{
struct
sk_buff
*
buf
;
struct
media
*
m_ptr
;
int
i
;
buf
=
cfg_reply_alloc
(
MAX_MEDIA
*
TLV_SPACE
(
TIPC_MAX_MEDIA_NAME
));
buf
=
tipc_
cfg_reply_alloc
(
MAX_MEDIA
*
TLV_SPACE
(
TIPC_MAX_MEDIA_NAME
));
if
(
!
buf
)
return
NULL
;
read_lock_bh
(
&
net_lock
);
read_lock_bh
(
&
tipc_
net_lock
);
for
(
i
=
0
,
m_ptr
=
media_list
;
i
<
media_count
;
i
++
,
m_ptr
++
)
{
cfg_append_tlv
(
buf
,
TIPC_TLV_MEDIA_NAME
,
m_ptr
->
name
,
tipc_
cfg_append_tlv
(
buf
,
TIPC_TLV_MEDIA_NAME
,
m_ptr
->
name
,
strlen
(
m_ptr
->
name
)
+
1
);
}
read_unlock_bh
(
&
net_lock
);
read_unlock_bh
(
&
tipc_
net_lock
);
return
buf
;
}
...
...
@@ -282,7 +283,7 @@ static struct bearer *bearer_find(const char *name)
struct
bearer
*
b_ptr
;
u32
i
;
for
(
i
=
0
,
b_ptr
=
bearers
;
i
<
MAX_BEARERS
;
i
++
,
b_ptr
++
)
{
for
(
i
=
0
,
b_ptr
=
tipc_
bearers
;
i
<
MAX_BEARERS
;
i
++
,
b_ptr
++
)
{
if
(
b_ptr
->
active
&&
(
!
strcmp
(
b_ptr
->
publ
.
name
,
name
)))
return
b_ptr
;
}
...
...
@@ -290,16 +291,16 @@ static struct bearer *bearer_find(const char *name)
}
/**
*
bearer_find
- locates bearer object with matching interface name
*
tipc_bearer_find_interface
- locates bearer object with matching interface name
*/
struct
bearer
*
bearer_find_interface
(
const
char
*
if_name
)
struct
bearer
*
tipc_
bearer_find_interface
(
const
char
*
if_name
)
{
struct
bearer
*
b_ptr
;
char
*
b_if_name
;
u32
i
;
for
(
i
=
0
,
b_ptr
=
bearers
;
i
<
MAX_BEARERS
;
i
++
,
b_ptr
++
)
{
for
(
i
=
0
,
b_ptr
=
tipc_
bearers
;
i
<
MAX_BEARERS
;
i
++
,
b_ptr
++
)
{
if
(
!
b_ptr
->
active
)
continue
;
b_if_name
=
strchr
(
b_ptr
->
publ
.
name
,
':'
)
+
1
;
...
...
@@ -310,54 +311,54 @@ struct bearer *bearer_find_interface(const char *if_name)
}
/**
* bearer_get_names - record names of bearers in buffer
*
tipc_
bearer_get_names - record names of bearers in buffer
*/
struct
sk_buff
*
bearer_get_names
(
void
)
struct
sk_buff
*
tipc_
bearer_get_names
(
void
)
{
struct
sk_buff
*
buf
;
struct
media
*
m_ptr
;
struct
bearer
*
b_ptr
;
int
i
,
j
;
buf
=
cfg_reply_alloc
(
MAX_BEARERS
*
TLV_SPACE
(
TIPC_MAX_BEARER_NAME
));
buf
=
tipc_
cfg_reply_alloc
(
MAX_BEARERS
*
TLV_SPACE
(
TIPC_MAX_BEARER_NAME
));
if
(
!
buf
)
return
NULL
;
read_lock_bh
(
&
net_lock
);
read_lock_bh
(
&
tipc_
net_lock
);
for
(
i
=
0
,
m_ptr
=
media_list
;
i
<
media_count
;
i
++
,
m_ptr
++
)
{
for
(
j
=
0
;
j
<
MAX_BEARERS
;
j
++
)
{
b_ptr
=
&
bearers
[
j
];
b_ptr
=
&
tipc_
bearers
[
j
];
if
(
b_ptr
->
active
&&
(
b_ptr
->
media
==
m_ptr
))
{
cfg_append_tlv
(
buf
,
TIPC_TLV_BEARER_NAME
,
tipc_
cfg_append_tlv
(
buf
,
TIPC_TLV_BEARER_NAME
,
b_ptr
->
publ
.
name
,
strlen
(
b_ptr
->
publ
.
name
)
+
1
);
}
}
}
read_unlock_bh
(
&
net_lock
);
read_unlock_bh
(
&
tipc_
net_lock
);
return
buf
;
}
void
bearer_add_dest
(
struct
bearer
*
b_ptr
,
u32
dest
)
void
tipc_
bearer_add_dest
(
struct
bearer
*
b_ptr
,
u32
dest
)
{
nmap_add
(
&
b_ptr
->
nodes
,
dest
);
disc_update_link_req
(
b_ptr
->
link_req
);
bcbearer_sort
();
tipc_
nmap_add
(
&
b_ptr
->
nodes
,
dest
);
tipc_
disc_update_link_req
(
b_ptr
->
link_req
);
tipc_
bcbearer_sort
();
}
void
bearer_remove_dest
(
struct
bearer
*
b_ptr
,
u32
dest
)
void
tipc_
bearer_remove_dest
(
struct
bearer
*
b_ptr
,
u32
dest
)
{
nmap_remove
(
&
b_ptr
->
nodes
,
dest
);
disc_update_link_req
(
b_ptr
->
link_req
);
bcbearer_sort
();
tipc_
nmap_remove
(
&
b_ptr
->
nodes
,
dest
);
tipc_
disc_update_link_req
(
b_ptr
->
link_req
);
tipc_
bcbearer_sort
();
}
/*
* bearer_push(): Resolve bearer congestion. Force the waiting
* links to push out their unsent packets, one packet per link
* per iteration, until all packets are gone or congestion reoccurs.
* 'net_lock' is read_locked when this function is called
* '
tipc_
net_lock' is read_locked when this function is called
* bearer.lock must be taken before calling
* Returns binary true(1) ore false(0)
*/
...
...
@@ -371,7 +372,7 @@ static int bearer_push(struct bearer *b_ptr)
while
(
!
list_empty
(
&
b_ptr
->
cong_links
)
&&
(
res
!=
PUSH_FAILED
))
{
list_for_each_entry_safe
(
ln
,
tln
,
&
b_ptr
->
cong_links
,
link_list
)
{
res
=
link_push_packet
(
ln
);
res
=
tipc_
link_push_packet
(
ln
);
if
(
res
==
PUSH_FAILED
)
break
;
if
(
res
==
PUSH_FINISHED
)
...
...
@@ -381,7 +382,7 @@ static int bearer_push(struct bearer *b_ptr)
return
list_empty
(
&
b_ptr
->
cong_links
);
}
void
bearer_lock_push
(
struct
bearer
*
b_ptr
)
void
tipc_
bearer_lock_push
(
struct
bearer
*
b_ptr
)
{
int
res
;
...
...
@@ -389,7 +390,7 @@ void bearer_lock_push(struct bearer *b_ptr)
res
=
bearer_push
(
b_ptr
);
spin_unlock_bh
(
&
b_ptr
->
publ
.
lock
);
if
(
res
)
bcbearer_push
();
tipc_
bcbearer_push
();
}
...
...
@@ -404,7 +405,7 @@ void tipc_continue(struct tipc_bearer *tb_ptr)
spin_lock_bh
(
&
b_ptr
->
publ
.
lock
);
b_ptr
->
continue_count
++
;
if
(
!
list_empty
(
&
b_ptr
->
cong_links
))
k_signal
((
Handler
)
bearer_lock_push
,
(
unsigned
long
)
b_ptr
);
tipc_k_signal
((
Handler
)
tipc_
bearer_lock_push
,
(
unsigned
long
)
b_ptr
);
b_ptr
->
publ
.
blocked
=
0
;
spin_unlock_bh
(
&
b_ptr
->
publ
.
lock
);
}
...
...
@@ -413,11 +414,11 @@ void tipc_continue(struct tipc_bearer *tb_ptr)
* Schedule link for sending of messages after the bearer
* has been deblocked by 'continue()'. This method is called
* when somebody tries to send a message via this link while
* the bearer is congested. 'net_lock' is in read_lock here
* the bearer is congested. '
tipc_
net_lock' is in read_lock here
* bearer.lock is busy
*/
static
void
bearer_schedule_unlocked
(
struct
bearer
*
b_ptr
,
struct
link
*
l_ptr
)
static
void
tipc_
bearer_schedule_unlocked
(
struct
bearer
*
b_ptr
,
struct
link
*
l_ptr
)
{
list_move_tail
(
&
l_ptr
->
link_list
,
&
b_ptr
->
cong_links
);
}
...
...
@@ -426,24 +427,24 @@ static void bearer_schedule_unlocked(struct bearer *b_ptr, struct link *l_ptr)
* Schedule link for sending of messages after the bearer
* has been deblocked by 'continue()'. This method is called
* when somebody tries to send a message via this link while
* the bearer is congested. 'net_lock' is in read_lock here,
* the bearer is congested. '
tipc_
net_lock' is in read_lock here,
* bearer.lock is free
*/
void
bearer_schedule
(
struct
bearer
*
b_ptr
,
struct
link
*
l_ptr
)
void
tipc_
bearer_schedule
(
struct
bearer
*
b_ptr
,
struct
link
*
l_ptr
)
{
spin_lock_bh
(
&
b_ptr
->
publ
.
lock
);
bearer_schedule_unlocked
(
b_ptr
,
l_ptr
);
tipc_
bearer_schedule_unlocked
(
b_ptr
,
l_ptr
);
spin_unlock_bh
(
&
b_ptr
->
publ
.
lock
);
}
/*
* bearer_resolve_congestion(): Check if there is bearer congestion,
*
tipc_
bearer_resolve_congestion(): Check if there is bearer congestion,
* and if there is, try to resolve it before returning.
* 'net_lock' is read_locked when this function is called
* '
tipc_
net_lock' is read_locked when this function is called
*/
int
bearer_resolve_congestion
(
struct
bearer
*
b_ptr
,
struct
link
*
l_ptr
)
int
tipc_
bearer_resolve_congestion
(
struct
bearer
*
b_ptr
,
struct
link
*
l_ptr
)
{
int
res
=
1
;
...
...
@@ -451,7 +452,7 @@ int bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr)
return
1
;
spin_lock_bh
(
&
b_ptr
->
publ
.
lock
);
if
(
!
bearer_push
(
b_ptr
))
{
bearer_schedule_unlocked
(
b_ptr
,
l_ptr
);
tipc_
bearer_schedule_unlocked
(
b_ptr
,
l_ptr
);
res
=
0
;
}
spin_unlock_bh
(
&
b_ptr
->
publ
.
lock
);
...
...
@@ -476,14 +477,19 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)
if
(
tipc_mode
!=
TIPC_NET_MODE
)
return
-
ENOPROTOOPT
;
if
(
!
bearer_name_validate
(
name
,
&
b_name
)
||
!
addr_domain_valid
(
bcast_scope
)
||
!
in_scope
(
bcast_scope
,
tipc_own_addr
)
||
(
priority
>
TIPC_NUM_LINK_PRI
))
!
tipc_addr_domain_valid
(
bcast_scope
)
||
!
in_scope
(
bcast_scope
,
tipc_own_addr
))
return
-
EINVAL
;
if
((
priority
<
TIPC_MIN_LINK_PRI
||
priority
>
TIPC_MAX_LINK_PRI
)
&&
(
priority
!=
TIPC_MEDIA_LINK_PRI
))
return
-
EINVAL
;
write_lock_bh
(
&
net_lock
);
if
(
!
bearers
)
write_lock_bh
(
&
tipc_
net_lock
);
if
(
!
tipc_
bearers
)
goto
failed
;
m_ptr
=
media_find
(
b_name
.
media_name
);
...
...
@@ -491,22 +497,23 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)
warn
(
"No media <%s>
\n
"
,
b_name
.
media_name
);
goto
failed
;
}
if
(
priority
==
TIPC_NUM_LINK_PRI
)
if
(
priority
==
TIPC_MEDIA_LINK_PRI
)
priority
=
m_ptr
->
priority
;
restart:
bearer_id
=
MAX_BEARERS
;
with_this_prio
=
1
;
for
(
i
=
MAX_BEARERS
;
i
--
!=
0
;
)
{
if
(
!
bearers
[
i
].
active
)
{
if
(
!
tipc_
bearers
[
i
].
active
)
{
bearer_id
=
i
;
continue
;
}
if
(
!
strcmp
(
name
,
bearers
[
i
].
publ
.
name
))
{
if
(
!
strcmp
(
name
,
tipc_
bearers
[
i
].
publ
.
name
))
{
warn
(
"Bearer <%s> already enabled
\n
"
,
name
);
goto
failed
;
}
if
((
bearers
[
i
].
priority
==
priority
)
&&
if
((
tipc_
bearers
[
i
].
priority
==
priority
)
&&
(
++
with_this_prio
>
2
))
{
if
(
priority
--
==
0
)
{
warn
(
"Third bearer <%s> with priority %u, unable to lower to %u
\n
"
,
...
...
@@ -523,7 +530,7 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)
goto
failed
;
}
b_ptr
=
&
bearers
[
bearer_id
];
b_ptr
=
&
tipc_
bearers
[
bearer_id
];
memset
(
b_ptr
,
0
,
sizeof
(
struct
bearer
));
strcpy
(
b_ptr
->
publ
.
name
,
name
);
...
...
@@ -542,16 +549,16 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)
INIT_LIST_HEAD
(
&
b_ptr
->
cong_links
);
INIT_LIST_HEAD
(
&
b_ptr
->
links
);
if
(
m_ptr
->
bcast
)
{
b_ptr
->
link_req
=
disc_init_link_req
(
b_ptr
,
&
m_ptr
->
bcast_addr
,
b_ptr
->
link_req
=
tipc_
disc_init_link_req
(
b_ptr
,
&
m_ptr
->
bcast_addr
,
bcast_scope
,
2
);
}
b_ptr
->
publ
.
lock
=
SPIN_LOCK_UNLOCKED
;
write_unlock_bh
(
&
net_lock
);
info
(
"Enabled bearer <%s>, discovery domain %s
\n
"
,
name
,
addr_string_fill
(
addr_string
,
bcast_scope
));
write_unlock_bh
(
&
tipc_
net_lock
);
info
(
"Enabled bearer <%s>, discovery domain %s
, priority %u
\n
"
,
name
,
addr_string_fill
(
addr_string
,
bcast_scope
)
,
priority
);
return
0
;
failed:
write_unlock_bh
(
&
net_lock
);
write_unlock_bh
(
&
tipc_
net_lock
);
return
res
;
}
...
...
@@ -569,11 +576,11 @@ int tipc_block_bearer(const char *name)
if
(
tipc_mode
!=
TIPC_NET_MODE
)
return
-
ENOPROTOOPT
;
read_lock_bh
(
&
net_lock
);
read_lock_bh
(
&
tipc_
net_lock
);
b_ptr
=
bearer_find
(
name
);
if
(
!
b_ptr
)
{
warn
(
"Attempt to block unknown bearer <%s>
\n
"
,
name
);
read_unlock_bh
(
&
net_lock
);
read_unlock_bh
(
&
tipc_
net_lock
);
return
-
EINVAL
;
}
...
...
@@ -583,11 +590,11 @@ int tipc_block_bearer(const char *name)
struct
node
*
n_ptr
=
l_ptr
->
owner
;
spin_lock_bh
(
&
n_ptr
->
lock
);
link_reset
(
l_ptr
);
tipc_
link_reset
(
l_ptr
);
spin_unlock_bh
(
&
n_ptr
->
lock
);
}
spin_unlock_bh
(
&
b_ptr
->
publ
.
lock
);
read_unlock_bh
(
&
net_lock
);
read_unlock_bh
(
&
tipc_
net_lock
);
info
(
"Blocked bearer <%s>
\n
"
,
name
);
return
TIPC_OK
;
}
...
...
@@ -595,7 +602,7 @@ int tipc_block_bearer(const char *name)
/**
* bearer_disable -
*
* Note: This routine assumes caller holds net_lock.
* Note: This routine assumes caller holds
tipc_
net_lock.
*/
static
int
bearer_disable
(
const
char
*
name
)
...
...
@@ -613,19 +620,19 @@ static int bearer_disable(const char *name)
return
-
EINVAL
;
}
disc_stop_link_req
(
b_ptr
->
link_req
);
tipc_
disc_stop_link_req
(
b_ptr
->
link_req
);
spin_lock_bh
(
&
b_ptr
->
publ
.
lock
);
b_ptr
->
link_req
=
NULL
;
b_ptr
->
publ
.
blocked
=
1
;
if
(
b_ptr
->
media
->
disable_bearer
)
{
spin_unlock_bh
(
&
b_ptr
->
publ
.
lock
);
write_unlock_bh
(
&
net_lock
);
write_unlock_bh
(
&
tipc_
net_lock
);
b_ptr
->
media
->
disable_bearer
(
&
b_ptr
->
publ
);
write_lock_bh
(
&
net_lock
);
write_lock_bh
(
&
tipc_
net_lock
);
spin_lock_bh
(
&
b_ptr
->
publ
.
lock
);
}
list_for_each_entry_safe
(
l_ptr
,
temp_l_ptr
,
&
b_ptr
->
links
,
link_list
)
{
link_delete
(
l_ptr
);
tipc_
link_delete
(
l_ptr
);
}
spin_unlock_bh
(
&
b_ptr
->
publ
.
lock
);
info
(
"Disabled bearer <%s>
\n
"
,
name
);
...
...
@@ -637,54 +644,54 @@ int tipc_disable_bearer(const char *name)
{
int
res
;
write_lock_bh
(
&
net_lock
);
write_lock_bh
(
&
tipc_
net_lock
);
res
=
bearer_disable
(
name
);
write_unlock_bh
(
&
net_lock
);
write_unlock_bh
(
&
tipc_
net_lock
);
return
res
;
}
int
bearer_init
(
void
)
int
tipc_
bearer_init
(
void
)
{
int
res
;
write_lock_bh
(
&
net_lock
);
bearers
=
kmalloc
(
MAX_BEARERS
*
sizeof
(
struct
bearer
),
GFP_ATOMIC
);
write_lock_bh
(
&
tipc_
net_lock
);
tipc_
bearers
=
kmalloc
(
MAX_BEARERS
*
sizeof
(
struct
bearer
),
GFP_ATOMIC
);
media_list
=
kmalloc
(
MAX_MEDIA
*
sizeof
(
struct
media
),
GFP_ATOMIC
);
if
(
bearers
&&
media_list
)
{
memset
(
bearers
,
0
,
MAX_BEARERS
*
sizeof
(
struct
bearer
));
if
(
tipc_
bearers
&&
media_list
)
{
memset
(
tipc_
bearers
,
0
,
MAX_BEARERS
*
sizeof
(
struct
bearer
));
memset
(
media_list
,
0
,
MAX_MEDIA
*
sizeof
(
struct
media
));
res
=
TIPC_OK
;
}
else
{
kfree
(
bearers
);
kfree
(
tipc_
bearers
);
kfree
(
media_list
);
bearers
=
0
;
tipc_
bearers
=
0
;
media_list
=
0
;
res
=
-
ENOMEM
;
}
write_unlock_bh
(
&
net_lock
);
write_unlock_bh
(
&
tipc_
net_lock
);
return
res
;
}
void
bearer_stop
(
void
)
void
tipc_
bearer_stop
(
void
)
{
u32
i
;
if
(
!
bearers
)
if
(
!
tipc_
bearers
)
return
;
for
(
i
=
0
;
i
<
MAX_BEARERS
;
i
++
)
{
if
(
bearers
[
i
].
active
)
bearers
[
i
].
publ
.
blocked
=
1
;
if
(
tipc_
bearers
[
i
].
active
)
tipc_
bearers
[
i
].
publ
.
blocked
=
1
;
}
for
(
i
=
0
;
i
<
MAX_BEARERS
;
i
++
)
{
if
(
bearers
[
i
].
active
)
bearer_disable
(
bearers
[
i
].
publ
.
name
);
if
(
tipc_
bearers
[
i
].
active
)
bearer_disable
(
tipc_
bearers
[
i
].
publ
.
name
);
}
kfree
(
bearers
);
kfree
(
tipc_
bearers
);
kfree
(
media_list
);
bearers
=
0
;
tipc_
bearers
=
0
;
media_list
=
0
;
media_count
=
0
;
}
...
...
net/tipc/bearer.h
浏览文件 @
27a7b041
...
...
@@ -37,7 +37,7 @@
#ifndef _TIPC_BEARER_H
#define _TIPC_BEARER_H
#include
<net/tipc/tipc_bearer.h>
#include
"core.h"
#include "bcast.h"
#define MAX_BEARERS 8
...
...
@@ -114,26 +114,24 @@ struct bearer_name {
struct
link
;
extern
struct
bearer
*
bearers
;
extern
struct
bearer
*
tipc_
bearers
;
void
media_addr_printf
(
struct
print_buf
*
pb
,
struct
tipc_media_addr
*
a
);
struct
sk_buff
*
media_get_names
(
void
);
void
tipc_
media_addr_printf
(
struct
print_buf
*
pb
,
struct
tipc_media_addr
*
a
);
struct
sk_buff
*
tipc_
media_get_names
(
void
);
struct
sk_buff
*
bearer_get_names
(
void
);
void
bearer_add_dest
(
struct
bearer
*
b_ptr
,
u32
dest
);
void
bearer_remove_dest
(
struct
bearer
*
b_ptr
,
u32
dest
);
void
bearer_schedule
(
struct
bearer
*
b_ptr
,
struct
link
*
l_ptr
);
struct
bearer
*
bearer_find_interface
(
const
char
*
if_name
);
int
bearer_resolve_congestion
(
struct
bearer
*
b_ptr
,
struct
link
*
l_ptr
);
int
bearer_init
(
void
);
void
bearer_stop
(
void
);
int
bearer_broadcast
(
struct
sk_buff
*
buf
,
struct
tipc_bearer
*
b_ptr
,
struct
tipc_media_addr
*
dest
);
void
bearer_lock_push
(
struct
bearer
*
b_ptr
);
struct
sk_buff
*
tipc_bearer_get_names
(
void
);
void
tipc_bearer_add_dest
(
struct
bearer
*
b_ptr
,
u32
dest
);
void
tipc_bearer_remove_dest
(
struct
bearer
*
b_ptr
,
u32
dest
);
void
tipc_bearer_schedule
(
struct
bearer
*
b_ptr
,
struct
link
*
l_ptr
);
struct
bearer
*
tipc_bearer_find_interface
(
const
char
*
if_name
);
int
tipc_bearer_resolve_congestion
(
struct
bearer
*
b_ptr
,
struct
link
*
l_ptr
);
int
tipc_bearer_init
(
void
);
void
tipc_bearer_stop
(
void
);
void
tipc_bearer_lock_push
(
struct
bearer
*
b_ptr
);
/**
* bearer_send- sends buffer to destination over bearer
*
tipc_
bearer_send- sends buffer to destination over bearer
*
* Returns true (1) if successful, or false (0) if unable to send
*
...
...
@@ -150,23 +148,23 @@ void bearer_lock_push(struct bearer *b_ptr);
* and let TIPC's link code deal with the undelivered message.
*/
static
inline
int
bearer_send
(
struct
bearer
*
b_ptr
,
struct
sk_buff
*
buf
,
static
inline
int
tipc_
bearer_send
(
struct
bearer
*
b_ptr
,
struct
sk_buff
*
buf
,
struct
tipc_media_addr
*
dest
)
{
return
!
b_ptr
->
media
->
send_msg
(
buf
,
&
b_ptr
->
publ
,
dest
);
}
/**
* bearer_congested - determines if bearer is currently congested
*
tipc_
bearer_congested - determines if bearer is currently congested
*/
static
inline
int
bearer_congested
(
struct
bearer
*
b_ptr
,
struct
link
*
l_ptr
)
static
inline
int
tipc_
bearer_congested
(
struct
bearer
*
b_ptr
,
struct
link
*
l_ptr
)
{
if
(
unlikely
(
b_ptr
->
publ
.
blocked
))
return
1
;
if
(
likely
(
list_empty
(
&
b_ptr
->
cong_links
)))
return
0
;
return
!
bearer_resolve_congestion
(
b_ptr
,
l_ptr
);
return
!
tipc_
bearer_resolve_congestion
(
b_ptr
,
l_ptr
);
}
#endif
net/tipc/cluster.c
浏览文件 @
27a7b041
...
...
@@ -44,15 +44,15 @@
#include "msg.h"
#include "bearer.h"
void
cluste
r_multicast
(
struct
cluster
*
c_ptr
,
struct
sk_buff
*
buf
,
void
tipc_clt
r_multicast
(
struct
cluster
*
c_ptr
,
struct
sk_buff
*
buf
,
u32
lower
,
u32
upper
);
struct
sk_buff
*
cluste
r_prepare_routing_msg
(
u32
data_size
,
u32
dest
);
struct
sk_buff
*
tipc_clt
r_prepare_routing_msg
(
u32
data_size
,
u32
dest
);
struct
node
**
local_nodes
=
0
;
struct
node_map
cluste
r_bcast_nodes
=
{
0
,{
0
,}};
u32
highest_allowed_slave
=
0
;
struct
node
**
tipc_
local_nodes
=
0
;
struct
node_map
tipc_clt
r_bcast_nodes
=
{
0
,{
0
,}};
u32
tipc_
highest_allowed_slave
=
0
;
struct
cluster
*
cluste
r_create
(
u32
addr
)
struct
cluster
*
tipc_clt
r_create
(
u32
addr
)
{
struct
_zone
*
z_ptr
;
struct
cluster
*
c_ptr
;
...
...
@@ -77,16 +77,16 @@ struct cluster *cluster_create(u32 addr)
}
memset
(
c_ptr
->
nodes
,
0
,
alloc
);
if
(
in_own_cluster
(
addr
))
local_nodes
=
c_ptr
->
nodes
;
tipc_
local_nodes
=
c_ptr
->
nodes
;
c_ptr
->
highest_slave
=
LOWEST_SLAVE
-
1
;
c_ptr
->
highest_node
=
0
;
z_ptr
=
zone_find
(
tipc_zone
(
addr
));
z_ptr
=
tipc_
zone_find
(
tipc_zone
(
addr
));
if
(
z_ptr
==
NULL
)
{
z_ptr
=
zone_create
(
addr
);
z_ptr
=
tipc_
zone_create
(
addr
);
}
if
(
z_ptr
!=
NULL
)
{
zone_attach_cluster
(
z_ptr
,
c_ptr
);
tipc_
zone_attach_cluster
(
z_ptr
,
c_ptr
);
c_ptr
->
owner
=
z_ptr
;
}
else
{
...
...
@@ -97,23 +97,23 @@ struct cluster *cluster_create(u32 addr)
return
c_ptr
;
}
void
cluste
r_delete
(
struct
cluster
*
c_ptr
)
void
tipc_clt
r_delete
(
struct
cluster
*
c_ptr
)
{
u32
n_num
;
if
(
!
c_ptr
)
return
;
for
(
n_num
=
1
;
n_num
<=
c_ptr
->
highest_node
;
n_num
++
)
{
node_delete
(
c_ptr
->
nodes
[
n_num
]);
tipc_
node_delete
(
c_ptr
->
nodes
[
n_num
]);
}
for
(
n_num
=
LOWEST_SLAVE
;
n_num
<=
c_ptr
->
highest_slave
;
n_num
++
)
{
node_delete
(
c_ptr
->
nodes
[
n_num
]);
tipc_
node_delete
(
c_ptr
->
nodes
[
n_num
]);
}
kfree
(
c_ptr
->
nodes
);
kfree
(
c_ptr
);
}
u32
cluste
r_next_node
(
struct
cluster
*
c_ptr
,
u32
addr
)
u32
tipc_clt
r_next_node
(
struct
cluster
*
c_ptr
,
u32
addr
)
{
struct
node
*
n_ptr
;
u32
n_num
=
tipc_node
(
addr
)
+
1
;
...
...
@@ -122,24 +122,24 @@ u32 cluster_next_node(struct cluster *c_ptr, u32 addr)
return
addr
;
for
(;
n_num
<=
c_ptr
->
highest_node
;
n_num
++
)
{
n_ptr
=
c_ptr
->
nodes
[
n_num
];
if
(
n_ptr
&&
node_has_active_links
(
n_ptr
))
if
(
n_ptr
&&
tipc_
node_has_active_links
(
n_ptr
))
return
n_ptr
->
addr
;
}
for
(
n_num
=
1
;
n_num
<
tipc_node
(
addr
);
n_num
++
)
{
n_ptr
=
c_ptr
->
nodes
[
n_num
];
if
(
n_ptr
&&
node_has_active_links
(
n_ptr
))
if
(
n_ptr
&&
tipc_
node_has_active_links
(
n_ptr
))
return
n_ptr
->
addr
;
}
return
0
;
}
void
cluste
r_attach_node
(
struct
cluster
*
c_ptr
,
struct
node
*
n_ptr
)
void
tipc_clt
r_attach_node
(
struct
cluster
*
c_ptr
,
struct
node
*
n_ptr
)
{
u32
n_num
=
tipc_node
(
n_ptr
->
addr
);
u32
max_n_num
=
tipc_max_nodes
;
if
(
in_own_cluster
(
n_ptr
->
addr
))
max_n_num
=
highest_allowed_slave
;
max_n_num
=
tipc_
highest_allowed_slave
;
assert
(
n_num
>
0
);
assert
(
n_num
<=
max_n_num
);
assert
(
c_ptr
->
nodes
[
n_num
]
==
0
);
...
...
@@ -149,12 +149,12 @@ void cluster_attach_node(struct cluster *c_ptr, struct node *n_ptr)
}
/**
*
cluste
r_select_router - select router to a cluster
*
tipc_clt
r_select_router - select router to a cluster
*
* Uses deterministic and fair algorithm.
*/
u32
cluste
r_select_router
(
struct
cluster
*
c_ptr
,
u32
ref
)
u32
tipc_clt
r_select_router
(
struct
cluster
*
c_ptr
,
u32
ref
)
{
u32
n_num
;
u32
ulim
=
c_ptr
->
highest_node
;
...
...
@@ -174,29 +174,29 @@ u32 cluster_select_router(struct cluster *c_ptr, u32 ref)
/* Lookup upwards with wrap-around */
do
{
if
(
node_is_up
(
c_ptr
->
nodes
[
n_num
]))
if
(
tipc_
node_is_up
(
c_ptr
->
nodes
[
n_num
]))
break
;
}
while
(
++
n_num
<=
ulim
);
if
(
n_num
>
ulim
)
{
n_num
=
1
;
do
{
if
(
node_is_up
(
c_ptr
->
nodes
[
n_num
]))
if
(
tipc_
node_is_up
(
c_ptr
->
nodes
[
n_num
]))
break
;
}
while
(
++
n_num
<
tstart
);
if
(
n_num
==
tstart
)
return
0
;
}
assert
(
n_num
<=
ulim
);
return
node_select_router
(
c_ptr
->
nodes
[
n_num
],
ref
);
return
tipc_
node_select_router
(
c_ptr
->
nodes
[
n_num
],
ref
);
}
/**
*
cluste
r_select_node - select destination node within a remote cluster
*
tipc_clt
r_select_node - select destination node within a remote cluster
*
* Uses deterministic and fair algorithm.
*/
struct
node
*
cluste
r_select_node
(
struct
cluster
*
c_ptr
,
u32
selector
)
struct
node
*
tipc_clt
r_select_node
(
struct
cluster
*
c_ptr
,
u32
selector
)
{
u32
n_num
;
u32
mask
=
tipc_max_nodes
;
...
...
@@ -215,11 +215,11 @@ struct node *cluster_select_node(struct cluster *c_ptr, u32 selector)
/* Lookup upwards with wrap-around */
for
(
n_num
=
start_entry
;
n_num
<=
c_ptr
->
highest_node
;
n_num
++
)
{
if
(
node_has_active_links
(
c_ptr
->
nodes
[
n_num
]))
if
(
tipc_
node_has_active_links
(
c_ptr
->
nodes
[
n_num
]))
return
c_ptr
->
nodes
[
n_num
];
}
for
(
n_num
=
1
;
n_num
<
start_entry
;
n_num
++
)
{
if
(
node_has_active_links
(
c_ptr
->
nodes
[
n_num
]))
if
(
tipc_
node_has_active_links
(
c_ptr
->
nodes
[
n_num
]))
return
c_ptr
->
nodes
[
n_num
];
}
return
0
;
...
...
@@ -229,7 +229,7 @@ struct node *cluster_select_node(struct cluster *c_ptr, u32 selector)
* Routing table management: See description in node.c
*/
struct
sk_buff
*
cluste
r_prepare_routing_msg
(
u32
data_size
,
u32
dest
)
struct
sk_buff
*
tipc_clt
r_prepare_routing_msg
(
u32
data_size
,
u32
dest
)
{
u32
size
=
INT_H_SIZE
+
data_size
;
struct
sk_buff
*
buf
=
buf_acquire
(
size
);
...
...
@@ -243,39 +243,39 @@ struct sk_buff *cluster_prepare_routing_msg(u32 data_size, u32 dest)
return
buf
;
}
void
cluste
r_bcast_new_route
(
struct
cluster
*
c_ptr
,
u32
dest
,
void
tipc_clt
r_bcast_new_route
(
struct
cluster
*
c_ptr
,
u32
dest
,
u32
lower
,
u32
upper
)
{
struct
sk_buff
*
buf
=
cluste
r_prepare_routing_msg
(
0
,
c_ptr
->
addr
);
struct
sk_buff
*
buf
=
tipc_clt
r_prepare_routing_msg
(
0
,
c_ptr
->
addr
);
struct
tipc_msg
*
msg
;
if
(
buf
)
{
msg
=
buf_msg
(
buf
);
msg_set_remote_node
(
msg
,
dest
);
msg_set_type
(
msg
,
ROUTE_ADDITION
);
cluste
r_multicast
(
c_ptr
,
buf
,
lower
,
upper
);
tipc_clt
r_multicast
(
c_ptr
,
buf
,
lower
,
upper
);
}
else
{
warn
(
"Memory squeeze: broadcast of new route failed
\n
"
);
}
}
void
cluste
r_bcast_lost_route
(
struct
cluster
*
c_ptr
,
u32
dest
,
void
tipc_clt
r_bcast_lost_route
(
struct
cluster
*
c_ptr
,
u32
dest
,
u32
lower
,
u32
upper
)
{
struct
sk_buff
*
buf
=
cluste
r_prepare_routing_msg
(
0
,
c_ptr
->
addr
);
struct
sk_buff
*
buf
=
tipc_clt
r_prepare_routing_msg
(
0
,
c_ptr
->
addr
);
struct
tipc_msg
*
msg
;
if
(
buf
)
{
msg
=
buf_msg
(
buf
);
msg_set_remote_node
(
msg
,
dest
);
msg_set_type
(
msg
,
ROUTE_REMOVAL
);
cluste
r_multicast
(
c_ptr
,
buf
,
lower
,
upper
);
tipc_clt
r_multicast
(
c_ptr
,
buf
,
lower
,
upper
);
}
else
{
warn
(
"Memory squeeze: broadcast of lost route failed
\n
"
);
}
}
void
cluste
r_send_slave_routes
(
struct
cluster
*
c_ptr
,
u32
dest
)
void
tipc_clt
r_send_slave_routes
(
struct
cluster
*
c_ptr
,
u32
dest
)
{
struct
sk_buff
*
buf
;
struct
tipc_msg
*
msg
;
...
...
@@ -288,7 +288,7 @@ void cluster_send_slave_routes(struct cluster *c_ptr, u32 dest)
assert
(
in_own_cluster
(
c_ptr
->
addr
));
if
(
highest
<=
LOWEST_SLAVE
)
return
;
buf
=
cluste
r_prepare_routing_msg
(
highest
-
LOWEST_SLAVE
+
1
,
buf
=
tipc_clt
r_prepare_routing_msg
(
highest
-
LOWEST_SLAVE
+
1
,
c_ptr
->
addr
);
if
(
buf
)
{
msg
=
buf_msg
(
buf
);
...
...
@@ -296,13 +296,13 @@ void cluster_send_slave_routes(struct cluster *c_ptr, u32 dest)
msg_set_type
(
msg
,
SLAVE_ROUTING_TABLE
);
for
(
n_num
=
LOWEST_SLAVE
;
n_num
<=
highest
;
n_num
++
)
{
if
(
c_ptr
->
nodes
[
n_num
]
&&
node_has_active_links
(
c_ptr
->
nodes
[
n_num
]))
{
tipc_
node_has_active_links
(
c_ptr
->
nodes
[
n_num
]))
{
send
=
1
;
msg_set_dataoctet
(
msg
,
n_num
);
}
}
if
(
send
)
link_send
(
buf
,
dest
,
dest
);
tipc_
link_send
(
buf
,
dest
,
dest
);
else
buf_discard
(
buf
);
}
else
{
...
...
@@ -310,7 +310,7 @@ void cluster_send_slave_routes(struct cluster *c_ptr, u32 dest)
}
}
void
cluste
r_send_ext_routes
(
struct
cluster
*
c_ptr
,
u32
dest
)
void
tipc_clt
r_send_ext_routes
(
struct
cluster
*
c_ptr
,
u32
dest
)
{
struct
sk_buff
*
buf
;
struct
tipc_msg
*
msg
;
...
...
@@ -323,20 +323,20 @@ void cluster_send_ext_routes(struct cluster *c_ptr, u32 dest)
assert
(
!
is_slave
(
dest
));
assert
(
in_own_cluster
(
dest
));
highest
=
c_ptr
->
highest_node
;
buf
=
cluste
r_prepare_routing_msg
(
highest
+
1
,
c_ptr
->
addr
);
buf
=
tipc_clt
r_prepare_routing_msg
(
highest
+
1
,
c_ptr
->
addr
);
if
(
buf
)
{
msg
=
buf_msg
(
buf
);
msg_set_remote_node
(
msg
,
c_ptr
->
addr
);
msg_set_type
(
msg
,
EXT_ROUTING_TABLE
);
for
(
n_num
=
1
;
n_num
<=
highest
;
n_num
++
)
{
if
(
c_ptr
->
nodes
[
n_num
]
&&
node_has_active_links
(
c_ptr
->
nodes
[
n_num
]))
{
tipc_
node_has_active_links
(
c_ptr
->
nodes
[
n_num
]))
{
send
=
1
;
msg_set_dataoctet
(
msg
,
n_num
);
}
}
if
(
send
)
link_send
(
buf
,
dest
,
dest
);
tipc_
link_send
(
buf
,
dest
,
dest
);
else
buf_discard
(
buf
);
}
else
{
...
...
@@ -344,7 +344,7 @@ void cluster_send_ext_routes(struct cluster *c_ptr, u32 dest)
}
}
void
cluste
r_send_local_routes
(
struct
cluster
*
c_ptr
,
u32
dest
)
void
tipc_clt
r_send_local_routes
(
struct
cluster
*
c_ptr
,
u32
dest
)
{
struct
sk_buff
*
buf
;
struct
tipc_msg
*
msg
;
...
...
@@ -354,20 +354,20 @@ void cluster_send_local_routes(struct cluster *c_ptr, u32 dest)
assert
(
is_slave
(
dest
));
assert
(
in_own_cluster
(
c_ptr
->
addr
));
buf
=
cluste
r_prepare_routing_msg
(
highest
,
c_ptr
->
addr
);
buf
=
tipc_clt
r_prepare_routing_msg
(
highest
,
c_ptr
->
addr
);
if
(
buf
)
{
msg
=
buf_msg
(
buf
);
msg_set_remote_node
(
msg
,
c_ptr
->
addr
);
msg_set_type
(
msg
,
LOCAL_ROUTING_TABLE
);
for
(
n_num
=
1
;
n_num
<=
highest
;
n_num
++
)
{
if
(
c_ptr
->
nodes
[
n_num
]
&&
node_has_active_links
(
c_ptr
->
nodes
[
n_num
]))
{
tipc_
node_has_active_links
(
c_ptr
->
nodes
[
n_num
]))
{
send
=
1
;
msg_set_dataoctet
(
msg
,
n_num
);
}
}
if
(
send
)
link_send
(
buf
,
dest
,
dest
);
tipc_
link_send
(
buf
,
dest
,
dest
);
else
buf_discard
(
buf
);
}
else
{
...
...
@@ -375,7 +375,7 @@ void cluster_send_local_routes(struct cluster *c_ptr, u32 dest)
}
}
void
cluste
r_recv_routing_table
(
struct
sk_buff
*
buf
)
void
tipc_clt
r_recv_routing_table
(
struct
sk_buff
*
buf
)
{
struct
tipc_msg
*
msg
=
buf_msg
(
buf
);
struct
cluster
*
c_ptr
;
...
...
@@ -388,9 +388,9 @@ void cluster_recv_routing_table(struct sk_buff *buf)
u32
c_num
;
u32
n_num
;
c_ptr
=
cluste
r_find
(
rem_node
);
c_ptr
=
tipc_clt
r_find
(
rem_node
);
if
(
!
c_ptr
)
{
c_ptr
=
cluste
r_create
(
rem_node
);
c_ptr
=
tipc_clt
r_create
(
rem_node
);
if
(
!
c_ptr
)
{
buf_discard
(
buf
);
return
;
...
...
@@ -412,10 +412,10 @@ void cluster_recv_routing_table(struct sk_buff *buf)
u32
addr
=
tipc_addr
(
z_num
,
c_num
,
n_num
);
n_ptr
=
c_ptr
->
nodes
[
n_num
];
if
(
!
n_ptr
)
{
n_ptr
=
node_create
(
addr
);
n_ptr
=
tipc_
node_create
(
addr
);
}
if
(
n_ptr
)
node_add_router
(
n_ptr
,
router
);
tipc_
node_add_router
(
n_ptr
,
router
);
}
}
break
;
...
...
@@ -428,10 +428,10 @@ void cluster_recv_routing_table(struct sk_buff *buf)
u32
addr
=
tipc_addr
(
z_num
,
c_num
,
slave_num
);
n_ptr
=
c_ptr
->
nodes
[
slave_num
];
if
(
!
n_ptr
)
{
n_ptr
=
node_create
(
addr
);
n_ptr
=
tipc_
node_create
(
addr
);
}
if
(
n_ptr
)
node_add_router
(
n_ptr
,
router
);
tipc_
node_add_router
(
n_ptr
,
router
);
}
}
break
;
...
...
@@ -445,9 +445,9 @@ void cluster_recv_routing_table(struct sk_buff *buf)
}
n_ptr
=
c_ptr
->
nodes
[
tipc_node
(
rem_node
)];
if
(
!
n_ptr
)
n_ptr
=
node_create
(
rem_node
);
n_ptr
=
tipc_
node_create
(
rem_node
);
if
(
n_ptr
)
node_add_router
(
n_ptr
,
router
);
tipc_
node_add_router
(
n_ptr
,
router
);
break
;
case
ROUTE_REMOVAL
:
if
(
!
is_slave
(
tipc_own_addr
))
{
...
...
@@ -459,7 +459,7 @@ void cluster_recv_routing_table(struct sk_buff *buf)
}
n_ptr
=
c_ptr
->
nodes
[
tipc_node
(
rem_node
)];
if
(
n_ptr
)
node_remove_router
(
n_ptr
,
router
);
tipc_
node_remove_router
(
n_ptr
,
router
);
break
;
default:
assert
(
!
"Illegal routing manager message received
\n
"
);
...
...
@@ -467,7 +467,7 @@ void cluster_recv_routing_table(struct sk_buff *buf)
buf_discard
(
buf
);
}
void
cluste
r_remove_as_router
(
struct
cluster
*
c_ptr
,
u32
router
)
void
tipc_clt
r_remove_as_router
(
struct
cluster
*
c_ptr
,
u32
router
)
{
u32
start_entry
;
u32
tstop
;
...
...
@@ -486,16 +486,16 @@ void cluster_remove_as_router(struct cluster *c_ptr, u32 router)
for
(
n_num
=
start_entry
;
n_num
<=
tstop
;
n_num
++
)
{
if
(
c_ptr
->
nodes
[
n_num
])
{
node_remove_router
(
c_ptr
->
nodes
[
n_num
],
router
);
tipc_
node_remove_router
(
c_ptr
->
nodes
[
n_num
],
router
);
}
}
}
/**
*
cluste
r_multicast - multicast message to local nodes
*
tipc_clt
r_multicast - multicast message to local nodes
*/
void
cluste
r_multicast
(
struct
cluster
*
c_ptr
,
struct
sk_buff
*
buf
,
void
tipc_clt
r_multicast
(
struct
cluster
*
c_ptr
,
struct
sk_buff
*
buf
,
u32
lower
,
u32
upper
)
{
struct
sk_buff
*
buf_copy
;
...
...
@@ -505,9 +505,9 @@ void cluster_multicast(struct cluster *c_ptr, struct sk_buff *buf,
assert
(
lower
<=
upper
);
assert
(((
lower
>=
1
)
&&
(
lower
<=
tipc_max_nodes
))
||
((
lower
>=
LOWEST_SLAVE
)
&&
(
lower
<=
highest_allowed_slave
)));
((
lower
>=
LOWEST_SLAVE
)
&&
(
lower
<=
tipc_
highest_allowed_slave
)));
assert
(((
upper
>=
1
)
&&
(
upper
<=
tipc_max_nodes
))
||
((
upper
>=
LOWEST_SLAVE
)
&&
(
upper
<=
highest_allowed_slave
)));
((
upper
>=
LOWEST_SLAVE
)
&&
(
upper
<=
tipc_
highest_allowed_slave
)));
assert
(
in_own_cluster
(
c_ptr
->
addr
));
tstop
=
is_slave
(
upper
)
?
c_ptr
->
highest_slave
:
c_ptr
->
highest_node
;
...
...
@@ -515,22 +515,22 @@ void cluster_multicast(struct cluster *c_ptr, struct sk_buff *buf,
tstop
=
upper
;
for
(
n_num
=
lower
;
n_num
<=
tstop
;
n_num
++
)
{
n_ptr
=
c_ptr
->
nodes
[
n_num
];
if
(
n_ptr
&&
node_has_active_links
(
n_ptr
))
{
if
(
n_ptr
&&
tipc_
node_has_active_links
(
n_ptr
))
{
buf_copy
=
skb_copy
(
buf
,
GFP_ATOMIC
);
if
(
buf_copy
==
NULL
)
break
;
msg_set_destnode
(
buf_msg
(
buf_copy
),
n_ptr
->
addr
);
link_send
(
buf_copy
,
n_ptr
->
addr
,
n_ptr
->
addr
);
tipc_
link_send
(
buf_copy
,
n_ptr
->
addr
,
n_ptr
->
addr
);
}
}
buf_discard
(
buf
);
}
/**
*
cluste
r_broadcast - broadcast message to all nodes within cluster
*
tipc_clt
r_broadcast - broadcast message to all nodes within cluster
*/
void
cluste
r_broadcast
(
struct
sk_buff
*
buf
)
void
tipc_clt
r_broadcast
(
struct
sk_buff
*
buf
)
{
struct
sk_buff
*
buf_copy
;
struct
cluster
*
c_ptr
;
...
...
@@ -541,7 +541,7 @@ void cluster_broadcast(struct sk_buff *buf)
u32
node_type
;
if
(
tipc_mode
==
TIPC_NET_MODE
)
{
c_ptr
=
cluste
r_find
(
tipc_own_addr
);
c_ptr
=
tipc_clt
r_find
(
tipc_own_addr
);
assert
(
in_own_cluster
(
c_ptr
->
addr
));
/* For now */
/* Send to standard nodes, then repeat loop sending to slaves */
...
...
@@ -550,13 +550,13 @@ void cluster_broadcast(struct sk_buff *buf)
for
(
node_type
=
1
;
node_type
<=
2
;
node_type
++
)
{
for
(
n_num
=
tstart
;
n_num
<=
tstop
;
n_num
++
)
{
n_ptr
=
c_ptr
->
nodes
[
n_num
];
if
(
n_ptr
&&
node_has_active_links
(
n_ptr
))
{
if
(
n_ptr
&&
tipc_
node_has_active_links
(
n_ptr
))
{
buf_copy
=
skb_copy
(
buf
,
GFP_ATOMIC
);
if
(
buf_copy
==
NULL
)
goto
exit
;
msg_set_destnode
(
buf_msg
(
buf_copy
),
n_ptr
->
addr
);
link_send
(
buf_copy
,
n_ptr
->
addr
,
tipc_
link_send
(
buf_copy
,
n_ptr
->
addr
,
n_ptr
->
addr
);
}
}
...
...
@@ -568,9 +568,9 @@ void cluster_broadcast(struct sk_buff *buf)
buf_discard
(
buf
);
}
int
cluste
r_init
(
void
)
int
tipc_clt
r_init
(
void
)
{
highest_allowed_slave
=
LOWEST_SLAVE
+
tipc_max_slaves
;
return
cluste
r_create
(
tipc_own_addr
)
?
TIPC_OK
:
-
ENOMEM
;
tipc_
highest_allowed_slave
=
LOWEST_SLAVE
+
tipc_max_slaves
;
return
tipc_clt
r_create
(
tipc_own_addr
)
?
TIPC_OK
:
-
ENOMEM
;
}
net/tipc/cluster.h
浏览文件 @
27a7b041
...
...
@@ -60,29 +60,29 @@ struct cluster {
};
extern
struct
node
**
local_nodes
;
extern
u32
highest_allowed_slave
;
extern
struct
node_map
cluste
r_bcast_nodes
;
extern
struct
node
**
tipc_
local_nodes
;
extern
u32
tipc_
highest_allowed_slave
;
extern
struct
node_map
tipc_clt
r_bcast_nodes
;
void
cluste
r_remove_as_router
(
struct
cluster
*
c_ptr
,
u32
router
);
void
cluste
r_send_ext_routes
(
struct
cluster
*
c_ptr
,
u32
dest
);
struct
node
*
cluste
r_select_node
(
struct
cluster
*
c_ptr
,
u32
selector
);
u32
cluste
r_select_router
(
struct
cluster
*
c_ptr
,
u32
ref
);
void
cluste
r_recv_routing_table
(
struct
sk_buff
*
buf
);
struct
cluster
*
cluste
r_create
(
u32
addr
);
void
cluste
r_delete
(
struct
cluster
*
c_ptr
);
void
cluste
r_attach_node
(
struct
cluster
*
c_ptr
,
struct
node
*
n_ptr
);
void
cluste
r_send_slave_routes
(
struct
cluster
*
c_ptr
,
u32
dest
);
void
cluste
r_broadcast
(
struct
sk_buff
*
buf
);
int
cluste
r_init
(
void
);
u32
cluste
r_next_node
(
struct
cluster
*
c_ptr
,
u32
addr
);
void
cluste
r_bcast_new_route
(
struct
cluster
*
c_ptr
,
u32
dest
,
u32
lo
,
u32
hi
);
void
cluste
r_send_local_routes
(
struct
cluster
*
c_ptr
,
u32
dest
);
void
cluste
r_bcast_lost_route
(
struct
cluster
*
c_ptr
,
u32
dest
,
u32
lo
,
u32
hi
);
void
tipc_clt
r_remove_as_router
(
struct
cluster
*
c_ptr
,
u32
router
);
void
tipc_clt
r_send_ext_routes
(
struct
cluster
*
c_ptr
,
u32
dest
);
struct
node
*
tipc_clt
r_select_node
(
struct
cluster
*
c_ptr
,
u32
selector
);
u32
tipc_clt
r_select_router
(
struct
cluster
*
c_ptr
,
u32
ref
);
void
tipc_clt
r_recv_routing_table
(
struct
sk_buff
*
buf
);
struct
cluster
*
tipc_clt
r_create
(
u32
addr
);
void
tipc_clt
r_delete
(
struct
cluster
*
c_ptr
);
void
tipc_clt
r_attach_node
(
struct
cluster
*
c_ptr
,
struct
node
*
n_ptr
);
void
tipc_clt
r_send_slave_routes
(
struct
cluster
*
c_ptr
,
u32
dest
);
void
tipc_clt
r_broadcast
(
struct
sk_buff
*
buf
);
int
tipc_clt
r_init
(
void
);
u32
tipc_clt
r_next_node
(
struct
cluster
*
c_ptr
,
u32
addr
);
void
tipc_clt
r_bcast_new_route
(
struct
cluster
*
c_ptr
,
u32
dest
,
u32
lo
,
u32
hi
);
void
tipc_clt
r_send_local_routes
(
struct
cluster
*
c_ptr
,
u32
dest
);
void
tipc_clt
r_bcast_lost_route
(
struct
cluster
*
c_ptr
,
u32
dest
,
u32
lo
,
u32
hi
);
static
inline
struct
cluster
*
cluste
r_find
(
u32
addr
)
static
inline
struct
cluster
*
tipc_clt
r_find
(
u32
addr
)
{
struct
_zone
*
z_ptr
=
zone_find
(
addr
);
struct
_zone
*
z_ptr
=
tipc_
zone_find
(
addr
);
if
(
z_ptr
)
return
z_ptr
->
clusters
[
1
];
...
...
net/tipc/config.c
浏览文件 @
27a7b041
...
...
@@ -70,13 +70,13 @@ static int req_tlv_space; /* request message TLV area size */
static
int
rep_headroom
;
/* reply message headroom to use */
void
cfg_link_event
(
u32
addr
,
char
*
name
,
int
up
)
void
tipc_
cfg_link_event
(
u32
addr
,
char
*
name
,
int
up
)
{
/* TIPC DOESN'T HANDLE LINK EVENT SUBSCRIPTIONS AT THE MOMENT */
}
struct
sk_buff
*
cfg_reply_alloc
(
int
payload_size
)
struct
sk_buff
*
tipc_
cfg_reply_alloc
(
int
payload_size
)
{
struct
sk_buff
*
buf
;
...
...
@@ -86,14 +86,14 @@ struct sk_buff *cfg_reply_alloc(int payload_size)
return
buf
;
}
int
cfg_append_tlv
(
struct
sk_buff
*
buf
,
int
tlv_type
,
int
tipc_
cfg_append_tlv
(
struct
sk_buff
*
buf
,
int
tlv_type
,
void
*
tlv_data
,
int
tlv_data_size
)
{
struct
tlv_desc
*
tlv
=
(
struct
tlv_desc
*
)
buf
->
tail
;
int
new_tlv_space
=
TLV_SPACE
(
tlv_data_size
);
if
(
skb_tailroom
(
buf
)
<
new_tlv_space
)
{
dbg
(
"cfg_append_tlv unable to append TLV
\n
"
);
dbg
(
"
tipc_
cfg_append_tlv unable to append TLV
\n
"
);
return
0
;
}
skb_put
(
buf
,
new_tlv_space
);
...
...
@@ -104,28 +104,28 @@ int cfg_append_tlv(struct sk_buff *buf, int tlv_type,
return
1
;
}
struct
sk_buff
*
cfg_reply_unsigned_type
(
u16
tlv_type
,
u32
value
)
struct
sk_buff
*
tipc_
cfg_reply_unsigned_type
(
u16
tlv_type
,
u32
value
)
{
struct
sk_buff
*
buf
;
u32
value_net
;
buf
=
cfg_reply_alloc
(
TLV_SPACE
(
sizeof
(
value
)));
buf
=
tipc_
cfg_reply_alloc
(
TLV_SPACE
(
sizeof
(
value
)));
if
(
buf
)
{
value_net
=
htonl
(
value
);
cfg_append_tlv
(
buf
,
tlv_type
,
&
value_net
,
tipc_
cfg_append_tlv
(
buf
,
tlv_type
,
&
value_net
,
sizeof
(
value_net
));
}
return
buf
;
}
struct
sk_buff
*
cfg_reply_string_type
(
u16
tlv_type
,
char
*
string
)
struct
sk_buff
*
tipc_
cfg_reply_string_type
(
u16
tlv_type
,
char
*
string
)
{
struct
sk_buff
*
buf
;
int
string_len
=
strlen
(
string
)
+
1
;
buf
=
cfg_reply_alloc
(
TLV_SPACE
(
string_len
));
buf
=
tipc_
cfg_reply_alloc
(
TLV_SPACE
(
string_len
));
if
(
buf
)
cfg_append_tlv
(
buf
,
tlv_type
,
string
,
string_len
);
tipc_
cfg_append_tlv
(
buf
,
tlv_type
,
string
,
string_len
);
return
buf
;
}
...
...
@@ -246,7 +246,7 @@ static void cfg_cmd_event(struct tipc_cmd_msg *msg,
exit:
rmsg.result_len = htonl(msg_sect[1].iov_len);
rmsg.retval = htonl(rv);
cfg_respond(msg_sect, 2u, orig);
tipc_
cfg_respond(msg_sect, 2u, orig);
}
#endif
...
...
@@ -255,26 +255,26 @@ static struct sk_buff *cfg_enable_bearer(void)
struct
tipc_bearer_config
*
args
;
if
(
!
TLV_CHECK
(
req_tlv_area
,
req_tlv_space
,
TIPC_TLV_BEARER_CONFIG
))
return
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
args
=
(
struct
tipc_bearer_config
*
)
TLV_DATA
(
req_tlv_area
);
if
(
tipc_enable_bearer
(
args
->
name
,
ntohl
(
args
->
detect_scope
),
ntohl
(
args
->
priority
)))
return
cfg_reply_error_string
(
"unable to enable bearer"
);
return
tipc_
cfg_reply_error_string
(
"unable to enable bearer"
);
return
cfg_reply_none
();
return
tipc_
cfg_reply_none
();
}
static
struct
sk_buff
*
cfg_disable_bearer
(
void
)
{
if
(
!
TLV_CHECK
(
req_tlv_area
,
req_tlv_space
,
TIPC_TLV_BEARER_NAME
))
return
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
if
(
tipc_disable_bearer
((
char
*
)
TLV_DATA
(
req_tlv_area
)))
return
cfg_reply_error_string
(
"unable to disable bearer"
);
return
tipc_
cfg_reply_error_string
(
"unable to disable bearer"
);
return
cfg_reply_none
();
return
tipc_
cfg_reply_none
();
}
static
struct
sk_buff
*
cfg_set_own_addr
(
void
)
...
...
@@ -282,25 +282,25 @@ static struct sk_buff *cfg_set_own_addr(void)
u32
addr
;
if
(
!
TLV_CHECK
(
req_tlv_area
,
req_tlv_space
,
TIPC_TLV_NET_ADDR
))
return
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
addr
=
*
(
u32
*
)
TLV_DATA
(
req_tlv_area
);
addr
=
ntohl
(
addr
);
if
(
addr
==
tipc_own_addr
)
return
cfg_reply_none
();
if
(
!
addr_node_valid
(
addr
))
return
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
return
tipc_
cfg_reply_none
();
if
(
!
tipc_
addr_node_valid
(
addr
))
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
" (node address)"
);
if
(
tipc_own_addr
)
return
cfg_reply_error_string
(
TIPC_CFG_NOT_SUPPORTED
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_NOT_SUPPORTED
" (cannot change node address once assigned)"
);
spin_unlock_bh
(
&
config_lock
);
stop_net
();
tipc_core_
stop_net
();
tipc_own_addr
=
addr
;
start_net
();
tipc_core_
start_net
();
spin_lock_bh
(
&
config_lock
);
return
cfg_reply_none
();
return
tipc_
cfg_reply_none
();
}
static
struct
sk_buff
*
cfg_set_remote_mng
(
void
)
...
...
@@ -308,12 +308,12 @@ static struct sk_buff *cfg_set_remote_mng(void)
u32
value
;
if
(
!
TLV_CHECK
(
req_tlv_area
,
req_tlv_space
,
TIPC_TLV_UNSIGNED
))
return
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
value
=
*
(
u32
*
)
TLV_DATA
(
req_tlv_area
);
value
=
ntohl
(
value
);
tipc_remote_management
=
(
value
!=
0
);
return
cfg_reply_none
();
return
tipc_
cfg_reply_none
();
}
static
struct
sk_buff
*
cfg_set_max_publications
(
void
)
...
...
@@ -321,15 +321,15 @@ static struct sk_buff *cfg_set_max_publications(void)
u32
value
;
if
(
!
TLV_CHECK
(
req_tlv_area
,
req_tlv_space
,
TIPC_TLV_UNSIGNED
))
return
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
value
=
*
(
u32
*
)
TLV_DATA
(
req_tlv_area
);
value
=
ntohl
(
value
);
if
(
value
!=
delimit
(
value
,
1
,
65535
))
return
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
" (max publications must be 1-65535)"
);
tipc_max_publications
=
value
;
return
cfg_reply_none
();
return
tipc_
cfg_reply_none
();
}
static
struct
sk_buff
*
cfg_set_max_subscriptions
(
void
)
...
...
@@ -337,15 +337,15 @@ static struct sk_buff *cfg_set_max_subscriptions(void)
u32
value
;
if
(
!
TLV_CHECK
(
req_tlv_area
,
req_tlv_space
,
TIPC_TLV_UNSIGNED
))
return
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
value
=
*
(
u32
*
)
TLV_DATA
(
req_tlv_area
);
value
=
ntohl
(
value
);
if
(
value
!=
delimit
(
value
,
1
,
65535
))
return
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
" (max subscriptions must be 1-65535"
);
tipc_max_subscriptions
=
value
;
return
cfg_reply_none
();
return
tipc_
cfg_reply_none
();
}
static
struct
sk_buff
*
cfg_set_max_ports
(
void
)
...
...
@@ -354,31 +354,31 @@ static struct sk_buff *cfg_set_max_ports(void)
u32
value
;
if
(
!
TLV_CHECK
(
req_tlv_area
,
req_tlv_space
,
TIPC_TLV_UNSIGNED
))
return
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
value
=
*
(
u32
*
)
TLV_DATA
(
req_tlv_area
);
value
=
ntohl
(
value
);
if
(
value
!=
delimit
(
value
,
127
,
65535
))
return
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
" (max ports must be 127-65535)"
);
if
(
value
==
tipc_max_ports
)
return
cfg_reply_none
();
return
tipc_
cfg_reply_none
();
if
(
atomic_read
(
&
tipc_user_count
)
>
2
)
return
cfg_reply_error_string
(
TIPC_CFG_NOT_SUPPORTED
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_NOT_SUPPORTED
" (cannot change max ports while TIPC users exist)"
);
spin_unlock_bh
(
&
config_lock
);
orig_mode
=
tipc_get_mode
();
if
(
orig_mode
==
TIPC_NET_MODE
)
stop_net
();
stop_core
();
tipc_core_
stop_net
();
tipc_core_stop
();
tipc_max_ports
=
value
;
start_core
();
tipc_core_start
();
if
(
orig_mode
==
TIPC_NET_MODE
)
start_net
();
tipc_core_
start_net
();
spin_lock_bh
(
&
config_lock
);
return
cfg_reply_none
();
return
tipc_
cfg_reply_none
();
}
static
struct
sk_buff
*
set_net_max
(
int
value
,
int
*
parameter
)
...
...
@@ -388,13 +388,13 @@ static struct sk_buff *set_net_max(int value, int *parameter)
if
(
value
!=
*
parameter
)
{
orig_mode
=
tipc_get_mode
();
if
(
orig_mode
==
TIPC_NET_MODE
)
stop_net
();
tipc_core_
stop_net
();
*
parameter
=
value
;
if
(
orig_mode
==
TIPC_NET_MODE
)
start_net
();
tipc_core_
start_net
();
}
return
cfg_reply_none
();
return
tipc_
cfg_reply_none
();
}
static
struct
sk_buff
*
cfg_set_max_zones
(
void
)
...
...
@@ -402,11 +402,11 @@ static struct sk_buff *cfg_set_max_zones(void)
u32
value
;
if
(
!
TLV_CHECK
(
req_tlv_area
,
req_tlv_space
,
TIPC_TLV_UNSIGNED
))
return
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
value
=
*
(
u32
*
)
TLV_DATA
(
req_tlv_area
);
value
=
ntohl
(
value
);
if
(
value
!=
delimit
(
value
,
1
,
255
))
return
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
" (max zones must be 1-255)"
);
return
set_net_max
(
value
,
&
tipc_max_zones
);
}
...
...
@@ -416,13 +416,13 @@ static struct sk_buff *cfg_set_max_clusters(void)
u32
value
;
if
(
!
TLV_CHECK
(
req_tlv_area
,
req_tlv_space
,
TIPC_TLV_UNSIGNED
))
return
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
value
=
*
(
u32
*
)
TLV_DATA
(
req_tlv_area
);
value
=
ntohl
(
value
);
if
(
value
!=
1
)
return
cfg_reply_error_string
(
TIPC_CFG_NOT_SUPPORTED
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_NOT_SUPPORTED
" (max clusters fixed at 1)"
);
return
cfg_reply_none
();
return
tipc_
cfg_reply_none
();
}
static
struct
sk_buff
*
cfg_set_max_nodes
(
void
)
...
...
@@ -430,11 +430,11 @@ static struct sk_buff *cfg_set_max_nodes(void)
u32
value
;
if
(
!
TLV_CHECK
(
req_tlv_area
,
req_tlv_space
,
TIPC_TLV_UNSIGNED
))
return
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
value
=
*
(
u32
*
)
TLV_DATA
(
req_tlv_area
);
value
=
ntohl
(
value
);
if
(
value
!=
delimit
(
value
,
8
,
2047
))
return
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
" (max nodes must be 8-2047)"
);
return
set_net_max
(
value
,
&
tipc_max_nodes
);
}
...
...
@@ -444,13 +444,13 @@ static struct sk_buff *cfg_set_max_slaves(void)
u32
value
;
if
(
!
TLV_CHECK
(
req_tlv_area
,
req_tlv_space
,
TIPC_TLV_UNSIGNED
))
return
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
value
=
*
(
u32
*
)
TLV_DATA
(
req_tlv_area
);
value
=
ntohl
(
value
);
if
(
value
!=
0
)
return
cfg_reply_error_string
(
TIPC_CFG_NOT_SUPPORTED
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_NOT_SUPPORTED
" (max secondary nodes fixed at 0)"
);
return
cfg_reply_none
();
return
tipc_
cfg_reply_none
();
}
static
struct
sk_buff
*
cfg_set_netid
(
void
)
...
...
@@ -458,21 +458,21 @@ static struct sk_buff *cfg_set_netid(void)
u32
value
;
if
(
!
TLV_CHECK
(
req_tlv_area
,
req_tlv_space
,
TIPC_TLV_UNSIGNED
))
return
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
value
=
*
(
u32
*
)
TLV_DATA
(
req_tlv_area
);
value
=
ntohl
(
value
);
if
(
value
!=
delimit
(
value
,
1
,
9999
))
return
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
" (network id must be 1-9999)"
);
if
(
tipc_own_addr
)
return
cfg_reply_error_string
(
TIPC_CFG_NOT_SUPPORTED
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_NOT_SUPPORTED
" (cannot change network id once part of network)"
);
return
set_net_max
(
value
,
&
tipc_net_id
);
}
struct
sk_buff
*
cfg_do_cmd
(
u32
orig_node
,
u16
cmd
,
const
void
*
request_area
,
struct
sk_buff
*
tipc_
cfg_do_cmd
(
u32
orig_node
,
u16
cmd
,
const
void
*
request_area
,
int
request_space
,
int
reply_headroom
)
{
struct
sk_buff
*
rep_tlv_buf
;
...
...
@@ -490,19 +490,19 @@ struct sk_buff *cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area,
if
(
likely
(
orig_node
==
tipc_own_addr
))
{
/* command is permitted */
}
else
if
(
cmd
>=
0x8000
)
{
rep_tlv_buf
=
cfg_reply_error_string
(
TIPC_CFG_NOT_SUPPORTED
rep_tlv_buf
=
tipc_
cfg_reply_error_string
(
TIPC_CFG_NOT_SUPPORTED
" (cannot be done remotely)"
);
goto
exit
;
}
else
if
(
!
tipc_remote_management
)
{
rep_tlv_buf
=
cfg_reply_error_string
(
TIPC_CFG_NO_REMOTE
);
rep_tlv_buf
=
tipc_
cfg_reply_error_string
(
TIPC_CFG_NO_REMOTE
);
goto
exit
;
}
else
if
(
cmd
>=
0x4000
)
{
u32
domain
=
0
;
if
((
nametbl_translate
(
TIPC_ZM_SRV
,
0
,
&
domain
)
==
0
)
||
if
((
tipc_
nametbl_translate
(
TIPC_ZM_SRV
,
0
,
&
domain
)
==
0
)
||
(
domain
!=
orig_node
))
{
rep_tlv_buf
=
cfg_reply_error_string
(
TIPC_CFG_NOT_ZONE_MSTR
);
rep_tlv_buf
=
tipc_
cfg_reply_error_string
(
TIPC_CFG_NOT_ZONE_MSTR
);
goto
exit
;
}
}
...
...
@@ -511,50 +511,50 @@ struct sk_buff *cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area,
switch
(
cmd
)
{
case
TIPC_CMD_NOOP
:
rep_tlv_buf
=
cfg_reply_none
();
rep_tlv_buf
=
tipc_
cfg_reply_none
();
break
;
case
TIPC_CMD_GET_NODES
:
rep_tlv_buf
=
node_get_nodes
(
req_tlv_area
,
req_tlv_space
);
rep_tlv_buf
=
tipc_
node_get_nodes
(
req_tlv_area
,
req_tlv_space
);
break
;
case
TIPC_CMD_GET_LINKS
:
rep_tlv_buf
=
node_get_links
(
req_tlv_area
,
req_tlv_space
);
rep_tlv_buf
=
tipc_
node_get_links
(
req_tlv_area
,
req_tlv_space
);
break
;
case
TIPC_CMD_SHOW_LINK_STATS
:
rep_tlv_buf
=
link_cmd_show_stats
(
req_tlv_area
,
req_tlv_space
);
rep_tlv_buf
=
tipc_
link_cmd_show_stats
(
req_tlv_area
,
req_tlv_space
);
break
;
case
TIPC_CMD_RESET_LINK_STATS
:
rep_tlv_buf
=
link_cmd_reset_stats
(
req_tlv_area
,
req_tlv_space
);
rep_tlv_buf
=
tipc_
link_cmd_reset_stats
(
req_tlv_area
,
req_tlv_space
);
break
;
case
TIPC_CMD_SHOW_NAME_TABLE
:
rep_tlv_buf
=
nametbl_get
(
req_tlv_area
,
req_tlv_space
);
rep_tlv_buf
=
tipc_
nametbl_get
(
req_tlv_area
,
req_tlv_space
);
break
;
case
TIPC_CMD_GET_BEARER_NAMES
:
rep_tlv_buf
=
bearer_get_names
();
rep_tlv_buf
=
tipc_
bearer_get_names
();
break
;
case
TIPC_CMD_GET_MEDIA_NAMES
:
rep_tlv_buf
=
media_get_names
();
rep_tlv_buf
=
tipc_
media_get_names
();
break
;
case
TIPC_CMD_SHOW_PORTS
:
rep_tlv_buf
=
port_get_ports
();
rep_tlv_buf
=
tipc_
port_get_ports
();
break
;
#if 0
case TIPC_CMD_SHOW_PORT_STATS:
rep_tlv_buf = port_show_stats(req_tlv_area, req_tlv_space);
break;
case TIPC_CMD_RESET_PORT_STATS:
rep_tlv_buf = cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED);
rep_tlv_buf =
tipc_
cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED);
break;
#endif
case
TIPC_CMD_SET_LOG_SIZE
:
rep_tlv_buf
=
log_resize
(
req_tlv_area
,
req_tlv_space
);
rep_tlv_buf
=
tipc_
log_resize
(
req_tlv_area
,
req_tlv_space
);
break
;
case
TIPC_CMD_DUMP_LOG
:
rep_tlv_buf
=
log_dump
();
rep_tlv_buf
=
tipc_
log_dump
();
break
;
case
TIPC_CMD_SET_LINK_TOL
:
case
TIPC_CMD_SET_LINK_PRI
:
case
TIPC_CMD_SET_LINK_WINDOW
:
rep_tlv_buf
=
link_cmd_config
(
req_tlv_area
,
req_tlv_space
,
cmd
);
rep_tlv_buf
=
tipc_
link_cmd_config
(
req_tlv_area
,
req_tlv_space
,
cmd
);
break
;
case
TIPC_CMD_ENABLE_BEARER
:
rep_tlv_buf
=
cfg_enable_bearer
();
...
...
@@ -593,31 +593,31 @@ struct sk_buff *cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area,
rep_tlv_buf
=
cfg_set_netid
();
break
;
case
TIPC_CMD_GET_REMOTE_MNG
:
rep_tlv_buf
=
cfg_reply_unsigned
(
tipc_remote_management
);
rep_tlv_buf
=
tipc_
cfg_reply_unsigned
(
tipc_remote_management
);
break
;
case
TIPC_CMD_GET_MAX_PORTS
:
rep_tlv_buf
=
cfg_reply_unsigned
(
tipc_max_ports
);
rep_tlv_buf
=
tipc_
cfg_reply_unsigned
(
tipc_max_ports
);
break
;
case
TIPC_CMD_GET_MAX_PUBL
:
rep_tlv_buf
=
cfg_reply_unsigned
(
tipc_max_publications
);
rep_tlv_buf
=
tipc_
cfg_reply_unsigned
(
tipc_max_publications
);
break
;
case
TIPC_CMD_GET_MAX_SUBSCR
:
rep_tlv_buf
=
cfg_reply_unsigned
(
tipc_max_subscriptions
);
rep_tlv_buf
=
tipc_
cfg_reply_unsigned
(
tipc_max_subscriptions
);
break
;
case
TIPC_CMD_GET_MAX_ZONES
:
rep_tlv_buf
=
cfg_reply_unsigned
(
tipc_max_zones
);
rep_tlv_buf
=
tipc_
cfg_reply_unsigned
(
tipc_max_zones
);
break
;
case
TIPC_CMD_GET_MAX_CLUSTERS
:
rep_tlv_buf
=
cfg_reply_unsigned
(
tipc_max_clusters
);
rep_tlv_buf
=
tipc_
cfg_reply_unsigned
(
tipc_max_clusters
);
break
;
case
TIPC_CMD_GET_MAX_NODES
:
rep_tlv_buf
=
cfg_reply_unsigned
(
tipc_max_nodes
);
rep_tlv_buf
=
tipc_
cfg_reply_unsigned
(
tipc_max_nodes
);
break
;
case
TIPC_CMD_GET_MAX_SLAVES
:
rep_tlv_buf
=
cfg_reply_unsigned
(
tipc_max_slaves
);
rep_tlv_buf
=
tipc_
cfg_reply_unsigned
(
tipc_max_slaves
);
break
;
case
TIPC_CMD_GET_NETID
:
rep_tlv_buf
=
cfg_reply_unsigned
(
tipc_net_id
);
rep_tlv_buf
=
tipc_
cfg_reply_unsigned
(
tipc_net_id
);
break
;
default:
rep_tlv_buf
=
NULL
;
...
...
@@ -655,7 +655,7 @@ static void cfg_named_msg_event(void *userdata,
/* Generate reply for request (if can't, return request) */
rep_buf
=
cfg_do_cmd
(
orig
->
node
,
rep_buf
=
tipc_
cfg_do_cmd
(
orig
->
node
,
ntohs
(
req_hdr
->
tcm_type
),
msg
+
sizeof
(
*
req_hdr
),
size
-
sizeof
(
*
req_hdr
),
...
...
@@ -675,7 +675,7 @@ static void cfg_named_msg_event(void *userdata,
tipc_send_buf2port
(
port_ref
,
orig
,
rep_buf
,
rep_buf
->
len
);
}
int
cfg_init
(
void
)
int
tipc_
cfg_init
(
void
)
{
struct
tipc_name_seq
seq
;
int
res
;
...
...
@@ -696,7 +696,7 @@ int cfg_init(void)
seq
.
type
=
TIPC_CFG_SRV
;
seq
.
lower
=
seq
.
upper
=
tipc_own_addr
;
res
=
nametbl_publish_rsv
(
mng
.
port_ref
,
TIPC_ZONE_SCOPE
,
&
seq
);
res
=
tipc_
nametbl_publish_rsv
(
mng
.
port_ref
,
TIPC_ZONE_SCOPE
,
&
seq
);
if
(
res
)
goto
failed
;
...
...
@@ -709,7 +709,7 @@ int cfg_init(void)
return
res
;
}
void
cfg_stop
(
void
)
void
tipc_
cfg_stop
(
void
)
{
if
(
mng
.
user_ref
)
{
tipc_detach
(
mng
.
user_ref
);
...
...
net/tipc/config.h
浏览文件 @
27a7b041
...
...
@@ -39,42 +39,41 @@
/* ---------------------------------------------------------------------- */
#include <linux/tipc.h>
#include <linux/tipc_config.h>
#include "core.h"
#include "link.h"
struct
sk_buff
*
cfg_reply_alloc
(
int
payload_size
);
int
cfg_append_tlv
(
struct
sk_buff
*
buf
,
int
tlv_type
,
struct
sk_buff
*
tipc_
cfg_reply_alloc
(
int
payload_size
);
int
tipc_
cfg_append_tlv
(
struct
sk_buff
*
buf
,
int
tlv_type
,
void
*
tlv_data
,
int
tlv_data_size
);
struct
sk_buff
*
cfg_reply_unsigned_type
(
u16
tlv_type
,
u32
value
);
struct
sk_buff
*
cfg_reply_string_type
(
u16
tlv_type
,
char
*
string
);
struct
sk_buff
*
tipc_
cfg_reply_unsigned_type
(
u16
tlv_type
,
u32
value
);
struct
sk_buff
*
tipc_
cfg_reply_string_type
(
u16
tlv_type
,
char
*
string
);
static
inline
struct
sk_buff
*
cfg_reply_none
(
void
)
static
inline
struct
sk_buff
*
tipc_
cfg_reply_none
(
void
)
{
return
cfg_reply_alloc
(
0
);
return
tipc_
cfg_reply_alloc
(
0
);
}
static
inline
struct
sk_buff
*
cfg_reply_unsigned
(
u32
value
)
static
inline
struct
sk_buff
*
tipc_
cfg_reply_unsigned
(
u32
value
)
{
return
cfg_reply_unsigned_type
(
TIPC_TLV_UNSIGNED
,
value
);
return
tipc_
cfg_reply_unsigned_type
(
TIPC_TLV_UNSIGNED
,
value
);
}
static
inline
struct
sk_buff
*
cfg_reply_error_string
(
char
*
string
)
static
inline
struct
sk_buff
*
tipc_
cfg_reply_error_string
(
char
*
string
)
{
return
cfg_reply_string_type
(
TIPC_TLV_ERROR_STRING
,
string
);
return
tipc_
cfg_reply_string_type
(
TIPC_TLV_ERROR_STRING
,
string
);
}
static
inline
struct
sk_buff
*
cfg_reply_ultra_string
(
char
*
string
)
static
inline
struct
sk_buff
*
tipc_
cfg_reply_ultra_string
(
char
*
string
)
{
return
cfg_reply_string_type
(
TIPC_TLV_ULTRA_STRING
,
string
);
return
tipc_
cfg_reply_string_type
(
TIPC_TLV_ULTRA_STRING
,
string
);
}
struct
sk_buff
*
cfg_do_cmd
(
u32
orig_node
,
u16
cmd
,
struct
sk_buff
*
tipc_
cfg_do_cmd
(
u32
orig_node
,
u16
cmd
,
const
void
*
req_tlv_area
,
int
req_tlv_space
,
int
headroom
);
void
cfg_link_event
(
u32
addr
,
char
*
name
,
int
up
);
int
cfg_init
(
void
);
void
cfg_stop
(
void
);
void
tipc_
cfg_link_event
(
u32
addr
,
char
*
name
,
int
up
);
int
tipc_
cfg_init
(
void
);
void
tipc_
cfg_stop
(
void
);
#endif
net/tipc/core.c
浏览文件 @
27a7b041
...
...
@@ -37,7 +37,6 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/random.h>
#include "core.h"
...
...
@@ -49,14 +48,14 @@
#include "subscr.h"
#include "config.h"
int
eth_media_start
(
void
);
void
eth_media_stop
(
void
);
int
handler_start
(
void
);
void
handler_stop
(
void
);
int
socket_init
(
void
);
void
socket_stop
(
void
);
int
netlink_start
(
void
);
void
netlink_stop
(
void
);
int
tipc_
eth_media_start
(
void
);
void
tipc_
eth_media_stop
(
void
);
int
tipc_
handler_start
(
void
);
void
tipc_
handler_stop
(
void
);
int
tipc_
socket_init
(
void
);
void
tipc_
socket_stop
(
void
);
int
tipc_
netlink_start
(
void
);
void
tipc_
netlink_stop
(
void
);
#define MOD_NAME "tipc_start: "
...
...
@@ -113,56 +112,56 @@ int tipc_get_mode(void)
}
/**
* stop_net - shut down TIPC networking sub-systems
*
tipc_core_
stop_net - shut down TIPC networking sub-systems
*/
void
stop_net
(
void
)
void
tipc_core_
stop_net
(
void
)
{
eth_media_stop
();
tipc_
stop_net
();
tipc_
eth_media_stop
();
tipc_
net_stop
();
}
/**
* start_net - start TIPC networking sub-systems
*/
int
start_net
(
void
)
int
tipc_core_
start_net
(
void
)
{
int
res
;
if
((
res
=
tipc_
start_ne
t
())
||
(
res
=
eth_media_start
()))
{
stop_net
();
if
((
res
=
tipc_
net_star
t
())
||
(
res
=
tipc_
eth_media_start
()))
{
tipc_core_
stop_net
();
}
return
res
;
}
/**
*
stop_core
- switch TIPC from SINGLE NODE to NOT RUNNING mode
*
tipc_core_stop
- switch TIPC from SINGLE NODE to NOT RUNNING mode
*/
void
stop_core
(
void
)
void
tipc_core_stop
(
void
)
{
if
(
tipc_mode
!=
TIPC_NODE_MODE
)
return
;
tipc_mode
=
TIPC_NOT_RUNNING
;
netlink_stop
();
handler_stop
();
cfg_stop
();
subscr_stop
();
reg_stop
();
nametbl_stop
();
ref_table_stop
();
socket_stop
();
tipc_
netlink_stop
();
tipc_
handler_stop
();
tipc_
cfg_stop
();
tipc_
subscr_stop
();
tipc_
reg_stop
();
tipc_
nametbl_stop
();
tipc_
ref_table_stop
();
tipc_
socket_stop
();
}
/**
*
start_core
- switch TIPC from NOT RUNNING to SINGLE NODE mode
*
tipc_core_start
- switch TIPC from NOT RUNNING to SINGLE NODE mode
*/
int
start_core
(
void
)
int
tipc_core_start
(
void
)
{
int
res
;
...
...
@@ -172,16 +171,16 @@ int start_core(void)
get_random_bytes
(
&
tipc_random
,
sizeof
(
tipc_random
));
tipc_mode
=
TIPC_NODE_MODE
;
if
((
res
=
handler_start
())
||
(
res
=
ref_table_init
(
tipc_max_ports
+
tipc_max_subscriptions
,
if
((
res
=
tipc_
handler_start
())
||
(
res
=
tipc_
ref_table_init
(
tipc_max_ports
+
tipc_max_subscriptions
,
tipc_random
))
||
(
res
=
reg_start
())
||
(
res
=
nametbl_init
())
||
(
res
=
k_signal
((
Handler
)
subscr_start
,
0
))
||
(
res
=
k_signal
((
Handler
)
cfg_init
,
0
))
||
(
res
=
netlink_start
())
||
(
res
=
socket_init
()))
{
stop_core
();
(
res
=
tipc_
reg_start
())
||
(
res
=
tipc_
nametbl_init
())
||
(
res
=
tipc_k_signal
((
Handler
)
tipc_
subscr_start
,
0
))
||
(
res
=
tipc_k_signal
((
Handler
)
tipc_
cfg_init
,
0
))
||
(
res
=
tipc_
netlink_start
())
||
(
res
=
tipc_
socket_init
()))
{
tipc_core_stop
();
}
return
res
;
}
...
...
@@ -191,7 +190,7 @@ static int __init tipc_init(void)
{
int
res
;
log_reinit
(
CONFIG_TIPC_LOG
);
tipc_
log_reinit
(
CONFIG_TIPC_LOG
);
info
(
"Activated (compiled "
__DATE__
" "
__TIME__
")
\n
"
);
tipc_own_addr
=
0
;
...
...
@@ -205,7 +204,7 @@ static int __init tipc_init(void)
tipc_max_slaves
=
delimit
(
CONFIG_TIPC_SLAVE_NODES
,
0
,
2047
);
tipc_net_id
=
4711
;
if
((
res
=
start_core
()))
if
((
res
=
tipc_core_start
()))
err
(
"Unable to start in single node mode
\n
"
);
else
info
(
"Started in single node mode
\n
"
);
...
...
@@ -214,10 +213,10 @@ static int __init tipc_init(void)
static
void
__exit
tipc_exit
(
void
)
{
stop_net
();
stop_core
();
tipc_core_
stop_net
();
tipc_core_stop
();
info
(
"Deactivated
\n
"
);
log_stop
();
tipc_
log_stop
();
}
module_init
(
tipc_init
);
...
...
net/tipc/core.h
浏览文件 @
27a7b041
...
...
@@ -37,6 +37,11 @@
#ifndef _TIPC_CORE_H
#define _TIPC_CORE_H
#include <linux/tipc.h>
#include <linux/tipc_config.h>
#include <net/tipc/tipc_msg.h>
#include <net/tipc/tipc_port.h>
#include <net/tipc/tipc_bearer.h>
#include <net/tipc/tipc.h>
#include <linux/types.h>
#include <linux/kernel.h>
...
...
@@ -60,9 +65,9 @@
#define assert(i) BUG_ON(!(i))
struct
tipc_msg
;
extern
struct
print_buf
*
CONS
,
*
LOG
;
extern
struct
print_buf
*
TEE
(
struct
print_buf
*
,
struct
print_buf
*
);
void
msg_print
(
struct
print_buf
*
,
struct
tipc_msg
*
,
const
char
*
);
extern
struct
print_buf
*
TIPC_CONS
,
*
TIPC_
LOG
;
extern
struct
print_buf
*
T
IPC_T
EE
(
struct
print_buf
*
,
struct
print_buf
*
);
void
tipc_
msg_print
(
struct
print_buf
*
,
struct
tipc_msg
*
,
const
char
*
);
void
tipc_printf
(
struct
print_buf
*
,
const
char
*
fmt
,
...);
void
tipc_dump
(
struct
print_buf
*
,
const
char
*
fmt
,
...);
...
...
@@ -79,7 +84,7 @@ void tipc_dump(struct print_buf*,const char *fmt, ...);
#define info(fmt, arg...) tipc_printf(TIPC_OUTPUT, KERN_NOTICE "TIPC: " fmt, ## arg)
#define dbg(fmt, arg...) do {if (DBG_OUTPUT) tipc_printf(DBG_OUTPUT, fmt, ## arg);} while(0)
#define msg_dbg(msg, txt) do {if (DBG_OUTPUT) msg_print(DBG_OUTPUT, msg, txt);} while(0)
#define msg_dbg(msg, txt) do {if (DBG_OUTPUT)
tipc_
msg_print(DBG_OUTPUT, msg, txt);} while(0)
#define dump(fmt, arg...) do {if (DBG_OUTPUT) tipc_dump(DBG_OUTPUT, fmt, ##arg);} while(0)
...
...
@@ -90,14 +95,14 @@ void tipc_dump(struct print_buf*,const char *fmt, ...);
* print buffer options are available:
*
* NULL : Output to null print buffer (i.e. print nowhere)
* CONS : Output to system console
* LOG : Output to TIPC log buffer
*
TIPC_
CONS : Output to system console
*
TIPC_
LOG : Output to TIPC log buffer
* &buf : Output to user-defined buffer (struct print_buf *)
* T
EE(&buf_a,&buf_b) : Output to two print buffers (eg. TEE(CONS,
LOG) )
* T
IPC_TEE(&buf_a,&buf_b) : Output to two print buffers (eg. TIPC_TEE(TIPC_CONS,TIPC_
LOG) )
*/
#ifndef TIPC_OUTPUT
#define TIPC_OUTPUT T
EE(CONS,
LOG)
#define TIPC_OUTPUT T
IPC_TEE(TIPC_CONS,TIPC_
LOG)
#endif
#ifndef DBG_OUTPUT
...
...
@@ -162,10 +167,10 @@ extern atomic_t tipc_user_count;
* Routines available to privileged subsystems
*/
extern
int
start_core
(
void
);
extern
void
stop_core
(
void
);
extern
int
start_net
(
void
);
extern
void
stop_net
(
void
);
extern
int
tipc_core_start
(
void
);
extern
void
tipc_core_stop
(
void
);
extern
int
tipc_core_
start_net
(
void
);
extern
void
tipc_core_
stop_net
(
void
);
static
inline
int
delimit
(
int
val
,
int
min
,
int
max
)
{
...
...
@@ -183,7 +188,7 @@ static inline int delimit(int val, int min, int max)
typedef
void
(
*
Handler
)
(
unsigned
long
);
u32
k_signal
(
Handler
routine
,
unsigned
long
argument
);
u32
tipc_
k_signal
(
Handler
routine
,
unsigned
long
argument
);
/**
* k_init_timer - initialize a timer
...
...
net/tipc/dbg.c
浏览文件 @
27a7b041
...
...
@@ -44,10 +44,10 @@ static char print_string[MAX_STRING];
static
spinlock_t
print_lock
=
SPIN_LOCK_UNLOCKED
;
static
struct
print_buf
cons_buf
=
{
NULL
,
0
,
NULL
,
NULL
};
struct
print_buf
*
CONS
=
&
cons_buf
;
struct
print_buf
*
TIPC_
CONS
=
&
cons_buf
;
static
struct
print_buf
log_buf
=
{
NULL
,
0
,
NULL
,
NULL
};
struct
print_buf
*
LOG
=
&
log_buf
;
struct
print_buf
*
TIPC_
LOG
=
&
log_buf
;
#define FORMAT(PTR,LEN,FMT) \
...
...
@@ -66,15 +66,15 @@ struct print_buf *LOG = &log_buf;
* simultaneous use of the print buffer(s) being manipulated.
* 2) tipc_printf() uses 'print_lock' to prevent simultaneous use of
* 'print_string' and to protect its print buffer(s).
* 3) TEE() uses 'print_lock' to protect its print buffer(s).
* 4) Routines of the form log_XXX() uses 'print_lock' to protect LOG.
* 3) T
IPC_T
EE() uses 'print_lock' to protect its print buffer(s).
* 4) Routines of the form log_XXX() uses 'print_lock' to protect
TIPC_
LOG.
*/
/**
* printbuf_init - initialize print buffer to empty
*
tipc_
printbuf_init - initialize print buffer to empty
*/
void
printbuf_init
(
struct
print_buf
*
pb
,
char
*
raw
,
u32
sz
)
void
tipc_
printbuf_init
(
struct
print_buf
*
pb
,
char
*
raw
,
u32
sz
)
{
if
(
!
pb
||
!
raw
||
(
sz
<
(
MAX_STRING
+
1
)))
return
;
...
...
@@ -87,26 +87,26 @@ void printbuf_init(struct print_buf *pb, char *raw, u32 sz)
}
/**
* printbuf_reset - reinitialize print buffer to empty state
*
tipc_
printbuf_reset - reinitialize print buffer to empty state
*/
void
printbuf_reset
(
struct
print_buf
*
pb
)
void
tipc_
printbuf_reset
(
struct
print_buf
*
pb
)
{
if
(
pb
&&
pb
->
buf
)
printbuf_init
(
pb
,
pb
->
buf
,
pb
->
size
);
tipc_
printbuf_init
(
pb
,
pb
->
buf
,
pb
->
size
);
}
/**
* printbuf_empty - test if print buffer is in empty state
*
tipc_
printbuf_empty - test if print buffer is in empty state
*/
int
printbuf_empty
(
struct
print_buf
*
pb
)
int
tipc_
printbuf_empty
(
struct
print_buf
*
pb
)
{
return
(
!
pb
||
!
pb
->
buf
||
(
pb
->
crs
==
pb
->
buf
));
}
/**
* printbuf_validate - check for print buffer overflow
*
tipc_
printbuf_validate - check for print buffer overflow
*
* Verifies that a print buffer has captured all data written to it.
* If data has been lost, linearize buffer and prepend an error message
...
...
@@ -114,7 +114,7 @@ int printbuf_empty(struct print_buf *pb)
* Returns length of print buffer data string (including trailing NULL)
*/
int
printbuf_validate
(
struct
print_buf
*
pb
)
int
tipc_
printbuf_validate
(
struct
print_buf
*
pb
)
{
char
*
err
=
" *** PRINT BUFFER WRAPPED AROUND ***
\n
"
;
char
*
cp_buf
;
...
...
@@ -126,13 +126,13 @@ int printbuf_validate(struct print_buf *pb)
if
(
pb
->
buf
[
pb
->
size
-
1
]
==
'\0'
)
{
cp_buf
=
kmalloc
(
pb
->
size
,
GFP_ATOMIC
);
if
(
cp_buf
!=
NULL
){
printbuf_init
(
&
cb
,
cp_buf
,
pb
->
size
);
printbuf_move
(
&
cb
,
pb
);
printbuf_move
(
pb
,
&
cb
);
tipc_
printbuf_init
(
&
cb
,
cp_buf
,
pb
->
size
);
tipc_
printbuf_move
(
&
cb
,
pb
);
tipc_
printbuf_move
(
pb
,
&
cb
);
kfree
(
cp_buf
);
memcpy
(
pb
->
buf
,
err
,
strlen
(
err
));
}
else
{
printbuf_reset
(
pb
);
tipc_
printbuf_reset
(
pb
);
tipc_printf
(
pb
,
err
);
}
}
...
...
@@ -140,13 +140,13 @@ int printbuf_validate(struct print_buf *pb)
}
/**
* printbuf_move - move print buffer contents to another print buffer
*
tipc_
printbuf_move - move print buffer contents to another print buffer
*
* Current contents of destination print buffer (if any) are discarded.
* Source print buffer becomes empty if a successful move occurs.
*/
void
printbuf_move
(
struct
print_buf
*
pb_to
,
struct
print_buf
*
pb_from
)
void
tipc_
printbuf_move
(
struct
print_buf
*
pb_to
,
struct
print_buf
*
pb_from
)
{
int
len
;
...
...
@@ -156,12 +156,12 @@ void printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from)
return
;
if
(
!
pb_from
||
!
pb_from
->
buf
)
{
printbuf_reset
(
pb_to
);
tipc_
printbuf_reset
(
pb_to
);
return
;
}
if
(
pb_to
->
size
<
pb_from
->
size
)
{
printbuf_reset
(
pb_to
);
tipc_
printbuf_reset
(
pb_to
);
tipc_printf
(
pb_to
,
"*** PRINT BUFFER OVERFLOW ***"
);
return
;
}
...
...
@@ -179,7 +179,7 @@ void printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from)
strcpy
(
pb_to
->
crs
,
pb_from
->
buf
);
pb_to
->
crs
+=
len
;
printbuf_reset
(
pb_from
);
tipc_
printbuf_reset
(
pb_from
);
}
/**
...
...
@@ -199,7 +199,7 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...)
strcpy
(
print_string
,
"*** STRING TOO LONG ***"
);
while
(
pb
)
{
if
(
pb
==
CONS
)
if
(
pb
==
TIPC_
CONS
)
printk
(
print_string
);
else
if
(
pb
->
buf
)
{
chars_left
=
pb
->
buf
+
pb
->
size
-
pb
->
crs
-
1
;
...
...
@@ -223,10 +223,10 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...)
}
/**
* TEE - perform next output operation on both print buffers
* T
IPC_T
EE - perform next output operation on both print buffers
*/
struct
print_buf
*
TEE
(
struct
print_buf
*
b0
,
struct
print_buf
*
b1
)
struct
print_buf
*
T
IPC_T
EE
(
struct
print_buf
*
b0
,
struct
print_buf
*
b1
)
{
struct
print_buf
*
pb
=
b0
;
...
...
@@ -294,96 +294,96 @@ void tipc_dump(struct print_buf *pb, const char *fmt, ...)
int
len
;
spin_lock_bh
(
&
print_lock
);
FORMAT
(
CONS
->
buf
,
len
,
fmt
);
printk
(
CONS
->
buf
);
FORMAT
(
TIPC_
CONS
->
buf
,
len
,
fmt
);
printk
(
TIPC_
CONS
->
buf
);
for
(;
pb
;
pb
=
pb
->
next
)
{
if
(
pb
==
CONS
)
if
(
pb
==
TIPC_
CONS
)
continue
;
printk
(
"
\n
---- Start of dump,%s log ----
\n\n
"
,
(
pb
==
LOG
)
?
"global"
:
"local"
);
(
pb
==
TIPC_
LOG
)
?
"global"
:
"local"
);
printbuf_dump
(
pb
);
printbuf_reset
(
pb
);
tipc_
printbuf_reset
(
pb
);
printk
(
"
\n
-------- End of dump --------
\n
"
);
}
spin_unlock_bh
(
&
print_lock
);
}
/**
* log_stop - free up TIPC log print buffer
*
tipc_
log_stop - free up TIPC log print buffer
*/
void
log_stop
(
void
)
void
tipc_
log_stop
(
void
)
{
spin_lock_bh
(
&
print_lock
);
if
(
LOG
->
buf
)
{
kfree
(
LOG
->
buf
);
LOG
->
buf
=
NULL
;
if
(
TIPC_
LOG
->
buf
)
{
kfree
(
TIPC_
LOG
->
buf
);
TIPC_
LOG
->
buf
=
NULL
;
}
spin_unlock_bh
(
&
print_lock
);
}
/**
* log_reinit - set TIPC log print buffer to specified size
*
tipc_
log_reinit - set TIPC log print buffer to specified size
*/
void
log_reinit
(
int
log_size
)
void
tipc_
log_reinit
(
int
log_size
)
{
log_stop
();
tipc_
log_stop
();
if
(
log_size
)
{
if
(
log_size
<=
MAX_STRING
)
log_size
=
MAX_STRING
+
1
;
spin_lock_bh
(
&
print_lock
);
printbuf_init
(
LOG
,
kmalloc
(
log_size
,
GFP_ATOMIC
),
log_size
);
tipc_printbuf_init
(
TIPC_
LOG
,
kmalloc
(
log_size
,
GFP_ATOMIC
),
log_size
);
spin_unlock_bh
(
&
print_lock
);
}
}
/**
* log_resize - reconfigure size of TIPC log buffer
*
tipc_
log_resize - reconfigure size of TIPC log buffer
*/
struct
sk_buff
*
log_resize
(
const
void
*
req_tlv_area
,
int
req_tlv_space
)
struct
sk_buff
*
tipc_
log_resize
(
const
void
*
req_tlv_area
,
int
req_tlv_space
)
{
u32
value
;
if
(
!
TLV_CHECK
(
req_tlv_area
,
req_tlv_space
,
TIPC_TLV_UNSIGNED
))
return
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_TLV_ERROR
);
value
=
*
(
u32
*
)
TLV_DATA
(
req_tlv_area
);
value
=
ntohl
(
value
);
if
(
value
!=
delimit
(
value
,
0
,
32768
))
return
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
return
tipc_
cfg_reply_error_string
(
TIPC_CFG_INVALID_VALUE
" (log size must be 0-32768)"
);
log_reinit
(
value
);
return
cfg_reply_none
();
tipc_
log_reinit
(
value
);
return
tipc_
cfg_reply_none
();
}
/**
* log_dump - capture TIPC log buffer contents in configuration message
*
tipc_
log_dump - capture TIPC log buffer contents in configuration message
*/
struct
sk_buff
*
log_dump
(
void
)
struct
sk_buff
*
tipc_
log_dump
(
void
)
{
struct
sk_buff
*
reply
;
spin_lock_bh
(
&
print_lock
);
if
(
!
LOG
->
buf
)
reply
=
cfg_reply_ultra_string
(
"log not activated
\n
"
);
else
if
(
printbuf_empty
(
LOG
))
reply
=
cfg_reply_ultra_string
(
"log is empty
\n
"
);
if
(
!
TIPC_
LOG
->
buf
)
reply
=
tipc_
cfg_reply_ultra_string
(
"log not activated
\n
"
);
else
if
(
tipc_printbuf_empty
(
TIPC_
LOG
))
reply
=
tipc_
cfg_reply_ultra_string
(
"log is empty
\n
"
);
else
{
struct
tlv_desc
*
rep_tlv
;
struct
print_buf
pb
;
int
str_len
;
str_len
=
min
(
LOG
->
size
,
32768u
);
reply
=
cfg_reply_alloc
(
TLV_SPACE
(
str_len
));
str_len
=
min
(
TIPC_
LOG
->
size
,
32768u
);
reply
=
tipc_
cfg_reply_alloc
(
TLV_SPACE
(
str_len
));
if
(
reply
)
{
rep_tlv
=
(
struct
tlv_desc
*
)
reply
->
data
;
printbuf_init
(
&
pb
,
TLV_DATA
(
rep_tlv
),
str_len
);
printbuf_move
(
&
pb
,
LOG
);
tipc_
printbuf_init
(
&
pb
,
TLV_DATA
(
rep_tlv
),
str_len
);
tipc_printbuf_move
(
&
pb
,
TIPC_
LOG
);
str_len
=
strlen
(
TLV_DATA
(
rep_tlv
))
+
1
;
skb_put
(
reply
,
TLV_SPACE
(
str_len
));
TLV_SET
(
rep_tlv
,
TIPC_TLV_ULTRA_STRING
,
NULL
,
str_len
);
...
...
net/tipc/dbg.h
浏览文件 @
27a7b041
...
...
@@ -44,16 +44,16 @@ struct print_buf {
struct
print_buf
*
next
;
};
void
printbuf_init
(
struct
print_buf
*
pb
,
char
*
buf
,
u32
sz
);
void
printbuf_reset
(
struct
print_buf
*
pb
);
int
printbuf_empty
(
struct
print_buf
*
pb
);
int
printbuf_validate
(
struct
print_buf
*
pb
);
void
printbuf_move
(
struct
print_buf
*
pb_to
,
struct
print_buf
*
pb_from
);
void
tipc_
printbuf_init
(
struct
print_buf
*
pb
,
char
*
buf
,
u32
sz
);
void
tipc_
printbuf_reset
(
struct
print_buf
*
pb
);
int
tipc_
printbuf_empty
(
struct
print_buf
*
pb
);
int
tipc_
printbuf_validate
(
struct
print_buf
*
pb
);
void
tipc_
printbuf_move
(
struct
print_buf
*
pb_to
,
struct
print_buf
*
pb_from
);
void
log_reinit
(
int
log_size
);
void
log_stop
(
void
);
void
tipc_
log_reinit
(
int
log_size
);
void
tipc_
log_stop
(
void
);
struct
sk_buff
*
log_resize
(
const
void
*
req_tlv_area
,
int
req_tlv_space
);
struct
sk_buff
*
log_dump
(
void
);
struct
sk_buff
*
tipc_
log_resize
(
const
void
*
req_tlv_area
,
int
req_tlv_space
);
struct
sk_buff
*
tipc_
log_dump
(
void
);
#endif
net/tipc/discover.c
浏览文件 @
27a7b041
...
...
@@ -93,7 +93,7 @@ int disc_create_link(const struct tipc_link_create *argv)
* disc_lost_link(): A link has lost contact
*/
void
disc_link_event
(
u32
addr
,
char
*
name
,
int
up
)
void
tipc_
disc_link_event
(
u32
addr
,
char
*
name
,
int
up
)
{
if
(
in_own_cluster
(
addr
))
return
;
...
...
@@ -103,14 +103,14 @@ void disc_link_event(u32 addr, char *name, int up)
}
/**
* disc_init_msg - initialize a link setup message
*
tipc_
disc_init_msg - initialize a link setup message
* @type: message type (request or response)
* @req_links: number of links associated with message
* @dest_domain: network domain of node(s) which should respond to message
* @b_ptr: ptr to bearer issuing message
*/
struct
sk_buff
*
disc_init_msg
(
u32
type
,
struct
sk_buff
*
tipc_
disc_init_msg
(
u32
type
,
u32
req_links
,
u32
dest_domain
,
struct
bearer
*
b_ptr
)
...
...
@@ -132,11 +132,11 @@ struct sk_buff *disc_init_msg(u32 type,
}
/**
* disc_recv_msg - handle incoming link setup message (request or response)
*
tipc_
disc_recv_msg - handle incoming link setup message (request or response)
* @buf: buffer containing message
*/
void
disc_recv_msg
(
struct
sk_buff
*
buf
)
void
tipc_
disc_recv_msg
(
struct
sk_buff
*
buf
)
{
struct
bearer
*
b_ptr
=
(
struct
bearer
*
)
TIPC_SKB_CB
(
buf
)
->
handle
;
struct
link
*
link
;
...
...
@@ -153,9 +153,9 @@ void disc_recv_msg(struct sk_buff *buf)
if
(
net_id
!=
tipc_net_id
)
return
;
if
(
!
addr_domain_valid
(
dest
))
if
(
!
tipc_
addr_domain_valid
(
dest
))
return
;
if
(
!
addr_node_valid
(
orig
))
if
(
!
tipc_
addr_node_valid
(
orig
))
return
;
if
(
orig
==
tipc_own_addr
)
return
;
...
...
@@ -169,11 +169,11 @@ void disc_recv_msg(struct sk_buff *buf)
/* Always accept link here */
struct
sk_buff
*
rbuf
;
struct
tipc_media_addr
*
addr
;
struct
node
*
n_ptr
=
node_find
(
orig
);
struct
node
*
n_ptr
=
tipc_
node_find
(
orig
);
int
link_up
;
dbg
(
" in own cluster
\n
"
);
if
(
n_ptr
==
NULL
)
{
n_ptr
=
node_create
(
orig
);
n_ptr
=
tipc_
node_create
(
orig
);
}
if
(
n_ptr
==
NULL
)
{
warn
(
"Memory squeeze; Failed to create node
\n
"
);
...
...
@@ -183,7 +183,7 @@ void disc_recv_msg(struct sk_buff *buf)
link
=
n_ptr
->
links
[
b_ptr
->
identity
];
if
(
!
link
)
{
dbg
(
"creating link
\n
"
);
link
=
link_create
(
b_ptr
,
orig
,
&
media_addr
);
link
=
tipc_
link_create
(
b_ptr
,
orig
,
&
media_addr
);
if
(
!
link
)
{
spin_unlock_bh
(
&
n_ptr
->
lock
);
return
;
...
...
@@ -196,13 +196,13 @@ void disc_recv_msg(struct sk_buff *buf)
warn
(
"New bearer address for %s
\n
"
,
addr_string_fill
(
addr_string
,
orig
));
memcpy
(
addr
,
&
media_addr
,
sizeof
(
*
addr
));
link_reset
(
link
);
tipc_
link_reset
(
link
);
}
link_up
=
link_is_up
(
link
);
link_up
=
tipc_
link_is_up
(
link
);
spin_unlock_bh
(
&
n_ptr
->
lock
);
if
((
type
==
DSC_RESP_MSG
)
||
link_up
)
return
;
rbuf
=
disc_init_msg
(
DSC_RESP_MSG
,
1
,
orig
,
b_ptr
);
rbuf
=
tipc_
disc_init_msg
(
DSC_RESP_MSG
,
1
,
orig
,
b_ptr
);
if
(
rbuf
!=
NULL
)
{
msg_dbg
(
buf_msg
(
rbuf
),
"SEND:"
);
b_ptr
->
media
->
send_msg
(
rbuf
,
&
b_ptr
->
publ
,
&
media_addr
);
...
...
@@ -212,11 +212,11 @@ void disc_recv_msg(struct sk_buff *buf)
}
/**
* disc_stop_link_req - stop sending periodic link setup requests
*
tipc_
disc_stop_link_req - stop sending periodic link setup requests
* @req: ptr to link request structure
*/
void
disc_stop_link_req
(
struct
link_req
*
req
)
void
tipc_
disc_stop_link_req
(
struct
link_req
*
req
)
{
if
(
!
req
)
return
;
...
...
@@ -228,11 +228,11 @@ void disc_stop_link_req(struct link_req *req)
}
/**
* disc_update_link_req - update frequency of periodic link setup requests
*
tipc_
disc_update_link_req - update frequency of periodic link setup requests
* @req: ptr to link request structure
*/
void
disc_update_link_req
(
struct
link_req
*
req
)
void
tipc_
disc_update_link_req
(
struct
link_req
*
req
)
{
if
(
!
req
)
return
;
...
...
@@ -282,7 +282,7 @@ static void disc_timeout(struct link_req *req)
}
/**
* disc_init_link_req - start sending periodic link setup requests
*
tipc_
disc_init_link_req - start sending periodic link setup requests
* @b_ptr: ptr to bearer issuing requests
* @dest: destination address for request messages
* @dest_domain: network domain of node(s) which should respond to message
...
...
@@ -291,7 +291,7 @@ static void disc_timeout(struct link_req *req)
* Returns pointer to link request structure, or NULL if unable to create.
*/
struct
link_req
*
disc_init_link_req
(
struct
bearer
*
b_ptr
,
struct
link_req
*
tipc_
disc_init_link_req
(
struct
bearer
*
b_ptr
,
const
struct
tipc_media_addr
*
dest
,
u32
dest_domain
,
u32
req_links
)
...
...
@@ -302,7 +302,7 @@ struct link_req *disc_init_link_req(struct bearer *b_ptr,
if
(
!
req
)
return
NULL
;
req
->
buf
=
disc_init_msg
(
DSC_REQ_MSG
,
req_links
,
dest_domain
,
b_ptr
);
req
->
buf
=
tipc_
disc_init_msg
(
DSC_REQ_MSG
,
req_links
,
dest_domain
,
b_ptr
);
if
(
!
req
->
buf
)
{
kfree
(
req
);
return
NULL
;
...
...
net/tipc/discover.h
浏览文件 @
27a7b041
...
...
@@ -37,20 +37,20 @@
#ifndef _TIPC_DISCOVER_H
#define _TIPC_DISCOVER_H
#include
<linux/tipc.h>
#include
"core.h"
struct
link_req
;
struct
link_req
*
disc_init_link_req
(
struct
bearer
*
b_ptr
,
struct
link_req
*
tipc_
disc_init_link_req
(
struct
bearer
*
b_ptr
,
const
struct
tipc_media_addr
*
dest
,
u32
dest_domain
,
u32
req_links
);
void
disc_update_link_req
(
struct
link_req
*
req
);
void
disc_stop_link_req
(
struct
link_req
*
req
);
void
tipc_
disc_update_link_req
(
struct
link_req
*
req
);
void
tipc_
disc_stop_link_req
(
struct
link_req
*
req
);
void
disc_recv_msg
(
struct
sk_buff
*
buf
);
void
tipc_
disc_recv_msg
(
struct
sk_buff
*
buf
);
void
disc_link_event
(
u32
addr
,
char
*
name
,
int
up
);
void
tipc_
disc_link_event
(
u32
addr
,
char
*
name
,
int
up
);
#if 0
int disc_create_link(const struct tipc_link_create *argv);
#endif
...
...
net/tipc/eth_media.c
浏览文件 @
27a7b041
...
...
@@ -38,13 +38,11 @@
#include <net/tipc/tipc_bearer.h>
#include <net/tipc/tipc_msg.h>
#include <linux/netdevice.h>
#include <linux/version.h>
#define MAX_ETH_BEARERS 2
#define TIPC_PROTOCOL 0x88ca
#define ETH_LINK_PRIORITY 10
#define ETH_LINK_PRIORITY TIPC_DEF_LINK_PRI
#define ETH_LINK_TOLERANCE TIPC_DEF_LINK_TOL
#define ETH_LINK_WINDOW TIPC_DEF_LINK_WIN
/**
* struct eth_bearer - Ethernet bearer data structure
...
...
@@ -78,7 +76,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
clone
->
nh
.
raw
=
clone
->
data
;
dev
=
((
struct
eth_bearer
*
)(
tb_ptr
->
usr_handle
))
->
dev
;
clone
->
dev
=
dev
;
dev
->
hard_header
(
clone
,
dev
,
TIPC_PROTOCOL
,
dev
->
hard_header
(
clone
,
dev
,
ETH_P_TIPC
,
&
dest
->
dev_addr
.
eth_addr
,
dev
->
dev_addr
,
clone
->
len
);
dev_queue_xmit
(
clone
);
...
...
@@ -141,7 +139,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
return
-
EDQUOT
;
if
(
!
eb_ptr
->
dev
)
{
eb_ptr
->
dev
=
dev
;
eb_ptr
->
tipc_packet_type
.
type
=
__constant_htons
(
TIPC_PROTOCOL
);
eb_ptr
->
tipc_packet_type
.
type
=
__constant_htons
(
ETH_P_TIPC
);
eb_ptr
->
tipc_packet_type
.
dev
=
dev
;
eb_ptr
->
tipc_packet_type
.
func
=
recv_msg
;
eb_ptr
->
tipc_packet_type
.
af_packet_priv
=
eb_ptr
;
...
...
@@ -240,13 +238,13 @@ static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size
}
/**
* eth_media_start - activate Ethernet bearer support
*
tipc_
eth_media_start - activate Ethernet bearer support
*
* Register Ethernet media type with TIPC bearer code. Also register
* with OS for notifications about device state changes.
*/
int
eth_media_start
(
void
)
int
tipc_
eth_media_start
(
void
)
{
struct
tipc_media_addr
bcast_addr
;
int
res
;
...
...
@@ -260,7 +258,7 @@ int eth_media_start(void)
res
=
tipc_register_media
(
TIPC_MEDIA_TYPE_ETH
,
"eth"
,
enable_bearer
,
disable_bearer
,
send_msg
,
eth_addr2str
,
&
bcast_addr
,
ETH_LINK_PRIORITY
,
ETH_LINK_TOLERANCE
,
TIPC_DEF_LINK_WIN
);
ETH_LINK_TOLERANCE
,
ETH_LINK_WINDOW
);
if
(
res
)
return
res
;
...
...
@@ -273,10 +271,10 @@ int eth_media_start(void)
}
/**
* eth_media_stop - deactivate Ethernet bearer support
*
tipc_
eth_media_stop - deactivate Ethernet bearer support
*/
void
eth_media_stop
(
void
)
void
tipc_
eth_media_stop
(
void
)
{
int
i
;
...
...
net/tipc/handler.c
浏览文件 @
27a7b041
...
...
@@ -52,7 +52,7 @@ static void process_signal_queue(unsigned long dummy);
static
DECLARE_TASKLET_DISABLED
(
tipc_tasklet
,
process_signal_queue
,
0
);
unsigned
int
k_signal
(
Handler
routine
,
unsigned
long
argument
)
unsigned
int
tipc_
k_signal
(
Handler
routine
,
unsigned
long
argument
)
{
struct
queue_item
*
item
;
...
...
@@ -93,7 +93,7 @@ static void process_signal_queue(unsigned long dummy)
spin_unlock_bh
(
&
qitem_lock
);
}
int
handler_start
(
void
)
int
tipc_
handler_start
(
void
)
{
tipc_queue_item_cache
=
kmem_cache_create
(
"tipc_queue_items"
,
sizeof
(
struct
queue_item
),
...
...
@@ -107,7 +107,7 @@ int handler_start(void)
return
0
;
}
void
handler_stop
(
void
)
void
tipc_
handler_stop
(
void
)
{
struct
list_head
*
l
,
*
n
;
struct
queue_item
*
item
;
...
...
net/tipc/link.c
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
net/tipc/link.h
浏览文件 @
27a7b041
...
...
@@ -221,44 +221,43 @@ struct link {
struct
port
;
struct
link
*
link_create
(
struct
bearer
*
b_ptr
,
const
u32
peer
,
struct
link
*
tipc_
link_create
(
struct
bearer
*
b_ptr
,
const
u32
peer
,
const
struct
tipc_media_addr
*
media_addr
);
void
link_delete
(
struct
link
*
l_ptr
);
void
link_changeover
(
struct
link
*
l_ptr
);
void
link_send_duplicate
(
struct
link
*
l_ptr
,
struct
link
*
dest
);
void
link_reset_fragments
(
struct
link
*
l_ptr
);
int
link_is_up
(
struct
link
*
l_ptr
);
int
link_is_active
(
struct
link
*
l_ptr
);
void
link_start
(
struct
link
*
l_ptr
);
u32
link_push_packet
(
struct
link
*
l_ptr
);
void
link_stop
(
struct
link
*
l_ptr
);
struct
sk_buff
*
link_cmd_config
(
const
void
*
req_tlv_area
,
int
req_tlv_space
,
u16
cmd
);
struct
sk_buff
*
link_cmd_show_stats
(
const
void
*
req_tlv_area
,
int
req_tlv_space
);
struct
sk_buff
*
link_cmd_reset_stats
(
const
void
*
req_tlv_area
,
int
req_tlv_space
);
void
link_reset
(
struct
link
*
l_ptr
);
int
link_send
(
struct
sk_buff
*
buf
,
u32
dest
,
u32
selector
);
int
link_send_buf
(
struct
link
*
l_ptr
,
struct
sk_buff
*
buf
);
u32
link_get_max_pkt
(
u32
dest
,
u32
selector
);
int
link_send_sections_fast
(
struct
port
*
sender
,
void
tipc_
link_delete
(
struct
link
*
l_ptr
);
void
tipc_
link_changeover
(
struct
link
*
l_ptr
);
void
tipc_
link_send_duplicate
(
struct
link
*
l_ptr
,
struct
link
*
dest
);
void
tipc_
link_reset_fragments
(
struct
link
*
l_ptr
);
int
tipc_
link_is_up
(
struct
link
*
l_ptr
);
int
tipc_
link_is_active
(
struct
link
*
l_ptr
);
void
tipc_
link_start
(
struct
link
*
l_ptr
);
u32
tipc_
link_push_packet
(
struct
link
*
l_ptr
);
void
tipc_
link_stop
(
struct
link
*
l_ptr
);
struct
sk_buff
*
tipc_
link_cmd_config
(
const
void
*
req_tlv_area
,
int
req_tlv_space
,
u16
cmd
);
struct
sk_buff
*
tipc_
link_cmd_show_stats
(
const
void
*
req_tlv_area
,
int
req_tlv_space
);
struct
sk_buff
*
tipc_
link_cmd_reset_stats
(
const
void
*
req_tlv_area
,
int
req_tlv_space
);
void
tipc_
link_reset
(
struct
link
*
l_ptr
);
int
tipc_
link_send
(
struct
sk_buff
*
buf
,
u32
dest
,
u32
selector
);
int
tipc_
link_send_buf
(
struct
link
*
l_ptr
,
struct
sk_buff
*
buf
);
u32
tipc_
link_get_max_pkt
(
u32
dest
,
u32
selector
);
int
tipc_
link_send_sections_fast
(
struct
port
*
sender
,
struct
iovec
const
*
msg_sect
,
const
u32
num_sect
,
u32
destnode
);
int
link_send_long_buf
(
struct
link
*
l_ptr
,
struct
sk_buff
*
buf
);
void
link_tunnel
(
struct
link
*
l_ptr
,
struct
tipc_msg
*
tnl_hdr
,
int
tipc_link_send_long_buf
(
struct
link
*
l_ptr
,
struct
sk_buff
*
buf
);
void
tipc_link_tunnel
(
struct
link
*
l_ptr
,
struct
tipc_msg
*
tnl_hdr
,
struct
tipc_msg
*
msg
,
u32
selector
);
void
link_recv_bundle
(
struct
sk_buff
*
buf
);
int
link_recv_fragment
(
struct
sk_buff
**
pending
,
void
tipc_
link_recv_bundle
(
struct
sk_buff
*
buf
);
int
tipc_
link_recv_fragment
(
struct
sk_buff
**
pending
,
struct
sk_buff
**
fb
,
struct
tipc_msg
**
msg
);
void
link_send_proto_msg
(
struct
link
*
l_ptr
,
u32
msg_typ
,
int
prob
,
u32
gap
,
void
tipc_
link_send_proto_msg
(
struct
link
*
l_ptr
,
u32
msg_typ
,
int
prob
,
u32
gap
,
u32
tolerance
,
u32
priority
,
u32
acked_mtu
);
void
link_push_queue
(
struct
link
*
l_ptr
);
u32
link_defer_pkt
(
struct
sk_buff
**
head
,
struct
sk_buff
**
tail
,
void
tipc_
link_push_queue
(
struct
link
*
l_ptr
);
u32
tipc_
link_defer_pkt
(
struct
sk_buff
**
head
,
struct
sk_buff
**
tail
,
struct
sk_buff
*
buf
);
void
link_wakeup_ports
(
struct
link
*
l_ptr
,
int
all
);
void
link_set_queue_limits
(
struct
link
*
l_ptr
,
u32
window
);
void
link_retransmit
(
struct
link
*
l_ptr
,
struct
sk_buff
*
start
,
u32
retransmits
);
void
tipc_
link_wakeup_ports
(
struct
link
*
l_ptr
,
int
all
);
void
tipc_
link_set_queue_limits
(
struct
link
*
l_ptr
,
u32
window
);
void
tipc_
link_retransmit
(
struct
link
*
l_ptr
,
struct
sk_buff
*
start
,
u32
retransmits
);
/*
* Link sequence number manipulation routines (uses modulo 2**16 arithmetic)
...
...
net/tipc/msg.c
浏览文件 @
27a7b041
...
...
@@ -41,18 +41,7 @@
#include "bearer.h"
void
msg_set_media_addr
(
struct
tipc_msg
*
m
,
struct
tipc_media_addr
*
a
)
{
memcpy
(
&
((
int
*
)
m
)[
5
],
a
,
sizeof
(
*
a
));
}
void
msg_get_media_addr
(
struct
tipc_msg
*
m
,
struct
tipc_media_addr
*
a
)
{
memcpy
(
a
,
&
((
int
*
)
m
)[
5
],
sizeof
(
*
a
));
}
void
msg_print
(
struct
print_buf
*
buf
,
struct
tipc_msg
*
msg
,
const
char
*
str
)
void
tipc_msg_print
(
struct
print_buf
*
buf
,
struct
tipc_msg
*
msg
,
const
char
*
str
)
{
u32
usr
=
msg_user
(
msg
);
tipc_printf
(
buf
,
str
);
...
...
@@ -318,7 +307,7 @@ void msg_print(struct print_buf *buf, struct tipc_msg *msg, const char *str)
tipc_printf
(
buf
,
":REQL(%u):"
,
msg_req_links
(
msg
));
tipc_printf
(
buf
,
":DDOM(%x):"
,
msg_dest_domain
(
msg
));
tipc_printf
(
buf
,
":NETID(%u):"
,
msg_bc_netid
(
msg
));
media_addr_printf
(
buf
,
orig
);
tipc_
media_addr_printf
(
buf
,
orig
);
}
if
(
msg_user
(
msg
)
==
BCAST_PROTOCOL
)
{
tipc_printf
(
buf
,
"BCNACK:AFTER(%u):"
,
msg_bcgap_after
(
msg
));
...
...
@@ -326,9 +315,9 @@ void msg_print(struct print_buf *buf, struct tipc_msg *msg, const char *str)
}
tipc_printf
(
buf
,
"
\n
"
);
if
((
usr
==
CHANGEOVER_PROTOCOL
)
&&
(
msg_msgcnt
(
msg
)))
{
msg_print
(
buf
,
msg_get_wrapped
(
msg
),
" /"
);
tipc_
msg_print
(
buf
,
msg_get_wrapped
(
msg
),
" /"
);
}
if
((
usr
==
MSG_FRAGMENTER
)
&&
(
msg_type
(
msg
)
==
FIRST_FRAGMENT
))
{
msg_print
(
buf
,
msg_get_wrapped
(
msg
),
" /"
);
tipc_
msg_print
(
buf
,
msg_get_wrapped
(
msg
),
" /"
);
}
}
net/tipc/msg.h
浏览文件 @
27a7b041
...
...
@@ -37,7 +37,7 @@
#ifndef _TIPC_MSG_H
#define _TIPC_MSG_H
#include
<net/tipc/tipc_msg.h>
#include
"core.h"
#define TIPC_VERSION 2
#define DATA_LOW TIPC_LOW_IMPORTANCE
...
...
@@ -805,14 +805,14 @@ static inline int msg_build(struct tipc_msg *hdr,
return
-
EFAULT
;
}
static
inline
void
msg_set_media_addr
(
struct
tipc_msg
*
m
,
struct
tipc_media_addr
*
a
)
{
memcpy
(
&
((
int
*
)
m
)[
5
],
a
,
sizeof
(
*
a
));
}
struct
tipc_media_addr
;
extern
void
msg_set_media_addr
(
struct
tipc_msg
*
m
,
struct
tipc_media_addr
*
a
);
extern
void
msg_get_media_addr
(
struct
tipc_msg
*
m
,
struct
tipc_media_addr
*
a
);
static
inline
void
msg_get_media_addr
(
struct
tipc_msg
*
m
,
struct
tipc_media_addr
*
a
)
{
memcpy
(
a
,
&
((
int
*
)
m
)[
5
],
sizeof
(
*
a
));
}
#endif
net/tipc/name_distr.c
浏览文件 @
27a7b041
...
...
@@ -114,10 +114,10 @@ static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest)
}
/**
* 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
named_publish
(
struct
publication
*
publ
)
void
tipc_
named_publish
(
struct
publication
*
publ
)
{
struct
sk_buff
*
buf
;
struct
distr_item
*
item
;
...
...
@@ -133,15 +133,15 @@ void named_publish(struct publication *publ)
item
=
(
struct
distr_item
*
)
msg_data
(
buf_msg
(
buf
));
publ_to_item
(
item
,
publ
);
dbg
(
"named_withdraw: broadcasting publish msg
\n
"
);
cluste
r_broadcast
(
buf
);
dbg
(
"
tipc_
named_withdraw: broadcasting publish msg
\n
"
);
tipc_clt
r_broadcast
(
buf
);
}
/**
* 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
named_withdraw
(
struct
publication
*
publ
)
void
tipc_
named_withdraw
(
struct
publication
*
publ
)
{
struct
sk_buff
*
buf
;
struct
distr_item
*
item
;
...
...
@@ -157,15 +157,15 @@ void named_withdraw(struct publication *publ)
item
=
(
struct
distr_item
*
)
msg_data
(
buf_msg
(
buf
));
publ_to_item
(
item
,
publ
);
dbg
(
"named_withdraw: broadcasting withdraw msg
\n
"
);
cluste
r_broadcast
(
buf
);
dbg
(
"
tipc_
named_withdraw: broadcasting withdraw msg
\n
"
);
tipc_clt
r_broadcast
(
buf
);
}
/**
* 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
named_node_up
(
unsigned
long
node
)
void
tipc_
named_node_up
(
unsigned
long
node
)
{
struct
publication
*
publ
;
struct
distr_item
*
item
=
0
;
...
...
@@ -175,7 +175,7 @@ void named_node_up(unsigned long node)
u32
max_item_buf
;
assert
(
in_own_cluster
(
node
));
read_lock_bh
(
&
nametbl_lock
);
read_lock_bh
(
&
tipc_
nametbl_lock
);
max_item_buf
=
TIPC_MAX_USER_MSG_SIZE
/
ITEM_SIZE
;
max_item_buf
*=
ITEM_SIZE
;
rest
=
publ_cnt
*
ITEM_SIZE
;
...
...
@@ -196,15 +196,15 @@ void named_node_up(unsigned long node)
left
-=
ITEM_SIZE
;
if
(
!
left
)
{
msg_set_link_selector
(
buf_msg
(
buf
),
node
);
dbg
(
"named_node_up: sending publish msg to "
dbg
(
"
tipc_
named_node_up: sending publish msg to "
"<%u.%u.%u>
\n
"
,
tipc_zone
(
node
),
tipc_cluster
(
node
),
tipc_node
(
node
));
link_send
(
buf
,
node
,
node
);
tipc_
link_send
(
buf
,
node
,
node
);
buf
=
0
;
}
}
exit:
read_unlock_bh
(
&
nametbl_lock
);
read_unlock_bh
(
&
tipc_
nametbl_lock
);
}
/**
...
...
@@ -221,36 +221,36 @@ void named_node_up(unsigned long node)
static
void
node_is_down
(
struct
publication
*
publ
)
{
struct
publication
*
p
;
write_lock_bh
(
&
nametbl_lock
);
write_lock_bh
(
&
tipc_
nametbl_lock
);
dbg
(
"node_is_down: withdrawing %u, %u, %u
\n
"
,
publ
->
type
,
publ
->
lower
,
publ
->
upper
);
publ
->
key
+=
1222345
;
p
=
nametbl_remove_publ
(
publ
->
type
,
publ
->
lower
,
p
=
tipc_
nametbl_remove_publ
(
publ
->
type
,
publ
->
lower
,
publ
->
node
,
publ
->
ref
,
publ
->
key
);
assert
(
p
==
publ
);
write_unlock_bh
(
&
nametbl_lock
);
write_unlock_bh
(
&
tipc_
nametbl_lock
);
if
(
publ
)
kfree
(
publ
);
}
/**
* named_recv - process name table update message sent by another node
*
tipc_
named_recv - process name table update message sent by another node
*/
void
named_recv
(
struct
sk_buff
*
buf
)
void
tipc_
named_recv
(
struct
sk_buff
*
buf
)
{
struct
publication
*
publ
;
struct
tipc_msg
*
msg
=
buf_msg
(
buf
);
struct
distr_item
*
item
=
(
struct
distr_item
*
)
msg_data
(
msg
);
u32
count
=
msg_data_sz
(
msg
)
/
ITEM_SIZE
;
write_lock_bh
(
&
nametbl_lock
);
write_lock_bh
(
&
tipc_
nametbl_lock
);
while
(
count
--
)
{
if
(
msg_type
(
msg
)
==
PUBLICATION
)
{
dbg
(
"named_recv: got publication for %u, %u, %u
\n
"
,
dbg
(
"
tipc_
named_recv: got publication for %u, %u, %u
\n
"
,
ntohl
(
item
->
type
),
ntohl
(
item
->
lower
),
ntohl
(
item
->
upper
));
publ
=
nametbl_insert_publ
(
ntohl
(
item
->
type
),
publ
=
tipc_
nametbl_insert_publ
(
ntohl
(
item
->
type
),
ntohl
(
item
->
lower
),
ntohl
(
item
->
upper
),
TIPC_CLUSTER_SCOPE
,
...
...
@@ -258,36 +258,36 @@ void named_recv(struct sk_buff *buf)
ntohl
(
item
->
ref
),
ntohl
(
item
->
key
));
if
(
publ
)
{
nodesub_subscribe
(
&
publ
->
subscr
,
tipc_
nodesub_subscribe
(
&
publ
->
subscr
,
msg_orignode
(
msg
),
publ
,
(
net_ev_handler
)
node_is_down
);
}
}
else
if
(
msg_type
(
msg
)
==
WITHDRAWAL
)
{
dbg
(
"named_recv: got withdrawl for %u, %u, %u
\n
"
,
dbg
(
"
tipc_
named_recv: got withdrawl for %u, %u, %u
\n
"
,
ntohl
(
item
->
type
),
ntohl
(
item
->
lower
),
ntohl
(
item
->
upper
));
publ
=
nametbl_remove_publ
(
ntohl
(
item
->
type
),
publ
=
tipc_
nametbl_remove_publ
(
ntohl
(
item
->
type
),
ntohl
(
item
->
lower
),
msg_orignode
(
msg
),
ntohl
(
item
->
ref
),
ntohl
(
item
->
key
));
if
(
publ
)
{
nodesub_unsubscribe
(
&
publ
->
subscr
);
tipc_
nodesub_unsubscribe
(
&
publ
->
subscr
);
kfree
(
publ
);
}
}
else
{
warn
(
"named_recv: unknown msg
\n
"
);
warn
(
"
tipc_
named_recv: unknown msg
\n
"
);
}
item
++
;
}
write_unlock_bh
(
&
nametbl_lock
);
write_unlock_bh
(
&
tipc_
nametbl_lock
);
buf_discard
(
buf
);
}
/**
* named_reinit - re-initialize local publication list
*
tipc_
named_reinit - re-initialize local publication list
*
* This routine is called whenever TIPC networking is (re)enabled.
* All existing publications by this node that have "cluster" or "zone" scope
...
...
@@ -295,15 +295,15 @@ void named_recv(struct sk_buff *buf)
* (If the node's address is unchanged, the update loop terminates immediately.)
*/
void
named_reinit
(
void
)
void
tipc_
named_reinit
(
void
)
{
struct
publication
*
publ
;
write_lock_bh
(
&
nametbl_lock
);
write_lock_bh
(
&
tipc_
nametbl_lock
);
list_for_each_entry
(
publ
,
&
publ_root
,
local_list
)
{
if
(
publ
->
node
==
tipc_own_addr
)
break
;
publ
->
node
=
tipc_own_addr
;
}
write_unlock_bh
(
&
nametbl_lock
);
write_unlock_bh
(
&
tipc_
nametbl_lock
);
}
net/tipc/name_distr.h
浏览文件 @
27a7b041
...
...
@@ -39,10 +39,10 @@
#include "name_table.h"
void
named_publish
(
struct
publication
*
publ
);
void
named_withdraw
(
struct
publication
*
publ
);
void
named_node_up
(
unsigned
long
node
);
void
named_recv
(
struct
sk_buff
*
buf
);
void
named_reinit
(
void
);
void
tipc_
named_publish
(
struct
publication
*
publ
);
void
tipc_
named_withdraw
(
struct
publication
*
publ
);
void
tipc_
named_node_up
(
unsigned
long
node
);
void
tipc_
named_recv
(
struct
sk_buff
*
buf
);
void
tipc_
named_reinit
(
void
);
#endif
net/tipc/name_table.c
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
net/tipc/name_table.h
浏览文件 @
27a7b041
...
...
@@ -85,24 +85,24 @@ struct publication {
};
extern
rwlock_t
nametbl_lock
;
extern
rwlock_t
tipc_
nametbl_lock
;
struct
sk_buff
*
nametbl_get
(
const
void
*
req_tlv_area
,
int
req_tlv_space
);
u32
nametbl_translate
(
u32
type
,
u32
instance
,
u32
*
node
);
int
nametbl_mc_translate
(
u32
type
,
u32
lower
,
u32
upper
,
u32
limit
,
struct
sk_buff
*
tipc_
nametbl_get
(
const
void
*
req_tlv_area
,
int
req_tlv_space
);
u32
tipc_
nametbl_translate
(
u32
type
,
u32
instance
,
u32
*
node
);
int
tipc_
nametbl_mc_translate
(
u32
type
,
u32
lower
,
u32
upper
,
u32
limit
,
struct
port_list
*
dports
);
int
nametbl_publish_rsv
(
u32
ref
,
unsigned
int
scope
,
int
tipc_
nametbl_publish_rsv
(
u32
ref
,
unsigned
int
scope
,
struct
tipc_name_seq
const
*
seq
);
struct
publication
*
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
);
int
nametbl_withdraw
(
u32
type
,
u32
lower
,
u32
ref
,
u32
key
);
struct
publication
*
nametbl_insert_publ
(
u32
type
,
u32
lower
,
u32
upper
,
int
tipc_
nametbl_withdraw
(
u32
type
,
u32
lower
,
u32
ref
,
u32
key
);
struct
publication
*
tipc_
nametbl_insert_publ
(
u32
type
,
u32
lower
,
u32
upper
,
u32
scope
,
u32
node
,
u32
ref
,
u32
key
);
struct
publication
*
nametbl_remove_publ
(
u32
type
,
u32
lower
,
struct
publication
*
tipc_
nametbl_remove_publ
(
u32
type
,
u32
lower
,
u32
node
,
u32
ref
,
u32
key
);
void
nametbl_subscribe
(
struct
subscription
*
s
);
void
nametbl_unsubscribe
(
struct
subscription
*
s
);
int
nametbl_init
(
void
);
void
nametbl_stop
(
void
);
void
tipc_
nametbl_subscribe
(
struct
subscription
*
s
);
void
tipc_
nametbl_unsubscribe
(
struct
subscription
*
s
);
int
tipc_
nametbl_init
(
void
);
void
tipc_
nametbl_stop
(
void
);
#endif
net/tipc/net.c
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
net/tipc/net.h
浏览文件 @
27a7b041
...
...
@@ -49,18 +49,16 @@ struct network {
};
extern
struct
network
net
;
extern
rwlock_t
net_lock
;
extern
struct
network
tipc_
net
;
extern
rwlock_t
tipc_
net_lock
;
int
net_init
(
void
);
void
net_stop
(
void
);
void
net_remove_as_router
(
u32
router
);
void
net_send_external_routes
(
u32
dest
);
void
net_route_msg
(
struct
sk_buff
*
buf
);
struct
node
*
net_select_remote_node
(
u32
addr
,
u32
ref
);
u32
net_select_router
(
u32
addr
,
u32
ref
);
void
tipc_net_remove_as_router
(
u32
router
);
void
tipc_net_send_external_routes
(
u32
dest
);
void
tipc_net_route_msg
(
struct
sk_buff
*
buf
);
struct
node
*
tipc_net_select_remote_node
(
u32
addr
,
u32
ref
);
u32
tipc_net_select_router
(
u32
addr
,
u32
ref
);
int
tipc_
start_ne
t
(
void
);
void
tipc_
stop_net
(
void
);
int
tipc_
net_star
t
(
void
);
void
tipc_
net_stop
(
void
);
#endif
net/tipc/netlink.c
浏览文件 @
27a7b041
...
...
@@ -47,9 +47,9 @@ static int handle_cmd(struct sk_buff *skb, struct genl_info *info)
int
hdr_space
=
NLMSG_SPACE
(
GENL_HDRLEN
+
TIPC_GENL_HDRLEN
);
if
((
req_userhdr
->
cmd
&
0xC000
)
&&
(
!
capable
(
CAP_NET_ADMIN
)))
rep_buf
=
cfg_reply_error_string
(
TIPC_CFG_NOT_NET_ADMIN
);
rep_buf
=
tipc_
cfg_reply_error_string
(
TIPC_CFG_NOT_NET_ADMIN
);
else
rep_buf
=
cfg_do_cmd
(
req_userhdr
->
dest
,
rep_buf
=
tipc_
cfg_do_cmd
(
req_userhdr
->
dest
,
req_userhdr
->
cmd
,
NLMSG_DATA
(
req_nlh
)
+
GENL_HDRLEN
+
TIPC_GENL_HDRLEN
,
NLMSG_PAYLOAD
(
req_nlh
,
GENL_HDRLEN
+
TIPC_GENL_HDRLEN
),
...
...
@@ -81,7 +81,7 @@ static struct genl_ops ops = {
static
int
family_registered
=
0
;
int
netlink_start
(
void
)
int
tipc_
netlink_start
(
void
)
{
...
...
@@ -103,7 +103,7 @@ int netlink_start(void)
return
-
EFAULT
;
}
void
netlink_stop
(
void
)
void
tipc_
netlink_stop
(
void
)
{
if
(
family_registered
)
{
genl_unregister_family
(
&
family
);
...
...
net/tipc/node.c
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
net/tipc/node.h
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
net/tipc/node_subscr.c
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
net/tipc/node_subscr.h
浏览文件 @
27a7b041
...
...
@@ -56,8 +56,8 @@ struct node_subscr {
struct
list_head
nodesub_list
;
};
void
nodesub_subscribe
(
struct
node_subscr
*
node_sub
,
u32
addr
,
void
tipc_
nodesub_subscribe
(
struct
node_subscr
*
node_sub
,
u32
addr
,
void
*
usr_handle
,
net_ev_handler
handle_down
);
void
nodesub_unsubscribe
(
struct
node_subscr
*
node_sub
);
void
tipc_
nodesub_unsubscribe
(
struct
node_subscr
*
node_sub
);
#endif
net/tipc/port.c
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
net/tipc/port.h
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
net/tipc/ref.c
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
net/tipc/ref.h
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
net/tipc/socket.c
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
net/tipc/subscr.c
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
net/tipc/subscr.h
浏览文件 @
27a7b041
...
...
@@ -60,11 +60,11 @@ struct subscription {
struct
subscriber
*
owner
;
};
int
subscr_overlap
(
struct
subscription
*
sub
,
int
tipc_
subscr_overlap
(
struct
subscription
*
sub
,
u32
found_lower
,
u32
found_upper
);
void
subscr_report_overlap
(
struct
subscription
*
sub
,
void
tipc_
subscr_report_overlap
(
struct
subscription
*
sub
,
u32
found_lower
,
u32
found_upper
,
u32
event
,
...
...
@@ -72,9 +72,9 @@ void subscr_report_overlap(struct subscription * sub,
u32
node
,
int
must_report
);
int
subscr_start
(
void
);
int
tipc_
subscr_start
(
void
);
void
subscr_stop
(
void
);
void
tipc_
subscr_stop
(
void
);
#endif
net/tipc/user_reg.c
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
net/tipc/user_reg.h
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
net/tipc/zone.c
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
net/tipc/zone.h
浏览文件 @
27a7b041
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录