tipc: introduce node contact FSM
[cascardo/linux.git] / net / tipc / link.c
index 657ba91..eaccf45 100644 (file)
@@ -88,10 +88,10 @@ static const struct nla_policy tipc_nl_prop_policy[TIPC_NLA_PROP_MAX + 1] = {
 /* Link FSM states and events:
  */
 enum {
-       WORKING_WORKING,
-       WORKING_UNKNOWN,
-       RESET_RESET,
-       RESET_UNKNOWN
+       TIPC_LINK_WORKING,
+       TIPC_LINK_PROBING,
+       TIPC_LINK_RESETTING,
+       TIPC_LINK_ESTABLISHING
 };
 
 enum {
@@ -103,31 +103,30 @@ enum {
 
 /* Link FSM state checking routines
  */
-static int link_working_working(struct tipc_link *l)
+static int link_working(struct tipc_link *l)
 {
-       return l->state == WORKING_WORKING;
+       return l->state == TIPC_LINK_WORKING;
 }
 
-static int link_working_unknown(struct tipc_link *l)
+static int link_probing(struct tipc_link *l)
 {
-       return l->state == WORKING_UNKNOWN;
+       return l->state == TIPC_LINK_PROBING;
 }
 
-static int link_reset_unknown(struct tipc_link *l)
+static int link_resetting(struct tipc_link *l)
 {
-       return l->state == RESET_UNKNOWN;
+       return l->state == TIPC_LINK_RESETTING;
 }
 
-static int link_reset_reset(struct tipc_link *l)
+static int link_establishing(struct tipc_link *l)
 {
-       return l->state == RESET_RESET;
+       return l->state == TIPC_LINK_ESTABLISHING;
 }
 
 static void link_handle_out_of_seq_msg(struct tipc_link *link,
                                       struct sk_buff *skb);
 static void tipc_link_proto_rcv(struct tipc_link *link,
                                struct sk_buff *skb);
-static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tol);
 static void link_state_event(struct tipc_link *l_ptr, u32 event);
 static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
                                      u16 rcvgap, int tolerance, int priority,
@@ -139,7 +138,8 @@ static void tipc_link_sync_rcv(struct tipc_node *n, struct sk_buff *buf);
 static void tipc_link_input(struct tipc_link *l, struct sk_buff *skb);
 static bool tipc_data_input(struct tipc_link *l, struct sk_buff *skb);
 static bool tipc_link_failover_rcv(struct tipc_link *l, struct sk_buff **skb);
-static void link_set_timer(struct tipc_link *link, unsigned long time);
+static void link_activate(struct tipc_link *link);
+
 /*
  *  Simple link routines
  */
@@ -148,21 +148,6 @@ static unsigned int align(unsigned int i)
        return (i + 3) & ~3u;
 }
 
-static void tipc_link_release(struct kref *kref)
-{
-       kfree(container_of(kref, struct tipc_link, ref));
-}
-
-static void tipc_link_get(struct tipc_link *l_ptr)
-{
-       kref_get(&l_ptr->ref);
-}
-
-static void tipc_link_put(struct tipc_link *l_ptr)
-{
-       kref_put(&l_ptr->ref, tipc_link_release);
-}
-
 static struct tipc_link *tipc_parallel_link(struct tipc_link *l)
 {
        struct tipc_node *n = l->owner;
@@ -179,7 +164,7 @@ int tipc_link_is_up(struct tipc_link *l_ptr)
 {
        if (!l_ptr)
                return 0;
-       return link_working_working(l_ptr) || link_working_unknown(l_ptr);
+       return link_working(l_ptr) || link_probing(l_ptr);
 }
 
 int tipc_link_is_active(struct tipc_link *l)
@@ -189,67 +174,6 @@ int tipc_link_is_active(struct tipc_link *l)
        return (node_active_link(n, 0) == l) || (node_active_link(n, 1) == l);
 }
 
-/**
- * link_timeout - handle expiration of link timer
- * @l_ptr: pointer to link
- */
-static void link_timeout(unsigned long data)
-{
-       struct tipc_link *l_ptr = (struct tipc_link *)data;
-       struct sk_buff *skb;
-
-       tipc_node_lock(l_ptr->owner);
-
-       /* update counters used in statistical profiling of send traffic */
-       l_ptr->stats.accu_queue_sz += skb_queue_len(&l_ptr->transmq);
-       l_ptr->stats.queue_sz_counts++;
-
-       skb = skb_peek(&l_ptr->transmq);
-       if (skb) {
-               struct tipc_msg *msg = buf_msg(skb);
-               u32 length = msg_size(msg);
-
-               if ((msg_user(msg) == MSG_FRAGMENTER) &&
-                   (msg_type(msg) == FIRST_FRAGMENT)) {
-                       length = msg_size(msg_get_wrapped(msg));
-               }
-               if (length) {
-                       l_ptr->stats.msg_lengths_total += length;
-                       l_ptr->stats.msg_length_counts++;
-                       if (length <= 64)
-                               l_ptr->stats.msg_length_profile[0]++;
-                       else if (length <= 256)
-                               l_ptr->stats.msg_length_profile[1]++;
-                       else if (length <= 1024)
-                               l_ptr->stats.msg_length_profile[2]++;
-                       else if (length <= 4096)
-                               l_ptr->stats.msg_length_profile[3]++;
-                       else if (length <= 16384)
-                               l_ptr->stats.msg_length_profile[4]++;
-                       else if (length <= 32768)
-                               l_ptr->stats.msg_length_profile[5]++;
-                       else
-                               l_ptr->stats.msg_length_profile[6]++;
-               }
-       }
-
-       /* do all other link processing performed on a periodic basis */
-       if (l_ptr->silent_intv_cnt || tipc_bclink_acks_missing(l_ptr->owner))
-               link_state_event(l_ptr, SILENCE_EVT);
-       l_ptr->silent_intv_cnt++;
-       if (skb_queue_len(&l_ptr->backlogq))
-               tipc_link_push_packets(l_ptr);
-       link_set_timer(l_ptr, l_ptr->keepalive_intv);
-       tipc_node_unlock(l_ptr->owner);
-       tipc_link_put(l_ptr);
-}
-
-static void link_set_timer(struct tipc_link *link, unsigned long time)
-{
-       if (!mod_timer(&link->timer, jiffies + time))
-               tipc_link_get(link);
-}
-
 /**
  * tipc_link_create - create a new link
  * @n_ptr: pointer to associated node
@@ -290,7 +214,6 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr,
                pr_warn("Link creation failed, no memory\n");
                return NULL;
        }
-       kref_init(&l_ptr->ref);
        l_ptr->addr = peer;
        if_name = strchr(b_ptr->name, ':') + 1;
        sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:unknown",
@@ -303,8 +226,8 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr,
        l_ptr->owner = n_ptr;
        l_ptr->peer_session = WILDCARD_SESSION;
        l_ptr->bearer_id = b_ptr->identity;
-       link_set_supervision_props(l_ptr, b_ptr->tolerance);
-       l_ptr->state = RESET_UNKNOWN;
+       l_ptr->tolerance = b_ptr->tolerance;
+       l_ptr->state = TIPC_LINK_RESETTING;
 
        l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg;
        msg = l_ptr->pmsg;
@@ -329,8 +252,6 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr,
        skb_queue_head_init(l_ptr->inputq);
        link_reset_statistics(l_ptr);
        tipc_node_attach_link(n_ptr, l_ptr);
-       setup_timer(&l_ptr->timer, link_timeout, (unsigned long)l_ptr);
-       link_set_timer(l_ptr, l_ptr->keepalive_intv);
        return l_ptr;
 }
 
@@ -341,12 +262,8 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr,
 void tipc_link_delete(struct tipc_link *l)
 {
        tipc_link_reset(l);
-       if (del_timer(&l->timer))
-               tipc_link_put(l);
-       /* Delete link now, or when timer is finished: */
        tipc_link_reset_fragments(l);
        tipc_node_detach_link(l->owner, l);
-       tipc_link_put(l);
 }
 
 void tipc_link_delete_list(struct net *net, unsigned int bearer_id)
