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

Function ngs_rehash

freebsd/netgraph/ng_socket.c:783–810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

781}
782
783static void
784ngs_rehash(node_p node)
785{
786 struct ngsock *priv = NG_NODE_PRIVATE(node);
787 struct ngshash *new;
788 struct hookpriv *hp;
789 hook_p hook;
790 uint32_t h;
791 u_long hmask;
792
793 new = hashinit_flags((priv->hmask + 1) * 2, M_NETGRAPH_SOCK, &hmask,
794 HASH_NOWAIT);
795 if (new == NULL)
796 return;
797
798 LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) {
799 hp = NG_HOOK_PRIVATE(hook);
800#ifdef INVARIANTS
801 LIST_REMOVE(hp, next);
802#endif
803 h = hash32_str(NG_HOOK_NAME(hook), HASHINIT) & hmask;
804 LIST_INSERT_HEAD(&new[h], hp, next);
805 }
806
807 hashdestroy(priv->hash, M_NETGRAPH_SOCK, priv->hmask);
808 priv->hash = new;
809 priv->hmask = hmask;
810}
811
812/*
813 * We allow any hook to be connected to the node.

Callers 1

ngs_newhookFunction · 0.85

Calls 3

hash32_strFunction · 0.85
hashinit_flagsFunction · 0.50
hashdestroyFunction · 0.50

Tested by

no test coverage detected