/* NOTE: we are using a combined hash table for both IPv4 and IPv6, the reason *forthisisthatIsuspectmostuserswillnotmakeheavyuseofboth *addressfamiliesatthesametimesoonetablewillusuallyendupwasted, *ifthisbecomesaproblemwecanalwaysaddahashtableforeachaddress
* family later */
/** *sel_netnode_hashfn_ipv4-IPv4hashingfunctionforthenodetable *@addr:IPv4address * *Description: *ThisistheIPv4hashingfunctionforthenodeinterfacetable,itreturns *thebucketnumberforthegivenIPaddress. *
*/ staticunsignedint sel_netnode_hashfn_ipv4(__be32 addr)
{ /* at some point we should determine if the mismatch in byte order
* affects the hash function dramatically */ return (addr & (SEL_NETNODE_HASH_SIZE - 1));
}
/** *sel_netnode_hashfn_ipv6-IPv6hashingfunctionforthenodetable *@addr:IPv6address * *Description: *ThisistheIPv6hashingfunctionforthenodeinterfacetable,itreturns *thebucketnumberforthegivenIPaddress. *
*/ staticunsignedint sel_netnode_hashfn_ipv6(conststruct in6_addr *addr)
{ /* just hash the least significant 32 bits to keep things fast (they *arethemostlikelytobedifferentanyway),wecanrevisitthis
* later if needed */ return (addr->s6_addr32[3] & (SEL_NETNODE_HASH_SIZE - 1));
}
switch (node->nsec.family) { case PF_INET:
idx = sel_netnode_hashfn_ipv4(node->nsec.addr.ipv4); break; case PF_INET6:
idx = sel_netnode_hashfn_ipv6(&node->nsec.addr.ipv6); break; default:
BUG(); return;
}
/* we need to impose a limit on the growth of the hash table so check
* this bucket to make sure it is within the specified bounds */
list_add_rcu(&node->list, &sel_netnode_hash[idx].list); if (sel_netnode_hash[idx].size == SEL_NETNODE_HASH_BKT_LIMIT) { struct sel_netnode *tail;
tail = list_entry(
rcu_dereference_protected(
list_tail_rcu(&sel_netnode_hash[idx].list),
lockdep_is_held(&sel_netnode_lock)), struct sel_netnode, list);
list_del_rcu(&tail->list);
kfree_rcu(tail, rcu);
} else
sel_netnode_hash[idx].size++;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.