Hello,
The code executed on failure in icmp6_mtudisc_clone() is always
the same so it can be declared in one place. Is anyone happy to
OK this?
- Michael
Index: icmp6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/icmp6.c,v
retrieving revision 1.225
diff -u -p -u -r1.225 icmp6.c
--- icmp6.c 11 Jul 2018 13:06:16 -0000 1.225
+++ icmp6.c 4 Sep 2018 15:50:29 -0000
@@ -1768,20 +1768,16 @@ icmp6_mtudisc_clone(struct sockaddr *dst
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
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
}
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