Index: net/if_etherip.c =================================================================== RCS file: /cvs/src/sys/net/if_etherip.c,v retrieving revision 1.7 diff -u -p -r1.7 if_etherip.c --- net/if_etherip.c 13 Apr 2016 11:41:15 -0000 1.7 +++ net/if_etherip.c 10 Oct 2016 04:06:11 -0000 @@ -368,26 +368,14 @@ ip_etherip_output(struct ifnet *ifp, str return ENETUNREACH; } - m->m_flags &= ~(M_BCAST|M_MCAST); - - M_PREPEND(m, sizeof(struct etherip_header), M_DONTWAIT); - if (m == NULL) { - etheripstat.etherip_adrops++; - return ENOBUFS; - } - eip = mtod(m, struct etherip_header *); - eip->eip_ver = ETHERIP_VERSION; - eip->eip_res = 0; - eip->eip_pad = 0; - - M_PREPEND(m, sizeof(struct ip), M_DONTWAIT); + M_PREPEND(m, sizeof(*ip) + sizeof(*eip), M_DONTWAIT); if (m == NULL) { etheripstat.etherip_adrops++; return ENOBUFS; } ip = mtod(m, struct ip *); - memset(ip, 0, sizeof(struct ip)); + memset(ip, 0, sizeof(struct ip)); ip->ip_v = IPVERSION; ip->ip_hl = sizeof(struct ip) >> 2; ip->ip_id = htons(ip_randomid()); @@ -398,6 +386,12 @@ ip_etherip_output(struct ifnet *ifp, str ip->ip_src = src->sin_addr; ip->ip_dst = dst->sin_addr; + eip = (struct etherip_header *)(ip + 1); + eip->eip_ver = ETHERIP_VERSION; + eip->eip_res = 0; + eip->eip_pad = 0; + + m->m_flags &= ~(M_BCAST|M_MCAST); m->m_pkthdr.ph_rtableid = sc->sc_rdomain; #if NPF > 0