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

Function ng_bridge_timeout

freebsd/netgraph/ng_bridge.c:1043–1085  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1041}
1042
1043static void
1044ng_bridge_timeout(node_p node, hook_p hook, void *arg1, int arg2)
1045{
1046 const priv_p priv = NG_NODE_PRIVATE(node);
1047 int bucket;
1048 int counter = 0;
1049 hook_p ret;
1050
1051 /* Update host time counters and remove stale entries */
1052 for (bucket = 0; bucket < priv->numBuckets; bucket++) {
1053 struct ng_bridge_hent **hptr = &SLIST_FIRST(&priv->tab[bucket]);
1054
1055 while (*hptr != NULL) {
1056 struct ng_bridge_hent *const hent = *hptr;
1057
1058 /* Remove hosts we haven't heard from in a while */
1059 if (++hent->host.staleness >= priv->conf.maxStaleness) {
1060 *hptr = SLIST_NEXT(hent, next);
1061 free(hent, M_NETGRAPH_BRIDGE);
1062 priv->numHosts--;
1063 } else {
1064 if (hent->host.age < 0xffff)
1065 hent->host.age++;
1066 hptr = &SLIST_NEXT(hent, next);
1067 counter++;
1068 }
1069 }
1070 }
1071 KASSERT(priv->numHosts == counter,
1072 ("%s: hosts: %d != %d", __func__, priv->numHosts, counter));
1073
1074 /* Decrease table size if necessary */
1075 ng_bridge_rehash(priv);
1076
1077 /* Decrease loop counter on muted looped back links */
1078 counter = 0;
1079 NG_NODE_FOREACH_HOOK(node, ng_bridge_unmute, &counter, ret);
1080 KASSERT(priv->numLinks == counter,
1081 ("%s: links: %d != %d", __func__, priv->numLinks, counter));
1082
1083 /* Register a new timeout, keeping the existing node reference */
1084 ng_callout(&priv->timer, node, NULL, hz, ng_bridge_timeout, NULL, 0);
1085}
1086
1087/*
1088 * Return node's "name", even if it doesn't have one.

Callers

nothing calls this directly

Calls 3

ng_bridge_rehashFunction · 0.85
ng_calloutFunction · 0.70
freeFunction · 0.50

Tested by

no test coverage detected