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

Function gre_transmit

freebsd/net/if_gre.c:690–812  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

688
689#define MTAG_GRE 1307983903
690static int
691gre_transmit(struct ifnet *ifp, struct mbuf *m)
692{
693 GRE_RLOCK_TRACKER;
694 struct gre_softc *sc;
695 struct grehdr *gh;
696 struct udphdr *uh;
697 uint32_t af, flowid;
698 int error, len;
699 uint16_t proto;
700
701 len = 0;
702 GRE_RLOCK();
703#ifdef MAC
704 error = mac_ifnet_check_transmit(ifp, m);
705 if (error) {
706 m_freem(m);
707 goto drop;
708 }
709#endif
710 error = ENETDOWN;
711 sc = ifp->if_softc;
712 if ((ifp->if_flags & IFF_MONITOR) != 0 ||
713 (ifp->if_flags & IFF_UP) == 0 ||
714 (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 ||
715 sc->gre_family == 0 ||
716 (error = if_tunnel_check_nesting(ifp, m, MTAG_GRE,
717 V_max_gre_nesting)) != 0) {
718 m_freem(m);
719 goto drop;
720 }
721 af = m->m_pkthdr.csum_data;
722 BPF_MTAP2(ifp, &af, sizeof(af), m);
723 m->m_flags &= ~(M_BCAST|M_MCAST);
724 flowid = gre_flowid(sc, m, af);
725 M_SETFIB(m, sc->gre_fibnum);
726 M_PREPEND(m, sc->gre_hlen, M_NOWAIT);
727 if (m == NULL) {
728 error = ENOBUFS;
729 goto drop;
730 }
731 bcopy(sc->gre_hdr, mtod(m, void *), sc->gre_hlen);
732 /* Determine GRE proto */
733 switch (af) {
734#ifdef INET
735 case AF_INET:
736 proto = htons(ETHERTYPE_IP);
737 break;
738#endif
739#ifdef INET6
740 case AF_INET6:
741 proto = htons(ETHERTYPE_IPV6);
742 break;
743#endif
744 default:
745 m_freem(m);
746 error = ENETDOWN;
747 goto drop;

Callers

nothing calls this directly

Calls 10

mac_ifnet_check_transmitFunction · 0.85
if_tunnel_check_nestingFunction · 0.85
gre_flowidFunction · 0.85
gre_cksum_addFunction · 0.85
gre_setseqnFunction · 0.85
in_gre_outputFunction · 0.85
in6_gre_outputFunction · 0.85
if_inc_counterFunction · 0.85
m_freemFunction · 0.50
in_cksum_skipFunction · 0.50

Tested by

no test coverage detected