aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-05-09 01:41:09 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-09 01:41:09 -0400
commita3ab3c13f1fe6eea92468ddd1681d41e133fe703 (patch)
tree8f08a86ecd8fc2b4fd35dc0ddc5bcec40194b61b
parent1b5d35358effb776b1ef47b26ec0df54af79d842 (diff)
parentca9cf06a0654fcf4b114a5a2d08723fc45d00317 (diff)
Merge branch 'tipc-next'
Ying Xue says: ==================== tipc: overhaul node action flags We currently have two problems with the node flags field: - The naming of the individual action flags is unclear and confusing - The flags are often not cleared individually, making it hard to follow where this happens. So the series aims to solve above two problems. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/tipc/link.c6
-rw-r--r--net/tipc/node.c19
-rw-r--r--net/tipc/node.h29
3 files changed, 27 insertions, 27 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c
index dce2bef81720..2140837fbab9 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1489,12 +1489,12 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr)
1489 goto unlock_discard; 1489 goto unlock_discard;
1490 1490
1491 /* Verify that communication with node is currently allowed */ 1491 /* Verify that communication with node is currently allowed */
1492 if ((n_ptr->flags & TIPC_NODE_DOWN) && 1492 if ((n_ptr->action_flags & TIPC_WAIT_PEER_LINKS_DOWN) &&
1493 msg_user(msg) == LINK_PROTOCOL && 1493 msg_user(msg) == LINK_PROTOCOL &&
1494 (msg_type(msg) == RESET_MSG || 1494 (msg_type(msg) == RESET_MSG ||
1495 msg_type(msg) == ACTIVATE_MSG) && 1495 msg_type(msg) == ACTIVATE_MSG) &&
1496 !msg_redundant_link(msg)) 1496 !msg_redundant_link(msg))
1497 n_ptr->flags &= ~TIPC_NODE_DOWN; 1497 n_ptr->action_flags &= ~TIPC_WAIT_PEER_LINKS_DOWN;
1498 1498
1499 if (tipc_node_blocked(n_ptr)) 1499 if (tipc_node_blocked(n_ptr))
1500 goto unlock_discard; 1500 goto unlock_discard;
@@ -1853,7 +1853,7 @@ static void tipc_link_proto_rcv(struct tipc_link *l_ptr, struct sk_buff *buf)
1853 * peer has lost contact -- don't allow peer's links 1853 * peer has lost contact -- don't allow peer's links
1854 * to reactivate before we recognize loss & clean up 1854 * to reactivate before we recognize loss & clean up
1855 */ 1855 */
1856 l_ptr->owner->flags = TIPC_NODE_RESET; 1856 l_ptr->owner->action_flags |= TIPC_WAIT_OWN_LINKS_DOWN;
1857 } 1857 }
1858 1858
1859 link_state_event(l_ptr, RESET_MSG); 1859 link_state_event(l_ptr, RESET_MSG);
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 74efebc1cb7a..facd5611e785 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -108,7 +108,7 @@ struct tipc_node *tipc_node_create(u32 addr)
108 break; 108 break;
109 } 109 }
110 list_add_tail_rcu(&n_ptr->list, &temp_node->list); 110 list_add_tail_rcu(&n_ptr->list, &temp_node->list);
111 n_ptr->flags = TIPC_NODE_DOWN; 111 n_ptr->action_flags = TIPC_WAIT_PEER_LINKS_DOWN;
112 n_ptr->signature = INVALID_NODE_SIG; 112 n_ptr->signature = INVALID_NODE_SIG;
113 113
114 tipc_num_nodes++; 114 tipc_num_nodes++;
@@ -267,7 +267,7 @@ void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
267 267
268static void node_established_contact(struct tipc_node *n_ptr) 268static void node_established_contact(struct tipc_node *n_ptr)
269{ 269{
270 n_ptr->flags |= TIPC_NODE_UP; 270 n_ptr->action_flags |= TIPC_NOTIFY_NODE_UP;
271 n_ptr->bclink.oos_state = 0; 271 n_ptr->bclink.oos_state = 0;
272 n_ptr->bclink.acked = tipc_bclink_get_last_sent(); 272 n_ptr->bclink.acked = tipc_bclink_get_last_sent();
273 tipc_bclink_add_node(n_ptr->addr); 273 tipc_bclink_add_node(n_ptr->addr);
@@ -308,10 +308,13 @@ static void node_lost_contact(struct tipc_node *n_ptr)
308 tipc_link_reset_fragments(l_ptr); 308 tipc_link_reset_fragments(l_ptr);
309 } 309 }
310 310
311 n_ptr->action_flags &= ~TIPC_WAIT_OWN_LINKS_DOWN;
312
311 /* Notify subscribers and prevent re-contact with node until 313 /* Notify subscribers and prevent re-contact with node until
312 * cleanup is done. 314 * cleanup is done.
313 */ 315 */
314 n_ptr->flags = TIPC_NODE_DOWN | TIPC_NODE_LOST; 316 n_ptr->action_flags |= TIPC_WAIT_PEER_LINKS_DOWN |
317 TIPC_NOTIFY_NODE_DOWN;
315} 318}
316 319
317struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) 320struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
@@ -459,18 +462,18 @@ void tipc_node_unlock(struct tipc_node *node)
459 int pkt_sz = 0; 462 int pkt_sz = 0;
460 u32 addr = 0; 463 u32 addr = 0;
461 464
462 if (likely(!node->flags)) { 465 if (likely(!node->action_flags)) {
463 spin_unlock_bh(&node->lock); 466 spin_unlock_bh(&node->lock);
464 return; 467 return;
465 } 468 }
466 469
467 if (node->flags & TIPC_NODE_LOST) { 470 if (node->action_flags & TIPC_NOTIFY_NODE_DOWN) {
468 list_replace_init(&node->nsub, &nsub_list); 471 list_replace_init(&node->nsub, &nsub_list);
469 node->flags &= ~TIPC_NODE_LOST; 472 node->action_flags &= ~TIPC_NOTIFY_NODE_DOWN;
470 } 473 }
471 if (node->flags & TIPC_NODE_UP) { 474 if (node->action_flags & TIPC_NOTIFY_NODE_UP) {
472 link = node->active_links[0]; 475 link = node->active_links[0];
473 node->flags &= ~TIPC_NODE_UP; 476 node->action_flags &= ~TIPC_NOTIFY_NODE_UP;
474 if (link) { 477 if (link) {
475 pkt_sz = ((link->max_pkt - INT_H_SIZE) / ITEM_SIZE) * 478 pkt_sz = ((link->max_pkt - INT_H_SIZE) / ITEM_SIZE) *
476 ITEM_SIZE; 479 ITEM_SIZE;
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 38f710fb75dc..5454edf994c3 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -47,20 +47,17 @@
47 */ 47 */
48#define INVALID_NODE_SIG 0x10000 48#define INVALID_NODE_SIG 0x10000
49 49
50/* Flags used to block (re)establishment of contact with a neighboring node 50/* Flags used to take different actions according to flag type
51 * TIPC_NODE_DOWN: indicate node is down and it's used to block the node's 51 * TIPC_WAIT_PEER_LINKS_DOWN: wait to see that peer's links are down
52 * links until RESET or ACTIVE message arrives 52 * TIPC_WAIT_OWN_LINKS_DOWN: wait until peer node is declared down
53 * TIPC_NODE_RESET: indicate node is reset 53 * TIPC_NOTIFY_NODE_DOWN: notify node is down
54 * TIPC_NODE_LOST: indicate node is lost and it's used to notify subscriptions 54 * TIPC_NOTIFY_NODE_UP: notify node is up
55 * when node lock is released
56 * TIPC_NODE_UP: indicate node is up and it's used to deliver local name table
57 * when node lock is released
58 */ 55 */
59enum { 56enum {
60 TIPC_NODE_DOWN = (1 << 1), 57 TIPC_WAIT_PEER_LINKS_DOWN = (1 << 1),
61 TIPC_NODE_RESET = (1 << 2), 58 TIPC_WAIT_OWN_LINKS_DOWN = (1 << 2),
62 TIPC_NODE_LOST = (1 << 3), 59 TIPC_NOTIFY_NODE_DOWN = (1 << 3),
63 TIPC_NODE_UP = (1 << 4) 60 TIPC_NOTIFY_NODE_UP = (1 << 4)
64}; 61};
65 62
66/** 63/**
@@ -96,7 +93,7 @@ struct tipc_node_bclink {
96 * @hash: links to adjacent nodes in unsorted hash chain 93 * @hash: links to adjacent nodes in unsorted hash chain
97 * @active_links: pointers to active links to node 94 * @active_links: pointers to active links to node
98 * @links: pointers to all links to node 95 * @links: pointers to all links to node
99 * @flags: bit mask of conditions preventing link establishment to node 96 * @action_flags: bit mask of different types of node actions
100 * @bclink: broadcast-related info 97 * @bclink: broadcast-related info
101 * @list: links to adjacent nodes in sorted list of cluster's nodes 98 * @list: links to adjacent nodes in sorted list of cluster's nodes
102 * @working_links: number of working links to node (both active and standby) 99 * @working_links: number of working links to node (both active and standby)
@@ -111,7 +108,7 @@ struct tipc_node {
111 struct hlist_node hash; 108 struct hlist_node hash;
112 struct tipc_link *active_links[2]; 109 struct tipc_link *active_links[2];
113 struct tipc_link *links[MAX_BEARERS]; 110 struct tipc_link *links[MAX_BEARERS];
114 unsigned int flags; 111 unsigned int action_flags;
115 struct tipc_node_bclink bclink; 112 struct tipc_node_bclink bclink;
116 struct list_head list; 113 struct list_head list;
117 int link_cnt; 114 int link_cnt;
@@ -144,8 +141,8 @@ static inline void tipc_node_lock(struct tipc_node *node)
144 141
145static inline bool tipc_node_blocked(struct tipc_node *node) 142static inline bool tipc_node_blocked(struct tipc_node *node)
146{ 143{
147 return (node->flags & (TIPC_NODE_DOWN | TIPC_NODE_LOST | 144 return (node->action_flags & (TIPC_WAIT_PEER_LINKS_DOWN |
148 TIPC_NODE_RESET)); 145 TIPC_NOTIFY_NODE_DOWN | TIPC_WAIT_OWN_LINKS_DOWN));
149} 146}
150 147
151#endif 148#endif