From: Jon M. <jm...@re...> - 2020-04-14 19:51:49
|
On 4/14/20 3:30 AM, Tuong Lien wrote: > Since commit 6a939f365bdb ("tipc: Auto removal of peer down node > instance"), a peer node instance is automatically clean up after 5 mins > without contact. This changed behavior is not really expected from user > who would expect to see the node with the "down" state in the node list > as before instead. > Also, the timer value is said to be small that the peer node might just > be rebooting, so will come back soon. This is absolutely no problem but > one wants to extend it to 10 minutes. > > This commit makes the timer configurable via the sysctl file: > > /proc/sys/net/tipc/node_cleanup > > which indicates in seconds how long a peer down node should be removed. > The default value is 300 i.e. 5 mins, while a value of '0' will disable > the auto removal feature. > > Signed-off-by: Tuong Lien <tuo...@de...> > --- > net/tipc/core.h | 1 + > net/tipc/node.c | 15 +++++++++------ > net/tipc/sysctl.c | 8 ++++++++ > 3 files changed, 18 insertions(+), 6 deletions(-) > > diff --git a/net/tipc/core.h b/net/tipc/core.h > index 631d83c9705f..7d07f9086936 100644 > --- a/net/tipc/core.h > +++ b/net/tipc/core.h > @@ -89,6 +89,7 @@ struct tipc_crypto; > extern unsigned int tipc_net_id __read_mostly; > extern int sysctl_tipc_rmem[3] __read_mostly; > extern int sysctl_tipc_named_timeout __read_mostly; > +extern int sysctl_tipc_node_cleanup __read_mostly; > > struct tipc_net { > u8 node_id[NODE_ID_LEN]; > diff --git a/net/tipc/node.c b/net/tipc/node.c > index 2373a66f3b59..5cf01e182730 100644 > --- a/net/tipc/node.c > +++ b/net/tipc/node.c > @@ -46,8 +46,11 @@ > #include "trace.h" > #include "crypto.h" > > +int sysctl_tipc_node_cleanup __read_mostly = 300; /* in seconds */ > + > #define INVALID_NODE_SIG 0x10000 > -#define NODE_CLEANUP_AFTER 300000 > +#define NODE_CLEANUP_AFTER \ > + msecs_to_jiffies(sysctl_tipc_node_cleanup * 1000) > > /* Flags used to take different actions according to flag type > * TIPC_NOTIFY_NODE_DOWN: notify node is down > @@ -130,7 +133,7 @@ struct tipc_node { > unsigned long keepalive_intv; > struct timer_list timer; > struct rcu_head rcu; > - unsigned long delete_at; > + unsigned long checkpt; > struct net *peer_net; > u32 peer_hash_mix; > #ifdef CONFIG_TIPC_CRYPTO > @@ -537,7 +540,7 @@ struct tipc_node *tipc_node_create(struct net *net, u32 addr, u8 *peer_id, > for (i = 0; i < MAX_BEARERS; i++) > spin_lock_init(&n->links[i].lock); > n->state = SELF_DOWN_PEER_LEAVING; > - n->delete_at = jiffies + msecs_to_jiffies(NODE_CLEANUP_AFTER); > + n->checkpt = jiffies; > n->signature = INVALID_NODE_SIG; > n->active_links[0] = INVALID_BEARER_ID; > n->active_links[1] = INVALID_BEARER_ID; > @@ -726,8 +729,8 @@ static bool tipc_node_cleanup(struct tipc_node *peer) > return false; > > tipc_node_write_lock(peer); > - > - if (!node_is_up(peer) && time_after(jiffies, peer->delete_at)) { > + if (!node_is_up(peer) && NODE_CLEANUP_AFTER && > + time_after(jiffies, peer->checkpt + NODE_CLEANUP_AFTER)) { > tipc_node_clear_links(peer); > tipc_node_delete_from_list(peer); > deleted = true; > @@ -1478,7 +1481,7 @@ static void node_lost_contact(struct tipc_node *n, > uint i; > > pr_debug("Lost contact with %x\n", n->addr); > - n->delete_at = jiffies + msecs_to_jiffies(NODE_CLEANUP_AFTER); > + n->checkpt = jiffies; > trace_tipc_node_lost_contact(n, true, " "); > > /* Clean up broadcast state */ > diff --git a/net/tipc/sysctl.c b/net/tipc/sysctl.c > index 58ab3d6dcdce..087a89b27b9a 100644 > --- a/net/tipc/sysctl.c > +++ b/net/tipc/sysctl.c > @@ -75,6 +75,14 @@ static struct ctl_table tipc_table[] = { > .extra1 = SYSCTL_ONE, > }, > #endif > + { > + .procname = "node_cleanup", > + .data = &sysctl_tipc_node_cleanup, > + .maxlen = sizeof(sysctl_tipc_node_cleanup), > + .mode = 0644, > + .proc_handler = proc_dointvec_minmax, > + .extra1 = SYSCTL_ZERO, > + }, > {} > }; > Acked-by: Jon Maloy <jm...@re...> |