Skip to content

Commit c140eb1

Browse files
LUU Duc Canhdavem330
authored andcommitted
tipc: fix failover problem
We see the following scenario: 1) Link endpoint B on node 1 discovers that its peer endpoint is gone. Since there is a second working link, failover procedure is started. 2) Link endpoint A on node 1 sends a FAILOVER message to peer endpoint A on node 2. The node item 1->2 goes to state FAILINGOVER. 3) Linke endpoint A/2 receives the failover, and is supposed to take down its parallell link endpoint B/2, while producing a FAILOVER message to send back to A/1. 4) However, B/2 has already been deleted, so no FAILOVER message can created. 5) Node 1->2 remains in state FAILINGOVER forever, refusing to receive any messages that can bring B/1 up again. We are left with a non- redundant link between node 1 and 2. We fix this with letting endpoint A/2 build a dummy FAILOVER message to send to back to A/1, so that the situation can be resolved. Signed-off-by: LUU Duc Canh <canh.d.luu@dektech.com.au> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 418b9a3 commit c140eb1

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

‎net/tipc/link.c‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,11 @@ char *tipc_link_name(struct tipc_link *l)
410410
return l->name;
411411
}
412412

413+
u32 tipc_link_state(struct tipc_link *l)
414+
{
415+
return l->state;
416+
}
417+
413418
/**
414419
* tipc_link_create - create a new link
415420
* @n: pointer to associated node
@@ -1385,6 +1390,36 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
13851390
__skb_queue_tail(xmitq, skb);
13861391
}
13871392

1393+
void tipc_link_create_dummy_tnl_msg(struct tipc_link *l,
1394+
struct sk_buff_head *xmitq)
1395+
{
1396+
u32 onode = tipc_own_addr(l->net);
1397+
struct tipc_msg *hdr, *ihdr;
1398+
struct sk_buff_head tnlq;
1399+
struct sk_buff *skb;
1400+
u32 dnode = l->addr;
1401+
1402+
skb_queue_head_init(&tnlq);
1403+
skb = tipc_msg_create(TUNNEL_PROTOCOL, FAILOVER_MSG,
1404+
INT_H_SIZE, BASIC_H_SIZE,
1405+
dnode, onode, 0, 0, 0);
1406+
if (!skb) {
1407+
pr_warn("%sunable to create tunnel packet\n", link_co_err);
1408+
return;
1409+
}
1410+
1411+
hdr = buf_msg(skb);
1412+
msg_set_msgcnt(hdr, 1);
1413+
msg_set_bearer_id(hdr, l->peer_bearer_id);
1414+
1415+
ihdr = (struct tipc_msg *)msg_data(hdr);
1416+
tipc_msg_init(onode, ihdr, TIPC_LOW_IMPORTANCE, TIPC_DIRECT_MSG,
1417+
BASIC_H_SIZE, dnode);
1418+
msg_set_errcode(ihdr, TIPC_ERR_NO_PORT);
1419+
__skb_queue_tail(&tnlq, skb);
1420+
tipc_link_xmit(l, &tnlq, xmitq);
1421+
}
1422+
13881423
/* tipc_link_tnl_prepare(): prepare and return a list of tunnel packets
13891424
* with contents of the link's transmit and backlog queues.
13901425
*/

‎net/tipc/link.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer,
8888
struct tipc_link **link);
8989
void tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl,
9090
int mtyp, struct sk_buff_head *xmitq);
91+
void tipc_link_create_dummy_tnl_msg(struct tipc_link *tnl,
92+
struct sk_buff_head *xmitq);
9193
void tipc_link_build_reset_msg(struct tipc_link *l, struct sk_buff_head *xmitq);
9294
int tipc_link_fsm_evt(struct tipc_link *l, int evt);
9395
bool tipc_link_is_up(struct tipc_link *l);
@@ -107,6 +109,7 @@ u16 tipc_link_rcv_nxt(struct tipc_link *l);
107109
u16 tipc_link_acked(struct tipc_link *l);
108110
u32 tipc_link_id(struct tipc_link *l);
109111
char *tipc_link_name(struct tipc_link *l);
112+
u32 tipc_link_state(struct tipc_link *l);
110113
char tipc_link_plane(struct tipc_link *l);
111114
int tipc_link_prio(struct tipc_link *l);
112115
int tipc_link_window(struct tipc_link *l);

‎net/tipc/node.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ struct tipc_node {
111111
int action_flags;
112112
struct list_head list;
113113
int state;
114+
bool failover_sent;
114115
u16 sync_point;
115116
int link_cnt;
116117
u16 working_links;
@@ -680,6 +681,7 @@ static void __tipc_node_link_up(struct tipc_node *n, int bearer_id,
680681
*slot0 = bearer_id;
681682
*slot1 = bearer_id;
682683
tipc_node_fsm_evt(n, SELF_ESTABL_CONTACT_EVT);
684+
n->failover_sent = false;
683685
n->action_flags |= TIPC_NOTIFY_NODE_UP;
684686
tipc_link_set_active(nl, true);
685687
tipc_bcast_add_peer(n->net, nl, xmitq);
@@ -1615,6 +1617,15 @@ static bool tipc_node_check_state(struct tipc_node *n, struct sk_buff *skb,
16151617
tipc_skb_queue_splice_tail_init(tipc_link_inputq(pl),
16161618
tipc_link_inputq(l));
16171619
}
1620+
/* If parallel link was already down, and this happened before
1621+
* the tunnel link came up, FAILOVER was never sent. Ensure that
1622+
* FAILOVER is sent to get peer out of NODE_FAILINGOVER state.
1623+
*/
1624+
if (n->state != NODE_FAILINGOVER && !n->failover_sent) {
1625+
tipc_link_create_dummy_tnl_msg(l, xmitq);
1626+
n->failover_sent = true;
1627+
}
1628+
16181629
/* If pkts arrive out of order, use lowest calculated syncpt */
16191630
if (less(syncpt, n->sync_point))
16201631
n->sync_point = syncpt;

0 commit comments

Comments
 (0)