Index: sys/netgraph/ng_bridge.c =================================================================== --- sys/netgraph/ng_bridge.c +++ sys/netgraph/ng_bridge.c @@ -138,7 +138,7 @@ u_char addr[6]; /* ethernet address */ link_p link; /* link where addr can be found */ u_int16_t age; /* seconds ago entry was created */ - u_int16_t staleness; /* seconds ago host last heard from */ + counter_u64_t staleness; /* seconds ago host last heard from */ SLIST_ENTRY(ng_bridge_host) next; /* next entry in bucket */ }; @@ -587,7 +587,8 @@ host->addr, sizeof(ary->hosts[i].addr)); ary->hosts[i].age = host->age; - ary->hosts[i].staleness = host->staleness; + ary->hosts[i].staleness = + counter_u64_fetch(host->staleness); strncpy(ary->hosts[i].hook, NG_HOOK_NAME(host->link->hook), sizeof(ary->hosts[i].hook)); @@ -740,7 +741,7 @@ /* Look up packet's source Ethernet address in hashtable */ if ((host = ng_bridge_get(priv, eh->ether_shost)) != NULL) { /* Update time since last heard from this host */ - host->staleness = 0; + counter_u64_zero(host->staleness); /* Did host jump to a different link? */ if (host->link != ctx.incoming) { @@ -962,8 +963,12 @@ return (0); bcopy(addr, host->addr, ETHER_ADDR_LEN); host->link = link; - host->staleness = 0; host->age = 0; + host->staleness = counter_u64_alloc(M_NOWAIT); + if (host->staleness == NULL) { + free(host, M_NETGRAPH_BRIDGE); + return (0); + } /* Add new element to hash bucket */ SLIST_INSERT_HEAD(&priv->tab[bucket], host, next); @@ -1054,6 +1059,7 @@ if (link == NULL || host->link == link) { *hptr = SLIST_NEXT(host, next); + counter_u64_free(host->staleness); free(host, M_NETGRAPH_BRIDGE); priv->numHosts--; } else @@ -1104,8 +1110,11 @@ struct ng_bridge_host *const host = *hptr; /* Remove hosts we haven't heard from in a while */ - if (++host->staleness >= priv->conf.maxStaleness) { + counter_u64_add(host->staleness, 1); + if (counter_u64_fetch(host->staleness) >= + priv->conf.maxStaleness) { *hptr = SLIST_NEXT(host, next); + counter_u64_free(host->staleness); free(host, M_NETGRAPH_BRIDGE); priv->numHosts--; } else {