aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/net.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /net/tipc/net.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'net/tipc/net.c')
-rw-r--r--net/tipc/net.c86
1 files changed, 9 insertions, 77 deletions
diff --git a/net/tipc/net.c b/net/tipc/net.c
index f61b7694138b..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,56 +109,6 @@
116*/ 109*/
117 110
118DEFINE_RWLOCK(tipc_net_lock); 111DEFINE_RWLOCK(tipc_net_lock);
119static struct _zone *tipc_zones[256] = { NULL, };
120struct network tipc_net = { tipc_zones };
121
122struct 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
127u32 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#if 0
133u32 tipc_net_next_node(u32 a)
134{
135 if (tipc_net.zones[tipc_zone(a)])
136 return tipc_zone_next_node(a);
137 return 0;
138}
139#endif
140
141void tipc_net_remove_as_router(u32 router)
142{
143 u32 z_num;
144
145 for (z_num = 1; z_num <= tipc_max_zones; z_num++) {
146 if (!tipc_net.zones[z_num])
147 continue;
148 tipc_zone_remove_as_router(tipc_net.zones[z_num], router);
149 }
150}
151
152void tipc_net_send_external_routes(u32 dest)
153{
154 u32 z_num;
155
156 for (z_num = 1; z_num <= tipc_max_zones; z_num++) {
157 if (tipc_net.zones[z_num])
158 tipc_zone_send_external_routes(tipc_net.zones[z_num], dest);
159 }
160}
161
162static void net_stop(void)
163{
164 u32 z_num;
165
166 for (z_num = 1; z_num <= tipc_max_zones; z_num++)
167 tipc_zone_delete(tipc_net.zones[z_num]);
168}
169 112
170static void net_route_named_msg(struct sk_buff *buf) 113static void net_route_named_msg(struct sk_buff *buf)
171{ 114{
@@ -174,22 +117,18 @@ static void net_route_named_msg(struct sk_buff *buf)
174 u32 dport; 117 u32 dport;
175 118
176 if (!msg_named(msg)) { 119 if (!msg_named(msg)) {
177 msg_dbg(msg, "tipc_net->drop_nam:");
178 buf_discard(buf); 120 buf_discard(buf);
179 return; 121 return;
180 } 122 }
181 123
182 dnode = addr_domain(msg_lookup_scope(msg)); 124 dnode = addr_domain(msg_lookup_scope(msg));
183 dport = tipc_nametbl_translate(msg_nametype(msg), msg_nameinst(msg), &dnode); 125 dport = tipc_nametbl_translate(msg_nametype(msg), msg_nameinst(msg), &dnode);
184 dbg("tipc_net->lookup<%u,%u>-><%u,%x>\n",
185 msg_nametype(msg), msg_nameinst(msg), dport, dnode);
186 if (dport) { 126 if (dport) {
187 msg_set_destnode(msg, dnode); 127 msg_set_destnode(msg, dnode);
188 msg_set_destport(msg, dport); 128 msg_set_destport(msg, dport);
189 tipc_net_route_msg(buf); 129 tipc_net_route_msg(buf);
190 return; 130 return;
191 } 131 }
192 msg_dbg(msg, "tipc_net->rej:NO NAME: ");
193 tipc_reject_msg(buf, TIPC_ERR_NO_NAME); 132 tipc_reject_msg(buf, TIPC_ERR_NO_NAME);
194} 133}
195 134
@@ -205,18 +144,14 @@ void tipc_net_route_msg(struct sk_buff *buf)
205 msg_incr_reroute_cnt(msg); 144 msg_incr_reroute_cnt(msg);
206 if (msg_reroute_cnt(msg) > 6) { 145 if (msg_reroute_cnt(msg) > 6) {
207 if (msg_errcode(msg)) { 146 if (msg_errcode(msg)) {
208 msg_dbg(msg, "NET>DISC>:");
209 buf_discard(buf); 147 buf_discard(buf);
210 } else { 148 } else {
211 msg_dbg(msg, "NET>REJ>:");
212 tipc_reject_msg(buf, msg_destport(msg) ? 149 tipc_reject_msg(buf, msg_destport(msg) ?
213 TIPC_ERR_NO_PORT : TIPC_ERR_NO_NAME); 150 TIPC_ERR_NO_PORT : TIPC_ERR_NO_NAME);
214 } 151 }
215 return; 152 return;
216 } 153 }
217 154
218 msg_dbg(msg, "tipc_net->rout: ");
219
220 /* Handle message for this node */ 155 /* Handle message for this node */
221 dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg); 156 dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg);
222 if (tipc_in_scope(dnode, tipc_own_addr)) { 157 if (tipc_in_scope(dnode, tipc_own_addr)) {
@@ -230,9 +165,6 @@ void tipc_net_route_msg(struct sk_buff *buf)
230 return; 165 return;
231 } 166 }
232 switch (msg_user(msg)) { 167 switch (msg_user(msg)) {
233 case ROUTE_DISTRIBUTOR:
234 tipc_cltr_recv_routing_table(buf);
235 break;
236 case NAME_DISTRIBUTOR: 168 case NAME_DISTRIBUTOR:
237 tipc_named_recv(buf); 169 tipc_named_recv(buf);
238 break; 170 break;
@@ -240,14 +172,13 @@ void tipc_net_route_msg(struct sk_buff *buf)
240 tipc_port_recv_proto_msg(buf); 172 tipc_port_recv_proto_msg(buf);
241 break; 173 break;
242 default: 174 default:
243 msg_dbg(msg,"DROP/NET/<REC<");
244 buf_discard(buf); 175 buf_discard(buf);
245 } 176 }
246 return; 177 return;
247 } 178 }
248 179
249 /* Handle message for another node */ 180 /* Handle message for another node */
250 msg_dbg(msg, "NET>SEND>: "); 181 skb_trim(buf, msg_size(msg));
251 tipc_link_send(buf, dnode, msg_link_selector(msg)); 182 tipc_link_send(buf, dnode, msg_link_selector(msg));
252} 183}
253 184
@@ -267,10 +198,9 @@ int tipc_net_start(u32 addr)
267 tipc_named_reinit(); 198 tipc_named_reinit();
268 tipc_port_reinit(); 199 tipc_port_reinit();
269 200
270 if ((res = tipc_cltr_init()) || 201 res = tipc_bclink_init();
271 (res = tipc_bclink_init())) { 202 if (res)
272 return res; 203 return res;
273 }
274 204
275 tipc_k_signal((Handler)tipc_subscr_start, 0); 205 tipc_k_signal((Handler)tipc_subscr_start, 0);
276 tipc_k_signal((Handler)tipc_cfg_init, 0); 206 tipc_k_signal((Handler)tipc_cfg_init, 0);
@@ -283,14 +213,16 @@ int tipc_net_start(u32 addr)
283 213
284void tipc_net_stop(void) 214void tipc_net_stop(void)
285{ 215{
216 struct tipc_node *node, *t_node;
217
286 if (tipc_mode != TIPC_NET_MODE) 218 if (tipc_mode != TIPC_NET_MODE)
287 return; 219 return;
288 write_lock_bh(&tipc_net_lock); 220 write_lock_bh(&tipc_net_lock);
289 tipc_bearer_stop(); 221 tipc_bearer_stop();
290 tipc_mode = TIPC_NODE_MODE; 222 tipc_mode = TIPC_NODE_MODE;
291 tipc_bclink_stop(); 223 tipc_bclink_stop();
292 net_stop(); 224 list_for_each_entry_safe(node, t_node, &tipc_node_list, list)
225 tipc_node_delete(node);
293 write_unlock_bh(&tipc_net_lock); 226 write_unlock_bh(&tipc_net_lock);
294 info("Left network mode\n"); 227 info("Left network mode\n");
295} 228}
296