Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet ip_encap uses kmem_alloc APIs instead of malloc.
details: https://anonhg.NetBSD.org/src/rev/329605476137
branches: trunk
changeset: 342150:329605476137
user: knakahara <knakahara%NetBSD.org@localhost>
date: Wed Dec 09 06:00:51 2015 +0000
description:
ip_encap uses kmem_alloc APIs instead of malloc.
diffstat:
sys/netinet/ip_encap.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diffs (85 lines):
diff -r 71a3cae211d9 -r 329605476137 sys/netinet/ip_encap.c
--- a/sys/netinet/ip_encap.c Wed Dec 09 05:56:24 2015 +0000
+++ b/sys/netinet/ip_encap.c Wed Dec 09 06:00:51 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_encap.c,v 1.46 2015/08/24 22:21:26 pooka Exp $ */
+/* $NetBSD: ip_encap.c,v 1.47 2015/12/09 06:00:51 knakahara Exp $ */
/* $KAME: ip_encap.c,v 1.73 2001/10/02 08:30:58 itojun Exp $ */
/*
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.46 2015/08/24 22:21:26 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.47 2015/12/09 06:00:51 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_mrouting.h"
@@ -85,6 +85,7 @@
#include <sys/errno.h>
#include <sys/protosw.h>
#include <sys/queue.h>
+#include <sys/kmem.h>
#include <net/if.h>
#include <net/route.h>
@@ -492,17 +493,17 @@
}
/* M_NETADDR ok? */
- ep = malloc(sizeof(*ep), M_NETADDR, M_NOWAIT|M_ZERO);
+ ep = kmem_zalloc(sizeof(*ep), KM_NOSLEEP);
if (ep == NULL) {
error = ENOBUFS;
goto fail;
}
- ep->addrpack = malloc(l, M_NETADDR, M_NOWAIT|M_ZERO);
+ ep->addrpack = kmem_zalloc(l, KM_NOSLEEP);
if (ep->addrpack == NULL) {
error = ENOBUFS;
goto gc;
}
- ep->maskpack = malloc(l, M_NETADDR, M_NOWAIT|M_ZERO);
+ ep->maskpack = kmem_zalloc(l, KM_NOSLEEP);
if (ep->maskpack == NULL) {
error = ENOBUFS;
goto gc;
@@ -550,11 +551,11 @@
gc:
if (ep->addrpack)
- free(ep->addrpack, M_NETADDR);
+ kmem_free(ep->addrpack, l);
if (ep->maskpack)
- free(ep->maskpack, M_NETADDR);
+ kmem_free(ep->maskpack, l);
if (ep)
- free(ep, M_NETADDR);
+ kmem_free(ep, sizeof(*ep));
fail:
splx(s);
return NULL;
@@ -580,7 +581,7 @@
if (error)
goto fail;
- ep = malloc(sizeof(*ep), M_NETADDR, M_NOWAIT); /*XXX*/
+ ep = kmem_alloc(sizeof(*ep), KM_NOSLEEP); /*XXX*/
if (ep == NULL) {
error = ENOBUFS;
goto fail;
@@ -701,10 +702,10 @@
if (error)
return error;
if (!ep->func) {
- free(p->addrpack, M_NETADDR);
- free(p->maskpack, M_NETADDR);
+ kmem_free(p->addrpack, ep->addrpack->sa_len);
+ kmem_free(p->maskpack, ep->maskpack->sa_len);
}
- free(p, M_NETADDR); /*XXX*/
+ kmem_free(p, sizeof(*p)); /*XXX*/
return 0;
}
}
Home |
Main Index |
Thread Index |
Old Index