@@ -366,6 +283,190 @@ void tipc_link_delete_list(struct net *net, unsigned int bearer_id)
        rcu_read_unlock();
 }
 
+/**
+ * tipc_link_fsm_evt - link finite state machine
+ * @l: pointer to link
+ * @evt: state machine event to be processed
+ * @xmitq: queue to prepend created protocol message, if any
+ */
+static int tipc_link_fsm_evt(struct tipc_link *l, int evt,
+                            struct sk_buff_head *xmitq)
+{
+       int mtyp = 0, rc = 0;
+       struct tipc_link *pl;
+       enum {
+               LINK_RESET    = 1,
+               LINK_ACTIVATE = (1 << 1),
+               SND_PROBE     = (1 << 2),
+               SND_STATE     = (1 << 3),
+               SND_RESET     = (1 << 4),
+               SND_ACTIVATE  = (1 << 5)
+       } actions = 0;
+
+       if (l->exec_mode == TIPC_LINK_BLOCKED)
+               return rc;
+
+       switch (l->state) {
+       case TIPC_LINK_WORKING:
+               switch (evt) {
+               case TRAFFIC_EVT:
+               case ACTIVATE_EVT:
+                       break;
+               case SILENCE_EVT:
+                       l->state = TIPC_LINK_PROBING;
+                       actions |= SND_PROBE;
+                       break;
+               case PEER_RESET_EVT:
+                       actions |= LINK_RESET | SND_ACTIVATE;
+                       break;
+               default:
+                       pr_debug("%s%u WORKING\n", link_unk_evt, evt);
+               }
+               break;
+       case TIPC_LINK_PROBING:
+               switch (evt) {
+               case TRAFFIC_EVT:
+               case ACTIVATE_EVT:
+                       l->state = TIPC_LINK_WORKING;
+                       break;
+               case PEER_RESET_EVT:
+                       actions |= LINK_RESET | SND_ACTIVATE;
+                       break;
+               case SILENCE_EVT:
+                       if (l->silent_intv_cnt <= l->abort_limit) {
+                               actions |= SND_PROBE;
+                               break;
+                       }
+                       actions |= LINK_RESET | SND_RESET;
+                       break;
+               default:
+                       pr_err("%s%u PROBING\n", link_unk_evt, evt);
+               }
+               break;
+       case TIPC_LINK_RESETTING:
+               switch (evt) {
+               case TRAFFIC_EVT:
+                       break;
+               case ACTIVATE_EVT:
+                       pl = node_active_link(l->owner, 0);
+                       if (pl && link_probing(pl))
+                               break;
+                       actions |= LINK_ACTIVATE;
+                       if (l->owner->working_links == 1)
+                               tipc_link_sync_xmit(l);
+                       break;
+               case PEER_RESET_EVT:
+                       l->state = TIPC_LINK_ESTABLISHING;
+                       actions |= SND_ACTIVATE;
+                       break;
+               case SILENCE_EVT:
+                       actions |= SND_RESET;
+                       break;
+               default:
+                       pr_err("%s%u in RESETTING\n", link_unk_evt, evt);
+               }
+               break;
+       case TIPC_LINK_ESTABLISHING:
+               switch (evt) {
+               case TRAFFIC_EVT:
+               case ACTIVATE_EVT:
+                       pl = node_active_link(l->owner, 0);
+                       if (pl && link_probing(pl))
+                               break;
+                       actions |= LINK_ACTIVATE;
+                       if (l->owner->working_links == 1)
+                               tipc_link_sync_xmit(l);
+                       break;
+               case PEER_RESET_EVT:
+                       break;
+               case SILENCE_EVT:
+                       actions |= SND_ACTIVATE;
+                       break;
+               default:
+                       pr_err("%s%u ESTABLISHING\n", link_unk_evt, evt);
+               }
+               break;
+       default:
+               pr_err("Unknown link state %u/%u\n", l->state, evt);
+       }
+
+       /* Perform actions as decided by FSM */
+       if (actions & LINK_RESET) {
+               l->exec_mode = TIPC_LINK_BLOCKED;
+               rc |= TIPC_LINK_DOWN_EVT;
+       }
+       if (actions & LINK_ACTIVATE) {
+               l->exec_mode = TIPC_LINK_OPEN;
+               rc |= TIPC_LINK_UP_EVT;
+       }
+       if (actions & (SND_STATE | SND_PROBE))
+               mtyp = STATE_MSG;
+       if (actions & SND_RESET)
+               mtyp = RESET_MSG;
+       if (actions & SND_ACTIVATE)
+               mtyp = ACTIVATE_MSG;
+       if (actions & (SND_PROBE | SND_STATE | SND_RESET | SND_ACTIVATE))
+               tipc_link_build_proto_msg(l, mtyp, actions & SND_PROBE,
+                                         0, 0, 0, xmitq);
+       return rc;
+}
+
+/* link_profile_stats - update statistical profiling of traffic
+ */
+static void link_profile_stats(struct tipc_link *l)
+{
+       struct sk_buff *skb;
+       struct tipc_msg *msg;
+       int length;
+
+       /* Update counters used in statistical profiling of send traffic */
+       l->stats.accu_queue_sz += skb_queue_len(&l->transmq);
+       l->stats.queue_sz_counts++;
+
+       skb = skb_peek(&l->transmq);
+       if (!skb)
+               return;
+       msg = buf_msg(skb);
+       length = msg_size(msg);
+
+       if (msg_user(msg) == MSG_FRAGMENTER) {
+               if (msg_type(msg) != FIRST_FRAGMENT)
+                       return;
+               length = msg_size(msg_get_wrapped(msg));
+       }
+       l->stats.msg_lengths_total += length;
+       l->stats.msg_length_counts++;
+       if (length <= 64)
+               l->stats.msg_length_profile[0]++;
+       else if (length <= 256)
+               l->stats.msg_length_profile[1]++;
+       else if (length <= 1024)
+               l->stats.msg_length_profile[2]++;
+       else if (length <= 4096)
+               l->stats.msg_length_profile[3]++;
+       else if (length <= 16384)
+               l->stats.msg_length_profile[4]++;
+       else if (length <= 32768)
+               l->stats.msg_length_profile[5]++;
+       else
+               l->stats.msg_length_profile[6]++;
+}
+
+/* tipc_link_timeout - perform periodic task as instructed from node timeout
+ */
+int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq)
+{
+       int rc = 0;
+
+       link_profile_stats(l);
+       if (l->silent_intv_cnt)
+               rc = tipc_link_fsm_evt(l, SILENCE_EVT, xmitq);
+       else if (link_working(l) && tipc_bclink_acks_missing(l->owner))
+               tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, 0, xmitq);
+       l->silent_intv_cnt++;
+       return rc;
+}
+
 /**
  * link_schedule_user - schedule a message sender for wakeup after congestion
  * @link: congested link
@@ -474,9 +575,10 @@ void tipc_link_reset(struct tipc_link *l_ptr)
        /* Prepare for renewed mtu size negotiation */
        l_ptr->mtu = l_ptr->advertised_mtu;
 
