Skip to content

Commit b4b5610

Browse files
ajstephensPaul Gortmaker
authored andcommitted
tipc: Ensure both nodes recognize loss of contact between them
Enhances TIPC to ensure that a node that loses contact with a neighboring node does not allow contact to be re-established until it sees that its peer has also recognized the loss of contact. Previously, nodes that were connected by two or more links could encounter a situation in which node A would lose contact with node B on all of its links, purge its name table of names published by B, and then fail to repopulate those names once contact with B was restored. This would happen because B was able to re-establish one or more links so quickly that it never reached a point where it had no links to A -- meaning that B never saw a loss of contact with A, and consequently didn't re-publish its names to A. This problem is now prevented by enhancing the cleanup done by TIPC following a loss of contact with a neighboring node to ensure that node A ignores all messages sent by B until it receives a LINK_PROTOCOL message that indicates B has lost contact with A, thereby preventing the (re)establishment of links between the nodes. The loss of contact is recognized when a RESET or ACTIVATE message is received that has a "redundant link exists" field of 0, indicating that B's sending link endpoint is in a reset state and that B has no other working links. Additionally, TIPC now suppresses the sending of (most) link protocol messages to a neighboring node while it is cleaning up after an earlier loss of contact with that node. This stops the peer node from prematurely activating its link endpoint, which would prevent TIPC from later activating its own end. TIPC still allows outgoing RESET messages to occur during cleanup, to avoid problems if its own node recognizes the loss of contact first and tries to notify the peer of the situation. Finally, TIPC now recognizes an impending loss of contact with a peer node as soon as it receives a RESET message on a working link that is the peer's only link to the node, and ensures that the link protocol suppression mentioned above goes into effect right away -- that is, even before its own link endpoints have failed. This is necessary to ensure correct operation when there are redundant links between the nodes, since otherwise TIPC would send an ACTIVATE message upon receiving a RESET on its first link and only begin suppressing when a RESET on its second link was received, instead of initiating suppression with the first RESET message as it needs to. Note: The reworked cleanup code also eliminates a check that prevented a link endpoint's discovery object from responding to incoming messages while stale name table entries are being purged. This check is now unnecessary and would have slowed down re-establishment of communication between the nodes in some situations. Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
1 parent 4b3743e commit b4b5610

4 files changed

Lines changed: 42 additions & 18 deletions

File tree

‎net/tipc/discover.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,6 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
159159
}
160160
tipc_node_lock(n_ptr);
161161

162-
/* Don't talk to neighbor during cleanup after last session */
163-
if (n_ptr->cleanup_required) {
164-
tipc_node_unlock(n_ptr);
165-
return;
166-
}
167-
168162
link = n_ptr->links[b_ptr->identity];
169163

170164
/* Create a link endpoint for this bearer, if necessary */

‎net/tipc/link.c‎

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,17 +1669,24 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
16691669
goto cont;
16701670
tipc_node_lock(n_ptr);
16711671

1672-
/* Don't talk to neighbor during cleanup after last session */
1672+
/* Locate unicast link endpoint that should handle message */
16731673

