summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormiko <miko@openbsd.org>2018-09-05 09:47:18 +0000
committermiko <miko@openbsd.org>2018-09-05 09:47:18 +0000
commit635a4d25fa560f6310694d18e0563c96c1f6f3bf (patch)
tree390d32ee403e8a257ffc3fc126325e093b2448ae /sys
parentAdd "op" column for CP_SPIN. Diff from fukaumi at soum.co.jp (diff)
downloadwireguard-openbsd-635a4d25fa560f6310694d18e0563c96c1f6f3bf.tar.xz
wireguard-openbsd-635a4d25fa560f6310694d18e0563c96c1f6f3bf.zip
factor error code in icmp6_mtudisc_clone(); ok kn@ florian@
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet6/icmp6.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index 64a1d649a22..37e12ad7e5f 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: icmp6.c,v 1.225 2018/07/11 13:06:16 claudio Exp $ */
+/* $OpenBSD: icmp6.c,v 1.226 2018/09/05 09:47:18 miko Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@@ -1768,20 +1768,16 @@ icmp6_mtudisc_clone(struct sockaddr *dst, u_int rtableid)
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 (!rtisvalid(rt) || (rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)))
+ goto bad;
/*
* No PMTU for local routes and permanent neighbors,
* ARP and NDP use the same expire timer as the route.
*/
if (ISSET(rt->rt_flags, RTF_LOCAL) ||
- (ISSET(rt->rt_flags, RTF_LLINFO) && rt->rt_expire == 0)) {
- rtfree(rt);
- return (NULL);
- }
+ (ISSET(rt->rt_flags, RTF_LLINFO) && rt->rt_expire == 0))
+ goto bad;
/* If we didn't get a host route, allocate one */
if ((rt->rt_flags & RTF_HOST) == 0) {
@@ -1799,10 +1795,8 @@ icmp6_mtudisc_clone(struct sockaddr *dst, u_int rtableid)
error = rtrequest(RTM_ADD, &info, rt->rt_priority, &nrt,
rtableid);
- if (error) {
- rtfree(rt);
- return (NULL);
- }
+ if (error)
+ goto bad;
nrt->rt_rmx = rt->rt_rmx;
rtfree(rt);
rt = nrt;
@@ -1810,12 +1804,13 @@ icmp6_mtudisc_clone(struct sockaddr *dst, u_int rtableid)
}
error = rt_timer_add(rt, icmp6_mtudisc_timeout, icmp6_mtudisc_timeout_q,
rtableid);
- if (error) {
- rtfree(rt);
- return (NULL);
- }
+ if (error)
+ goto bad;
return (rt);
+bad:
+ rtfree(rt);
+ return (NULL);
}
void