Module Name:    src
Committed By:   christos
Date:           Fri Oct  4 14:23:14 UTC 2013

Modified Files:
        src/sys/netinet6: ip6_input.c

Log Message:
check result of setscope, from logan.


To generate a diff of this commit:
cvs rdiff -u -r1.143 -r1.144 src/sys/netinet6/ip6_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/netinet6/ip6_input.c
diff -u src/sys/netinet6/ip6_input.c:1.143 src/sys/netinet6/ip6_input.c:1.144
--- src/sys/netinet6/ip6_input.c:1.143	Sat Jun 29 17:06:58 2013
+++ src/sys/netinet6/ip6_input.c	Fri Oct  4 10:23:14 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_input.c,v 1.143 2013/06/29 21:06:58 rmind Exp $	*/
+/*	$NetBSD: ip6_input.c,v 1.144 2013/10/04 14:23:14 christos Exp $	*/
 /*	$KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.143 2013/06/29 21:06:58 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.144 2013/10/04 14:23:14 christos Exp $");
 
 #include "opt_gateway.h"
 #include "opt_inet.h"
@@ -806,17 +806,21 @@ static struct m_tag *
 ip6_setdstifaddr(struct mbuf *m, const struct in6_ifaddr *ia)
 {
 	struct m_tag *mtag;
+	struct ip6aux *ip6a;
 
 	mtag = ip6_addaux(m);
-	if (mtag != NULL) {
-		struct ip6aux *ip6a;
+	if (mtag == NULL)
+		return NULL;
 
-		ip6a = (struct ip6aux *)(mtag + 1);
-		in6_setscope(&ip6a->ip6a_src, ia->ia_ifp, &ip6a->ip6a_scope_id);
-		ip6a->ip6a_src = ia->ia_addr.sin6_addr;
-		ip6a->ip6a_flags = ia->ia6_flags;
+	ip6a = (struct ip6aux *)(mtag + 1);
+	if (in6_setscope(&ip6a->ip6a_src, ia->ia_ifp, &ip6a->ip6a_scope_id)) {
+		IP6_STATINC(IP6_STAT_BADSCOPE);
+		return NULL;
 	}
-	return mtag;	/* NULL if failed to set */
+
+	ip6a->ip6a_src = ia->ia_addr.sin6_addr;
+	ip6a->ip6a_flags = ia->ia6_flags;
+	return mtag;
 }
 
 const struct ip6aux *

Reply via email to