Deleted Added
full compact
ip_input.c (108466) ip_input.c (109623)
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 108466 2002-12-30 20:22:40Z sam $
34 * $FreeBSD: head/sys/netinet/ip_input.c 109623 2003-01-21 08:56:16Z alfred $
35 */
36
37#include "opt_bootp.h"
38#include "opt_ipfw.h"
39#include "opt_ipdn.h"
40#include "opt_ipdivert.h"
41#include "opt_ipfilter.h"
42#include "opt_ipstealth.h"

--- 775 unchanged lines hidden (view full) ---

818 /*
819 * Divert or tee packet to the divert protocol if required.
820 */
821 if (divert_info != 0) {
822 struct mbuf *clone = NULL;
823
824 /* Clone packet if we're doing a 'tee' */
825 if ((divert_info & IP_FW_PORT_TEE_FLAG) != 0)
35 */
36
37#include "opt_bootp.h"
38#include "opt_ipfw.h"
39#include "opt_ipdn.h"
40#include "opt_ipdivert.h"
41#include "opt_ipfilter.h"
42#include "opt_ipstealth.h"

--- 775 unchanged lines hidden (view full) ---

818 /*
819 * Divert or tee packet to the divert protocol if required.
820 */
821 if (divert_info != 0) {
822 struct mbuf *clone = NULL;
823
824 /* Clone packet if we're doing a 'tee' */
825 if ((divert_info & IP_FW_PORT_TEE_FLAG) != 0)
826 clone = m_dup(m, M_DONTWAIT);
826 clone = m_dup(m, M_NOWAIT);
827
828 /* Restore packet header fields to original values */
829 ip->ip_len += hlen;
830 ip->ip_len = htons(ip->ip_len);
831 ip->ip_off = htons(ip->ip_off);
832
833 /* Deliver packet to divert input routine */
834 divert_packet(m, 1, divert_info & 0xffff, args.divert_rule);

--- 143 unchanged lines hidden (view full) ---

978 * Enforce upper bound on number of fragmented packets
979 * for which we attempt reassembly;
980 * If maxfrag is 0, never accept fragments.
981 * If maxfrag is -1, accept all fragments without limitation.
982 */
983 if ((ip_maxfragpackets >= 0) && (ip_nfragpackets >= ip_maxfragpackets))
984 goto dropfrag;
985 ip_nfragpackets++;
827
828 /* Restore packet header fields to original values */
829 ip->ip_len += hlen;
830 ip->ip_len = htons(ip->ip_len);
831 ip->ip_off = htons(ip->ip_off);
832
833 /* Deliver packet to divert input routine */
834 divert_packet(m, 1, divert_info & 0xffff, args.divert_rule);

--- 143 unchanged lines hidden (view full) ---

978 * Enforce upper bound on number of fragmented packets
979 * for which we attempt reassembly;
980 * If maxfrag is 0, never accept fragments.
981 * If maxfrag is -1, accept all fragments without limitation.
982 */
983 if ((ip_maxfragpackets >= 0) && (ip_nfragpackets >= ip_maxfragpackets))
984 goto dropfrag;
985 ip_nfragpackets++;
986 if ((t = m_get(M_DONTWAIT, MT_FTABLE)) == NULL)
986 if ((t = m_get(M_NOWAIT, MT_FTABLE)) == NULL)
987 goto dropfrag;
988 fp = mtod(t, struct ipq *);
989#ifdef MAC
990 mac_init_ipq(fp);
991 mac_create_ipq(m, fp);
992#endif
993 TAILQ_INSERT_HEAD(head, fp, ipq_list);
994 nipq++;

--- 587 unchanged lines hidden (view full) ---

1582struct mbuf *
1583ip_srcroute()
1584{
1585 register struct in_addr *p, *q;
1586 register struct mbuf *m;
1587
1588 if (ip_nhops == 0)
1589 return ((struct mbuf *)0);
987 goto dropfrag;
988 fp = mtod(t, struct ipq *);
989#ifdef MAC
990 mac_init_ipq(fp);
991 mac_create_ipq(m, fp);
992#endif
993 TAILQ_INSERT_HEAD(head, fp, ipq_list);
994 nipq++;

--- 587 unchanged lines hidden (view full) ---

1582struct mbuf *
1583ip_srcroute()
1584{
1585 register struct in_addr *p, *q;
1586 register struct mbuf *m;
1587
1588 if (ip_nhops == 0)
1589 return ((struct mbuf *)0);
1590 m = m_get(M_DONTWAIT, MT_HEADER);
1590 m = m_get(M_NOWAIT, MT_HEADER);
1591 if (m == 0)
1592 return ((struct mbuf *)0);
1593
1594#define OPTSIZ (sizeof(ip_srcrt.nop) + sizeof(ip_srcrt.srcopt))
1595
1596 /* length is (nhops+1)*sizeof(addr) + sizeof(nop + srcrt header) */
1597 m->m_len = ip_nhops * sizeof(struct in_addr) + sizeof(struct in_addr) +
1598 OPTSIZ;

--- 158 unchanged lines hidden (view full) ---

1757 * because unnecessary, or because rate limited), so we are
1758 * really we are wasting a lot of work here.
1759 *
1760 * We don't use m_copy() because it might return a reference
1761 * to a shared cluster. Both this function and ip_output()
1762 * assume exclusive access to the IP header in `m', so any
1763 * data in a cluster may change before we reach icmp_error().
1764 */
1591 if (m == 0)
1592 return ((struct mbuf *)0);
1593
1594#define OPTSIZ (sizeof(ip_srcrt.nop) + sizeof(ip_srcrt.srcopt))
1595
1596 /* length is (nhops+1)*sizeof(addr) + sizeof(nop + srcrt header) */
1597 m->m_len = ip_nhops * sizeof(struct in_addr) + sizeof(struct in_addr) +
1598 OPTSIZ;

--- 158 unchanged lines hidden (view full) ---

1757 * because unnecessary, or because rate limited), so we are
1758 * really we are wasting a lot of work here.
1759 *
1760 * We don't use m_copy() because it might return a reference
1761 * to a shared cluster. Both this function and ip_output()
1762 * assume exclusive access to the IP header in `m', so any
1763 * data in a cluster may change before we reach icmp_error().
1764 */
1765 MGET(mcopy, M_DONTWAIT, m->m_type);
1766 if (mcopy != NULL && !m_dup_pkthdr(mcopy, m, M_DONTWAIT)) {
1765 MGET(mcopy, M_NOWAIT, m->m_type);
1766 if (mcopy != NULL && !m_dup_pkthdr(mcopy, m, M_NOWAIT)) {
1767 /*
1768 * It's probably ok if the pkthdr dup fails (because
1769 * the deep copy of the tag chain failed), but for now
1770 * be conservative and just discard the copy since
1771 * code below may some day want the tags.
1772 */
1773 m_free(mcopy);
1774 mcopy = NULL;

--- 388 unchanged lines hidden ---
1767 /*
1768 * It's probably ok if the pkthdr dup fails (because
1769 * the deep copy of the tag chain failed), but for now
1770 * be conservative and just discard the copy since
1771 * code below may some day want the tags.
1772 */
1773 m_free(mcopy);
1774 mcopy = NULL;

--- 388 unchanged lines hidden ---