aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/discover.c
diff options
context:
space:
mode:
authorAllan Stephens <Allan.Stephens@windriver.com>2011-04-21 14:58:26 -0400
committerPaul Gortmaker <paul.gortmaker@windriver.com>2011-05-10 16:03:59 -0400
commit3a777ff8b14456e15991c9fcc225943453dc3a75 (patch)
tree50f2b2ca5c9a2a4a1df107da4db00611ae938f32 /net/tipc/discover.c
parentdc63d91eb1cf74233c68b0058dcd477f5d019d02 (diff)
tipc: Enhance handling of discovery object creation failures
Modifies bearer creation and deletion code to improve handling of scenarios when a neighbor discovery object cannot be created. The creation routine now aborts the creation of a bearer if its discovery object cannot be created, and deletes the newly created bearer, rather than failing quietly and leaving an unusable bearer hanging around. Since the exit via the goto label really isn't a definitive failure in all cases, relabel it appropriately. Signed-off-by: Allan Stephens <Allan.Stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc/discover.c')
-rw-r--r--net/tipc/discover.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index d2163bd99e59..6acf32a9eef8 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -216,22 +216,6 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
216} 216}
217 217
218/** 218/**
219 * tipc_disc_stop_link_req - stop sending periodic link setup requests
220 * @req: ptr to link request structure
221 */
222
223void tipc_disc_stop_link_req(struct link_req *req)
224{
225 if (!req)
226 return;
227
228 k_cancel_timer(&req->timer);
229 k_term_timer(&req->timer);
230 buf_discard(req->buf);
231 kfree(req);
232}
233
234/**
235 * tipc_disc_update_link_req - update frequency of periodic link setup requests 219 * tipc_disc_update_link_req - update frequency of periodic link setup requests
236 * @req: ptr to link request structure 220 * @req: ptr to link request structure
237 */ 221 */
@@ -286,28 +270,27 @@ static void disc_timeout(struct link_req *req)
286} 270}
287 271
288/** 272/**
289 * tipc_disc_init_link_req - start sending periodic link setup requests 273 * tipc_disc_create - create object to send periodic link setup requests
290 * @b_ptr: ptr to bearer issuing requests 274 * @b_ptr: ptr to bearer issuing requests
291 * @dest: destination address for request messages 275 * @dest: destination address for request messages
292 * @dest_domain: network domain to which links can be established 276 * @dest_domain: network domain to which links can be established
293 * 277 *
294 * Returns pointer to link request structure, or NULL if unable to create. 278 * Returns 0 if successful, otherwise -errno.
295 */ 279 */
296 280
297struct link_req *tipc_disc_init_link_req(struct tipc_bearer *b_ptr, 281int tipc_disc_create(struct tipc_bearer *b_ptr,
298 const struct tipc_media_addr *dest, 282 struct tipc_media_addr *dest, u32 dest_domain)
299 u32 dest_domain)
300{ 283{
301 struct link_req *req; 284 struct link_req *req;
302 285
303 req = kmalloc(sizeof(*req), GFP_ATOMIC); 286 req = kmalloc(sizeof(*req), GFP_ATOMIC);
304 if (!req) 287 if (!req)
305 return NULL; 288 return -ENOMEM;
306 289
307 req->buf = tipc_disc_init_msg(DSC_REQ_MSG, dest_domain, b_ptr); 290 req->buf = tipc_disc_init_msg(DSC_REQ_MSG, dest_domain, b_ptr);
308 if (!req->buf) { 291 if (!req->buf) {
309 kfree(req); 292 kfree(req);
310 return NULL; 293 return -ENOMSG;
311 } 294 }
312 295
313 memcpy(&req->dest, dest, sizeof(*dest)); 296 memcpy(&req->dest, dest, sizeof(*dest));
@@ -316,6 +299,20 @@ struct link_req *tipc_disc_init_link_req(struct tipc_bearer *b_ptr,
316 req->timer_intv = TIPC_LINK_REQ_INIT; 299 req->timer_intv = TIPC_LINK_REQ_INIT;
317 k_init_timer(&req->timer, (Handler)disc_timeout, (unsigned long)req); 300 k_init_timer(&req->timer, (Handler)disc_timeout, (unsigned long)req);
318 k_start_timer(&req->timer, req->timer_intv); 301 k_start_timer(&req->timer, req->timer_intv);
319 return req; 302 b_ptr->link_req = req;
303 return 0;
304}
305
306/**
307 * tipc_disc_delete - destroy object sending periodic link setup requests
308 * @req: ptr to link request structure
309 */
310
311void tipc_disc_delete(struct link_req *req)
312{
313 k_cancel_timer(&req->timer);
314 k_term_timer(&req->timer);
315 buf_discard(req->buf);
316 kfree(req);
320} 317}
321 318