-       l_ptr->state = RESET_UNKNOWN;
+       l_ptr->state = TIPC_LINK_RESETTING;
 
-       if ((prev_state == RESET_UNKNOWN) || (prev_state == RESET_RESET))
+       if ((prev_state == TIPC_LINK_RESETTING) ||
+           (prev_state == TIPC_LINK_ESTABLISHING))
                return;
 
        tipc_node_link_down(l_ptr->owner, l_ptr->bearer_id);
@@ -515,6 +617,8 @@ static void link_activate(struct tipc_link *link)
        link->rcv_nxt = 1;
        link->stats.recv_info = 1;
        link->silent_intv_cnt = 0;
+       link->state = TIPC_LINK_WORKING;
+       link->exec_mode = TIPC_LINK_OPEN;
        tipc_node_link_up(node, link->bearer_id);
        tipc_bearer_add_dest(node->net, link->bearer_id, link->addr);
 }
@@ -524,132 +628,29 @@ static void link_activate(struct tipc_link *link)
  * @l_ptr: pointer to link
  * @event: state machine event to process
  */
-static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
+static void link_state_event(struct tipc_link *l, unsigned int evt)
 {
-       struct tipc_link *other;
+       int rc;
+       struct sk_buff_head xmitq;
+       struct sk_buff *skb;
 
-       if (l_ptr->exec_mode == TIPC_LINK_BLOCKED)
+       if (l->exec_mode == TIPC_LINK_BLOCKED)
                return;
 
-       switch (l_ptr->state) {
-       case WORKING_WORKING:
-               switch (event) {
-               case TRAFFIC_EVT:
-               case ACTIVATE_MSG:
-                       l_ptr->silent_intv_cnt = 0;
-                       break;
-               case SILENCE_EVT:
-                       if (!l_ptr->silent_intv_cnt) {
-                               if (tipc_bclink_acks_missing(l_ptr->owner))
-                                       tipc_link_proto_xmit(l_ptr, STATE_MSG,
-                                                            0, 0, 0, 0);
-                               break;
-                       }
-                       l_ptr->state = WORKING_UNKNOWN;
-                       tipc_link_proto_xmit(l_ptr, STATE_MSG, 1, 0, 0, 0);
-                       break;
-               case RESET_MSG:
-                       pr_debug("%s<%s>, requested by peer\n",
-                                link_rst_msg, l_ptr->name);
-                       tipc_link_reset(l_ptr);
-                       l_ptr->state = RESET_RESET;
-                       tipc_link_proto_xmit(l_ptr, ACTIVATE_MSG,
-                                            0, 0, 0, 0);
-                       break;
-               default:
-                       pr_debug("%s%u in WW state\n", link_unk_evt, event);
-               }
-               break;
-       case WORKING_UNKNOWN:
-               switch (event) {
-               case TRAFFIC_EVT:
-               case ACTIVATE_MSG:
-                       l_ptr->state = WORKING_WORKING;
-                       l_ptr->silent_intv_cnt = 0;
-                       break;
-               case RESET_MSG:
-                       pr_debug("%s<%s>, requested by peer while probing\n",
-                                link_rst_msg, l_ptr->name);
-                       tipc_link_reset(l_ptr);
-                       l_ptr->state = RESET_RESET;
-                       tipc_link_proto_xmit(l_ptr, ACTIVATE_MSG,
-                                            0, 0, 0, 0);
-                       break;
-               case SILENCE_EVT:
-                       if (!l_ptr->silent_intv_cnt) {
-                               l_ptr->state = WORKING_WORKING;
-                               if (tipc_bclink_acks_missing(l_ptr->owner))
-                                       tipc_link_proto_xmit(l_ptr, STATE_MSG,
-                                                            0, 0, 0, 0);
-                       } else if (l_ptr->silent_intv_cnt <
-                                  l_ptr->abort_limit) {
-                               tipc_link_proto_xmit(l_ptr, STATE_MSG,
-                                                    1, 0, 0, 0);
-                       } else {        /* Link has failed */
-                               pr_debug("%s<%s>, peer not responding\n",
-                                        link_rst_msg, l_ptr->name);
-                               tipc_link_reset(l_ptr);
-                               l_ptr->state = RESET_UNKNOWN;
-                               tipc_link_proto_xmit(l_ptr, RESET_MSG,
-                                                    0, 0, 0, 0);
-                       }
-                       break;
-               default:
-                       pr_err("%s%u in WU state\n", link_unk_evt, event);
-               }
-               break;
-       case RESET_UNKNOWN:
-               switch (event) {
-               case TRAFFIC_EVT:
-                       break;
-               case ACTIVATE_MSG:
-                       other = node_active_link(l_ptr->owner, 0);
-                       if (other && link_working_unknown(other))
-                               break;
-                       l_ptr->state = WORKING_WORKING;
-                       link_activate(l_ptr);
-                       tipc_link_proto_xmit(l_ptr, STATE_MSG, 1, 0, 0, 0);
-                       if (l_ptr->owner->working_links == 1)
-                               tipc_link_sync_xmit(l_ptr);
-                       break;
-               case RESET_MSG:
-                       l_ptr->state = RESET_RESET;
-                       tipc_link_proto_xmit(l_ptr, ACTIVATE_MSG,
-                                            1, 0, 0, 0);
-                       break;
-               case SILENCE_EVT:
-                       tipc_link_proto_xmit(l_ptr, RESET_MSG, 0, 0, 0, 0);
-                       break;
-               default:
-                       pr_err("%s%u in RU state\n", link_unk_evt, event);
-               }
-               break;
-       case RESET_RESET:
-               switch (event) {
-               case TRAFFIC_EVT:
-               case ACTIVATE_MSG:
-                       other = node_active_link(l_ptr->owner, 0);
-                       if (other && link_working_unknown(other))
-                               break;
-                       l_ptr->state = WORKING_WORKING;
-                       link_activate(l_ptr);
-                       tipc_link_proto_xmit(l_ptr, STATE_MSG, 1, 0, 0, 0);
-                       if (l_ptr->owner->working_links == 1)
-                               tipc_link_sync_xmit(l_ptr);
-                       break;
-               case RESET_MSG:
-                       break;
-               case SILENCE_EVT:
-                       tipc_link_proto_xmit(l_ptr, ACTIVATE_MSG,
-                                            0, 0, 0, 0);
-                       break;
-               default:
-                       pr_err("%s%u in RR state\n", link_unk_evt, event);
-               }
-               break;
-       default:
-               pr_err("Unknown link state %u/%u\n", l_ptr->state, event);
-       }
+       __skb_queue_head_init(&xmitq);
+
+       rc = tipc_link_fsm_evt(l, evt, &xmitq);
+
+       if (rc & TIPC_LINK_UP_EVT)
+               link_activate(l);
+
+       if (rc & TIPC_LINK_DOWN_EVT)
+               tipc_link_reset(l);
+
+       skb = __skb_dequeue(&xmitq);
+       if (!skb)
+               return;
+       tipc_bearer_send(l->owner->net, l->bearer_id, skb, &l->media_addr);
 }
 
 /**
@@ -910,9 +911,13 @@ static void link_retransmit_failure(struct tipc_link *l_ptr,
 
        if (l_ptr->addr) {
                /* Handle failure on standard link */
