ip_input.c (57401) | ip_input.c (58698) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)ip_input.c 8.2 (Berkeley) 1/4/94 | 1/* 2 * Copyright (c) 1982, 1986, 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)ip_input.c 8.2 (Berkeley) 1/4/94 |
34 * $FreeBSD: head/sys/netinet/ip_input.c 57401 2000-02-23 20:11:57Z guido $ | 34 * $FreeBSD: head/sys/netinet/ip_input.c 58698 2000-03-27 19:14:27Z jlemon $ |
35 */ 36 37#define _IP_VHL 38 39#include "opt_bootp.h" 40#include "opt_ipfw.h" 41#include "opt_ipdn.h" 42#include "opt_ipdivert.h" --- 276 unchanged lines hidden (view full) --- 319 } 320 if (hlen > m->m_len) { 321 if ((m = m_pullup(m, hlen)) == 0) { 322 ipstat.ips_badhlen++; 323 return; 324 } 325 ip = mtod(m, struct ip *); 326 } | 35 */ 36 37#define _IP_VHL 38 39#include "opt_bootp.h" 40#include "opt_ipfw.h" 41#include "opt_ipdn.h" 42#include "opt_ipdivert.h" --- 276 unchanged lines hidden (view full) --- 319 } 320 if (hlen > m->m_len) { 321 if ((m = m_pullup(m, hlen)) == 0) { 322 ipstat.ips_badhlen++; 323 return; 324 } 325 ip = mtod(m, struct ip *); 326 } |
327 if (hlen == sizeof(struct ip)) { 328 sum = in_cksum_hdr(ip); | 327 if (m->m_pkthdr.csum_flags & CSUM_IP_CHECKED) { 328 sum = !(m->m_pkthdr.csum_flags & CSUM_IP_VALID); |
329 } else { | 329 } else { |
330 sum = in_cksum(m, hlen); | 330 if (hlen == sizeof(struct ip)) { 331 sum = in_cksum_hdr(ip); 332 } else { 333 sum = in_cksum(m, hlen); 334 } |
331 } 332 if (sum) { 333 ipstat.ips_badsum++; 334 goto bad; 335 } 336 337 /* 338 * Convert fields to host representation. --- 497 unchanged lines hidden (view full) --- 836 if (GETIP(q)->ip_off > ip->ip_off) 837 break; 838 839 /* 840 * If there is a preceding segment, it may provide some of 841 * our data already. If so, drop the data from the incoming 842 * segment. If it provides all of our data, drop us, otherwise 843 * stick new segment in the proper place. | 335 } 336 if (sum) { 337 ipstat.ips_badsum++; 338 goto bad; 339 } 340 341 /* 342 * Convert fields to host representation. --- 497 unchanged lines hidden (view full) --- 840 if (GETIP(q)->ip_off > ip->ip_off) 841 break; 842 843 /* 844 * If there is a preceding segment, it may provide some of 845 * our data already. If so, drop the data from the incoming 846 * segment. If it provides all of our data, drop us, otherwise 847 * stick new segment in the proper place. |
848 * 849 * If some of the data is dropped from the the preceding 850 * segment, then it's checksum is invalidated. |
|
844 */ 845 if (p) { 846 i = GETIP(p)->ip_off + GETIP(p)->ip_len - ip->ip_off; 847 if (i > 0) { 848 if (i >= ip->ip_len) 849 goto dropfrag; 850 m_adj(m, i); | 851 */ 852 if (p) { 853 i = GETIP(p)->ip_off + GETIP(p)->ip_len - ip->ip_off; 854 if (i > 0) { 855 if (i >= ip->ip_len) 856 goto dropfrag; 857 m_adj(m, i); |
858 m->m_pkthdr.csum_flags = 0; |
|
851 ip->ip_off += i; 852 ip->ip_len -= i; 853 } 854 m->m_nextpkt = p->m_nextpkt; 855 p->m_nextpkt = m; 856 } else { 857 m->m_nextpkt = fp->ipq_frags; 858 fp->ipq_frags = m; --- 6 unchanged lines hidden (view full) --- 865 for (; q != NULL && ip->ip_off + ip->ip_len > GETIP(q)->ip_off; 866 q = nq) { 867 i = (ip->ip_off + ip->ip_len) - 868 GETIP(q)->ip_off; 869 if (i < GETIP(q)->ip_len) { 870 GETIP(q)->ip_len -= i; 871 GETIP(q)->ip_off += i; 872 m_adj(q, i); | 859 ip->ip_off += i; 860 ip->ip_len -= i; 861 } 862 m->m_nextpkt = p->m_nextpkt; 863 p->m_nextpkt = m; 864 } else { 865 m->m_nextpkt = fp->ipq_frags; 866 fp->ipq_frags = m; --- 6 unchanged lines hidden (view full) --- 873 for (; q != NULL && ip->ip_off + ip->ip_len > GETIP(q)->ip_off; 874 q = nq) { 875 i = (ip->ip_off + ip->ip_len) - 876 GETIP(q)->ip_off; 877 if (i < GETIP(q)->ip_len) { 878 GETIP(q)->ip_len -= i; 879 GETIP(q)->ip_off += i; 880 m_adj(q, i); |
881 q->m_pkthdr.csum_flags = 0; |
|
873 break; 874 } 875 nq = q->m_nextpkt; 876 m->m_nextpkt = nq; 877 m_freem(q); 878 } 879 880inserted: --- 41 unchanged lines hidden (view full) --- 922 m->m_next = 0; 923 m_cat(m, t); 924 nq = q->m_nextpkt; 925 q->m_nextpkt = 0; 926 for (q = nq; q != NULL; q = nq) { 927 nq = q->m_nextpkt; 928 q->m_nextpkt = NULL; 929 m_cat(m, q); | 882 break; 883 } 884 nq = q->m_nextpkt; 885 m->m_nextpkt = nq; 886 m_freem(q); 887 } 888 889inserted: --- 41 unchanged lines hidden (view full) --- 931 m->m_next = 0; 932 m_cat(m, t); 933 nq = q->m_nextpkt; 934 q->m_nextpkt = 0; 935 for (q = nq; q != NULL; q = nq) { 936 nq = q->m_nextpkt; 937 q->m_nextpkt = NULL; 938 m_cat(m, q); |
939 m->m_pkthdr.csum_flags &= q->m_pkthdr.csum_flags; 940 m->m_pkthdr.csum_data += q->m_pkthdr.csum_data; |
|
930 } 931 932#ifdef IPDIVERT 933 /* 934 * Extract firewall instructions from the fragment structure. 935 */ 936 *divinfo = fp->ipq_div_info; 937 *divcookie = fp->ipq_div_cookie; --- 818 unchanged lines hidden --- | 941 } 942 943#ifdef IPDIVERT 944 /* 945 * Extract firewall instructions from the fragment structure. 946 */ 947 *divinfo = fp->ipq_div_info; 948 *divcookie = fp->ipq_div_cookie; --- 818 unchanged lines hidden --- |