diff options
Diffstat (limited to 'net/tipc/node.c')
| -rw-r--r-- | net/tipc/node.c | 84 |
1 files changed, 23 insertions, 61 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c index 6b226faad89f..a34cabc2c43a 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
| @@ -39,6 +39,8 @@ | |||
| 39 | #include "node.h" | 39 | #include "node.h" |
| 40 | #include "name_distr.h" | 40 | #include "name_distr.h" |
| 41 | 41 | ||
| 42 | #define NODE_HTABLE_SIZE 512 | ||
| 43 | |||
| 42 | static void node_lost_contact(struct tipc_node *n_ptr); | 44 | static void node_lost_contact(struct tipc_node *n_ptr); |
| 43 | static void node_established_contact(struct tipc_node *n_ptr); | 45 | static void node_established_contact(struct tipc_node *n_ptr); |
| 44 | 46 | ||
| @@ -49,9 +51,19 @@ LIST_HEAD(tipc_node_list); | |||
| 49 | static u32 tipc_num_nodes; | 51 | static u32 tipc_num_nodes; |
| 50 | 52 | ||
| 51 | static atomic_t tipc_num_links = ATOMIC_INIT(0); | 53 | static atomic_t tipc_num_links = ATOMIC_INIT(0); |
| 52 | u32 tipc_own_tag; | ||
| 53 | 54 | ||
| 54 | /** | 55 | /* |
| 56 | * A trivial power-of-two bitmask technique is used for speed, since this | ||
| 57 | * operation is done for every incoming TIPC packet. The number of hash table | ||
| 58 | * entries has been chosen so that no hash chain exceeds 8 nodes and will | ||
| 59 | * usually be much smaller (typically only a single node). | ||
| 60 | */ | ||
| 61 | static inline unsigned int tipc_hashfn(u32 addr) | ||
| 62 | { | ||
| 63 | return addr & (NODE_HTABLE_SIZE - 1); | ||
| 64 | } | ||
| 65 | |||
| 66 | /* | ||
| 55 | * tipc_node_find - locate specified node object, if it exists | 67 | * tipc_node_find - locate specified node object, if it exists |
| 56 | */ | 68 | */ |
| 57 | 69 | ||
| @@ -113,6 +125,7 @@ struct tipc_node *tipc_node_create(u32 addr) | |||
| 113 | } | 125 | } |
| 114 | list_add_tail(&n_ptr->list, &temp_node->list); | 126 | list_add_tail(&n_ptr->list, &temp_node->list); |
| 115 | n_ptr->block_setup = WAIT_PEER_DOWN; | 127 | n_ptr->block_setup = WAIT_PEER_DOWN; |
| 128 | n_ptr->signature = INVALID_NODE_SIG; | ||
| 116 | 129 | ||
| 117 | tipc_num_nodes++; | 130 | tipc_num_nodes++; |
| 118 | 131 | ||
| @@ -253,63 +266,14 @@ void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | |||
| 253 | n_ptr->link_cnt--; | 266 | n_ptr->link_cnt--; |
| 254 | } | 267 | } |
| 255 | 268 | ||
| 256 | /* | ||
| 257 | * Routing table management - five cases to handle: | ||
| 258 | * | ||
| 259 | * 1: A link towards a zone/cluster external node comes up. | ||
| 260 | * => Send a multicast message updating routing tables of all | ||
| 261 | * system nodes within own cluster that the new destination | ||
| 262 | * can be reached via this node. | ||
| 263 | * (node.establishedContact()=>cluster.multicastNewRoute()) | ||
| 264 | * | ||
| 265 | * 2: A link towards a slave node comes up. | ||
| 266 | * => Send a multicast message updating routing tables of all | ||
| 267 | * system nodes within own cluster that the new destination | ||
| 268 | * can be reached via this node. | ||
| 269 | * (node.establishedContact()=>cluster.multicastNewRoute()) | ||
| 270 | * => Send a message to the slave node about existence | ||
| 271 | * of all system nodes within cluster: | ||
| 272 | * (node.establishedContact()=>cluster.sendLocalRoutes()) | ||
| 273 | * | ||
| 274 | * 3: A new cluster local system node becomes available. | ||
| 275 | * => Send message(s) to this particular node containing | ||
| 276 | * information about all cluster external and slave | ||
| 277 | * nodes which can be reached via this node. | ||
| 278 | * (node.establishedContact()==>network.sendExternalRoutes()) | ||
| 279 | * (node.establishedContact()==>network.sendSlaveRoutes()) | ||
| 280 | * => Send messages to all directly connected slave nodes | ||
| 281 | * containing information about the existence of the new node | ||
| 282 | * (node.establishedContact()=>cluster.multicastNewRoute()) | ||
| 283 | * | ||
| 284 | * 4: The link towards a zone/cluster external node or slave | ||
| 285 | * node goes down. | ||
| 286 | * => Send a multcast message updating routing tables of all | ||
| 287 | * nodes within cluster that the new destination can not any | ||
| 288 | * longer be reached via this node. | ||
| 289 | * (node.lostAllLinks()=>cluster.bcastLostRoute()) | ||
| 290 | * | ||
| 291 | * 5: A cluster local system node becomes unavailable. | ||
| 292 | * => Remove all references to this node from the local | ||
| 293 | * routing tables. Note: This is a completely node | ||
| 294 | * local operation. | ||
| 295 | * (node.lostAllLinks()=>network.removeAsRouter()) | ||
| 296 | * => Send messages to all directly connected slave nodes | ||
| 297 | * containing information about loss of the node | ||
| 298 | * (node.establishedContact()=>cluster.multicastLostRoute()) | ||
| 299 | * | ||
| 300 | */ | ||
| 301 | |||
| 302 | static void node_established_contact(struct tipc_node *n_ptr) | 269 | static void node_established_contact(struct tipc_node *n_ptr) |
| 303 | { | 270 | { |
| 304 | tipc_k_signal((Handler)tipc_named_node_up, n_ptr->addr); | 271 | tipc_k_signal((Handler)tipc_named_node_up, n_ptr->addr); |
| 305 | 272 | ||
| 306 | /* Syncronize broadcast acks */ | 273 | if (n_ptr->bclink.supportable) { |
| 307 | n_ptr->bclink.acked = tipc_bclink_get_last_sent(); | 274 | n_ptr->bclink.acked = tipc_bclink_get_last_sent(); |
| 308 | |||
| 309 | if (n_ptr->bclink.supported) { | ||
| 310 | tipc_bclink_add_node(n_ptr->addr); | 275 | tipc_bclink_add_node(n_ptr->addr); |
| 311 | if (n_ptr->addr < tipc_own_addr) | 276 | n_ptr->bclink.supported = 1; |
| 312 | tipc_own_tag++; | ||
| 313 | } | 277 | } |
| 314 | } | 278 | } |
| 315 | 279 | ||
| @@ -338,22 +302,20 @@ static void node_lost_contact(struct tipc_node *n_ptr) | |||
| 338 | /* Flush broadcast link info associated with lost node */ | 302 | /* Flush broadcast link info associated with lost node */ |
| 339 | 303 | ||
| 340 | if (n_ptr->bclink.supported) { | 304 | if (n_ptr->bclink.supported) { |
| 341 | n_ptr->bclink.gap_after = n_ptr->bclink.gap_to = 0; | ||
| 342 | while (n_ptr->bclink.deferred_head) { | 305 | while (n_ptr->bclink.deferred_head) { |
| 343 | struct sk_buff *buf = n_ptr->bclink.deferred_head; | 306 | struct sk_buff *buf = n_ptr->bclink.deferred_head; |
| 344 | n_ptr->bclink.deferred_head = buf->next; | 307 | n_ptr->bclink.deferred_head = buf->next; |
| 345 | buf_discard(buf); | 308 | kfree_skb(buf); |
| 346 | } | 309 | } |
| 310 | n_ptr->bclink.deferred_size = 0; | ||
| 347 | 311 | ||
| 348 | if (n_ptr->bclink.defragm) { | 312 | if (n_ptr->bclink.defragm) { |
| 349 | buf_discard(n_ptr->bclink.defragm); | 313 | kfree_skb(n_ptr->bclink.defragm); |
| 350 | n_ptr->bclink.defragm = NULL; | 314 | n_ptr->bclink.defragm = NULL; |
| 351 | } | 315 | } |
| 352 | 316 | ||
| 353 | tipc_bclink_remove_node(n_ptr->addr); | 317 | tipc_bclink_remove_node(n_ptr->addr); |
| 354 | tipc_bclink_acknowledge(n_ptr, INVALID_LINK_SEQ); | 318 | tipc_bclink_acknowledge(n_ptr, INVALID_LINK_SEQ); |
| 355 | if (n_ptr->addr < tipc_own_addr) | ||
| 356 | tipc_own_tag--; | ||
| 357 | 319 | ||
| 358 | n_ptr->bclink.supported = 0; | 320 | n_ptr->bclink.supported = 0; |
| 359 | } | 321 | } |
| @@ -444,12 +406,12 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
| 444 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | 406 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE |
| 445 | " (network address)"); | 407 | " (network address)"); |
| 446 | 408 | ||
| 447 | if (tipc_mode != TIPC_NET_MODE) | 409 | if (!tipc_own_addr) |
| 448 | return tipc_cfg_reply_none(); | 410 | return tipc_cfg_reply_none(); |
| 449 | 411 | ||
| 450 | read_lock_bh(&tipc_net_lock); | 412 | read_lock_bh(&tipc_net_lock); |
| 451 | 413 | ||
| 452 | /* Get space for all unicast links + multicast link */ | 414 | /* Get space for all unicast links + broadcast link */ |
| 453 | 415 | ||
| 454 | payload_size = TLV_SPACE(sizeof(link_info)) * | 416 | payload_size = TLV_SPACE(sizeof(link_info)) * |
| 455 | (atomic_read(&tipc_num_links) + 1); | 417 | (atomic_read(&tipc_num_links) + 1); |
