| 688 | |
| 689 | #define MTAG_GRE 1307983903 |
| 690 | static int |
| 691 | gre_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; |
nothing calls this directly
no test coverage detected