aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/name_distr.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/name_distr.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/name_distr.c')
-rw-r--r--net/tipc/name_distr.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index 6ac3c543250b..80025a1b3bfd 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -2,7 +2,7 @@
2 * net/tipc/name_distr.c: TIPC name distribution code 2 * net/tipc/name_distr.c: TIPC name distribution code
3 * 3 *
4 * Copyright (c) 2000-2006, Ericsson AB 4 * Copyright (c) 2000-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,10 +35,7 @@
35 */ 35 */
36 36
37#include "core.h" 37#include "core.h"
38#include "cluster.h"
39#include "dbg.h"
40#include "link.h" 38#include "link.h"
41#include "msg.h"
42#include "name_distr.h" 39#include "name_distr.h"
43 40
44#define ITEM_SIZE sizeof(struct distr_item) 41#define ITEM_SIZE sizeof(struct distr_item)
@@ -76,7 +73,7 @@ struct distr_item {
76 */ 73 */
77 74
78static LIST_HEAD(publ_root); 75static LIST_HEAD(publ_root);
79static u32 publ_cnt = 0; 76static u32 publ_cnt;
80 77
81/** 78/**
82 * publ_to_item - add publication info to a publication message 79 * publ_to_item - add publication info to a publication message
@@ -89,7 +86,6 @@ static void publ_to_item(struct distr_item *i, struct publication *p)
89 i->upper = htonl(p->upper); 86 i->upper = htonl(p->upper);
90 i->ref = htonl(p->ref); 87 i->ref = htonl(p->ref);
91 i->key = htonl(p->key); 88 i->key = htonl(p->key);
92 dbg("publ_to_item: %u, %u, %u\n", p->type, p->lower, p->upper);
93} 89}
94 90
95/** 91/**
@@ -98,7 +94,7 @@ static void publ_to_item(struct distr_item *i, struct publication *p)
98 94
99static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest) 95static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest)
100{ 96{
101 struct sk_buff *buf = buf_acquire(LONG_H_SIZE + size); 97 struct sk_buff *buf = tipc_buf_acquire(LONG_H_SIZE + size);
102 struct tipc_msg *msg; 98 struct tipc_msg *msg;
103 99
104 if (buf != NULL) { 100 if (buf != NULL) {
@@ -109,6 +105,24 @@ static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest)
109 return buf; 105 return buf;
110} 106}
111 107
108static void named_cluster_distribute(struct sk_buff *buf)
109{
110 struct sk_buff *buf_copy;
111 struct tipc_node *n_ptr;
112
113 list_for_each_entry(n_ptr, &tipc_node_list, list) {
114 if (tipc_node_active_links(n_ptr)) {
115 buf_copy = skb_copy(buf, GFP_ATOMIC);
116 if (!buf_copy)
117 break;
118 msg_set_destnode(buf_msg(buf_copy), n_ptr->addr);
119 tipc_link_send(buf_copy, n_ptr->addr, n_ptr->addr);
120 }
121 }
122
123 buf_discard(buf);
124}
125
112/** 126/**
113 * tipc_named_publish - tell other nodes about a new publication by this node 127 * tipc_named_publish - tell other nodes about a new publication by this node
114 */ 128 */
@@ -129,8 +143,7 @@ void tipc_named_publish(struct publication *publ)
129 143
130 item = (struct distr_item *)msg_data(buf_msg(buf)); 144 item = (struct distr_item *)msg_data(buf_msg(buf));
131 publ_to_item(item, publ); 145 publ_to_item(item, publ);
132 dbg("tipc_named_withdraw: broadcasting publish msg\n"); 146 named_cluster_distribute(buf);
133 tipc_cltr_broadcast(buf);
134} 147}
135 148
136/** 149/**
@@ -147,14 +160,13 @@ void tipc_named_withdraw(struct publication *publ)
147 160
148 buf = named_prepare_buf(WITHDRAWAL, ITEM_SIZE, 0); 161 buf = named_prepare_buf(WITHDRAWAL, ITEM_SIZE, 0);
149 if (!buf) { 162 if (!buf) {
150 warn("Withdrawl distribution failure\n"); 163 warn("Withdrawal distribution failure\n");
151 return; 164 return;
152 } 165 }
153 166
154 item = (struct distr_item *)msg_data(buf_msg(buf)); 167 item = (struct distr_item *)msg_data(buf_msg(buf));
155 publ_to_item(item, publ); 168 publ_to_item(item, publ);
156 dbg("tipc_named_withdraw: broadcasting withdraw msg\n"); 169 named_cluster_distribute(buf);
157 tipc_cltr_broadcast(buf);
158} 170}
159 171
160/** 172/**
@@ -191,9 +203,6 @@ void tipc_named_node_up(unsigned long node)
191 left -= ITEM_SIZE; 203 left -= ITEM_SIZE;
192 if (!left) { 204 if (!left) {
193 msg_set_link_selector(buf_msg(buf), node); 205 msg_set_link_selector(buf_msg(buf), node);
194 dbg("tipc_named_node_up: sending publish msg to "
195 "<%u.%u.%u>\n", tipc_zone(node),
196 tipc_cluster(node), tipc_node(node));
197 tipc_link_send(buf, node, node); 206 tipc_link_send(buf, node, node);
198 buf = NULL; 207 buf = NULL;
199 } 208 }
@@ -203,26 +212,25 @@ exit:
203} 212}
204 213
205/** 214/**
206 * node_is_down - remove publication associated with a failed node 215 * named_purge_publ - remove publication associated with a failed node
207 * 216 *
208 * Invoked for each publication issued by a newly failed node. 217 * Invoked for each publication issued by a newly failed node.
209 * Removes publication structure from name table & deletes it. 218 * Removes publication structure from name table & deletes it.
210 * In rare cases the link may have come back up again when this 219 * In rare cases the link may have come back up again when this
211 * function is called, and we have two items representing the same 220 * function is called, and we have two items representing the same
212 * publication. Nudge this item's key to distinguish it from the other. 221 * publication. Nudge this item's key to distinguish it from the other.
213 * (Note: Publication's node subscription is already unsubscribed.)
214 */ 222 */
215 223
216static void node_is_down(struct publication *publ) 224static void named_purge_publ(struct publication *publ)
217{ 225{
218 struct publication *p; 226 struct publication *p;
219 227
220 write_lock_bh(&tipc_nametbl_lock); 228 write_lock_bh(&tipc_nametbl_lock);
221 dbg("node_is_down: withdrawing %u, %u, %u\n",
222 publ->type, publ->lower, publ->upper);
223 publ->key += 1222345; 229 publ->key += 1222345;
224 p = tipc_nametbl_remove_publ(publ->type, publ->lower, 230 p = tipc_nametbl_remove_publ(publ->type, publ->lower,
225 publ->node, publ->ref, publ->key); 231 publ->node, publ->ref, publ->key);
232 if (p)
233 tipc_nodesub_unsubscribe(&p->subscr);
226 write_unlock_bh(&tipc_nametbl_lock); 234 write_unlock_bh(&tipc_nametbl_lock);
227 235
228 if (p != publ) { 236 if (p != publ) {
@@ -231,9 +239,7 @@ static void node_is_down(struct publication *publ)
231 publ->type, publ->lower, publ->node, publ->ref, publ->key); 239 publ->type, publ->lower, publ->node, publ->ref, publ->key);
232 } 240 }
233 241
234 if (p) { 242 kfree(p);
235 kfree(p);
236 }
237} 243}
238 244
239/** 245/**
@@ -250,9 +256,6 @@ void tipc_named_recv(struct sk_buff *buf)
250 write_lock_bh(&tipc_nametbl_lock); 256 write_lock_bh(&tipc_nametbl_lock);
251 while (count--) { 257 while (count--) {
252 if (msg_type(msg) == PUBLICATION) { 258 if (msg_type(msg) == PUBLICATION) {
253 dbg("tipc_named_recv: got publication for %u, %u, %u\n",
254 ntohl(item->type), ntohl(item->lower),
255 ntohl(item->upper));
256 publ = tipc_nametbl_insert_publ(ntohl(item->type), 259 publ = tipc_nametbl_insert_publ(ntohl(item->type),
257 ntohl(item->lower), 260 ntohl(item->lower),
258 ntohl(item->upper), 261 ntohl(item->upper),
@@ -264,12 +267,10 @@ void tipc_named_recv(struct sk_buff *buf)
264 tipc_nodesub_subscribe(&publ->subscr, 267 tipc_nodesub_subscribe(&publ->subscr,
265 msg_orignode(msg), 268 msg_orignode(msg),
266 publ, 269 publ,
267 (net_ev_handler)node_is_down); 270 (net_ev_handler)
271 named_purge_publ);
268 } 272 }
269 } else if (msg_type(msg) == WITHDRAWAL) { 273 } else if (msg_type(msg) == WITHDRAWAL) {
270 dbg("tipc_named_recv: got withdrawl for %u, %u, %u\n",
271 ntohl(item->type), ntohl(item->lower),
272 ntohl(item->upper));
273 publ = tipc_nametbl_remove_publ(ntohl(item->type), 274 publ = tipc_nametbl_remove_publ(ntohl(item->type),
274 ntohl(item->lower), 275 ntohl(item->lower),
275 msg_orignode(msg), 276 msg_orignode(msg),