Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/netinet/ip_input.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/netinet/ip_input.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.114.4.10 retrieving revision 1.115 diff -u -p -r1.114.4.10 -r1.115 --- src/sys/netinet/ip_input.c 2002/11/13 00:34:59 1.114.4.10 +++ src/sys/netinet/ip_input.c 2000/06/28 03:01:16 1.115 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_input.c,v 1.114.4.10 2002/11/13 00:34:59 itojun Exp $ */ +/* $NetBSD: ip_input.c,v 1.115 2000/06/28 03:01:16 mrg Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -120,7 +120,8 @@ #include #include -#include +#include + #include #include @@ -138,8 +139,6 @@ /* just for gif_ttl */ #include #include "gif.h" -#include -#include "gre.h" #ifdef MROUTING #include @@ -209,8 +208,6 @@ u_int16_t ip_id; struct ipqhead ipq; int ipq_locked; -int ip_nfragpackets = 0; -int ip_maxfragpackets = 200; static __inline int ipq_lock_try __P((void)); static __inline void ipq_unlock __P((void)); @@ -310,7 +307,9 @@ ip_init() TAILQ_INIT(&in_ifaddr); in_ifaddrhashtbl = hashinit(IN_IFADDR_HASH_SIZE, M_IFADDR, M_WAITOK, &in_ifaddrhash); - ip_mtudisc_timeout_q = rt_timer_queue_create(ip_mtudisc_timeout); + if (ip_mtudisc != 0) + ip_mtudisc_timeout_q = + rt_timer_queue_create(ip_mtudisc_timeout); #ifdef GATEWAY ipflow_init(); #endif @@ -461,14 +460,6 @@ ip_input(struct mbuf *m) #endif #ifdef PFIL_HOOKS -#ifdef IPSEC - /* - * let ipfilter look at packet on the wire, - * not the decapsulated packet. - */ - if (ipsec_gethist(m, NULL)) - goto nofilt; -#endif /* * Run through list of hooks for input packets. If there are any * filters which require that additional packets in the flow are @@ -489,9 +480,6 @@ ip_input(struct mbuf *m) return; ip = mtod(m, struct ip *); } -#ifdef IPSEC -nofilt:; -#endif #endif /* PFIL_HOOKS */ /* @@ -622,13 +610,6 @@ nofilt:; ipstat.ips_cantforward++; return; } -#ifdef IPSEC - if (ipsec4_in_reject(m, NULL)) { - ipsecstat.in_polvio++; - goto bad; - } -#endif - ip_forward(m, 0); } return; @@ -707,19 +688,6 @@ found: IPQ_UNLOCK(); } -#ifdef IPSEC - /* - * enforce IPsec policy checking if we are seeing last header. - * note that we do not visit this with protocols with pcb layer - * code - like udp/tcp/raw ip. - */ - if ((inetsw[ip_protox[ip->ip_p]].pr_flags & PR_LASTHDR) != 0 && - ipsec4_in_reject(m, NULL)) { - ipsecstat.in_polvio++; - goto bad; - } -#endif - /* * Switch out to protocol's input routine. */ @@ -768,17 +736,6 @@ ip_reass(ipqe, fp) * If first fragment to arrive, create a reassembly queue. */ if (fp == 0) { - /* - * Enforce upper bound on number of fragmented packets - * for which we attempt reassembly; - * If maxfrag is 0, never accept fragments. - * If maxfrag is -1, accept all fragments without limitation. - */ - if (ip_maxfragpackets < 0) - ; - else if (ip_nfragpackets >= ip_maxfragpackets) - goto dropfrag; - ip_nfragpackets++; MALLOC(fp, struct ipq *, sizeof (struct ipq), M_FTABLE, M_NOWAIT); if (fp == NULL) @@ -894,7 +851,6 @@ insert: ip->ip_dst = fp->ipq_dst; LIST_REMOVE(fp, ipq_q); FREE(fp, M_FTABLE); - ip_nfragpackets--; m->m_len += (ip->ip_hl << 2); m->m_data -= (ip->ip_hl << 2); /* some debugging cruft by sklower, below, will go away soon */ @@ -933,7 +889,6 @@ ip_freef(fp) } LIST_REMOVE(fp, ipq_q); FREE(fp, M_FTABLE); - ip_nfragpackets--; } /* @@ -955,17 +910,6 @@ ip_slowtimo() ip_freef(fp); } } - /* - * If we are over the maximum number of fragments - * (due to the limit being lowered), drain off - * enough to get down to the new limit. - */ - if (ip_maxfragpackets < 0) - ; - else { - while (ip_nfragpackets > ip_maxfragpackets && ipq.lh_first) - ip_freef(ipq.lh_first); - } IPQ_UNLOCK(); #ifdef GATEWAY ipflow_slowtimo(); @@ -1455,11 +1399,8 @@ ip_forward(m, srcrt) /* * Save at most 68 bytes of the packet in case * we need to generate an ICMP message to the src. - * Pullup to avoid sharing mbuf cluster between m and mcopy. */ - mcopy = m_copym(m, 0, imin((int)ip->ip_len, 68), M_DONTWAIT); - if (mcopy) - mcopy = m_pullup(mcopy, ip->ip_hl << 2); + mcopy = m_copy(m, 0, imin((int)ip->ip_len, 68)); /* * If forwarding packet using same interface that it came in on, @@ -1496,7 +1437,7 @@ ip_forward(m, srcrt) #ifdef IPSEC /* Don't lookup socket in forwading case */ - (void)ipsec_setsocket(m, NULL); + ipsec_setsocket(m, NULL); #endif error = ip_output(m, (struct mbuf *)0, &ipforward_rt, (IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)), 0); @@ -1714,14 +1655,18 @@ ip_sysctl(name, namelen, oldp, oldlenp, case IPCTL_MTUDISC: error = sysctl_int(oldp, oldlenp, newp, newlen, &ip_mtudisc); - if (error == 0 && ip_mtudisc == 0) - rt_timer_queue_remove_all(ip_mtudisc_timeout_q, TRUE); + if (ip_mtudisc != 0 && ip_mtudisc_timeout_q == NULL) { + ip_mtudisc_timeout_q = + rt_timer_queue_create(ip_mtudisc_timeout); + } else if (ip_mtudisc == 0 && ip_mtudisc_timeout_q != NULL) { + rt_timer_queue_destroy(ip_mtudisc_timeout_q, TRUE); + ip_mtudisc_timeout_q = NULL; + } return error; case IPCTL_ANONPORTMIN: old = anonportmin; error = sysctl_int(oldp, oldlenp, newp, newlen, &anonportmin); - if (anonportmin >= anonportmax || anonportmin < 0 - || anonportmin > 65535 + if (anonportmin >= anonportmax || anonportmin > 65535 #ifndef IPNOPRIVPORTS || anonportmin < IPPORT_RESERVED #endif @@ -1733,8 +1678,7 @@ ip_sysctl(name, namelen, oldp, oldlenp, case IPCTL_ANONPORTMAX: old = anonportmax; error = sysctl_int(oldp, oldlenp, newp, newlen, &anonportmax); - if (anonportmin >= anonportmax || anonportmax < 0 - || anonportmax > 65535 + if (anonportmin >= anonportmax || anonportmax > 65535 #ifndef IPNOPRIVPORTS || anonportmax < IPPORT_RESERVED #endif @@ -1746,8 +1690,8 @@ ip_sysctl(name, namelen, oldp, oldlenp, case IPCTL_MTUDISCTIMEOUT: error = sysctl_int(oldp, oldlenp, newp, newlen, &ip_mtudisc_timeout); - if (error == 0) - rt_timer_queue_change(ip_mtudisc_timeout_q, + if (ip_mtudisc_timeout_q != NULL) + rt_timer_queue_change(ip_mtudisc_timeout_q, ip_mtudisc_timeout); return (error); #ifdef GATEWAY @@ -1772,41 +1716,6 @@ ip_sysctl(name, namelen, oldp, oldlenp, &ip_gif_ttl)); #endif -#if NGRE > 0 - case IPCTL_GRE_TTL: - return(sysctl_int(oldp, oldlenp, newp, newlen, - &ip_gre_ttl)); -#endif - -#ifndef IPNOPRIVPORTS - case IPCTL_LOWPORTMIN: - old = lowportmin; - error = sysctl_int(oldp, oldlenp, newp, newlen, &lowportmin); - if (lowportmin >= lowportmax - || lowportmin > IPPORT_RESERVEDMAX - || lowportmin < IPPORT_RESERVEDMIN - ) { - lowportmin = old; - return (EINVAL); - } - return (error); - case IPCTL_LOWPORTMAX: - old = lowportmax; - error = sysctl_int(oldp, oldlenp, newp, newlen, &lowportmax); - if (lowportmin >= lowportmax - || lowportmax > IPPORT_RESERVEDMAX - || lowportmax < IPPORT_RESERVEDMIN - ) { - lowportmax = old; - return (EINVAL); - } - return (error); -#endif - - case IPCTL_MAXFRAGPACKETS: - return (sysctl_int(oldp, oldlenp, newp, newlen, - &ip_maxfragpackets)); - default: return (EOPNOTSUPP); }