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

Function vxlan_input

freebsd/net/if_vxlan.c:2794–2855  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2792}
2793
2794static int
2795vxlan_input(struct vxlan_socket *vso, uint32_t vni, struct mbuf **m0,
2796 const struct sockaddr *sa)
2797{
2798 struct vxlan_softc *sc;
2799 struct ifnet *ifp;
2800 struct mbuf *m;
2801 struct ether_header *eh;
2802 int error;
2803
2804 sc = vxlan_socket_lookup_softc(vso, vni);
2805 if (sc == NULL)
2806 return (ENOENT);
2807
2808 ifp = sc->vxl_ifp;
2809 m = *m0;
2810 eh = mtod(m, struct ether_header *);
2811
2812 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
2813 error = ENETDOWN;
2814 goto out;
2815 } else if (ifp == m->m_pkthdr.rcvif) {
2816 /* XXX Does not catch more complex loops. */
2817 error = EDEADLK;
2818 goto out;
2819 }
2820
2821 if (sc->vxl_flags & VXLAN_FLAG_LEARN)
2822 vxlan_ftable_learn(sc, sa, eh->ether_shost);
2823
2824 m_clrprotoflags(m);
2825 m->m_pkthdr.rcvif = ifp;
2826 M_SETFIB(m, ifp->if_fib);
2827 if (((ifp->if_capenable & IFCAP_RXCSUM &&
2828 m->m_pkthdr.csum_flags & CSUM_INNER_L3_CALC) ||
2829 (ifp->if_capenable & IFCAP_RXCSUM_IPV6 &&
2830 !(m->m_pkthdr.csum_flags & CSUM_INNER_L3_CALC)))) {
2831 uint32_t csum_flags = 0;
2832
2833 if (m->m_pkthdr.csum_flags & CSUM_INNER_L3_CALC)
2834 csum_flags |= CSUM_L3_CALC;
2835 if (m->m_pkthdr.csum_flags & CSUM_INNER_L3_VALID)
2836 csum_flags |= CSUM_L3_VALID;
2837 if (m->m_pkthdr.csum_flags & CSUM_INNER_L4_CALC)
2838 csum_flags |= CSUM_L4_CALC;
2839 if (m->m_pkthdr.csum_flags & CSUM_INNER_L4_VALID)
2840 csum_flags |= CSUM_L4_VALID;
2841 m->m_pkthdr.csum_flags = csum_flags;
2842 counter_u64_add(sc->vxl_stats.rxcsum, 1);
2843 } else {
2844 /* clear everything */
2845 m->m_pkthdr.csum_flags = 0;
2846 m->m_pkthdr.csum_data = 0;
2847 }
2848
2849 error = netisr_dispatch(NETISR_ETHER, m);
2850 *m0 = NULL;
2851

Callers 1

vxlan_rcv_udp_packetFunction · 0.85

Calls 6

vxlan_ftable_learnFunction · 0.85
netisr_dispatchFunction · 0.85
vxlan_releaseFunction · 0.85
m_clrprotoflagsFunction · 0.50
counter_u64_addFunction · 0.50

Tested by

no test coverage detected