Source-Changes-HG archive

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

[src/trunk]: src/sys/net Don't assume that rt_tag family is AF_MPLS but verif...



details:   https://anonhg.NetBSD.org/src/rev/658f21c0a91b
branches:  trunk
changeset: 755905:658f21c0a91b
user:      kefren <kefren%NetBSD.org@localhost>
date:      Sun Jun 27 13:39:11 2010 +0000

description:
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

diffstat:

 sys/net/if_ethersubr.c |   7 ++++---
 sys/net/if_mpls.c      |  11 ++++++-----
 2 files changed, 10 insertions(+), 8 deletions(-)

diffs (68 lines):

diff -r c2998dc69f94 -r 658f21c0a91b sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Sun Jun 27 12:09:41 2010 +0000
+++ b/sys/net/if_ethersubr.c    Sun Jun 27 13:39:11 2010 +0000
@@ -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)
diff -r c2998dc69f94 -r 658f21c0a91b sys/net/if_mpls.c
--- a/sys/net/if_mpls.c Sun Jun 27 12:09:41 2010 +0000
+++ b/sys/net/if_mpls.c Sun Jun 27 13:39:11 2010 +0000
@@ -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);



Home | Main Index | Thread Index | Old Index