Module Name:    src
Committed By:   ozaki-r
Date:           Thu Mar 26 04:05:58 UTC 2015

Modified Files:
        src/sys/netinet: ip_input.c

Log Message:
Tidy up the regular path of ip_forward

No functional change is intended.


To generate a diff of this commit:
cvs rdiff -u -r1.319 -r1.320 src/sys/netinet/ip_input.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/ip_input.c
diff -u src/sys/netinet/ip_input.c:1.319 src/sys/netinet/ip_input.c:1.320
--- src/sys/netinet/ip_input.c:1.319	Mon Jun 16 00:33:39 2014
+++ src/sys/netinet/ip_input.c	Thu Mar 26 04:05:58 2015
@@ -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 @@ ip_forward(struct mbuf *m, int srcrt)
 		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_forward(struct mbuf *m, int srcrt)
 	    (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;

Reply via email to