diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-12-09 09:27:41 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-12-09 09:27:41 +0000 |
commit | 99222c4300c0dca733dbe8fe01ca17dfc14dd566 (patch) | |
tree | eeef0f072f69b25776769b616b973391417b9589 /sys | |
parent | f7bb146b9bb2a9097bf395978d1e8bae2e2967a5 (diff) |
Always pass a valid interface pointer to rtdeletemsg().
This will allows for stricter checks inside rtdeletemsg() and it should be
up to the caller to decide if the route needs to be deleted or not.
ok vgross@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/ip_icmp.c | 36 | ||||
-rw-r--r-- | sys/netinet6/icmp6.c | 34 |
2 files changed, 43 insertions, 27 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index f0b2d14f08d..378dfb03836 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_icmp.c,v 1.150 2015/12/03 21:11:53 sashan Exp $ */ +/* $OpenBSD: ip_icmp.c,v 1.151 2015/12/09 09:27:40 mpi Exp $ */ /* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */ /* @@ -1042,19 +1042,21 @@ icmp_mtudisc(struct icmp *icp, u_int rtableid) void icmp_mtudisc_timeout(struct rtentry *rt, struct rttimer *r) { - if (rt == NULL) - panic("icmp_mtudisc_timeout: bad route to timeout"); + struct ifnet *ifp; + int s; - if ((rt->rt_flags & (RTF_DYNAMIC | RTF_HOST)) == - (RTF_DYNAMIC | RTF_HOST)) { + ifp = if_get(rt->rt_ifidx); + if (ifp == NULL) + return; + + if ((rt->rt_flags & (RTF_DYNAMIC|RTF_HOST)) == (RTF_DYNAMIC|RTF_HOST)) { void *(*ctlfunc)(int, struct sockaddr *, u_int, void *); struct sockaddr_in sin; - int s; sin = *satosin(rt_key(rt)); s = splsoftnet(); - rtdeletemsg(rt, NULL, r->rtt_tableid); + rtdeletemsg(rt, ifp, r->rtt_tableid); /* Notify TCP layer of increased Path MTU estimate */ ctlfunc = inetsw[ip_protox[IPPROTO_TCP]].pr_ctlinput; @@ -1062,9 +1064,12 @@ icmp_mtudisc_timeout(struct rtentry *rt, struct rttimer *r) (*ctlfunc)(PRC_MTUINC, sintosa(&sin), r->rtt_tableid, NULL); splx(s); - } else + } else { if ((rt->rt_rmx.rmx_locks & RTV_MTU) == 0) rt->rt_rmx.rmx_mtu = 0; + } + + if_put(ifp); } /* @@ -1088,17 +1093,20 @@ icmp_ratelimit(const struct in_addr *dst, const int type, const int code) void icmp_redirect_timeout(struct rtentry *rt, struct rttimer *r) { - if (rt == NULL) - panic("icmp_redirect_timeout: bad route to timeout"); + struct ifnet *ifp; + int s; - if ((rt->rt_flags & (RTF_DYNAMIC | RTF_HOST)) == - (RTF_DYNAMIC | RTF_HOST)) { - int s; + ifp = if_get(rt->rt_ifidx); + if (ifp == NULL) + return; + if ((rt->rt_flags & (RTF_DYNAMIC|RTF_HOST)) == (RTF_DYNAMIC|RTF_HOST)) { s = splsoftnet(); - rtdeletemsg(rt, NULL, r->rtt_tableid); + rtdeletemsg(rt, ifp, r->rtt_tableid); splx(s); } + + if_put(ifp); } int diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 192837e6900..62604db81b6 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icmp6.c,v 1.182 2015/12/03 21:11:53 sashan Exp $ */ +/* $OpenBSD: icmp6.c,v 1.183 2015/12/09 09:27:40 mpi Exp $ */ /* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ /* @@ -1952,34 +1952,42 @@ icmp6_mtudisc_clone(struct sockaddr *dst, u_int rdomain) void icmp6_mtudisc_timeout(struct rtentry *rt, struct rttimer *r) { - if (rt == NULL) - panic("icmp6_mtudisc_timeout: bad route to timeout"); - if ((rt->rt_flags & (RTF_DYNAMIC | RTF_HOST)) == - (RTF_DYNAMIC | RTF_HOST)) { - int s; + struct ifnet *ifp; + int s; + ifp = if_get(rt->rt_ifidx); + if (ifp == NULL) + return; + + if ((rt->rt_flags & (RTF_DYNAMIC|RTF_HOST)) == (RTF_DYNAMIC|RTF_HOST)) { s = splsoftnet(); - rtdeletemsg(rt, NULL, r->rtt_tableid); + rtdeletemsg(rt, ifp, r->rtt_tableid); splx(s); } else { if (!(rt->rt_rmx.rmx_locks & RTV_MTU)) rt->rt_rmx.rmx_mtu = 0; } + + if_put(ifp); } void icmp6_redirect_timeout(struct rtentry *rt, struct rttimer *r) { - if (rt == NULL) - panic("icmp6_redirect_timeout: bad route to timeout"); - if ((rt->rt_flags & (RTF_GATEWAY | RTF_DYNAMIC | RTF_HOST)) == - (RTF_GATEWAY | RTF_DYNAMIC | RTF_HOST)) { - int s; + struct ifnet *ifp; + int s; + ifp = if_get(rt->rt_ifidx); + if (ifp == NULL) + return; + + if ((rt->rt_flags & (RTF_DYNAMIC|RTF_HOST)) == (RTF_DYNAMIC|RTF_HOST)) { s = splsoftnet(); - rtdeletemsg(rt, NULL, r->rtt_tableid); + rtdeletemsg(rt, ifp, r->rtt_tableid); splx(s); } + + if_put(ifp); } int *icmpv6ctl_vars[ICMPV6CTL_MAXID] = ICMPV6CTL_VARS; |