diff options
| author | Hiren Panchasara <hiren@FreeBSD.org> | 2015-05-20 01:08:01 +0000 |
|---|---|---|
| committer | Hiren Panchasara <hiren@FreeBSD.org> | 2015-05-20 01:08:01 +0000 |
| commit | 2645638064960797fdfb0a5e80f7fa1af7833861 (patch) | |
| tree | 1b512437258c37ec52c0a80e065e3322d50750df | |
| parent | 738dbe7419b7915c9adaed58595d0f108fb3fe11 (diff) | |
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
Notes
Notes:
svn path=/head/; revision=283136
| -rw-r--r-- | sys/netinet/tcp_hostcache.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c index ca13f27edd93..6ff447ce2e35 100644 --- a/sys/netinet/tcp_hostcache.c +++ b/sys/netinet/tcp_hostcache.c @@ -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); +} |
