Module Name:    src
Committed By:   maxv
Date:           Thu Apr 12 07:28:10 UTC 2018

Modified Files:
        src/sys/netinet: raw_ip.c
        src/sys/netinet6: icmp6.c raw_ip6.c

Log Message:
Synchronize the code between raw_ip6.c<->icmp6.c<->raw_ip.c, so that it is
the same everywhere.


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/netinet/raw_ip.c
cvs rdiff -u -r1.225 -r1.226 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.167 -r1.168 src/sys/netinet6/raw_ip6.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/raw_ip.c
diff -u src/sys/netinet/raw_ip.c:1.173 src/sys/netinet/raw_ip.c:1.174
--- src/sys/netinet/raw_ip.c:1.173	Thu Apr 12 06:49:39 2018
+++ src/sys/netinet/raw_ip.c	Thu Apr 12 07:28:10 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip.c,v 1.173 2018/04/12 06:49:39 maxv Exp $	*/
+/*	$NetBSD: raw_ip.c,v 1.174 2018/04/12 07:28:10 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.173 2018/04/12 06:49:39 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.174 2018/04/12 07:28:10 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -199,11 +199,13 @@ rip_input(struct mbuf *m, ...)
 		if (!in_nullhost(inp->inp_faddr) &&
 		    !in_hosteq(inp->inp_faddr, ip->ip_src))
 			continue;
-		if (last == NULL)
+
+		if (last == NULL) {
 			;
+		}
 #if defined(IPSEC)
 		else if (ipsec_used && ipsec_in_reject(m, last)) {
-			/* do not inject data to pcb */
+			/* do not inject data into pcb */
 		}
 #endif
 		else if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) {
@@ -211,6 +213,7 @@ rip_input(struct mbuf *m, ...)
 			    n);
 			opts = NULL;
 		}
+
 		last = inp;
 	}
 
@@ -218,7 +221,7 @@ rip_input(struct mbuf *m, ...)
 	if (ipsec_used && last != NULL && ipsec_in_reject(m, last)) {
 		m_freem(m);
 		IP_STATDEC(IP_STAT_DELIVERED);
-		/* do not inject data to pcb */
+		/* do not inject data into pcb */
 	} else
 #endif
 	if (last != NULL) {

Index: src/sys/netinet6/icmp6.c
diff -u src/sys/netinet6/icmp6.c:1.225 src/sys/netinet6/icmp6.c:1.226
--- src/sys/netinet6/icmp6.c:1.225	Thu Apr 12 06:49:39 2018
+++ src/sys/netinet6/icmp6.c	Thu Apr 12 07:28:10 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.c,v 1.225 2018/04/12 06:49:39 maxv Exp $	*/
+/*	$NetBSD: icmp6.c,v 1.226 2018/04/12 07:28:10 maxv Exp $	*/
 /*	$KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.225 2018/04/12 06:49:39 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.226 2018/04/12 07:28:10 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1965,7 +1965,7 @@ icmp6_rip6_input(struct mbuf **mp, int o
 	struct in6pcb *last = NULL;
 	struct sockaddr_in6 rip6src;
 	struct icmp6_hdr *icmp6;
-	struct mbuf *opts = NULL;
+	struct mbuf *n, *opts = NULL;
 
 	IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off, sizeof(*icmp6));
 	if (icmp6 == NULL) {
@@ -1995,31 +1995,36 @@ icmp6_rip6_input(struct mbuf **mp, int o
 		if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr) &&
 		   !IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr, &ip6->ip6_src))
 			continue;
-		if (in6p->in6p_icmp6filt
-		    && ICMP6_FILTER_WILLBLOCK(icmp6->icmp6_type,
-				 in6p->in6p_icmp6filt))
+		if (in6p->in6p_icmp6filt &&
+		    ICMP6_FILTER_WILLBLOCK(icmp6->icmp6_type,
+		    in6p->in6p_icmp6filt))
 			continue;
-		if (last) {
-			struct	mbuf *n;
+
+		if (last == NULL) {
+			;
+		}
 #ifdef IPSEC
-			if (!ipsec_used || !ipsec_in_reject(m, last))
+		else if (ipsec_used && ipsec_in_reject(m, last)) {
+			/* do not inject data into pcb */
+		}
 #endif
