diff options
author | Jon Paul Maloy <jon.maloy@ericsson.com> | 2016-04-15 13:33:05 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-04-15 16:09:06 -0400 |
commit | 42b18f605feaf7aa1825b35656bb7d6fdc132b45 (patch) | |
tree | 99c067ee64a848cdc1aaf29a8a9e33e5e4281ef9 | |
parent | 88e8ac7000dc7ccf99975cc4070907e26a1027f9 (diff) |
tipc: refactor function tipc_link_timeout()
The function tipc_link_timeout() is unnecessary complex, and can
easily be made more readable.
We do that with this commit. The only functional change is that we
remove a redundant test for whether the broadcast link is up or not.
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/tipc/link.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c index 238b12526b58..774ad3cd1f1c 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -704,37 +704,33 @@ static void link_profile_stats(struct tipc_link *l) | |||
704 | */ | 704 | */ |
705 | int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq) | 705 | int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq) |
706 | { | 706 | { |
707 | int rc = 0; | 707 | int mtyp, rc = 0; |
708 | int mtyp = STATE_MSG; | 708 | bool state = false; |
709 | bool xmit = false; | 709 | bool probe = false; |
710 | bool prb = false; | 710 | bool setup = false; |
711 | u16 bc_snt = l->bc_sndlink->snd_nxt - 1; | 711 | u16 bc_snt = l->bc_sndlink->snd_nxt - 1; |
712 | u16 bc_acked = l->bc_rcvlink->acked; | 712 | u16 bc_acked = l->bc_rcvlink->acked; |
713 | bool bc_up = link_is_up(l->bc_rcvlink); | ||
714 | 713 | ||
715 | link_profile_stats(l); | 714 | link_profile_stats(l); |
716 | 715 | ||
717 | switch (l->state) { | 716 | switch (l->state) { |
718 | case LINK_ESTABLISHED: | 717 | case LINK_ESTABLISHED: |
719 | case LINK_SYNCHING: | 718 | case LINK_SYNCHING: |
720 | if (!l->silent_intv_cnt) { | 719 | if (l->silent_intv_cnt > l->abort_limit) |
721 | if (bc_up && (bc_acked != bc_snt)) | 720 | return tipc_link_fsm_evt(l, LINK_FAILURE_EVT); |
722 | xmit = true; | 721 | mtyp = STATE_MSG; |
723 | } else if (l->silent_intv_cnt <= l->abort_limit) { | 722 | state = bc_acked != bc_snt; |
724 | xmit = true; | 723 | probe = l->silent_intv_cnt; |
725 | prb = true; | 724 | if (probe) |
726 | } else { | 725 | l->silent_intv_cnt++; |
727 | rc |= tipc_link_fsm_evt(l, LINK_FAILURE_EVT); | ||
728 | } | ||
729 | l->silent_intv_cnt++; | ||
730 | break; | 726 | break; |
731 | case LINK_RESET: | 727 | case LINK_RESET: |
732 | xmit = l->rst_cnt++ <= 4; | 728 | setup = l->rst_cnt++ <= 4; |
733 | xmit |= !(l->rst_cnt % 16); | 729 | setup |= !(l->rst_cnt % 16); |
734 | mtyp = RESET_MSG; | 730 | mtyp = RESET_MSG; |
735 | break; | 731 | break; |
736 | case LINK_ESTABLISHING: | 732 | case LINK_ESTABLISHING: |
737 | xmit = true; | 733 | setup = true; |
738 | mtyp = ACTIVATE_MSG; | 734 | mtyp = ACTIVATE_MSG; |
739 | break; | 735 | break; |
740 | case LINK_PEER_RESET: | 736 | case LINK_PEER_RESET: |
@@ -745,8 +741,8 @@ int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq) | |||
745 | break; | 741 | break; |
746 | } | 742 | } |
747 | 743 | ||
748 | if (xmit) | 744 | if (state || probe || setup) |
749 | tipc_link_build_proto_msg(l, mtyp, prb, 0, 0, 0, xmitq); | 745 | tipc_link_build_proto_msg(l, mtyp, probe, 0, 0, 0, xmitq); |
750 | 746 | ||
751 | return rc; | 747 | return rc; |
752 | } | 748 | } |