summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2013-08-08 14:59:23 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2013-08-08 14:59:23 +0000
commitf8031f5cb16bc9135a60e4c4cd6d483747bb31fd (patch)
tree6737aa38c4b3d7426357a467e1d713e81f8128a2 /sys
parent533fb0d29aa4d95c0c8946a66e9f3c70aacd9859 (diff)
Constify the table of common MTUs and use nitems(), no functional change.
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/ip_icmp.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index 68018a65ece..91d8213b45e 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_icmp.c,v 1.103 2013/08/08 14:29:28 mpi Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.104 2013/08/08 14:59:22 mpi Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
@@ -959,19 +959,18 @@ icmp_mtudisc_clone(struct in_addr dst, u_int rtableid)
return (rt);
}
+/* Table of common MTUs: */
+static const u_short mtu_table[] = {
+ 65535, 65280, 32000, 17914, 9180, 8166,
+ 4352, 2002, 1492, 1006, 508, 296, 68, 0
+};
+
void
icmp_mtudisc(struct icmp *icp, u_int rtableid)
{
struct rtentry *rt;
u_long mtu = ntohs(icp->icmp_nextmtu); /* Why a long? IPv6 */
- /* Table of common MTUs: */
-
- static u_short mtu_table[] = {
- 65535, 65280, 32000, 17914, 9180, 8166,
- 4352, 2002, 1492, 1006, 508, 296, 68, 0
- };
-
rt = icmp_mtudisc_clone(icp->icmp_ip.ip_dst, rtableid);
if (rt == 0)
return;
@@ -985,7 +984,6 @@ icmp_mtudisc(struct icmp *icp, u_int rtableid)
mtu -= (icp->icmp_ip.ip_hl << 2);
/* If we still can't guess a value, try the route */
-
if (mtu == 0) {
mtu = rt->rt_rmx.rmx_mtu;
@@ -995,7 +993,7 @@ icmp_mtudisc(struct icmp *icp, u_int rtableid)
mtu = rt->rt_ifp->if_mtu;
}
- for (i = 0; i < sizeof(mtu_table) / sizeof(mtu_table[0]); i++)
+ for (i = 0; i < nitems(mtu_table); i++)
if (mtu > mtu_table[i]) {
mtu = mtu_table[i];
break;