Skip to content

Commit 169bf91

Browse files
Jon Paul Maloydavem330
authored andcommitted
tipc: ensure that idle links are deleted when a bearer is disabled
commit afaa3f6 (tipc: purge links when bearer is disabled) was an attempt to resolve a problem that turned out to have a more profound reason. When we disable a bearer, we delete all its pertaining links if there is no other bearer to perform failover to, or if the module is shutting down. In case there are dual bearers, we wait with deleting links until the failover procedure is finished. However, this misses the case when a link on the removed bearer was already down, so that there will be no failover procedure to finish the link delete. This causes confusion if a new bearer is added to replace the removed one, and also entails a small memory leak. This commit takes the current state of the link into account when deciding when to delete it, and also reverses the above-mentioned commit. Reviewed-by: Erik Hugne <[email protected]> Signed-off-by: Jon Maloy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ddb4b9a commit 169bf91

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

net/tipc/bearer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info)
747747
return -EINVAL;
748748
}
749749

750-
bearer_disable(net, bearer, true);
750+
bearer_disable(net, bearer, false);
751751
rtnl_unlock();
752752

753753
return 0;

net/tipc/link.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ void tipc_link_delete_list(struct net *net, unsigned int bearer_id,
344344
struct tipc_net *tn = net_generic(net, tipc_net_id);
345345
struct tipc_link *link;
346346
struct tipc_node *node;
347+
bool del_link;
347348

348349
rcu_read_lock();
349350
list_for_each_entry_rcu(node, &tn->node_list, list) {
@@ -353,12 +354,13 @@ void tipc_link_delete_list(struct net *net, unsigned int bearer_id,
353354
tipc_node_unlock(node);
354355
continue;
355356
}
357+
del_link = !tipc_link_is_up(link) && !link->exp_msg_count;
356358
tipc_link_reset(link);
357359
if (del_timer(&link->timer))
358360
tipc_link_put(link);
359361
link->flags |= LINK_STOPPED;
360362
/* Delete link now, or when failover is finished: */
361-
if (shutting_down || !tipc_node_is_up(node))
363+
if (shutting_down || !tipc_node_is_up(node) || del_link)
362364
tipc_link_delete(link);
363365
tipc_node_unlock(node);
364366
}

0 commit comments

Comments
 (0)