Deleted Added
full compact
tcp_hostcache.c (190948) tcp_hostcache.c (191816)
1/*-
2 * Copyright (c) 2002 Andre Oppermann, Internet Business Solutions AG
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 49 unchanged lines hidden (view full) ---

58 */
59
60/*
61 * Many thanks to jlemon for basic structure of tcp_syncache which is being
62 * followed here.
63 */
64
65#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002 Andre Oppermann, Internet Business Solutions AG
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 49 unchanged lines hidden (view full) ---

58 */
59
60/*
61 * Many thanks to jlemon for basic structure of tcp_syncache which is being
62 * followed here.
63 */
64
65#include <sys/cdefs.h>
66__FBSDID("$FreeBSD: head/sys/netinet/tcp_hostcache.c 190948 2009-04-11 22:07:19Z rwatson $");
66__FBSDID("$FreeBSD: head/sys/netinet/tcp_hostcache.c 191816 2009-05-05 10:56:12Z zec $");
67
68#include "opt_inet6.h"
69
70#include <sys/param.h>
71#include <sys/systm.h>
72#include <sys/kernel.h>
73#include <sys/lock.h>
74#include <sys/mutex.h>

--- 147 unchanged lines hidden (view full) ---

222 NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
223 uma_zone_set_max(V_tcp_hostcache.zone, V_tcp_hostcache.cache_limit);
224
225 /*
226 * Set up periodic cache cleanup.
227 */
228 callout_init(&V_tcp_hc_callout, CALLOUT_MPSAFE);
229 callout_reset(&V_tcp_hc_callout, V_tcp_hostcache.prune * hz,
67
68#include "opt_inet6.h"
69
70#include <sys/param.h>
71#include <sys/systm.h>
72#include <sys/kernel.h>
73#include <sys/lock.h>
74#include <sys/mutex.h>

--- 147 unchanged lines hidden (view full) ---

222 NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
223 uma_zone_set_max(V_tcp_hostcache.zone, V_tcp_hostcache.cache_limit);
224
225 /*
226 * Set up periodic cache cleanup.
227 */
228 callout_init(&V_tcp_hc_callout, CALLOUT_MPSAFE);
229 callout_reset(&V_tcp_hc_callout, V_tcp_hostcache.prune * hz,
230 tcp_hc_purge, 0);
230 tcp_hc_purge, curvnet);
231}
232
233/*
234 * Internal function: look up an entry in the hostcache or return NULL.
235 *
236 * If an entry has been returned, the caller becomes responsible for
237 * unlocking the bucket row after he is done reading/modifying the entry.
238 */

--- 390 unchanged lines hidden (view full) ---

629
630/*
631 * Expire and purge (old|all) entries in the tcp_hostcache. Runs
632 * periodically from the callout.
633 */
634static void
635tcp_hc_purge(void *arg)
636{
231}
232
233/*
234 * Internal function: look up an entry in the hostcache or return NULL.
235 *
236 * If an entry has been returned, the caller becomes responsible for
237 * unlocking the bucket row after he is done reading/modifying the entry.
238 */

--- 390 unchanged lines hidden (view full) ---

629
630/*
631 * Expire and purge (old|all) entries in the tcp_hostcache. Runs
632 * periodically from the callout.
633 */
634static void
635tcp_hc_purge(void *arg)
636{
637 CURVNET_SET((struct vnet *) arg);
637 INIT_VNET_INET(curvnet);
638 struct hc_metrics *hc_entry, *hc_next;
638 INIT_VNET_INET(curvnet);
639 struct hc_metrics *hc_entry, *hc_next;
639 int all = (intptr_t)arg;
640 int all = 0; /* XXX was: (intptr_t)arg - makes no sense? */
640 int i;
641
642 if (V_tcp_hostcache.purgeall) {
643 all = 1;
644 V_tcp_hostcache.purgeall = 0;
645 }
646
647 for (i = 0; i < V_tcp_hostcache.hashsize; i++) {

--- 9 unchanged lines hidden (view full) ---

657 } else
658 hc_entry->rmx_expire -= V_tcp_hostcache.prune;
659 }
660 THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
661 }
662
663 callout_reset(&V_tcp_hc_callout, V_tcp_hostcache.prune * hz,
664 tcp_hc_purge, arg);
641 int i;
642
643 if (V_tcp_hostcache.purgeall) {
644 all = 1;
645 V_tcp_hostcache.purgeall = 0;
646 }
647
648 for (i = 0; i < V_tcp_hostcache.hashsize; i++) {

--- 9 unchanged lines hidden (view full) ---

658 } else
659 hc_entry->rmx_expire -= V_tcp_hostcache.prune;
660 }
661 THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
662 }
663
664 callout_reset(&V_tcp_hc_callout, V_tcp_hostcache.prune * hz,
665 tcp_hc_purge, arg);
666 CURVNET_RESTORE();
665}
667}