1674-
if (n_ptr->cleanup_required) {
1674+
l_ptr = n_ptr->links[b_ptr->identity];
1675+
if (unlikely(!l_ptr)) {
16751676
tipc_node_unlock(n_ptr);
16761677
goto cont;
16771678
}
16781679

1679-
/* Locate unicast link endpoint that should handle message */
1680+
/* Verify that communication with node is currently allowed */
16801681

1681-
l_ptr = n_ptr->links[b_ptr->identity];
1682-
if (unlikely(!l_ptr)) {
1682+
if ((n_ptr->block_setup & WAIT_PEER_DOWN) &&
1683+
msg_user(msg) == LINK_PROTOCOL &&
1684+
(msg_type(msg) == RESET_MSG ||
1685+
msg_type(msg) == ACTIVATE_MSG) &&
1686+
!msg_redundant_link(msg))
1687+
n_ptr->block_setup &= ~WAIT_PEER_DOWN;
1688+
1689+
if (n_ptr->block_setup) {
16831690
tipc_node_unlock(n_ptr);
16841691
goto cont;
16851692
}
@@ -1914,6 +1921,12 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
19141921

19151922
if (link_blocked(l_ptr))
19161923
return;
1924+
1925+
/* Abort non-RESET send if communication with node is prohibited */
1926+
1927+
if ((l_ptr->owner->block_setup) && (msg_typ != RESET_MSG))
1928+
return;
1929+
19171930
msg_set_type(msg, msg_typ);
19181931
msg_set_net_plane(msg, l_ptr->b_ptr->net_plane);
19191932
msg_set_bcast_ack(msg, mod(l_ptr->owner->bclink.last_in));
@@ -2045,6 +2058,16 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
20452058
if (less_eq(msg_session(msg), l_ptr->peer_session))
20462059
break; /* duplicate or old reset: ignore */
20472060
}
2061+
2062+
if (!msg_redundant_link(msg) && (link_working_working(l_ptr) ||
2063+
link_working_unknown(l_ptr))) {
2064+
/*
2065+
* peer has lost contact -- don't allow peer's links
2066+
* to reactivate before we recognize loss & clean up
2067+
*/
2068+
l_ptr->owner->block_setup = WAIT_NODE_DOWN;
2069+
}
2070+
20482071
/* fall thru' */
20492072
case ACTIVATE_MSG:
20502073
/* Update link settings according other endpoint's values */

‎net/tipc/node.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ struct tipc_node *tipc_node_create(u32 addr)
112112
break;
113113
}
114114
list_add_tail(&n_ptr->list, &temp_node->list);
115+
n_ptr->block_setup = WAIT_PEER_DOWN;
115116

116117
tipc_num_nodes++;
117118

@@ -312,15 +313,15 @@ static void node_established_contact(struct tipc_node *n_ptr)
312313
}
313314
}
314315

315-
static void node_cleanup_finished(unsigned long node_addr)
316+
static void node_name_purge_complete(unsigned long node_addr)
316317
{
317318
struct tipc_node *n_ptr;
318319

319320
read_lock_bh(&tipc_net_lock);
320321
n_ptr = tipc_node_find(node_addr);
321322
if (n_ptr) {
322323
tipc_node_lock(n_ptr);
323-
n_ptr->cleanup_required = 0;
324+
n_ptr->block_setup &= ~WAIT_NAMES_GONE;
324325
tipc_node_unlock(n_ptr);
325326
}
326327
read_unlock_bh(&tipc_net_lock);
@@ -371,10 +372,10 @@ static void node_lost_contact(struct tipc_node *n_ptr)
371372
/* Notify subscribers */
372373
tipc_nodesub_notify(n_ptr);
373374

374-
/* Prevent re-contact with node until all cleanup is done */
375+
/* Prevent re-contact with node until cleanup is done */
375376

376-
n_ptr->cleanup_required = 1;
377-
tipc_k_signal((Handler)node_cleanup_finished, n_ptr->addr);
377+
n_ptr->block_setup = WAIT_PEER_DOWN | WAIT_NAMES_GONE;
378+
tipc_k_signal((Handler)node_name_purge_complete, n_ptr->addr);
378379
}
379380

380381
struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)

‎net/tipc/node.h‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242
#include "net.h"
4343
#include "bearer.h"
4444

45+
/* Flags used to block (re)establishment of contact with a neighboring node */
46+
47+
#define WAIT_PEER_DOWN 0x0001 /* wait to see that peer's links are down */
48+
#define WAIT_NAMES_GONE 0x0002 /* wait for peer's publications to be purged */
49+
#define WAIT_NODE_DOWN 0x0004 /* wait until peer node is declared down */
50+
4551
/**
4652
* struct tipc_node - TIPC node structure
4753
* @addr: network address of node
@@ -52,7 +58,7 @@
5258
* @active_links: pointers to active links to node
5359
* @links: pointers to all links to node
5460
* @working_links: number of working links to node (both active and standby)
55-
* @cleanup_required: non-zero if cleaning up after a prior loss of contact
61+
* @block_setup: bit mask of conditions preventing link establishment to node
5662
* @link_cnt: number of links to node
5763
* @permit_changeover: non-zero if node has redundant links to this system
5864
* @bclink: broadcast-related info
@@ -77,7 +83,7 @@ struct tipc_node {
7783
struct link *links[MAX_BEARERS];
7884
int link_cnt;
7985
int working_links;
80-
int cleanup_required;
86+
int block_setup;
8187
int permit_changeover;
8288
struct {
8389
int supported;

0 commit comments

Comments
 (0)