Add a new sysctl net.inet.tcp.hostcache.purgenow=1 to expire and purge all

entries in hostcache immediately.

In collaboration with:	bz, rwatson
MFC after:	1 week
Relnotes:	yes
Sponsored by:	Limelight Networks
This commit is contained in:
Hiren Panchasara 2015-05-20 01:08:01 +00:00
parent 738dbe7419
commit 2645638064
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=283136

View File

@ -117,6 +117,7 @@ static VNET_DEFINE(struct callout, tcp_hc_callout);
static struct hc_metrics *tcp_hc_lookup(struct in_conninfo *);
static struct hc_metrics *tcp_hc_insert(struct in_conninfo *);
static int sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS);
static int sysctl_tcp_hc_purgenow(SYSCTL_HANDLER_ARGS);
static void tcp_hc_purge_internal(int);
static void tcp_hc_purge(void *);
@ -155,6 +156,9 @@ SYSCTL_PROC(_net_inet_tcp_hostcache, OID_AUTO, list,
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_SKIP, 0, 0,
sysctl_tcp_hc_list, "A", "List of all hostcache entries");
SYSCTL_PROC(_net_inet_tcp_hostcache, OID_AUTO, purgenow,
CTLTYPE_INT | CTLFLAG_RW, NULL, 0,
sysctl_tcp_hc_purgenow, "I", "Immediately purge all entries");
static MALLOC_DEFINE(M_HOSTCACHE, "hostcache", "TCP hostcache");
@ -696,3 +700,24 @@ tcp_hc_purge(void *arg)
tcp_hc_purge, arg);
CURVNET_RESTORE();
}
/*
* Expire and purge all entries in hostcache immediately.
*/
static int
sysctl_tcp_hc_purgenow(SYSCTL_HANDLER_ARGS)
{
int error, val;
val = 0;
error = sysctl_handle_int(oidp, &val, 0, req);
if (error || !req->newptr)
return (error);
tcp_hc_purge_internal(1);
callout_reset(&V_tcp_hc_callout, V_tcp_hostcache.prune * hz,
tcp_hc_purge, curvnet);
return (0);
}