Module Name:    src
Committed By:   kefren
Date:           Sun Jun 27 13:39:11 UTC 2010

Modified Files:
        src/sys/net: if_ethersubr.c if_mpls.c

Log Message:
Don't assume that rt_tag family is AF_MPLS but verify it.
This way rt_tag can be used for other future work also, not only MPLS


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/net/if_ethersubr.c
cvs rdiff -u -r1.2 -r1.3 src/sys/net/if_mpls.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/net/if_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.182 src/sys/net/if_ethersubr.c:1.183
--- src/sys/net/if_ethersubr.c:1.182	Sat Jun 26 14:24:28 2010
+++ src/sys/net/if_ethersubr.c	Sun Jun 27 13:39:11 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.182 2010/06/26 14:24:28 kefren Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.183 2010/06/27 13:39:11 kefren Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.182 2010/06/26 14:24:28 kefren Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.183 2010/06/27 13:39:11 kefren Exp $");
 
 #include "opt_inet.h"
 #include "opt_atalk.h"
@@ -454,7 +454,8 @@
 	}
 
 #ifdef MPLS
-		if (rt0 != NULL && rt_gettag(rt0) != NULL) {
+		if (rt0 != NULL && rt_gettag(rt0) != NULL &&
+		    rt_gettag(rt0)->sa_family == AF_MPLS) {
 			union mpls_shim msh;
 			msh.s_addr = MPLS_GETSADDR(rt0);
 			if (msh.shim.label != MPLS_LABEL_IMPLNULL)

Index: src/sys/net/if_mpls.c
diff -u src/sys/net/if_mpls.c:1.2 src/sys/net/if_mpls.c:1.3
--- src/sys/net/if_mpls.c:1.2	Sat Jun 26 15:17:56 2010
+++ src/sys/net/if_mpls.c	Sun Jun 27 13:39:11 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mpls.c,v 1.2 2010/06/26 15:17:56 kefren Exp $ */
+/*	$NetBSD: if_mpls.c,v 1.3 2010/06/27 13:39:11 kefren Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.2 2010/06/26 15:17:56 kefren Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.3 2010/06/27 13:39:11 kefren Exp $");
 
 #include "opt_inet.h"
 #include "opt_mpls.h"
@@ -199,7 +199,7 @@
 		return ENETDOWN;
 	}
 
-	if (rt_gettag(rt) == NULL) {
+	if (rt_gettag(rt) == NULL || rt_gettag(rt)->sa_family != AF_MPLS) {
 		m_freem(m);
 		return EINVAL;
 	}
@@ -346,9 +346,10 @@
 	if ((rt = rtalloc1((const struct sockaddr*)&dst, 1)) == NULL)
 		goto done;
 
-	/* MPLS packet with no tagged route ? */
+	/* MPLS packet with no MPLS tagged route ? */
 	if ((rt->rt_flags & RTF_GATEWAY) == 0 ||
-	     rt_gettag(rt) == NULL)
+	     rt_gettag(rt) == NULL ||
+	     rt_gettag(rt)->sa_family != AF_MPLS)
 		goto done;
 
 	tshim.s_addr = MPLS_GETSADDR(rt);

Reply via email to