-			if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
-				if (last->in6p_flags & IN6P_CONTROLOPTS)
-					ip6_savecontrol(last, &opts, ip6, n);
-				/* strip intermediate headers */
-				m_adj(n, off);
-				if (sbappendaddr(&last->in6p_socket->so_rcv,
-				    sin6tosa(&rip6src), n, opts) == 0) {
-					soroverflow(last->in6p_socket);
-					m_freem(n);
-					if (opts)
-						m_freem(opts);
-				} else
-					sorwakeup(last->in6p_socket);
-				opts = NULL;
+		else if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
+			if (last->in6p_flags & IN6P_CONTROLOPTS)
+				ip6_savecontrol(last, &opts, ip6, n);
+			/* strip intermediate headers */
+			m_adj(n, off);
+			if (sbappendaddr(&last->in6p_socket->so_rcv,
+			    sin6tosa(&rip6src), n, opts) == 0) {
+				soroverflow(last->in6p_socket);
+				m_freem(n);
+				if (opts)
+					m_freem(opts);
+			} else {
+				sorwakeup(last->in6p_socket);
 			}
+			opts = NULL;
 		}
+
 		last = in6p;
 	}
 

Index: src/sys/netinet6/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.167 src/sys/netinet6/raw_ip6.c:1.168
--- src/sys/netinet6/raw_ip6.c:1.167	Thu Apr 12 06:49:39 2018
+++ src/sys/netinet6/raw_ip6.c	Thu Apr 12 07:28:10 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.167 2018/04/12 06:49:39 maxv Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.168 2018/04/12 07:28:10 maxv Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.167 2018/04/12 06:49:39 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.168 2018/04/12 07:28:10 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -149,7 +149,7 @@ rip6_input(struct mbuf **mp, int *offp, 
 	struct in6pcb *in6p;
 	struct in6pcb *last = NULL;
 	struct sockaddr_in6 rip6src;
-	struct mbuf *opts = NULL;
+	struct mbuf *n, *opts = NULL;
 
 	RIP6_STATINC(RIP6_STAT_IPACKETS);
 
@@ -189,29 +189,33 @@ rip6_input(struct mbuf **mp, int *offp, 
 				continue;
 			}
 		}
-		if (last) {
-			struct	mbuf *n;
 
+		if (last == NULL) {
+			;
+		}
 #ifdef IPSEC
-			if (!ipsec_used || !ipsec_in_reject(m, last))
+		else if (ipsec_used && ipsec_in_reject(m, last)) {
+			/* do not inject data into pcb */
+		}
 #endif
-			if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
-				if (last->in6p_flags & IN6P_CONTROLOPTS)
-					ip6_savecontrol(last, &opts, ip6, n);
-				/* strip intermediate headers */
-				m_adj(n, *offp);
-				if (sbappendaddr(&last->in6p_socket->so_rcv,
-				    sin6tosa(&rip6src), n, opts) == 0) {
-					soroverflow(last->in6p_socket);
-					m_freem(n);
-					if (opts)
-						m_freem(opts);
-					RIP6_STATINC(RIP6_STAT_FULLSOCK);
-				} else
-					sorwakeup(last->in6p_socket);
-				opts = NULL;
+		else if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
+			if (last->in6p_flags & IN6P_CONTROLOPTS)
+				ip6_savecontrol(last, &opts, ip6, n);
+			/* strip intermediate headers */
+			m_adj(n, *offp);
+			if (sbappendaddr(&last->in6p_socket->so_rcv,
+			    sin6tosa(&rip6src), n, opts) == 0) {
+				soroverflow(last->in6p_socket);
+				m_freem(n);
+				if (opts)
+					m_freem(opts);
+				RIP6_STATINC(RIP6_STAT_FULLSOCK);
+			} else {
+				sorwakeup(last->in6p_socket);
 			}
+			opts = NULL;
 		}
+
 		last = in6p;
 	}
 

Reply via email to