diff options
author | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2023-06-27 21:02:14 +0000 |
---|---|---|
committer | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2023-06-27 21:02:14 +0000 |
commit | ba125fe74fb005ca4a345169a6e17220928765ee (patch) | |
tree | 6b70b709cf3adcefe7b992cfb6086352946b66db /sys | |
parent | 7befcc7b05e64cf7b0625af32146ef0cc28d8ef4 (diff) |
Introduce M_IFGROUP type of memory allocation. M_TEMP is unreasonable
for interface groups data allocations.
ok kn claudio bluhm
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if.c | 20 | ||||
-rw-r--r-- | 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, \ |