From 94e8a6f55b92b6de2d309053fd93a3b3a8dbc656 Mon Sep 17 00:00:00 2001 From: mvs Date: Tue, 27 Jun 2023 21:02:13 +0000 Subject: [PATCH] Introduce M_IFGROUP type of memory allocation. M_TEMP is unreasonable for interface groups data allocations. ok kn claudio bluhm --- sys/net/if.c | 20 ++++++++++---------- sys/sys/malloc.h | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index a4755f6b91b..770537cf61a 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.700 2023/06/12 21:19:54 mvs Exp $ */ +/* $OpenBSD: if.c,v 1.701 2023/06/27 21:02:13 mvs Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -2784,7 +2784,7 @@ if_creategroup(const char *groupname) { struct ifg_group *ifg; - if ((ifg = malloc(sizeof(*ifg), M_TEMP, M_NOWAIT)) == NULL) + if ((ifg = malloc(sizeof(*ifg), M_IFGROUP, M_NOWAIT)) == NULL) return (NULL); strlcpy(ifg->ifg_group, groupname, sizeof(ifg->ifg_group)); @@ -2819,11 +2819,11 @@ if_addgroup(struct ifnet *ifp, const char *groupname) if (!strcmp(ifgl->ifgl_group->ifg_group, groupname)) return (EEXIST); - if ((ifgl = malloc(sizeof(*ifgl), M_TEMP, M_NOWAIT)) == NULL) + if ((ifgl = malloc(sizeof(*ifgl), M_IFGROUP, M_NOWAIT)) == NULL) return (ENOMEM); - if ((ifgm = malloc(sizeof(*ifgm), M_TEMP, M_NOWAIT)) == NULL) { - free(ifgl, M_TEMP, sizeof(*ifgl)); + if ((ifgm = malloc(sizeof(*ifgm), M_IFGROUP, M_NOWAIT)) == NULL) { + free(ifgl, M_IFGROUP, sizeof(*ifgl)); return (ENOMEM); } @@ -2834,8 +2834,8 @@ if_addgroup(struct ifnet *ifp, const char *groupname) if (ifg == NULL) { ifg = if_creategroup(groupname); if (ifg == NULL) { - free(ifgl, M_TEMP, sizeof(*ifgl)); - free(ifgm, M_TEMP, sizeof(*ifgm)); + free(ifgl, M_IFGROUP, sizeof(*ifgl)); + free(ifgm, M_IFGROUP, sizeof(*ifgm)); return (ENOMEM); } } else @@ -2878,7 +2878,7 @@ if_delgroup(struct ifnet *ifp, const char *groupname) if (ifgm != NULL) { TAILQ_REMOVE(&ifgl->ifgl_group->ifg_members, ifgm, ifgm_next); - free(ifgm, M_TEMP, sizeof(*ifgm)); + free(ifgm, M_IFGROUP, sizeof(*ifgm)); } #if NPF > 0 @@ -2891,10 +2891,10 @@ if_delgroup(struct ifnet *ifp, const char *groupname) #if NPF > 0 pfi_detach_ifgroup(ifgl->ifgl_group); #endif - free(ifgl->ifgl_group, M_TEMP, sizeof(*ifgl->ifgl_group)); + free(ifgl->ifgl_group, M_IFGROUP, sizeof(*ifgl->ifgl_group)); } - free(ifgl, M_TEMP, sizeof(*ifgl)); + free(ifgl, M_IFGROUP, sizeof(*ifgl)); return (0); } diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index 97bf9ff60b4..832fec21c02 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.h,v 1.122 2022/02/03 17:18:22 guenther Exp $ */ +/* $OpenBSD: malloc.h,v 1.123 2023/06/27 21:02:13 mvs Exp $ */ /* $NetBSD: malloc.h,v 1.39 1998/07/12 19:52:01 augustss Exp $ */ /* @@ -72,7 +72,7 @@ /* 7 - free */ /* 8 - free */ #define M_IFADDR 9 /* interface address */ -/* 10 - free */ +#define M_IFGROUP 10 /* interface group */ #define M_SYSCTL 11 /* sysctl buffers (persistent storage) */ #define M_COUNTERS 12 /* per CPU counters */ /* 13 - free */ @@ -190,7 +190,7 @@ NULL, \ NULL, \ "ifaddr", /* 9 M_IFADDR */ \ - NULL, \ + "ifgroup", /* 10 M_IFGROUP */ \ "sysctl", /* 11 M_SYSCTL */ \ "counters", /* 12 M_COUNTERS */ \ NULL, \ -- 2.20.1