MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ng_netflow_expire

Function ng_netflow_expire

freebsd/netgraph/netflow/netflow.c:1087–1176  ·  view source on GitHub ↗

Periodic flow expiry run. */

Source from the content-addressed store, hash-verified

1085
1086/* Periodic flow expiry run. */
1087void
1088ng_netflow_expire(void *arg)
1089{
1090 struct flow_entry *fle, *fle1;
1091 struct flow_hash_entry *hsh;
1092 priv_p priv = (priv_p )arg;
1093 int used, i;
1094
1095 /*
1096 * Going through all the cache.
1097 */
1098 used = uma_zone_get_cur(priv->zone);
1099 for (hsh = priv->hash, i = 0; i < NBUCKETS; hsh++, i++) {
1100 /*
1101 * Skip entries, that are already being worked on.
1102 */
1103 if (mtx_trylock(&hsh->mtx) == 0)
1104 continue;
1105
1106 TAILQ_FOREACH_SAFE(fle, &hsh->head, fle_hash, fle1) {
1107 /*
1108 * Interrupt thread wants this entry!
1109 * Quick! Quick! Bail out!
1110 */
1111 if (hsh->mtx.mtx_lock & MTX_CONTESTED)
1112 break;
1113
1114 /*
1115 * Don't expire aggressively while hash collision
1116 * ratio is predicted small.
1117 */
1118 if (used <= (NBUCKETS*2) && !INACTIVE(fle))
1119 break;
1120
1121 if ((INACTIVE(fle) && (SMALL(fle) ||
1122 (used > (NBUCKETS*2)))) || AGED(fle)) {
1123 TAILQ_REMOVE(&hsh->head, fle, fle_hash);
1124 expire_flow(priv, priv_to_fib(priv,
1125 fle->f.r.fib), fle, NG_NOFLAGS);
1126 used--;
1127 counter_u64_add(priv->nfinfo_inact_exp, 1);
1128 }
1129 }
1130 mtx_unlock(&hsh->mtx);
1131 }
1132
1133#ifdef INET6
1134 used = uma_zone_get_cur(priv->zone6);
1135 for (hsh = priv->hash6, i = 0; i < NBUCKETS; hsh++, i++) {
1136 struct flow6_entry *fle6;
1137
1138 /*
1139 * Skip entries, that are already being worked on.
1140 */
1141 if (mtx_trylock(&hsh->mtx) == 0)
1142 continue;
1143
1144 TAILQ_FOREACH_SAFE(fle, &hsh->head, fle_hash, fle1) {

Callers

nothing calls this directly

Calls 4

uma_zone_get_curFunction · 0.85
expire_flowFunction · 0.85
counter_u64_addFunction · 0.50
mtx_unlockFunction · 0.50

Tested by

no test coverage detected