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

Function ng_netflow_rcvdata

freebsd/netgraph/netflow/ng_netflow.c:586–989  ·  view source on GitHub ↗

Receive data on hook. */

Source from the content-addressed store, hash-verified

584
585/* Receive data on hook. */
586static int
587ng_netflow_rcvdata (hook_p hook, item_p item)
588{
589 const node_p node = NG_HOOK_NODE(hook);
590 const priv_p priv = NG_NODE_PRIVATE(node);
591 const iface_p iface = NG_HOOK_PRIVATE(hook);
592 hook_p out;
593 struct mbuf *m = NULL, *m_old = NULL;
594 struct ip *ip = NULL;
595 struct ip6_hdr *ip6 = NULL;
596 struct m_tag *mtag;
597 int pullup_len = 0, off;
598 uint8_t acct = 0, bypass = 0, flags = 0, upper_proto = 0;
599 int error = 0, l3_off = 0;
600 unsigned int src_if_index;
601 caddr_t upper_ptr = NULL;
602 fib_export_p fe;
603 uint32_t fib;
604
605 if ((hook == priv->export) || (hook == priv->export9)) {
606 /*
607 * Data arrived on export hook.
608 * This must not happen.
609 */
610 log(LOG_ERR, "ng_netflow: incoming data on export hook!\n");
611 ERROUT(EINVAL);
612 }
613
614 if (hook == iface->hook) {
615 if ((iface->info.conf & NG_NETFLOW_CONF_INGRESS) == 0)
616 bypass = 1;
617 out = iface->out;
618 } else if (hook == iface->out) {
619 if ((iface->info.conf & NG_NETFLOW_CONF_EGRESS) == 0)
620 bypass = 1;
621 out = iface->hook;
622 } else
623 ERROUT(EINVAL);
624
625 if ((!bypass) && (iface->info.conf &
626 (NG_NETFLOW_CONF_ONCE | NG_NETFLOW_CONF_THISONCE))) {
627 mtag = m_tag_locate(NGI_M(item), MTAG_NETFLOW,
628 MTAG_NETFLOW_CALLED, NULL);
629 while (mtag != NULL) {
630 if ((iface->info.conf & NG_NETFLOW_CONF_ONCE) ||
631 ((ng_ID_t *)(mtag + 1))[0] == NG_NODE_ID(node)) {
632 bypass = 1;
633 break;
634 }
635 mtag = m_tag_locate(NGI_M(item), MTAG_NETFLOW,
636 MTAG_NETFLOW_CALLED, mtag);
637 }
638 }
639
640 if (bypass) {
641 if (out == NULL)
642 ERROUT(ENOTCONN);
643

Callers

nothing calls this directly

Calls 8

m_tag_locateFunction · 0.85
m_tag_allocFunction · 0.85
ng_netflow_fib_initFunction · 0.85
ng_netflow_flow_addFunction · 0.85
ng_netflow_flow6_addFunction · 0.85
logFunction · 0.50
m_tag_prependFunction · 0.50
counter_u64_addFunction · 0.50

Tested by

no test coverage detected