Skip to content

Commit c819930

Browse files
Jon Paul Maloydavem330
authored andcommitted
tipc: update node FSM when peer RESET message is received
The change made in the previous commit revealed a small flaw in the way the node FSM is updated. When the function tipc_node_link_down() is called for the last link to a node, we should check whether this was caused by a local reset or by a received RESET message from the peer. In the latter case, we can directly issue a PEER_LOST_CONTACT_EVT to the node FSM, so that it is ready to re-establish contact. If this is not done, the peer node will sometimes have to go through a second establish cycle before the link becomes stable. We fix this in this commit by conditionally issuing the mentioned event in the function tipc_node_link_down(). We also move LINK_RESET FSM even away from the link_reset() function and into the caller function, partially because it is easier to follow the code when state changes are gathered at a limited number of locations, partially because there will be cases in future commits where we don't want the link to go RESET mode when link_reset() is called. Signed-off-by: Jon Maloy <[email protected]> Acked-by: Ying Xue <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 282b3a0 commit c819930

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

net/tipc/link.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ bool tipc_link_is_up(struct tipc_link *l)
120120
return link_is_up(l);
121121
}
122122

123+
bool tipc_link_peer_is_down(struct tipc_link *l)
124+
{
125+
return l->state == LINK_PEER_RESET;
126+
}
127+
123128
bool tipc_link_is_reset(struct tipc_link *l)
124129
{
125130
return l->state & (LINK_RESET | LINK_FAILINGOVER | LINK_ESTABLISHING);
@@ -584,8 +589,6 @@ void tipc_link_purge_queues(struct tipc_link *l_ptr)
584589

585590
void tipc_link_reset(struct tipc_link *l)
586591
{
587-
tipc_link_fsm_evt(l, LINK_RESET_EVT);
588-
589592
/* Link is down, accept any session */
590593
l->peer_session = WILDCARD_SESSION;
591594

net/tipc/link.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ void tipc_link_build_reset_msg(struct tipc_link *l, struct sk_buff_head *xmitq);
217217
int tipc_link_fsm_evt(struct tipc_link *l, int evt);
218218
void tipc_link_reset_fragments(struct tipc_link *l_ptr);
219219
bool tipc_link_is_up(struct tipc_link *l);
220+
bool tipc_link_peer_is_down(struct tipc_link *l);
220221
bool tipc_link_is_reset(struct tipc_link *l);
221222
bool tipc_link_is_establishing(struct tipc_link *l);
222223
bool tipc_link_is_synching(struct tipc_link *l);

net/tipc/node.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#include "socket.h"
4242
#include "bcast.h"
4343
#include "discover.h"
44-
#define pr_debug printk
44+
4545
/* Node FSM states and events:
4646
*/
4747
enum {
@@ -420,6 +420,10 @@ static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id,
420420
}
421421

422422
if (!tipc_node_is_up(n)) {
423+
if (tipc_link_peer_is_down(l))
424+
tipc_node_fsm_evt(n, PEER_LOST_CONTACT_EVT);
425+
tipc_node_fsm_evt(n, SELF_LOST_CONTACT_EVT);
426+
tipc_link_fsm_evt(l, LINK_RESET_EVT);
423427
tipc_link_reset(l);
424428
tipc_link_build_reset_msg(l, xmitq);
425429
*maddr = &n->links[*bearer_id].maddr;
@@ -434,6 +438,7 @@ static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id,
434438
n->sync_point = tnl->rcv_nxt + (U16_MAX / 2 - 1);
435439
tipc_link_tnl_prepare(l, tnl, FAILOVER_MSG, xmitq);
436440
tipc_link_reset(l);
441+
tipc_link_fsm_evt(l, LINK_RESET_EVT);
437442
tipc_link_fsm_evt(l, LINK_FAILOVER_BEGIN_EVT);
438443
tipc_node_fsm_evt(n, NODE_FAILOVER_BEGIN_EVT);
439444
*maddr = &n->links[tnl->bearer_id].maddr;
@@ -581,6 +586,7 @@ void tipc_node_check_dest(struct net *net, u32 onode,
581586
goto exit;
582587
}
583588
tipc_link_reset(l);
589+
tipc_link_fsm_evt(l, LINK_RESET_EVT);
584590
if (n->state == NODE_FAILINGOVER)
585591
tipc_link_fsm_evt(l, LINK_FAILOVER_BEGIN_EVT);
586592
le->link = l;
@@ -863,9 +869,6 @@ static void node_lost_contact(struct tipc_node *n_ptr,
863869
tipc_link_fsm_evt(l, LINK_FAILOVER_END_EVT);
864870
}
865871

866-
/* Prevent re-contact with node until cleanup is done */
867-
tipc_node_fsm_evt(n_ptr, SELF_LOST_CONTACT_EVT);
868-
869872
/* Notify publications from this node */
870873
n_ptr->action_flags |= TIPC_NOTIFY_NODE_DOWN;
871874

0 commit comments

Comments
 (0)