| version 1.284.2.2, 2010/08/17 06:47:46 |
version 1.284.2.3, 2010/11/06 08:08:49 |
| Line 231 int in_multientries; /* total number o |
|
| Line 231 int in_multientries; /* total number o |
|
| struct in_multihashhead *in_multihashtbl; |
struct in_multihashhead *in_multihashtbl; |
| struct ifqueue ipintrq; |
struct ifqueue ipintrq; |
| |
|
| |
ipid_state_t * ip_ids; |
| uint16_t ip_id; |
uint16_t ip_id; |
| |
|
| percpu_t *ipstat_percpu; |
percpu_t *ipstat_percpu; |
|
|
| |
|
| ip_reass_init(); |
ip_reass_init(); |
| |
|
| ip_initid(); |
ip_ids = ip_id_init(); |
| ip_id = time_second & 0xfffff; |
ip_id = time_second & 0xfffff; |
| |
|
| ipintrq.ifq_maxlen = ipqmaxlen; |
ipintrq.ifq_maxlen = ipqmaxlen; |
|
|
| * If offset or IP_MF are set, must reassemble. |
* If offset or IP_MF are set, must reassemble. |
| */ |
*/ |
| if (ip->ip_off & ~htons(IP_DF|IP_RF)) { |
if (ip->ip_off & ~htons(IP_DF|IP_RF)) { |
| struct mbuf *m_final; |
|
| u_int off, flen; |
|
| bool mff; |
|
| |
|
| /* |
|
| * Prevent TCP blind data attacks by not allowing non-initial |
|
| * fragments to start at less than 68 bytes (minimal fragment |
|
| * size) and making sure the first fragment is at least 68 |
|
| * bytes. |
|
| */ |
|
| off = (ntohs(ip->ip_off) & IP_OFFMASK) << 3; |
|
| if ((off > 0 ? off + hlen : len) < IP_MINFRAGSIZE - 1) { |
|
| IP_STATINC(IP_STAT_BADFRAGS); |
|
| goto bad; |
|
| } |
|
| |
|
| /* Fragment length and MF flag. */ |
|
| flen = ntohs(ip->ip_len) - hlen; |
|
| mff = (ip->ip_off & htons(IP_MF)) != 0; |
|
| if (mff) { |
|
| /* |
|
| * Make sure that fragments have a data length |
|
| * which is non-zero and multiple of 8 bytes. |
|
| */ |
|
| if (flen == 0 || (flen & 0x7) != 0) { |
|
| IP_STATINC(IP_STAT_BADFRAGS); |
|
| goto bad; |
|
| } |
|
| } |
|
| |
|
| /* |
|
| * Adjust total IP length to not reflect header and convert |
|
| * offset of this to bytes. XXX: clobbers struct ip. |
|
| */ |
|
| ip->ip_len = htons(flen); |
|
| ip->ip_off = htons(off); |
|
| |
|
| /* |
/* |
| * Pass to IP reassembly mechanism. |
* Pass to IP reassembly mechanism. |
| */ |
*/ |
| if (ip_reass_packet(m, ip, mff, &m_final) != 0) { |
if (ip_reass_packet(&m, ip) != 0) { |
| /* Failed; invalid fragment(s) or packet. */ |
/* Failed; invalid fragment(s) or packet. */ |
| goto bad; |
goto bad; |
| } |
} |
| if (m_final == NULL) { |
if (m == NULL) { |
| /* More fragments should come; silently return. */ |
/* More fragments should come; silently return. */ |
| return; |
return; |
| } |
} |
| /* Reassembly is done, we have the final packet. */ |
/* |
| m = m_final; |
* Reassembly is done, we have the final packet. |
| |
* Updated cached data in local variable(s). |
| /* Updated local variable(s). */ |
*/ |
| ip = mtod(m, struct ip *); |
ip = mtod(m, struct ip *); |
| hlen = ip->ip_hl << 2; |
hlen = ip->ip_hl << 2; |
| } |
} |