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

Function hash6_insert

freebsd/netgraph/netflow/netflow.c:393–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391
392#ifdef INET6
393static int
394hash6_insert(priv_p priv, struct flow_hash_entry *hsh6, struct flow6_rec *r,
395 int plen, uint8_t flags, uint8_t tcp_flags)
396{
397 struct flow6_entry *fle6;
398
399 mtx_assert(&hsh6->mtx, MA_OWNED);
400
401 fle6 = uma_zalloc_arg(priv->zone6, priv, M_NOWAIT);
402 if (fle6 == NULL) {
403 priv->nfinfo_alloc_failed++;
404 return (ENOMEM);
405 }
406
407 /*
408 * Now fle is totally ours. It is detached from all lists,
409 * we can safely edit it.
410 */
411
412 fle6->f.version = IP6VERSION;
413 bcopy(r, &fle6->f.r, sizeof(struct flow6_rec));
414 fle6->f.bytes = plen;
415 fle6->f.packets = 1;
416 fle6->f.tcp_flags = tcp_flags;
417
418 fle6->f.first = fle6->f.last = time_uptime;
419
420 /*
421 * First we do route table lookup on destination address. So we can
422 * fill in out_ifx, dst_mask, nexthop, and dst_as in future releases.
423 */
424 if ((flags & NG_NETFLOW_CONF_NODSTLOOKUP) == 0) {
425 struct rtentry *rt;
426 struct route_nhop_data rnd;
427
428 rt = fib6_lookup_rt(r->fib, &fle6->f.r.dst.r_dst6, 0, NHR_NONE, &rnd);
429 if (rt != NULL) {
430 struct in6_addr addr;
431 uint32_t scopeid;
432 struct nhop_object *nh = nhop_select_func(rnd.rnd_nhop, 0);
433 int plen;
434
435 rt_get_inet6_prefix_plen(rt, &addr, &plen, &scopeid);
436 fle6->f.fle_o_ifx = nh->nh_ifp->if_index;
437 if (nh->gw_sa.sa_len == AF_INET6)
438 fle6->f.n.next_hop6 = nh->gw6_sa.sin6_addr;
439 fle6->f.dst_mask = plen;
440 }
441 }
442
443 if ((flags & NG_NETFLOW_CONF_NOSRCLOOKUP) == 0) {
444 /* Do route lookup on source address, to fill in src_mask. */
445 struct rtentry *rt;
446 struct route_nhop_data rnd;
447
448 rt = fib6_lookup_rt(r->fib, &fle6->f.r.src.r_src6, 0, NHR_NONE, &rnd);
449 if (rt != NULL) {
450 struct in6_addr addr;

Callers 1

ng_netflow_flow6_addFunction · 0.85

Calls 5

mtx_assertFunction · 0.85
uma_zalloc_argFunction · 0.85
fib6_lookup_rtFunction · 0.85
nhop_select_funcFunction · 0.85
rt_get_inet6_prefix_plenFunction · 0.85

Tested by

no test coverage detected