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

Function ng_netflow_flow6_add

freebsd/netgraph/netflow/netflow.c:776–894  ·  view source on GitHub ↗

Insert IPv6 packet from into flow cache. */

Source from the content-addressed store, hash-verified

774#ifdef INET6
775/* Insert IPv6 packet from into flow cache. */
776int
777ng_netflow_flow6_add(priv_p priv, fib_export_p fe, struct ip6_hdr *ip6,
778 caddr_t upper_ptr, uint8_t upper_proto, uint8_t flags,
779 unsigned int src_if_index)
780{
781 struct flow_entry *fle = NULL, *fle1;
782 struct flow6_entry *fle6;
783 struct flow_hash_entry *hsh;
784 struct flow6_rec r;
785 int plen;
786 int error = 0;
787 uint8_t tcp_flags = 0;
788
789 /* check version */
790 if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION)
791 return (EINVAL);
792
793 bzero(&r, sizeof(r));
794
795 r.src.r_src6 = ip6->ip6_src;
796 r.dst.r_dst6 = ip6->ip6_dst;
797 r.fib = fe->fib;
798
799 /* Assume L4 template by default */
800 r.flow_type = NETFLOW_V9_FLOW_V6_L4;
801
802 plen = ntohs(ip6->ip6_plen) + sizeof(struct ip6_hdr);
803
804#if 0
805 /* XXX: set DSCP/CoS value */
806 r.r_tos = ip->ip_tos;
807#endif
808 if ((flags & NG_NETFLOW_IS_FRAG) == 0) {
809 switch(upper_proto) {
810 case IPPROTO_TCP:
811 {
812 struct tcphdr *tcp;
813
814 tcp = (struct tcphdr *)upper_ptr;
815 r.r_ports = *(uint32_t *)upper_ptr;
816 tcp_flags = tcp->th_flags;
817 break;
818 }
819 case IPPROTO_UDP:
820 case IPPROTO_SCTP:
821 r.r_ports = *(uint32_t *)upper_ptr;
822 break;
823 }
824 }
825
826 r.r_ip_p = upper_proto;
827 r.r_i_ifx = src_if_index;
828
829 counter_u64_add(priv->nfinfo_packets6, 1);
830 counter_u64_add(priv->nfinfo_bytes6, plen);
831
832 /* Find hash slot. */
833 hsh = &priv->hash6[ip6_hash(&r)];

Callers 1

ng_netflow_rcvdataFunction · 0.85

Calls 7

bzeroFunction · 0.85
ip6_hashFunction · 0.85
expire_flowFunction · 0.85
hash6_insertFunction · 0.85
counter_u64_addFunction · 0.50
mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50

Tested by

no test coverage detected