summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorChristopher Pascoe <pascoe@cvs.openbsd.org>2005-07-31 03:30:56 +0000
committerChristopher Pascoe <pascoe@cvs.openbsd.org>2005-07-31 03:30:56 +0000
commit572772cf7ccf3f3860c0121c89ee22e0001d0692 (patch)
tree610ab2d75d296c730135e6ff5a6fc7544b6f5bf0 /sys/netinet
parent2c25fdbabd0951de2d2c84e82326825b902ced70 (diff)
Change the API for icmp_do_error so that it takes the mtu directly, rather
than a pointer to struct ifnet containing it. Saves a 448 byte stack allocation in ip_forward which previously faked up a struct ifnet just for this purpose. idea ok deraadt millert
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/ip_icmp.c14
-rw-r--r--sys/netinet/ip_icmp.h6
-rw-r--r--sys/netinet/ip_input.c26
3 files changed, 17 insertions, 29 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index 757a629021c..f82e5ab5fe7 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_icmp.c,v 1.67 2005/06/30 08:51:31 markus Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.68 2005/07/31 03:30:55 pascoe Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
@@ -128,8 +128,7 @@ icmp_init(void)
}
struct mbuf *
-icmp_do_error(struct mbuf *n, int type, int code, n_long dest,
- struct ifnet *destifp)
+icmp_do_error(struct mbuf *n, int type, int code, n_long dest, int destmtu)
{
struct ip *oip = mtod(n, struct ip *), *nip;
unsigned oiplen = oip->ip_hl << 2;
@@ -223,8 +222,8 @@ icmp_do_error(struct mbuf *n, int type, int code, n_long dest,
icp->icmp_pptr = code;
code = 0;
} else if (type == ICMP_UNREACH &&
- code == ICMP_UNREACH_NEEDFRAG && destifp)
- icp->icmp_nextmtu = htons(destifp->if_mtu);
+ code == ICMP_UNREACH_NEEDFRAG && destmtu)
+ icp->icmp_nextmtu = htons(destmtu);
}
icp->icmp_code = code;
@@ -274,12 +273,11 @@ freeit:
* The ip packet inside has ip_off and ip_len in host byte order.
*/
void
-icmp_error(struct mbuf *n, int type, int code, n_long dest,
- struct ifnet *destifp)
+icmp_error(struct mbuf *n, int type, int code, n_long dest, int destmtu)
{
struct mbuf *m;
- m = icmp_do_error(n, type, code, dest, destifp);
+ m = icmp_do_error(n, type, code, dest, destmtu);
if (m != NULL)
icmp_reflect(m);
}
diff --git a/sys/netinet/ip_icmp.h b/sys/netinet/ip_icmp.h
index 33ac0b288f0..1a79d3a06bd 100644
--- a/sys/netinet/ip_icmp.h
+++ b/sys/netinet/ip_icmp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_icmp.h,v 1.20 2003/06/02 23:28:14 millert Exp $ */
+/* $OpenBSD: ip_icmp.h,v 1.21 2005/07/31 03:30:55 pascoe Exp $ */
/* $NetBSD: ip_icmp.h,v 1.10 1996/02/13 23:42:28 christos Exp $ */
/*
@@ -206,8 +206,8 @@ struct icmp {
#ifdef _KERNEL
struct mbuf *
- icmp_do_error(struct mbuf *, int, int, n_long, struct ifnet *);
-void icmp_error(struct mbuf *, int, int, n_long, struct ifnet *);
+ icmp_do_error(struct mbuf *, int, int, n_long, int);
+void icmp_error(struct mbuf *, int, int, n_long, int);
void icmp_input(struct mbuf *, ...);
void icmp_init(void);
void icmp_reflect(struct mbuf *);
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index cebb993c66a..63eac232f89 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.129 2005/06/15 07:24:05 markus Exp $ */
+/* $OpenBSD: ip_input.c,v 1.130 2005/07/31 03:30:55 pascoe Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -1402,13 +1402,9 @@ ip_forward(m, srcrt)
struct ip *ip = mtod(m, struct ip *);
struct sockaddr_in *sin;
struct rtentry *rt;
- int error, type = 0, code = 0;
+ int error, type = 0, code = 0, destmtu = 0;
struct mbuf *mcopy;
n_long dest;
- struct ifnet *destifp;
-#ifdef IPSEC
- struct ifnet dummyifp;
-#endif
dest = 0;
#ifdef DIAGNOSTIC
@@ -1505,7 +1501,6 @@ ip_forward(m, srcrt)
}
if (mcopy == NULL)
return;
- destifp = NULL;
switch (error) {
@@ -1529,16 +1524,11 @@ ip_forward(m, srcrt)
#ifdef IPSEC
if (ipforward_rt.ro_rt) {
struct rtentry *rt = ipforward_rt.ro_rt;
- destifp = ipforward_rt.ro_rt->rt_ifp;
- /*
- * XXX BUG ALERT
- * The "dummyifp" code relies upon the fact
- * that icmp_error() touches only ifp->if_mtu.
- */
- if (rt->rt_rmx.rmx_mtu) {
- dummyifp.if_mtu = rt->rt_rmx.rmx_mtu;
- destifp = &dummyifp;
- }
+
+ if (rt->rt_rmx.rmx_mtu)
+ destmtu = rt->rt_rmx.rmx_mtu;
+ else
+ destmtu = ipforward_rt.ro_rt->rt_ifp->if_mtu;
}
#endif /*IPSEC*/
ipstat.ips_cantfrag++;
@@ -1562,7 +1552,7 @@ ip_forward(m, srcrt)
#endif
}
- icmp_error(mcopy, type, code, dest, destifp);
+ icmp_error(mcopy, type, code, dest, destmtu);
}
int