Commit 42b18f60 authored by Jon Paul Maloy's avatar Jon Paul Maloy Committed by David S. Miller

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: default avatarYing Xue <ying.xue@windriver.com>
Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 88e8ac70
...@@ -704,37 +704,33 @@ static void link_profile_stats(struct tipc_link *l) ...@@ -704,37 +704,33 @@ static void link_profile_stats(struct tipc_link *l)
*/ */
int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq) int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq)
{ {
int rc = 0; int mtyp, rc = 0;
int mtyp = STATE_MSG; bool state = false;
bool xmit = false; bool probe = false;
bool prb = false; bool setup = false;
u16 bc_snt = l->bc_sndlink->snd_nxt - 1; u16 bc_snt = l->bc_sndlink->snd_nxt - 1;
u16 bc_acked = l->bc_rcvlink->acked; u16 bc_acked = l->bc_rcvlink->acked;
bool bc_up = link_is_up(l->bc_rcvlink);
link_profile_stats(l); link_profile_stats(l);
switch (l->state) { switch (l->state) {
case LINK_ESTABLISHED: case LINK_ESTABLISHED:
case LINK_SYNCHING: case LINK_SYNCHING:
if (!l->silent_intv_cnt) { if (l->silent_intv_cnt > l->abort_limit)
if (bc_up && (bc_acked != bc_snt)) return tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
xmit = true; mtyp = STATE_MSG;
} else if (l->silent_intv_cnt <= l->abort_limit) { state = bc_acked != bc_snt;
xmit = true; probe = l->silent_intv_cnt;
prb = true; if (probe)
} else { l->silent_intv_cnt++;
rc |= tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
}
l->silent_intv_cnt++;
break; break;
case LINK_RESET: case LINK_RESET:
xmit = l->rst_cnt++ <= 4; setup = l->rst_cnt++ <= 4;
xmit |= !(l->rst_cnt % 16); setup |= !(l->rst_cnt % 16);
mtyp = RESET_MSG; mtyp = RESET_MSG;
break; break;
case LINK_ESTABLISHING: case LINK_ESTABLISHING:
xmit = true; setup = true;
mtyp = ACTIVATE_MSG; mtyp = ACTIVATE_MSG;
break; break;
case LINK_PEER_RESET: case LINK_PEER_RESET:
...@@ -745,8 +741,8 @@ int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq) ...@@ -745,8 +741,8 @@ int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq)
break; break;
} }
if (xmit) if (state || probe || setup)
tipc_link_build_proto_msg(l, mtyp, prb, 0, 0, 0, xmitq); tipc_link_build_proto_msg(l, mtyp, probe, 0, 0, 0, xmitq);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment