Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/ip_icmp.c
Show First 20 Lines • Show All 303 Lines • ▼ Show 20 Lines | #endif | ||||
} else | } else | ||||
stdreply: icmpelen = max(8, min(V_icmp_quotelen, ntohs(oip->ip_len) - | stdreply: icmpelen = max(8, min(V_icmp_quotelen, ntohs(oip->ip_len) - | ||||
oiphlen)); | oiphlen)); | ||||
icmplen = min(oiphlen + icmpelen, nlen); | icmplen = min(oiphlen + icmpelen, nlen); | ||||
if (icmplen < sizeof(struct ip)) | if (icmplen < sizeof(struct ip)) | ||||
goto freeit; | goto freeit; | ||||
if (MHLEN > sizeof(struct ip) + ICMP_MINLEN + icmplen) | /* | ||||
* XXX m_align may add up to sizeof(long) - 1 padding bytes. This | |||||
* logic does not belong here; this is a short-term fix for a buffer | |||||
* underwrite. | |||||
*/ | |||||
if (MHLEN > (sizeof(struct ip) + ICMP_MINLEN + icmplen + | |||||
sizeof(long) - 1) & ~(sizeof(long) - 1)) | |||||
m = m_gethdr(M_NOWAIT, MT_DATA); | m = m_gethdr(M_NOWAIT, MT_DATA); | ||||
else | 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 | ||||
Show All 36 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->m_data >= M_START(m) + sizeof(struct ip)); | |||||
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 |