diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2016-11-16 12:48:20 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2016-11-16 12:48:20 +0000 |
commit | 1bea9cc716c5561415646a5fffbf7c4ff5293d6c (patch) | |
tree | 96cd28e2523e36c6438f719be817a069aaeeb5bb /sys | |
parent | 255ed497ec5b7184e27867eaa5222ffeb0e32b82 (diff) |
Bring icmp6_mtudisc_clone() in line with icmp_mtudisc_clone(). The
IPv4 dynamic route inherits the priority. Only clone from a valid
IPv6 route. Do not use splsoftnet() in IPv6. Some stylistic changes
to make the functions similar.
OK mpi@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/ip_icmp.c | 5 | ||||
-rw-r--r-- | sys/netinet6/icmp6.c | 29 |
2 files changed, 18 insertions, 16 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index 843ebd4fb6c..392728490b3 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_icmp.c,v 1.155 2016/11/16 12:21:46 bluhm Exp $ */ +/* $OpenBSD: ip_icmp.c,v 1.156 2016/11/16 12:48:19 bluhm Exp $ */ /* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */ /* @@ -960,7 +960,8 @@ icmp_mtudisc_clone(struct in_addr dst, u_int rtableid) info.rti_info[RTAX_LABEL] = rtlabel_id2sa(rt->rt_labelid, &sa_rl); - error = rtrequest(RTM_ADD, &info, RTP_DEFAULT, &nrt, rtableid); + error = rtrequest(RTM_ADD, &info, rt->rt_priority, &nrt, + rtableid); if (error) { rtfree(rt); return (NULL); diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index a4e363870a6..27e7ad6275a 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icmp6.c,v 1.192 2016/11/16 12:21:46 bluhm Exp $ */ +/* $OpenBSD: icmp6.c,v 1.193 2016/11/16 12:48:19 bluhm Exp $ */ /* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ /* @@ -1901,21 +1901,24 @@ icmp6_ratelimit(const struct in6_addr *dst, const int type, const int code) } struct rtentry * -icmp6_mtudisc_clone(struct sockaddr *dst, u_int rdomain) +icmp6_mtudisc_clone(struct sockaddr *dst, u_int rtableid) { struct rtentry *rt; int error; - rt = rtalloc(dst, RT_RESOLVE, rdomain); - if (rt == NULL) - return NULL; + rt = rtalloc(dst, RT_RESOLVE, rtableid); + + /* Check if the route is actually usable */ + if (!rtisvalid(rt) || (rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE))) { + rtfree(rt); + return (NULL); + } /* If we didn't get a host route, allocate one */ if ((rt->rt_flags & RTF_HOST) == 0) { struct rtentry *nrt; struct rt_addrinfo info; struct sockaddr_rtlabel sa_rl; - int s; memset(&info, 0, sizeof(info)); info.rti_flags = RTF_GATEWAY | RTF_HOST | RTF_DYNAMIC; @@ -1924,26 +1927,24 @@ icmp6_mtudisc_clone(struct sockaddr *dst, u_int rdomain) info.rti_info[RTAX_LABEL] = rtlabel_id2sa(rt->rt_labelid, &sa_rl); - s = splsoftnet(); error = rtrequest(RTM_ADD, &info, rt->rt_priority, &nrt, - rdomain); - splx(s); + rtableid); if (error) { rtfree(rt); - return NULL; + return (NULL); } nrt->rt_rmx = rt->rt_rmx; rtfree(rt); rt = nrt; } - error = rt_timer_add(rt, icmp6_mtudisc_timeout, - icmp6_mtudisc_timeout_q, rdomain); + error = rt_timer_add(rt, icmp6_mtudisc_timeout, icmp6_mtudisc_timeout_q, + rtableid); if (error) { rtfree(rt); - return NULL; + return (NULL); } - return rt; /* caller need to call rtfree() */ + return (rt); } void |