]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tipc: update node FSM when peer RESET message is received
authorJon Paul Maloy <jon.maloy@ericsson.com>
Thu, 15 Oct 2015 18:52:46 +0000 (14:52 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 16 Oct 2015 06:55:23 +0000 (23:55 -0700)
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 <jon.maloy@ericsson.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/link.c
net/tipc/link.h
net/tipc/node.c

index 737b5980020d9059b5ba7f427b0432acfb0750f5..ff9b0b92e62e7b1a99d99a89384656fefac9fc44 100644 (file)
@@ -120,6 +120,11 @@ bool tipc_link_is_up(struct tipc_link *l)
        return link_is_up(l);
 }
 
+bool tipc_link_peer_is_down(struct tipc_link *l)
+{
+       return l->state == LINK_PEER_RESET;
+}
+
 bool tipc_link_is_reset(struct tipc_link *l)
 {
        return l->state & (LINK_RESET | LINK_FAILINGOVER | LINK_ESTABLISHING);
@@ -584,8 +589,6 @@ void tipc_link_purge_queues(struct tipc_link *l_ptr)
 
 void tipc_link_reset(struct tipc_link *l)
 {
-       tipc_link_fsm_evt(l, LINK_RESET_EVT);
-
        /* Link is down, accept any session */
        l->peer_session = WILDCARD_SESSION;
 
index 5872f090c8d8b9c18aafee46bb31adbccde8a946..0201212cb49a9cdfaa1f7318db8d0a034fa73b0d 100644 (file)
@@ -217,6 +217,7 @@ void tipc_link_build_reset_msg(struct tipc_link *l, struct sk_buff_head *xmitq);
 int tipc_link_fsm_evt(struct tipc_link *l, int evt);
 void tipc_link_reset_fragments(struct tipc_link *l_ptr);
 bool tipc_link_is_up(struct tipc_link *l);
+bool tipc_link_peer_is_down(struct tipc_link *l);
 bool tipc_link_is_reset(struct tipc_link *l);
 bool tipc_link_is_establishing(struct tipc_link *l);
 bool tipc_link_is_synching(struct tipc_link *l);
index fba6e1af28e895169bba36af0bc820e39e179622..d1f340116c84c510fb80d22e50f1242d60ea4652 100644 (file)
@@ -41,7 +41,7 @@
 #include "socket.h"
 #include "bcast.h"
 #include "discover.h"
-#define pr_debug printk
+
 /* Node FSM states and events:
  */
 enum {
@@ -420,6 +420,10 @@ static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id,
        }
 
        if (!tipc_node_is_up(n)) {
+               if (tipc_link_peer_is_down(l))
+                       tipc_node_fsm_evt(n, PEER_LOST_CONTACT_EVT);
+               tipc_node_fsm_evt(n, SELF_LOST_CONTACT_EVT);
+               tipc_link_fsm_evt(l, LINK_RESET_EVT);
                tipc_link_reset(l);
                tipc_link_build_reset_msg(l, xmitq);
                *maddr = &n->links[*bearer_id].maddr;
@@ -434,6 +438,7 @@ static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id,
        n->sync_point = tnl->rcv_nxt + (U16_MAX / 2 - 1);
        tipc_link_tnl_prepare(l, tnl, FAILOVER_MSG, xmitq);
        tipc_link_reset(l);
+       tipc_link_fsm_evt(l, LINK_RESET_EVT);
        tipc_link_fsm_evt(l, LINK_FAILOVER_BEGIN_EVT);
        tipc_node_fsm_evt(n, NODE_FAILOVER_BEGIN_EVT);
        *maddr = &n->links[tnl->bearer_id].maddr;
@@ -581,6 +586,7 @@ void tipc_node_check_dest(struct net *net, u32 onode,
                        goto exit;
                }
                tipc_link_reset(l);
+               tipc_link_fsm_evt(l, LINK_RESET_EVT);
                if (n->state == NODE_FAILINGOVER)
                        tipc_link_fsm_evt(l, LINK_FAILOVER_BEGIN_EVT);
                le->link = l;
@@ -863,9 +869,6 @@ static void node_lost_contact(struct tipc_node *n_ptr,
                        tipc_link_fsm_evt(l, LINK_FAILOVER_END_EVT);
        }
 
-       /* Prevent re-contact with node until cleanup is done */
-       tipc_node_fsm_evt(n_ptr, SELF_LOST_CONTACT_EVT);
-
        /* Notify publications from this node */
        n_ptr->action_flags |= TIPC_NOTIFY_NODE_DOWN;