diff options
Diffstat (limited to 'net/tipc/net.c')
-rw-r--r-- | net/tipc/net.c | 76 |
1 files changed, 8 insertions, 68 deletions
diff --git a/net/tipc/net.c b/net/tipc/net.c index 1a621cfd6604..68b3dd637291 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * net/tipc/net.c: TIPC network routing code | 2 | * net/tipc/net.c: TIPC network routing code |
3 | * | 3 | * |
4 | * Copyright (c) 1995-2006, Ericsson AB | 4 | * Copyright (c) 1995-2006, Ericsson AB |
5 | * Copyright (c) 2005, Wind River Systems | 5 | * Copyright (c) 2005, 2010-2011, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
@@ -35,18 +35,11 @@ | |||
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include "core.h" | 37 | #include "core.h" |
38 | #include "bearer.h" | ||
39 | #include "net.h" | 38 | #include "net.h" |
40 | #include "zone.h" | ||
41 | #include "addr.h" | ||
42 | #include "name_table.h" | ||
43 | #include "name_distr.h" | 39 | #include "name_distr.h" |
44 | #include "subscr.h" | 40 | #include "subscr.h" |
45 | #include "link.h" | ||
46 | #include "msg.h" | ||
47 | #include "port.h" | 41 | #include "port.h" |
48 | #include "bcast.h" | 42 | #include "node.h" |
49 | #include "discover.h" | ||
50 | #include "config.h" | 43 | #include "config.h" |
51 | 44 | ||
52 | /* | 45 | /* |
@@ -116,47 +109,6 @@ | |||
116 | */ | 109 | */ |
117 | 110 | ||
118 | DEFINE_RWLOCK(tipc_net_lock); | 111 | DEFINE_RWLOCK(tipc_net_lock); |
119 | static struct _zone *tipc_zones[256] = { NULL, }; | ||
120 | struct network tipc_net = { tipc_zones }; | ||
121 | |||
122 | struct tipc_node *tipc_net_select_remote_node(u32 addr, u32 ref) | ||
123 | { | ||
124 | return tipc_zone_select_remote_node(tipc_net.zones[tipc_zone(addr)], addr, ref); | ||
125 | } | ||
126 | |||
127 | u32 tipc_net_select_router(u32 addr, u32 ref) | ||
128 | { | ||
129 | return tipc_zone_select_router(tipc_net.zones[tipc_zone(addr)], addr, ref); | ||
130 | } | ||
131 | |||
132 | void tipc_net_remove_as_router(u32 router) | ||
133 | { | ||
134 | u32 z_num; | ||
135 | |||
136 | for (z_num = 1; z_num <= tipc_max_zones; z_num++) { | ||
137 | if (!tipc_net.zones[z_num]) | ||
138 | continue; | ||
139 | tipc_zone_remove_as_router(tipc_net.zones[z_num], router); | ||
140 | } | ||
141 | } | ||
142 | |||
143 | void tipc_net_send_external_routes(u32 dest) | ||
144 | { | ||
145 | u32 z_num; | ||
146 | |||
147 | for (z_num = 1; z_num <= tipc_max_zones; z_num++) { | ||
148 | if (tipc_net.zones[z_num]) | ||
149 | tipc_zone_send_external_routes(tipc_net.zones[z_num], dest); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | static void net_stop(void) | ||
154 | { | ||
155 | u32 z_num; | ||
156 | |||
157 | for (z_num = 1; z_num <= tipc_max_zones; z_num++) | ||
158 | tipc_zone_delete(tipc_net.zones[z_num]); | ||
159 | } | ||
160 | 112 | ||
161 | static void net_route_named_msg(struct sk_buff *buf) | 113 | static void net_route_named_msg(struct sk_buff *buf) |
162 | { | 114 | { |
@@ -165,22 +117,18 @@ static void net_route_named_msg(struct sk_buff *buf) | |||
165 | u32 dport; | 117 | u32 dport; |
166 | 118 | ||
167 | if (!msg_named(msg)) { | 119 | if (!msg_named(msg)) { |
168 | msg_dbg(msg, "tipc_net->drop_nam:"); | ||
169 | buf_discard(buf); | 120 | buf_discard(buf); |
170 | return; | 121 | return; |
171 | } | 122 | } |
172 | 123 | ||
173 | dnode = addr_domain(msg_lookup_scope(msg)); | 124 | dnode = addr_domain(msg_lookup_scope(msg)); |
174 | dport = tipc_nametbl_translate(msg_nametype(msg), msg_nameinst(msg), &dnode); | 125 | dport = tipc_nametbl_translate(msg_nametype(msg), msg_nameinst(msg), &dnode); |
175 | dbg("tipc_net->lookup<%u,%u>-><%u,%x>\n", | ||
176 | msg_nametype(msg), msg_nameinst(msg), dport, dnode); | ||
177 | if (dport) { | 126 | if (dport) { |
178 | msg_set_destnode(msg, dnode); | 127 | msg_set_destnode(msg, dnode); |
179 | msg_set_destport(msg, dport); | 128 | msg_set_destport(msg, dport); |
180 | tipc_net_route_msg(buf); | 129 | tipc_net_route_msg(buf); |
181 | return; | 130 | return; |
182 | } | 131 | } |
183 | msg_dbg(msg, "tipc_net->rej:NO NAME: "); | ||
184 | tipc_reject_msg(buf, TIPC_ERR_NO_NAME); | 132 | tipc_reject_msg(buf, TIPC_ERR_NO_NAME); |
185 | } | 133 | } |
186 | 134 | ||
@@ -196,18 +144,14 @@ void tipc_net_route_msg(struct sk_buff *buf) | |||
196 | msg_incr_reroute_cnt(msg); | 144 | msg_incr_reroute_cnt(msg); |
197 | if (msg_reroute_cnt(msg) > 6) { | 145 | if (msg_reroute_cnt(msg) > 6) { |
198 | if (msg_errcode(msg)) { | 146 | if (msg_errcode(msg)) { |
199 | msg_dbg(msg, "NET>DISC>:"); | ||
200 | buf_discard(buf); | 147 | buf_discard(buf); |
201 | } else { | 148 | } else { |
202 | msg_dbg(msg, "NET>REJ>:"); | ||
203 | tipc_reject_msg(buf, msg_destport(msg) ? | 149 | tipc_reject_msg(buf, msg_destport(msg) ? |
204 | TIPC_ERR_NO_PORT : TIPC_ERR_NO_NAME); | 150 | TIPC_ERR_NO_PORT : TIPC_ERR_NO_NAME); |
205 | } | 151 | } |
206 | return; | 152 | return; |
207 | } | 153 | } |
208 | 154 | ||
209 | msg_dbg(msg, "tipc_net->rout: "); | ||
210 | |||
211 | /* Handle message for this node */ | 155 | /* Handle message for this node */ |
212 | dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg); | 156 | dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg); |
213 | if (tipc_in_scope(dnode, tipc_own_addr)) { | 157 | if (tipc_in_scope(dnode, tipc_own_addr)) { |
@@ -221,9 +165,6 @@ void tipc_net_route_msg(struct sk_buff *buf) | |||
221 | return; | 165 | return; |
222 | } | 166 | } |
223 | switch (msg_user(msg)) { | 167 | switch (msg_user(msg)) { |
224 | case ROUTE_DISTRIBUTOR: | ||
225 | tipc_cltr_recv_routing_table(buf); | ||
226 | break; | ||
227 | case NAME_DISTRIBUTOR: | 168 | case NAME_DISTRIBUTOR: |
228 | tipc_named_recv(buf); | 169 | tipc_named_recv(buf); |
229 | break; | 170 | break; |
@@ -231,14 +172,12 @@ void tipc_net_route_msg(struct sk_buff *buf) | |||
231 | tipc_port_recv_proto_msg(buf); | 172 | tipc_port_recv_proto_msg(buf); |
232 | break; | 173 | break; |
233 | default: | 174 | default: |
234 | msg_dbg(msg,"DROP/NET/<REC<"); | ||
235 | buf_discard(buf); | 175 | buf_discard(buf); |
236 | } | 176 | } |
237 | return; | 177 | return; |
238 | } | 178 | } |
239 | 179 | ||
240 | /* Handle message for another node */ | 180 | /* Handle message for another node */ |
241 | msg_dbg(msg, "NET>SEND>: "); | ||
242 | skb_trim(buf, msg_size(msg)); | 181 | skb_trim(buf, msg_size(msg)); |
243 | tipc_link_send(buf, dnode, msg_link_selector(msg)); | 182 | tipc_link_send(buf, dnode, msg_link_selector(msg)); |
244 | } | 183 | } |
@@ -259,10 +198,9 @@ int tipc_net_start(u32 addr) | |||
259 | tipc_named_reinit(); | 198 | tipc_named_reinit(); |
260 | tipc_port_reinit(); | 199 | tipc_port_reinit(); |
261 | 200 | ||
262 | if ((res = tipc_cltr_init()) || | 201 | res = tipc_bclink_init(); |
263 | (res = tipc_bclink_init())) { | 202 | if (res) |
264 | return res; | 203 | return res; |
265 | } | ||
266 | 204 | ||
267 | tipc_k_signal((Handler)tipc_subscr_start, 0); | 205 | tipc_k_signal((Handler)tipc_subscr_start, 0); |
268 | tipc_k_signal((Handler)tipc_cfg_init, 0); | 206 | tipc_k_signal((Handler)tipc_cfg_init, 0); |
@@ -275,14 +213,16 @@ int tipc_net_start(u32 addr) | |||
275 | 213 | ||
276 | void tipc_net_stop(void) | 214 | void tipc_net_stop(void) |
277 | { | 215 | { |
216 | struct tipc_node *node, *t_node; | ||
217 | |||
278 | if (tipc_mode != TIPC_NET_MODE) | 218 | if (tipc_mode != TIPC_NET_MODE) |
279 | return; | 219 | return; |
280 | write_lock_bh(&tipc_net_lock); | 220 | write_lock_bh(&tipc_net_lock); |
281 | tipc_bearer_stop(); | 221 | tipc_bearer_stop(); |
282 | tipc_mode = TIPC_NODE_MODE; | 222 | tipc_mode = TIPC_NODE_MODE; |
283 | tipc_bclink_stop(); | 223 | tipc_bclink_stop(); |
284 | net_stop(); | 224 | list_for_each_entry_safe(node, t_node, &tipc_node_list, list) |
225 | tipc_node_delete(node); | ||
285 | write_unlock_bh(&tipc_net_lock); | 226 | write_unlock_bh(&tipc_net_lock); |
286 | info("Left network mode\n"); | 227 | info("Left network mode\n"); |
287 | } | 228 | } |
288 | |||