Index: if_vxlan.c =================================================================== RCS file: /cvs/src/sys/net/if_vxlan.c,v retrieving revision 1.76 diff -u -p -r1.76 if_vxlan.c --- if_vxlan.c 8 Nov 2019 07:16:29 -0000 1.76 +++ if_vxlan.c 12 Apr 2020 01:36:26 -0000 @@ -82,6 +82,8 @@ struct vxlan_softc { void vxlanattach(int); int vxlanioctl(struct ifnet *, u_long, caddr_t); +int vxlanoutput(struct ifnet *, struct mbuf *, struct sockaddr *, + struct rtentry *); void vxlanstart(struct ifnet *); int vxlan_clone_create(struct if_clone *, int); int vxlan_clone_destroy(struct ifnet *); @@ -150,6 +152,7 @@ vxlan_clone_create(struct if_clone *ifc, ifp->if_softc = sc; ifp->if_ioctl = vxlanioctl; + ifp->if_output = vxlanoutput; ifp->if_start = vxlanstart; IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); @@ -294,6 +297,33 @@ vxlan_multicast_join(struct ifnet *ifp, if_detachhook_add(mifp, &sc->sc_dtask); return (0); +} + +int +vxlanoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, + struct rtentry *rt) +{ + struct m_tag *mtag; + + /* Try to limit infinite recursion through misconfiguration. */ + for (mtag = m_tag_find(m, PACKET_TAG_GRE, NULL); mtag; + mtag = m_tag_find(m, PACKET_TAG_GRE, mtag)) { + if (memcmp((caddr_t)(mtag + 1), &ifp->if_index, + sizeof(ifp->if_index)) == 0) { + m_freem(m); + return (EIO); + } + } + + mtag = m_tag_get(PACKET_TAG_GRE, sizeof(ifp->if_index), M_NOWAIT); + if (mtag == NULL) { + m_freem(m); + return (ENOMEM); + } + memcpy((caddr_t)(mtag + 1), &ifp->if_index, sizeof(ifp->if_index)); + m_tag_prepend(m, mtag); + + return (ether_output(ifp, m, dst, rt)); } void