Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/ip_icmp.c
Show First 20 Lines • Show All 314 Lines • ▼ Show 20 Lines | else | ||||
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); | m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); | ||||
if (m == NULL) | if (m == NULL) | ||||
goto freeit; | goto freeit; | ||||
#ifdef MAC | #ifdef MAC | ||||
mac_netinet_icmp_reply(n, m); | mac_netinet_icmp_reply(n, m); | ||||
#endif | #endif | ||||
icmplen = min(icmplen, M_TRAILINGSPACE(m) - | icmplen = min(icmplen, M_TRAILINGSPACE(m) - | ||||
sizeof(struct ip) - ICMP_MINLEN); | sizeof(struct ip) - ICMP_MINLEN); | ||||
m_align(m, ICMP_MINLEN + icmplen); | m_align(m, sizeof(struct ip) + ICMP_MINLEN + icmplen); | ||||
m->m_data += sizeof(struct ip); | |||||
m->m_len = ICMP_MINLEN + icmplen; | m->m_len = ICMP_MINLEN + icmplen; | ||||
/* XXX MRT make the outgoing packet use the same FIB | /* XXX MRT make the outgoing packet use the same FIB | ||||
* that was associated with the incoming packet | * that was associated with the incoming packet | ||||
*/ | */ | ||||
M_SETFIB(m, M_GETFIB(n)); | M_SETFIB(m, M_GETFIB(n)); | ||||
icp = mtod(m, struct icmp *); | icp = mtod(m, struct icmp *); | ||||
ICMPSTAT_INC(icps_outhist[type]); | ICMPSTAT_INC(icps_outhist[type]); | ||||
Show All 25 Lines | #endif | ||||
/* | /* | ||||
* Set up ICMP message mbuf and copy old IP header (without options | * Set up ICMP message mbuf and copy old IP header (without options | ||||
* in front of ICMP message. | * in front of ICMP message. | ||||
* If the original mbuf was meant to bypass the firewall, the error | * If the original mbuf was meant to bypass the firewall, the error | ||||
* reply should bypass as well. | * reply should bypass as well. | ||||
*/ | */ | ||||
m->m_flags |= n->m_flags & M_SKIP_FIREWALL; | m->m_flags |= n->m_flags & M_SKIP_FIREWALL; | ||||
KASSERT(M_LEADINGSPACE(m) >= sizeof(struct ip), | |||||
("insufficient space for ip header")); | |||||
m->m_data -= sizeof(struct ip); | m->m_data -= sizeof(struct ip); | ||||
m->m_len += sizeof(struct ip); | m->m_len += sizeof(struct ip); | ||||
m->m_pkthdr.len = m->m_len; | m->m_pkthdr.len = m->m_len; | ||||
m->m_pkthdr.rcvif = n->m_pkthdr.rcvif; | m->m_pkthdr.rcvif = n->m_pkthdr.rcvif; | ||||
nip = mtod(m, struct ip *); | nip = mtod(m, struct ip *); | ||||
bcopy((caddr_t)oip, (caddr_t)nip, sizeof(struct ip)); | bcopy((caddr_t)oip, (caddr_t)nip, sizeof(struct ip)); | ||||
nip->ip_len = htons(m->m_len); | nip->ip_len = htons(m->m_len); | ||||
nip->ip_v = IPVERSION; | nip->ip_v = IPVERSION; | ||||
▲ Show 20 Lines • Show All 694 Lines • Show Last 20 Lines |