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

Function ip_hash

freebsd/netgraph/netflow/netflow.c:130–142  ·  view source on GitHub ↗

* Generate hash for a given flow record. * * FIB is not used here, because: * most VRFS will carry public IPv4 addresses which are unique even * without FIB private addresses can overlap, but this is worked out * via flow_rec bcmp() containing fib id. In IPv6 world addresses are * all globally unique (it's not fully true, there is FC00::/7 for example, * but chances of address overlap are M

Source from the content-addressed store, hash-verified

128 * but chances of address overlap are MUCH smaller)
129 */
130static inline uint32_t
131ip_hash(struct flow_rec *r)
132{
133
134 switch (r->r_ip_p) {
135 case IPPROTO_TCP:
136 case IPPROTO_UDP:
137 return FULL_HASH(r->r_src.s_addr, r->r_dst.s_addr,
138 r->r_sport, r->r_dport);
139 default:
140 return ADDR_HASH(r->r_src.s_addr, r->r_dst.s_addr);
141 }
142}
143
144#ifdef INET6
145/* Generate hash for a given flow6 record. Use lower 4 octets from v6 addresses */

Callers 1

ng_netflow_flow_addFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected