Module Name:    src
Committed By:   msaitoh
Date:           Tue Jul 30 03:05:39 UTC 2013

Modified Files:
        src/sys/net [netbsd-6]: if_mpls.c

Log Message:
Pull up following revision(s) (requested by kefren in ticket #921):
        sys/net/if_mpls.c: revision 1.9
stop abusing kmem during softint context to prevent panic


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.8.1 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_mpls.c
diff -u src/sys/net/if_mpls.c:1.8 src/sys/net/if_mpls.c:1.8.8.1
--- src/sys/net/if_mpls.c:1.8	Sun Jul  3 18:46:12 2011
+++ src/sys/net/if_mpls.c	Tue Jul 30 03:05:39 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mpls.c,v 1.8 2011/07/03 18:46:12 kefren Exp $ */
+/*	$NetBSD: if_mpls.c,v 1.8.8.1 2013/07/30 03:05:39 msaitoh 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.8 2011/07/03 18:46:12 kefren Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.8.8.1 2013/07/30 03:05:39 msaitoh Exp $");
 
 #include "opt_inet.h"
 #include "opt_mpls.h"
@@ -38,7 +38,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 
 #include <sys/param.h>
 
 #include <sys/errno.h>
-#include <sys/kmem.h>
 #include <sys/malloc.h>
 #include <sys/mbuf.h>
 #include <sys/sysctl.h>
@@ -518,25 +517,21 @@ mpls_unlabel_inet(struct mbuf *m)
 static struct mbuf *
 mpls_label_inet(struct mbuf *m, union mpls_shim *ms, uint offset)
 {
-	struct ip *iphdr;
+	struct ip iphdr;
 
 	if (mpls_mapttl_inet || mpls_mapprec_inet) {
 		if ((m->m_len < sizeof(struct ip)) &&
 		    (m = m_pullup(m, offset + sizeof(struct ip))) == 0)
 			return NULL; /* XXX */
-		iphdr = kmem_alloc(sizeof(struct ip), KM_NOSLEEP);
-		if (iphdr == NULL)
-			return NULL;
-		m_copydata(m, offset, sizeof(struct ip), iphdr);
+		m_copydata(m, offset, sizeof(struct ip), &iphdr);
 
 		/* Map TTL */
 		if (mpls_mapttl_inet)
-			ms->shim.ttl = iphdr->ip_ttl;
+			ms->shim.ttl = iphdr.ip_ttl;
 
 		/* Copy IP precedence to EXP */
 		if (mpls_mapprec_inet)
-			ms->shim.exp = ((u_int8_t)iphdr->ip_tos) >> 5;
-		kmem_free (iphdr, sizeof(struct ip));
+			ms->shim.exp = ((u_int8_t)iphdr.ip_tos) >> 5;
 	}
 
 	if ((m = mpls_prepend_shim(m, ms)) == NULL)
@@ -592,23 +587,19 @@ mpls_unlabel_inet6(struct mbuf *m)
 static struct mbuf *
 mpls_label_inet6(struct mbuf *m, union mpls_shim *ms, uint offset)
 {
-	struct ip6_hdr *ip6h;
+	struct ip6_hdr ip6h;
 
 	if (mpls_mapttl_inet6 || mpls_mapclass_inet6) {
 		if (m->m_len < sizeof(struct ip6_hdr) &&
 		    (m = m_pullup(m, offset + sizeof(struct ip6_hdr))) == 0)
 			return NULL;
-		ip6h = kmem_alloc(sizeof(struct ip6_hdr), KM_NOSLEEP);
-		if (ip6h == NULL)
-			return NULL;
-		m_copydata(m, offset, sizeof(struct ip6_hdr), ip6h);
+		m_copydata(m, offset, sizeof(struct ip6_hdr), &ip6h);
 
 		if (mpls_mapttl_inet6)
-			ms->shim.ttl = ip6h->ip6_hlim;
+			ms->shim.ttl = ip6h.ip6_hlim;
 
 		if (mpls_mapclass_inet6)
-			ms->shim.exp = ip6h->ip6_vfc << 1 >> 5;
-		kmem_free(ip6h, sizeof(struct ip6_hdr));
+			ms->shim.exp = ip6h.ip6_vfc << 1 >> 5;
 	}
 
 	if ((m = mpls_prepend_shim(m, ms)) == NULL)

Reply via email to