-               link_print(l_ptr, "Resetting link\n");
+               link_print(l_ptr, "Resetting link ");
+               pr_info("Failed msg: usr %u, typ %u, len %u, err %u\n",
+                       msg_user(msg), msg_type(msg), msg_size(msg),
+                       msg_errcode(msg));
+               pr_info("sqno %u, prev: %x, src: %x\n",
+                       msg_seqno(msg), msg_prevnode(msg), msg_orignode(msg));
                tipc_link_reset(l_ptr);
-
        } else {
                /* Handle failure on broadcast link */
                struct tipc_node *n_ptr;
@@ -1066,15 +1071,8 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr)
                if (unlikely(!l_ptr))
                        goto unlock;
 
-               /* Verify that communication with node is currently allowed */
-               if ((n_ptr->action_flags & TIPC_WAIT_PEER_LINKS_DOWN) &&
-                   msg_user(msg) == LINK_PROTOCOL &&
-                   (msg_type(msg) == RESET_MSG ||
-                   msg_type(msg) == ACTIVATE_MSG) &&
-                   !msg_redundant_link(msg))
-                       n_ptr->action_flags &= ~TIPC_WAIT_PEER_LINKS_DOWN;
-
-               if (tipc_node_blocked(n_ptr))
+               /* Is reception of this pkt permitted at the moment ? */
+               if (!tipc_node_filter_skb(n_ptr, msg))
                        goto unlock;
 
                /* Validate message sequence number info */
