version 1.63, 1998/04/29 21:37:55 |
version 1.71, 1998/09/30 21:52:25 |
|
|
/* $NetBSD$ */ |
/* $NetBSD$ */ |
|
|
/*- |
|
* Copyright (c) 1998 The NetBSD Foundation, Inc. |
|
* All rights reserved. |
|
* |
|
* This code is derived from software contributed to The NetBSD Foundation |
|
* by Public Access Networks Corporation ("Panix"). It was developed under |
|
* contract to Panix by Eric Haszlakiewicz and Thor Lancelot Simon. |
|
* |
|
* Redistribution and use in source and binary forms, with or without |
|
* modification, are permitted provided that the following conditions |
|
* are met: |
|
* 1. Redistributions of source code must retain the above copyright |
|
* notice, this list of conditions and the following disclaimer. |
|
* 2. Redistributions in binary form must reproduce the above copyright |
|
* notice, this list of conditions and the following disclaimer in the |
|
* documentation and/or other materials provided with the distribution. |
|
* 3. All advertising materials mentioning features or use of this software |
|
* must display the following acknowledgement: |
|
* This product includes software developed by the NetBSD |
|
* Foundation, Inc. and its contributors. |
|
* 4. Neither the name of The NetBSD Foundation nor the names of its |
|
* contributors may be used to endorse or promote products derived |
|
* from this software without specific prior written permission. |
|
* |
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
* POSSIBILITY OF SUCH DAMAGE. |
|
*/ |
|
|
|
/* |
/* |
* Copyright (c) 1982, 1986, 1988, 1993 |
* Copyright (c) 1982, 1986, 1988, 1993 |
* The Regents of the University of California. All rights reserved. |
* The Regents of the University of California. All rights reserved. |
|
|
* @(#)ip_input.c 8.2 (Berkeley) 1/4/94 |
* @(#)ip_input.c 8.2 (Berkeley) 1/4/94 |
*/ |
*/ |
|
|
|
/*- |
|
* Copyright (c) 1998 The NetBSD Foundation, Inc. |
|
* All rights reserved. |
|
* |
|
* This code is derived from software contributed to The NetBSD Foundation |
|
* by Public Access Networks Corporation ("Panix"). It was developed under |
|
* contract to Panix by Eric Haszlakiewicz and Thor Lancelot Simon. |
|
* |
|
* Redistribution and use in source and binary forms, with or without |
|
* modification, are permitted provided that the following conditions |
|
* are met: |
|
* 1. Redistributions of source code must retain the above copyright |
|
* notice, this list of conditions and the following disclaimer. |
|
* 2. Redistributions in binary form must reproduce the above copyright |
|
* notice, this list of conditions and the following disclaimer in the |
|
* documentation and/or other materials provided with the distribution. |
|
* 3. All advertising materials mentioning features or use of this software |
|
* must display the following acknowledgement: |
|
* This product includes software developed by the NetBSD |
|
* Foundation, Inc. and its contributors. |
|
* 4. Neither the name of The NetBSD Foundation nor the names of its |
|
* contributors may be used to endorse or promote products derived |
|
* from this software without specific prior written permission. |
|
* |
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
* POSSIBILITY OF SUCH DAMAGE. |
|
*/ |
|
|
#include "opt_gateway.h" |
#include "opt_gateway.h" |
|
#include "opt_pfil_hooks.h" |
#include "opt_mrouting.h" |
#include "opt_mrouting.h" |
|
|
#include <sys/param.h> |
#include <sys/param.h> |
|
|
m_adj(m, len - m->m_pkthdr.len); |
m_adj(m, len - m->m_pkthdr.len); |
} |
} |
|
|
|
/* |
|
* Assume that we can create a fast-forward IP flow entry |
|
* based on this packet. |
|
*/ |
|
m->m_flags |= M_CANFASTFWD; |
|
|
#ifdef PFIL_HOOKS |
#ifdef PFIL_HOOKS |
/* |
/* |
* Run through list of hooks for input packets. |
* Run through list of hooks for input packets. If there are any |
|
* filters which require that additional packets in the flow are |
|
* not fast-forwarded, they must clear the M_CANFASTFWD flag. |
|
* Note that filters must _never_ set this flag, as another filter |
|
* in the list may have previously cleared it. |
*/ |
*/ |
m0 = m; |
m0 = m; |
for (pfh = pfil_hook_get(PFIL_IN); pfh; pfh = pfh->pfil_link.tqe_next) |
for (pfh = pfil_hook_get(PFIL_IN); pfh; pfh = pfh->pfil_link.tqe_next) |
|
|
rv = pfh->pfil_func(ip, hlen, m->m_pkthdr.rcvif, 0, &m0); |
rv = pfh->pfil_func(ip, hlen, m->m_pkthdr.rcvif, 0, &m0); |
if (rv) |
if (rv) |
goto next; |
goto next; |
ip = mtod(m = m0, struct ip *); |
m = m0; |
|
if (m == NULL) |
|
goto next; |
|
ip = mtod(m, struct ip *); |
} |
} |
#endif /* PFIL_HOOKS */ |
#endif /* PFIL_HOOKS */ |
|
|
|
|
break; |
break; |
|
|
case IPOPT_TS_TSANDADDR: |
case IPOPT_TS_TSANDADDR: |
if (ipt->ipt_ptr + sizeof(n_time) + |
if (ipt->ipt_ptr - 1 + sizeof(n_time) + |
sizeof(struct in_addr) > ipt->ipt_len) |
sizeof(struct in_addr) > ipt->ipt_len) |
goto bad; |
goto bad; |
ipaddr.sin_addr = dst; |
ipaddr.sin_addr = dst; |
|
|
break; |
break; |
|
|
case IPOPT_TS_PRESPEC: |
case IPOPT_TS_PRESPEC: |
if (ipt->ipt_ptr + sizeof(n_time) + |
if (ipt->ipt_ptr - 1 + sizeof(n_time) + |
sizeof(struct in_addr) > ipt->ipt_len) |
sizeof(struct in_addr) > ipt->ipt_len) |
goto bad; |
goto bad; |
bcopy((caddr_t)sin, (caddr_t)&ipaddr.sin_addr, |
bcopy((caddr_t)sin, (caddr_t)&ipaddr.sin_addr, |
Line 1117 ip_forward(m, srcrt) |
|
Line 1131 ip_forward(m, srcrt) |
|
dest = 0; |
dest = 0; |
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
if (ipprintfs) |
if (ipprintfs) |
printf("forward: src %x dst %x ttl %x\n", |
printf("forward: src %2.2x dst %2.2x ttl %x\n", |
ip->ip_src.s_addr, ip->ip_dst.s_addr, ip->ip_ttl); |
ntohl(ip->ip_src.s_addr), |
|
ntohl(ip->ip_dst.s_addr), ip->ip_ttl); |
#endif |
#endif |
if (m->m_flags & M_BCAST || in_canforward(ip->ip_dst) == 0) { |
if (m->m_flags & M_BCAST || in_canforward(ip->ip_dst) == 0) { |
ipstat.ips_cantforward++; |
ipstat.ips_cantforward++; |
Line 1197 ip_forward(m, srcrt) |
|
Line 1212 ip_forward(m, srcrt) |
|
else { |
else { |
if (mcopy) { |
if (mcopy) { |
#ifdef GATEWAY |
#ifdef GATEWAY |
ipflow_create(&ipforward_rt, mcopy); |
if (mcopy->m_flags & M_CANFASTFWD) |
|
ipflow_create(&ipforward_rt, mcopy); |
#endif |
#endif |
m_freem(mcopy); |
m_freem(mcopy); |
} |
} |
Line 1387 ip_sysctl(name, namelen, oldp, oldlenp, |
|
Line 1403 ip_sysctl(name, namelen, oldp, oldlenp, |
|
rt_timer_queue_change(ip_mtudisc_timeout_q, |
rt_timer_queue_change(ip_mtudisc_timeout_q, |
ip_mtudisc_timeout); |
ip_mtudisc_timeout); |
return (error); |
return (error); |
|
#ifdef GATEWAY |
|
case IPCTL_MAXFLOWS: |
|
{ |
|
int s; |
|
|
|
error = sysctl_int(oldp, oldlenp, newp, newlen, |
|
&ip_maxflows); |
|
s = splsoftnet(); |
|
ipflow_reap(0); |
|
splx(s); |
|
return (error); |
|
} |
|
#endif |
default: |
default: |
return (EOPNOTSUPP); |
return (EOPNOTSUPP); |
} |
} |