node.c (f1379173326de4c745c4f610501486e4f3bd9248) node.c (9df3b7eb6ec1c7734482f782bf8335a2737c02f0)
1/*
2 * net/tipc/node.c: TIPC node management routines
3 *
4 * Copyright (c) 2000-2006, Ericsson AB
5 * Copyright (c) 2005-2006, 2010-2011, Wind River Systems
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 219 unchanged lines hidden (view full) ---

228 if (n_ptr->link_cnt >= 2) {
229 err("Attempt to create third link to %s\n",
230 tipc_addr_string_fill(addr_string, n_ptr->addr));
231 return NULL;
232 }
233
234 if (!n_ptr->links[bearer_id]) {
235 n_ptr->links[bearer_id] = l_ptr;
1/*
2 * net/tipc/node.c: TIPC node management routines
3 *
4 * Copyright (c) 2000-2006, Ericsson AB
5 * Copyright (c) 2005-2006, 2010-2011, Wind River Systems
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 219 unchanged lines hidden (view full) ---

228 if (n_ptr->link_cnt >= 2) {
229 err("Attempt to create third link to %s\n",
230 tipc_addr_string_fill(addr_string, n_ptr->addr));
231 return NULL;
232 }
233
234 if (!n_ptr->links[bearer_id]) {
235 n_ptr->links[bearer_id] = l_ptr;
236 tipc_net.links++;
236 atomic_inc(&tipc_net.links);
237 n_ptr->link_cnt++;
238 return n_ptr;
239 }
240 err("Attempt to establish second link on <%s> to %s\n",
241 l_ptr->b_ptr->name,
242 tipc_addr_string_fill(addr_string, l_ptr->addr));
243 }
244 return NULL;
245}
246
247void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr)
248{
249 n_ptr->links[l_ptr->b_ptr->identity] = NULL;
237 n_ptr->link_cnt++;
238 return n_ptr;
239 }
240 err("Attempt to establish second link on <%s> to %s\n",
241 l_ptr->b_ptr->name,
242 tipc_addr_string_fill(addr_string, l_ptr->addr));
243 }
244 return NULL;
245}
246
247void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr)
248{
249 n_ptr->links[l_ptr->b_ptr->identity] = NULL;
250 tipc_net.links--;
250 atomic_dec(&tipc_net.links);
251 n_ptr->link_cnt--;
252}
253
254/*
255 * Routing table management - five cases to handle:
256 *
257 * 1: A link towards a zone/cluster external node comes up.
258 * => Send a multicast message updating routing tables of all

--- 186 unchanged lines hidden (view full) ---

445
446 if (tipc_mode != TIPC_NET_MODE)
447 return tipc_cfg_reply_none();
448
449 read_lock_bh(&tipc_net_lock);
450
451 /* Get space for all unicast links + multicast link */
452
251 n_ptr->link_cnt--;
252}
253
254/*
255 * Routing table management - five cases to handle:
256 *
257 * 1: A link towards a zone/cluster external node comes up.
258 * => Send a multicast message updating routing tables of all

--- 186 unchanged lines hidden (view full) ---

445
446 if (tipc_mode != TIPC_NET_MODE)
447 return tipc_cfg_reply_none();
448
449 read_lock_bh(&tipc_net_lock);
450
451 /* Get space for all unicast links + multicast link */
452
453 payload_size = TLV_SPACE(sizeof(link_info)) * (tipc_net.links + 1);
453 payload_size = TLV_SPACE(sizeof(link_info)) *
454 (atomic_read(&tipc_net.links) + 1);
454 if (payload_size > 32768u) {
455 read_unlock_bh(&tipc_net_lock);
456 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
457 " (too many links)");
458 }
459 buf = tipc_cfg_reply_alloc(payload_size);
460 if (!buf) {
461 read_unlock_bh(&tipc_net_lock);

--- 34 unchanged lines hidden ---
455 if (payload_size > 32768u) {
456 read_unlock_bh(&tipc_net_lock);
457 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
458 " (too many links)");
459 }
460 buf = tipc_cfg_reply_alloc(payload_size);
461 if (!buf) {
462 read_unlock_bh(&tipc_net_lock);

--- 34 unchanged lines hidden ---