@@ -1102,7 +1100,7 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr)
                        link_prepare_wakeup(l_ptr);
 
                /* Process the incoming packet */
-               if (unlikely(!link_working_working(l_ptr))) {
+               if (unlikely(!link_working(l_ptr))) {
                        if (msg_user(msg) == LINK_PROTOCOL) {
                                tipc_link_proto_rcv(l_ptr, skb);
                                link_retrieve_defq(l_ptr, &head);
@@ -1113,7 +1111,7 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr)
                        /* Traffic message. Conditionally activate link */
                        link_state_event(l_ptr, TRAFFIC_EVT);
 
-                       if (link_working_working(l_ptr)) {
+                       if (link_working(l_ptr)) {
                                /* Re-insert buffer in front of queue */
                                __skb_queue_head(&head, skb);
                                skb = NULL;
@@ -1122,7 +1120,7 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr)
                        goto unlock;
                }
 
-               /* Link is now in state WORKING_WORKING */
+               /* Link is now in state TIPC_LINK_WORKING */
                if (unlikely(seq_no != l_ptr->rcv_nxt)) {
                        link_handle_out_of_seq_msg(l_ptr, skb);
                        link_retrieve_defq(l_ptr, &head);
@@ -1365,21 +1363,11 @@ static void tipc_link_proto_rcv(struct tipc_link *l_ptr,
        switch (msg_type(msg)) {
 
        case RESET_MSG:
-               if (!link_working_unknown(l_ptr) &&
+               if (!link_probing(l_ptr) &&
                    (l_ptr->peer_session != WILDCARD_SESSION)) {
                        if (less_eq(msg_session(msg), l_ptr->peer_session))
                                break; /* duplicate or old reset: ignore */
                }
-
-               if (!msg_redundant_link(msg) && (link_working_working(l_ptr) ||
-                               link_working_unknown(l_ptr))) {
-                       /*
-                        * peer has lost contact -- don't allow peer's links
-                        * to reactivate before we recognize loss & clean up
-                        */
-                       l_ptr->owner->action_flags |= TIPC_WAIT_OWN_LINKS_DOWN;
-               }
-
                link_state_event(l_ptr, RESET_MSG);
 
                /* fall thru' */
@@ -1389,7 +1377,7 @@ static void tipc_link_proto_rcv(struct tipc_link *l_ptr,
 
                msg_tol = msg_link_tolerance(msg);
                if (msg_tol > l_ptr->tolerance)
-                       link_set_supervision_props(l_ptr, msg_tol);
+                       l_ptr->tolerance = msg_tol;
 
                if (msg_linkprio(msg) > l_ptr->priority)
                        l_ptr->priority = msg_linkprio(msg);
@@ -1408,6 +1396,8 @@ static void tipc_link_proto_rcv(struct tipc_link *l_ptr,
                l_ptr->peer_session = msg_session(msg);
                l_ptr->peer_bearer_id = msg_bearer_id(msg);
 
+               if (!msg_peer_is_up(msg))
+                       tipc_node_fsm_evt(l_ptr->owner, PEER_LOST_CONTACT_EVT);
                if (msg_type(msg) == ACTIVATE_MSG)
                        link_state_event(l_ptr, ACTIVATE_MSG);
                break;
@@ -1415,15 +1405,15 @@ static void tipc_link_proto_rcv(struct tipc_link *l_ptr,
 
                msg_tol = msg_link_tolerance(msg);
                if (msg_tol)
-                       link_set_supervision_props(l_ptr, msg_tol);
+                       l_ptr->tolerance = msg_tol;
 
                if (msg_linkprio(msg) &&
                    (msg_linkprio(msg) != l_ptr->priority)) {
-                       pr_debug("%s<%s>, priority change %u->%u\n",
-                                link_rst_msg, l_ptr->name,
-                                l_ptr->priority, msg_linkprio(msg));
+                       pr_info("%s<%s>, priority change %u->%u\n",
+                               link_rst_msg, l_ptr->name,
+                               l_ptr->priority, msg_linkprio(msg));
                        l_ptr->priority = msg_linkprio(msg);
-                       tipc_link_reset(l_ptr); /* Enforce change to take effect */
+                       tipc_link_reset(l_ptr);
                        break;
                }
 
@@ -1432,7 +1422,7 @@ static void tipc_link_proto_rcv(struct tipc_link *l_ptr,
 
                link_state_event(l_ptr, TRAFFIC_EVT);
                l_ptr->stats.recv_states++;
-               if (link_reset_unknown(l_ptr))
+               if (link_resetting(l_ptr))
                        break;
 
                if (less_eq(l_ptr->rcv_nxt, msg_next_sent(msg)))
@@ -1446,15 +1436,18 @@ static void tipc_link_proto_rcv(struct tipc_link *l_ptr,
                        tipc_bclink_update_link_state(l_ptr->owner,
                                                      msg_last_bcast(msg));
 
-               if (rec_gap || (msg_probe(msg))) {
+               if (rec_gap || (msg_probe(msg)))
                        tipc_link_proto_xmit(l_ptr, STATE_MSG, 0,
                                             rec_gap, 0, 0);
-               }
+
                if (msg_seq_gap(msg)) {
                        l_ptr->stats.recv_nacks++;
                        tipc_link_retransmit(l_ptr, skb_peek(&l_ptr->transmq),
                                             msg_seq_gap(msg));
                }
+               if (tipc_link_is_up(l_ptr))
+                       tipc_node_fsm_evt(l_ptr->owner,
+                                         PEER_ESTABL_CONTACT_EVT);
                break;
        }
 exit:
@@ -1478,10 +1471,6 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
        if (l->exec_mode == TIPC_LINK_BLOCKED)
                return;
 
-       /* Abort non-RESET send if communication with node is prohibited */
-       if ((tipc_node_blocked(l->owner)) && (mtyp != RESET_MSG))
-               return;
-
        msg_set_type(hdr, mtyp);
        msg_set_net_plane(hdr, l->net_plane);
        msg_set_bcast_ack(hdr, l->owner->bclink.last_in);
@@ -1738,18 +1727,6 @@ exit:
        return *skb;
 }
 
-static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tol)
-{
-       unsigned long intv = ((tol / 4) > 500) ? 500 : tol / 4;
-
-       if ((tol < TIPC_MIN_LINK_TOL) || (tol > TIPC_MAX_LINK_TOL))
-               return;
-
-       l_ptr->tolerance = tol;
-       l_ptr->keepalive_intv = msecs_to_jiffies(intv);
-       l_ptr->abort_limit = tol / (jiffies_to_msecs(l_ptr->keepalive_intv));
-}
-
 void tipc_link_set_queue_limits(struct tipc_link *l, u32 win)
 {
        int max_bulk = TIPC_MAX_PUBLICATIONS / (l->mtu / ITEM_SIZE);
@@ -1811,27 +1788,28 @@ static void link_reset_statistics(struct tipc_link *l_ptr)
        l_ptr->stats.recv_info = l_ptr->rcv_nxt;
 }
 
-static void link_print(struct tipc_link *l_ptr, const char *str)
+static void link_print(struct tipc_link *l, const char *str)
 {
-       struct tipc_net *tn = net_generic(l_ptr->owner->net, tipc_net_id);
-       struct tipc_bearer *b_ptr;
-
-       rcu_read_lock();
-       b_ptr = rcu_dereference_rtnl(tn->bearer_list[l_ptr->bearer_id]);
-       if (b_ptr)
-               pr_info("%s Link %x<%s>:", str, l_ptr->addr, b_ptr->name);
-       rcu_read_unlock();
-
-       if (link_working_unknown(l_ptr))
-               pr_cont(":WU\n");
-       else if (link_reset_reset(l_ptr))
-               pr_cont(":RR\n");
-       else if (link_reset_unknown(l_ptr))
-               pr_cont(":RU\n");
-       else if (link_working_working(l_ptr))
-               pr_cont(":WW\n");
+       struct sk_buff *hskb = skb_peek(&l->transmq);
+       u16 head = hskb ? msg_seqno(buf_msg(hskb)) : l->snd_nxt;
+       u16 tail = l->snd_nxt - 1;
+
+       pr_info("%s Link <%s>:", str, l->name);
+
+       if (link_probing(l))
+               pr_cont(":P\n");
+       else if (link_establishing(l))
+               pr_cont(":E\n");
+       else if (link_resetting(l))
+               pr_cont(":R\n");
+       else if (link_working(l))
+               pr_cont(":W\n");
        else
                pr_cont("\n");
+
+       pr_info("XMTQ: %u [%u-%u], BKLGQ: %u, SNDNX: %u, RCVNX: %u\n",
+               skb_queue_len(&l->transmq), head, tail,
+               skb_queue_len(&l->backlogq), l->snd_nxt, l->rcv_nxt);
 }
 
 /* Parse and validate nested (link) properties valid for media, bearer and link
@@ -1926,7 +1904,7 @@ int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info)
                        u32 tol;
 
                        tol = nla_get_u32(props[TIPC_NLA_PROP_TOL]);
-                       link_set_supervision_props(link, tol);
+                       link->tolerance = tol;
                        tipc_link_proto_xmit(link, STATE_MSG, 0, 0, tol, 0);
                }
                if (props[TIPC_NLA_PROP_PRIO]) {