summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2018-10-10 11:47:00 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2018-10-10 11:47:00 +0000
commit6680be4f191226402a6424962e47cf802fe7826d (patch)
tree4f1f5665613ea3d37deed20b430dcd69cf4bb1f7
parent6a3005e690de49bee6e3e3f6f15abfaa9c49e553 (diff)
RT_TABLEID_MAX is 255, fix places that assumed that it is less than 255.
rtable 255 is a valid routing table or domain id that wasn't handled by the ip[6]_mroute code or by snmpd. The arrays in the ip[6]_mroute code where off by one and didn't allocate space for rtable 255; snmpd simply ignored rtable 255. All other places in the tree seem to handle RT_TABLEID_MAX correctly. OK florian@ benno@ henning@ deraadt@
-rw-r--r--sys/netinet/ip_mroute.c10
-rw-r--r--sys/netinet6/ip6_mroute.c6
-rw-r--r--sys/netinet6/ip6_var.h4
-rw-r--r--usr.sbin/snmpd/kroute.c4
4 files changed, 12 insertions, 12 deletions
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index 78ac4c52bc2..3efae2186e7 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_mroute.c,v 1.122 2018/04/30 19:07:44 tb Exp $ */
+/* $OpenBSD: ip_mroute.c,v 1.123 2018/10/10 11:46:59 reyk Exp $ */
/* $NetBSD: ip_mroute.c,v 1.85 2004/04/26 01:31:57 matt Exp $ */
/*
@@ -95,9 +95,9 @@ int mcast_debug = 1;
* Globals. All but ip_mrouter and ip_mrtproto could be static,
* except for netstat or debugging purposes.
*/
-struct socket *ip_mrouter[RT_TABLEID_MAX];
-struct rttimer_queue *mrouterq[RT_TABLEID_MAX];
-uint64_t mrt_count[RT_TABLEID_MAX];
+struct socket *ip_mrouter[RT_TABLEID_MAX + 1];
+struct rttimer_queue *mrouterq[RT_TABLEID_MAX + 1];
+uint64_t mrt_count[RT_TABLEID_MAX + 1];
int ip_mrtproto = IGMP_DVMRP; /* for netstat only */
struct mrtstat mrtstat;
@@ -473,7 +473,7 @@ mrt_sysctl_mfc(void *oldp, size_t *oldlenp)
msa.msa_len = *oldlenp;
msa.msa_needed = 0;
- for (rtableid = 0; rtableid < RT_TABLEID_MAX; rtableid++)
+ for (rtableid = 0; rtableid <= RT_TABLEID_MAX; rtableid++)
rtable_walk(rtableid, AF_INET, mrt_rtwalk_mfcsysctl, &msa);
if (msa.msa_minfos != NULL && msa.msa_needed > 0 &&
diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c
index 35459945aa7..089cddb4502 100644
--- a/sys/netinet6/ip6_mroute.c
+++ b/sys/netinet6/ip6_mroute.c
@@ -128,8 +128,8 @@ void phyint_send6(struct ifnet *, struct ip6_hdr *, struct mbuf *);
* Globals. All but ip6_mrouter, ip6_mrtproto and mrt6stat could be static,
* except for netstat or debugging purposes.
*/
-struct socket *ip6_mrouter[RT_TABLEID_MAX];
-struct rttimer_queue *mrouter6q[RT_TABLEID_MAX];
+struct socket *ip6_mrouter[RT_TABLEID_MAX + 1];
+struct rttimer_queue *mrouter6q[RT_TABLEID_MAX + 1];
int ip6_mrouter_ver = 0;
int ip6_mrtproto; /* for netstat only */
struct mrt6stat mrt6stat;
@@ -451,7 +451,7 @@ mrt6_sysctl_mfc(void *oldp, size_t *oldlenp)
msa.ms6a_len = *oldlenp;
msa.ms6a_needed = 0;
- for (rtableid = 0; rtableid < RT_TABLEID_MAX; rtableid++)
+ for (rtableid = 0; rtableid <= RT_TABLEID_MAX; rtableid++)
rtable_walk(rtableid, AF_INET6, mrt6_rtwalk_mf6csysctl, &msa);
if (msa.ms6a_minfos != NULL && msa.ms6a_needed > 0 &&
diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h
index c6fcbef957a..30e45f4bd83 100644
--- a/sys/netinet6/ip6_var.h
+++ b/sys/netinet6/ip6_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_var.h,v 1.83 2018/02/10 05:52:08 florian Exp $ */
+/* $OpenBSD: ip6_var.h,v 1.84 2018/10/10 11:46:59 reyk Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
@@ -279,7 +279,7 @@ extern int ip6_mcast_pmtu; /* path MTU discovery for multicast */
extern int ip6_neighborgcthresh; /* Threshold # of NDP entries for GC */
extern int ip6_maxdynroutes; /* Max # of routes created via redirect */
-extern struct socket *ip6_mrouter[RT_TABLEID_MAX]; /* multicast routing daemon */
+extern struct socket *ip6_mrouter[RT_TABLEID_MAX + 1]; /* multicast routing daemon */
extern int ip6_sendredirects; /* send IP redirects when forwarding? */
extern int ip6_maxfragpackets; /* Maximum packets in reassembly queue */
extern int ip6_maxfrags; /* Maximum fragments in reassembly queue */
diff --git a/usr.sbin/snmpd/kroute.c b/usr.sbin/snmpd/kroute.c
index e24c3f7e9a9..3604f884dea 100644
--- a/usr.sbin/snmpd/kroute.c
+++ b/usr.sbin/snmpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.35 2017/07/24 11:00:01 friehm Exp $ */
+/* $OpenBSD: kroute.c,v 1.36 2018/10/10 11:46:59 reyk Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -211,7 +211,7 @@ ktable_init(void)
{
u_int i;
- for (i = 0; i < RT_TABLEID_MAX; i++)
+ for (i = 0; i <= RT_TABLEID_MAX; i++)
if (ktable_exists(i, NULL))
ktable_update(i);
}