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.169.2.8 retrieving revision 1.212 diff -u -p -r1.169.2.8 -r1.212 --- src/sys/netinet/ip_input.c 2005/11/10 14:11:07 1.169.2.8 +++ src/sys/netinet/ip_input.c 2005/02/26 22:45:12 1.212 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_input.c,v 1.169.2.8 2005/11/10 14:11:07 skrll Exp $ */ +/* $NetBSD: ip_input.c,v 1.212 2005/02/26 22:45:12 perry Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -98,7 +98,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.169.2.8 2005/11/10 14:11:07 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.212 2005/02/26 22:45:12 perry Exp $"); #include "opt_inet.h" #include "opt_gateway.h" @@ -131,7 +131,6 @@ __KERNEL_RCSID(0, "$NetBSD: ip_input.c,v #include #include #include -#include #include #include #include @@ -201,6 +200,7 @@ int ipprintfs = 0; #endif int ip_do_randomid = 0; +int ip_do_loopback_cksum = 0; /* * XXX - Setting ip_checkinterface mostly implements the receive side of @@ -1226,7 +1226,6 @@ insert: for (t = m; t; t = t->m_next) plen += t->m_len; m->m_pkthdr.len = plen; - m->m_pkthdr.csum_flags = 0; } return (m); @@ -1823,9 +1822,13 @@ ip_forward(struct mbuf *m, int srcrt) struct ip *ip = mtod(m, struct ip *); struct sockaddr_in *sin; struct rtentry *rt; - int error, type = 0, code = 0, destmtu = 0; + int error, type = 0, code = 0; struct mbuf *mcopy; n_long dest; + struct ifnet *destifp; +#if defined(IPSEC) || defined(FAST_IPSEC) + struct ifnet dummyifp; +#endif /* * We are now in the output path. @@ -1853,6 +1856,7 @@ ip_forward(struct mbuf *m, int srcrt) icmp_error(m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, dest, 0); return; } + ip->ip_ttl -= IPTTLDEC; sin = satosin(&ipforward_rt.ro_dst); if ((rt = ipforward_rt.ro_rt) == 0 || @@ -1867,7 +1871,7 @@ ip_forward(struct mbuf *m, int srcrt) rtalloc(&ipforward_rt); if (ipforward_rt.ro_rt == 0) { - icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, dest, 0); + icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, dest, 0); return; } rt = ipforward_rt.ro_rt; @@ -1882,8 +1886,6 @@ ip_forward(struct mbuf *m, int srcrt) if (mcopy) mcopy = m_pullup(mcopy, ip->ip_hl << 2); - ip->ip_ttl -= IPTTLDEC; - /* * If forwarding packet using same interface that it came in on, * perhaps should send a redirect to sender to shortcut a hop. @@ -1940,6 +1942,7 @@ ip_forward(struct mbuf *m, int srcrt) } if (mcopy == NULL) return; + destifp = NULL; switch (error) { @@ -1961,7 +1964,7 @@ ip_forward(struct mbuf *m, int srcrt) code = ICMP_UNREACH_NEEDFRAG; #if !defined(IPSEC) && !defined(FAST_IPSEC) if (ipforward_rt.ro_rt) - destmtu = ipforward_rt.ro_rt->rt_ifp->if_mtu; + destifp = ipforward_rt.ro_rt->rt_ifp; #else /* * If the packet is routed over IPsec tunnel, tell the @@ -1980,7 +1983,7 @@ ip_forward(struct mbuf *m, int srcrt) &ipsecerror); if (sp == NULL) - destmtu = ipforward_rt.ro_rt->rt_ifp->if_mtu; + destifp = ipforward_rt.ro_rt->rt_ifp; else { /* count IPsec header size */ ipsechdr = ipsec4_hdrsiz(mcopy, @@ -1989,18 +1992,24 @@ ip_forward(struct mbuf *m, int srcrt) /* * find the correct route for outer IPv4 * header, compute tunnel MTU. + * + * XXX BUG ALERT + * The "dummyifp" code relies upon the fact + * that icmp_error() touches only ifp->if_mtu. */ - + /*XXX*/ + destifp = NULL; if (sp->req != NULL && sp->req->sav != NULL && sp->req->sav->sah != NULL) { ro = &sp->req->sav->sah->sa_route; if (ro->ro_rt && ro->ro_rt->rt_ifp) { - destmtu = + dummyifp.if_mtu = ro->ro_rt->rt_rmx.rmx_mtu ? ro->ro_rt->rt_rmx.rmx_mtu : ro->ro_rt->rt_ifp->if_mtu; - destmtu -= ipsechdr; + dummyifp.if_mtu -= ipsechdr; + destifp = &dummyifp; } } @@ -2032,7 +2041,7 @@ ip_forward(struct mbuf *m, int srcrt) break; #endif } - icmp_error(mcopy, type, code, dest, destmtu); + icmp_error(mcopy, type, code, dest, destifp); } void @@ -2332,11 +2341,4 @@ SYSCTL_SETUP(sysctl_net_inet_ip_setup, " NULL, 0, &ip_do_loopback_cksum, 0, CTL_NET, PF_INET, IPPROTO_IP, IPCTL_LOOPBACKCKSUM, CTL_EOL); - sysctl_createv(clog, 0, NULL, NULL, - CTLFLAG_PERMANENT, - CTLTYPE_STRUCT, "stats", - SYSCTL_DESCR("IP statistics"), - NULL, 0, &ipstat, sizeof(ipstat), - CTL_NET, PF_INET, IPPROTO_IP, IPCTL_STATS, - CTL_EOL); }