Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet6 Avoid memset and rtcache_free if unnecessary



details:   https://anonhg.NetBSD.org/src/rev/2c7b43cabb51
branches:  trunk
changeset: 816843:2c7b43cabb51
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Fri Jul 29 06:02:03 2016 +0000

description:
Avoid memset and rtcache_free if unnecessary

It's the same as ip_output.

diffstat:

 sys/netinet6/ip6_output.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (45 lines):

diff -r 76c3eae311ed -r 2c7b43cabb51 sys/netinet6/ip6_output.c
--- a/sys/netinet6/ip6_output.c Fri Jul 29 05:23:24 2016 +0000
+++ b/sys/netinet6/ip6_output.c Fri Jul 29 06:02:03 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_output.c,v 1.171 2016/06/27 18:35:54 christos Exp $        */
+/*     $NetBSD: ip6_output.c,v 1.172 2016/07/29 06:02:03 ozaki-r Exp $ */
 /*     $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $    */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.171 2016/06/27 18:35:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.172 2016/07/29 06:02:03 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -189,8 +189,6 @@
        int bound = curlwp_bind();
        bool release_psref_ia = false;
 
-       memset(&ip6route, 0, sizeof(ip6route));
-
 #ifdef  DIAGNOSTIC
        if ((m->m_flags & M_PKTHDR) == 0)
                panic("ip6_output: no HDR");
@@ -437,6 +435,7 @@
         */
        /* initialize cached route */
        if (ro == NULL) {
+               memset(&ip6route, 0, sizeof(ip6route));
                ro = &ip6route;
        }
        ro_pmtu = ro;
@@ -974,7 +973,8 @@
                IP6_STATINC(IP6_STAT_FRAGMENTED);
 
 done:
-       rtcache_free(&ip6route);
+       if (ro == &ip6route)
+               rtcache_free(&ip6route);
 
 #ifdef IPSEC
        if (sp != NULL)



Home | Main Index | Thread Index | Old Index