Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet Tidy up the regular path of ip_forward



details:   https://anonhg.NetBSD.org/src/rev/e6dbeb77e446
branches:  trunk
changeset: 336880:e6dbeb77e446
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Mar 26 04:05:58 2015 +0000

description:
Tidy up the regular path of ip_forward

No functional change is intended.

diffstat:

 sys/netinet/ip_input.c |  46 +++++++++++++++++++++++++++-------------------
 1 files changed, 27 insertions(+), 19 deletions(-)

diffs (78 lines):

diff -r bba6dc9a822c -r e6dbeb77e446 sys/netinet/ip_input.c
--- a/sys/netinet/ip_input.c    Wed Mar 25 16:23:02 2015 +0000
+++ b/sys/netinet/ip_input.c    Thu Mar 26 04:05:58 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_input.c,v 1.319 2014/06/16 00:33:39 ozaki-r Exp $   */
+/*     $NetBSD: ip_input.c,v 1.320 2015/03/26 04:05:58 ozaki-r Exp $   */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.319 2014/06/16 00:33:39 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.320 2015/03/26 04:05:58 ozaki-r Exp $");
 
 #include "opt_inet.h"
 #include "opt_compat_netbsd.h"
@@ -1189,6 +1189,7 @@
                struct sockaddr         dst;
                struct sockaddr_in      dst4;
        } u;
+       uint64_t *ips;
 
        KASSERTMSG(cpu_softintr_p(), "ip_forward: not in the software "
            "interrupt handler; synchronization assumptions violated");
@@ -1269,27 +1270,34 @@
            (IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)),
            NULL, NULL);
 
-       if (error)
+       if (error) {
                IP_STATINC(IP_STAT_CANTFORWARD);
-       else {
-               uint64_t *ips = IP_STAT_GETREF();
-               ips[IP_STAT_FORWARD]++;
-               if (type) {
-                       ips[IP_STAT_REDIRECTSENT]++;
-                       IP_STAT_PUTREF();
-               } else {
-                       IP_STAT_PUTREF();
-                       if (mcopy) {
+               goto error;
+       }
+
+       ips = IP_STAT_GETREF();
+       ips[IP_STAT_FORWARD]++;
+
+       if (type) {
+               ips[IP_STAT_REDIRECTSENT]++;
+               IP_STAT_PUTREF();
+               goto redirect;
+       }
+
+       IP_STAT_PUTREF();
+       if (mcopy) {
 #ifdef GATEWAY
-                               if (mcopy->m_flags & M_CANFASTFWD)
-                                       ipflow_create(&ipforward_rt, mcopy);
+               if (mcopy->m_flags & M_CANFASTFWD)
+                       ipflow_create(&ipforward_rt, mcopy);
 #endif
-                               m_freem(mcopy);
-                       }
-                       SOFTNET_UNLOCK();
-                       return;
-               }
+               m_freem(mcopy);
        }
+
+       SOFTNET_UNLOCK();
+       return;
+
+redirect:
+error:
        if (mcopy == NULL) {
                SOFTNET_UNLOCK();
                return;



Home | Main Index | Thread Index | Old Index