aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/net.c
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2011-01-13 01:06:28 -0500
committerPaul Mundt <lethal@linux-sh.org>2011-01-13 01:06:28 -0500
commitf43dc23d5ea91fca257be02138a255f02d98e806 (patch)
treeb29722f6e965316e90ac97abf79923ced250dc21 /net/tipc/net.c
parentf8e53553f452dcbf67cb89c8cba63a1cd6eb4cc0 (diff)
parent4162cf64973df51fc885825bc9ca4d055891c49f (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 into common/serial-rework
Conflicts: arch/sh/kernel/cpu/sh2/setup-sh7619.c arch/sh/kernel/cpu/sh2a/setup-mxg.c arch/sh/kernel/cpu/sh2a/setup-sh7201.c arch/sh/kernel/cpu/sh2a/setup-sh7203.c arch/sh/kernel/cpu/sh2a/setup-sh7206.c arch/sh/kernel/cpu/sh3/setup-sh7705.c arch/sh/kernel/cpu/sh3/setup-sh770x.c arch/sh/kernel/cpu/sh3/setup-sh7710.c arch/sh/kernel/cpu/sh3/setup-sh7720.c arch/sh/kernel/cpu/sh4/setup-sh4-202.c arch/sh/kernel/cpu/sh4/setup-sh7750.c arch/sh/kernel/cpu/sh4/setup-sh7760.c arch/sh/kernel/cpu/sh4a/setup-sh7343.c arch/sh/kernel/cpu/sh4a/setup-sh7366.c arch/sh/kernel/cpu/sh4a/setup-sh7722.c arch/sh/kernel/cpu/sh4a/setup-sh7723.c arch/sh/kernel/cpu/sh4a/setup-sh7724.c arch/sh/kernel/cpu/sh4a/setup-sh7763.c arch/sh/kernel/cpu/sh4a/setup-sh7770.c arch/sh/kernel/cpu/sh4a/setup-sh7780.c arch/sh/kernel/cpu/sh4a/setup-sh7785.c arch/sh/kernel/cpu/sh4a/setup-sh7786.c arch/sh/kernel/cpu/sh4a/setup-shx3.c arch/sh/kernel/cpu/sh5/setup-sh5.c drivers/serial/sh-sci.c drivers/serial/sh-sci.h include/linux/serial_sci.h
Diffstat (limited to 'net/tipc/net.c')
-rw-r--r--net/tipc/net.c105
1 files changed, 20 insertions, 85 deletions
diff --git a/net/tipc/net.c b/net/tipc/net.c
index 7906608bf510..9bacfd00b91e 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -35,18 +35,10 @@
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"
49#include "discover.h"
50#include "config.h" 42#include "config.h"
51 43
52/* 44/*
@@ -116,70 +108,25 @@
116*/ 108*/
117 109
118DEFINE_RWLOCK(tipc_net_lock); 110DEFINE_RWLOCK(tipc_net_lock);
119struct network tipc_net = { NULL }; 111struct network tipc_net;
120 112
121struct tipc_node *tipc_net_select_remote_node(u32 addr, u32 ref) 113static int net_start(void)
122{ 114{
123 return tipc_zone_select_remote_node(tipc_net.zones[tipc_zone(addr)], addr, ref); 115 tipc_net.nodes = kcalloc(tipc_max_nodes + 1,
124} 116 sizeof(*tipc_net.nodes), GFP_ATOMIC);
125 117 tipc_net.highest_node = 0;
126u32 tipc_net_select_router(u32 addr, u32 ref)
127{
128 return tipc_zone_select_router(tipc_net.zones[tipc_zone(addr)], addr, ref);
129}
130
131#if 0
132u32 tipc_net_next_node(u32 a)
133{
134 if (tipc_net.zones[tipc_zone(a)])
135 return tipc_zone_next_node(a);
136 return 0;
137}
138#endif
139
140void tipc_net_remove_as_router(u32 router)
141{
142 u32 z_num;
143
144 for (z_num = 1; z_num <= tipc_max_zones; z_num++) {
145 if (!tipc_net.zones[z_num])
146 continue;
147 tipc_zone_remove_as_router(tipc_net.zones[z_num], router);
148 }
149}
150
151void tipc_net_send_external_routes(u32 dest)
152{
153 u32 z_num;
154
155 for (z_num = 1; z_num <= tipc_max_zones; z_num++) {
156 if (tipc_net.zones[z_num])
157 tipc_zone_send_external_routes(tipc_net.zones[z_num], dest);
158 }
159}
160 118
161static int net_init(void) 119 return tipc_net.nodes ? 0 : -ENOMEM;
162{
163 memset(&tipc_net, 0, sizeof(tipc_net));
164 tipc_net.zones = kcalloc(tipc_max_zones + 1, sizeof(struct _zone *), GFP_ATOMIC);
165 if (!tipc_net.zones) {
166 return -ENOMEM;
167 }
168 return 0;
169} 120}
170 121
171static void net_stop(void) 122static void net_stop(void)
172{ 123{
173 u32 z_num; 124 u32 n_num;
174 125
175 if (!tipc_net.zones) 126 for (n_num = 1; n_num <= tipc_net.highest_node; n_num++)
176 return; 127 tipc_node_delete(tipc_net.nodes[n_num]);
177 128 kfree(tipc_net.nodes);
178 for (z_num = 1; z_num <= tipc_max_zones; z_num++) { 129 tipc_net.nodes = NULL;
179 tipc_zone_delete(tipc_net.zones[z_num]);
180 }
181 kfree(tipc_net.zones);
182 tipc_net.zones = NULL;
183} 130}
184 131
185static void net_route_named_msg(struct sk_buff *buf) 132static void net_route_named_msg(struct sk_buff *buf)
@@ -189,22 +136,18 @@ static void net_route_named_msg(struct sk_buff *buf)
189 u32 dport; 136 u32 dport;
190 137
191 if (!msg_named(msg)) { 138 if (!msg_named(msg)) {
192 msg_dbg(msg, "tipc_net->drop_nam:");
193 buf_discard(buf); 139 buf_discard(buf);
194 return; 140 return;
195 } 141 }
196 142
197 dnode = addr_domain(msg_lookup_scope(msg)); 143 dnode = addr_domain(msg_lookup_scope(msg));
198 dport = tipc_nametbl_translate(msg_nametype(msg), msg_nameinst(msg), &dnode); 144 dport = tipc_nametbl_translate(msg_nametype(msg), msg_nameinst(msg), &dnode);
199 dbg("tipc_net->lookup<%u,%u>-><%u,%x>\n",
200 msg_nametype(msg), msg_nameinst(msg), dport, dnode);
201 if (dport) { 145 if (dport) {
202 msg_set_destnode(msg, dnode); 146 msg_set_destnode(msg, dnode);
203 msg_set_destport(msg, dport); 147 msg_set_destport(msg, dport);
204 tipc_net_route_msg(buf); 148 tipc_net_route_msg(buf);
205 return; 149 return;
206 } 150 }
207 msg_dbg(msg, "tipc_net->rej:NO NAME: ");
208 tipc_reject_msg(buf, TIPC_ERR_NO_NAME); 151 tipc_reject_msg(buf, TIPC_ERR_NO_NAME);
209} 152}
210 153
@@ -220,21 +163,17 @@ void tipc_net_route_msg(struct sk_buff *buf)
220 msg_incr_reroute_cnt(msg); 163 msg_incr_reroute_cnt(msg);
221 if (msg_reroute_cnt(msg) > 6) { 164 if (msg_reroute_cnt(msg) > 6) {
222 if (msg_errcode(msg)) { 165 if (msg_errcode(msg)) {
223 msg_dbg(msg, "NET>DISC>:");
224 buf_discard(buf); 166 buf_discard(buf);
225 } else { 167 } else {
226 msg_dbg(msg, "NET>REJ>:");
227 tipc_reject_msg(buf, msg_destport(msg) ? 168 tipc_reject_msg(buf, msg_destport(msg) ?
228 TIPC_ERR_NO_PORT : TIPC_ERR_NO_NAME); 169 TIPC_ERR_NO_PORT : TIPC_ERR_NO_NAME);
229 } 170 }
230 return; 171 return;
231 } 172 }
232 173
233 msg_dbg(msg, "tipc_net->rout: ");
234
235 /* Handle message for this node */ 174 /* Handle message for this node */
236 dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg); 175 dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg);
237 if (in_scope(dnode, tipc_own_addr)) { 176 if (tipc_in_scope(dnode, tipc_own_addr)) {
238 if (msg_isdata(msg)) { 177 if (msg_isdata(msg)) {
239 if (msg_mcast(msg)) 178 if (msg_mcast(msg))
240 tipc_port_recv_mcast(buf, NULL); 179 tipc_port_recv_mcast(buf, NULL);
@@ -245,9 +184,6 @@ void tipc_net_route_msg(struct sk_buff *buf)
245 return; 184 return;
246 } 185 }
247 switch (msg_user(msg)) { 186 switch (msg_user(msg)) {
248 case ROUTE_DISTRIBUTOR:
249 tipc_cltr_recv_routing_table(buf);
250 break;
251 case NAME_DISTRIBUTOR: 187 case NAME_DISTRIBUTOR:
252 tipc_named_recv(buf); 188 tipc_named_recv(buf);
253 break; 189 break;
@@ -255,14 +191,13 @@ void tipc_net_route_msg(struct sk_buff *buf)
255 tipc_port_recv_proto_msg(buf); 191 tipc_port_recv_proto_msg(buf);
256 break; 192 break;
257 default: 193 default:
258 msg_dbg(msg,"DROP/NET/<REC<");
259 buf_discard(buf); 194 buf_discard(buf);
260 } 195 }
261 return; 196 return;
262 } 197 }
263 198
264 /* Handle message for another node */ 199 /* Handle message for another node */
265 msg_dbg(msg, "NET>SEND>: "); 200 skb_trim(buf, msg_size(msg));
266 tipc_link_send(buf, dnode, msg_link_selector(msg)); 201 tipc_link_send(buf, dnode, msg_link_selector(msg));
267} 202}
268 203
@@ -282,19 +217,19 @@ int tipc_net_start(u32 addr)
282 tipc_named_reinit(); 217 tipc_named_reinit();
283 tipc_port_reinit(); 218 tipc_port_reinit();
284 219
285 if ((res = tipc_bearer_init()) || 220 res = net_start();
286 (res = net_init()) || 221 if (res)
287 (res = tipc_cltr_init()) || 222 return res;
288 (res = tipc_bclink_init())) { 223 res = tipc_bclink_init();
224 if (res)
289 return res; 225 return res;
290 }
291 226
292 tipc_k_signal((Handler)tipc_subscr_start, 0); 227 tipc_k_signal((Handler)tipc_subscr_start, 0);
293 tipc_k_signal((Handler)tipc_cfg_init, 0); 228 tipc_k_signal((Handler)tipc_cfg_init, 0);
294 229
295 info("Started in network mode\n"); 230 info("Started in network mode\n");
296 info("Own node address %s, network identity %u\n", 231 info("Own node address %s, network identity %u\n",
297 addr_string_fill(addr_string, tipc_own_addr), tipc_net_id); 232 tipc_addr_string_fill(addr_string, tipc_own_addr), tipc_net_id);
298 return 0; 233 return 0;
299} 234}
300 235
@@ -308,6 +243,6 @@ void tipc_net_stop(void)
308 tipc_bclink_stop(); 243 tipc_bclink_stop();
309 net_stop(); 244 net_stop();
310 write_unlock_bh(&tipc_net_lock); 245 write_unlock_bh(&tipc_net_lock);
311 info("Left network mode \n"); 246 info("Left network mode\n");
312} 247}
313 248