git: 40c711523e3a - stable/13 - net: add if_allocdescr() to permit updating iface description from the kernel
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 23 Jan 2023 22:12:29 UTC
The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=40c711523e3ae6323294c2a1ec8285e494a338da commit 40c711523e3ae6323294c2a1ec8285e494a338da Author: Alexander V. Chernikov <melifaro@FreeBSD.org> AuthorDate: 2022-11-30 13:49:07 +0000 Commit: Alexander V. Chernikov <melifaro@FreeBSD.org> CommitDate: 2023-01-23 22:10:07 +0000 net: add if_allocdescr() to permit updating iface description from the kernel Reviewed by: kp,zlei Differential Revision: https://reviews.freebsd.org/D37566 MFC after: 2 weeks (cherry picked from commit 984b27d879e14d88834ddfb7b9f9a4c40a84c492) --- sys/net/if.c | 10 ++++++++-- sys/net/if_var.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 813525c2e7bd..4df376cbc7a6 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -2573,8 +2573,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) else if (ifr_buffer_get_length(ifr) == 0) descrbuf = NULL; else { - descrbuf = malloc(ifr_buffer_get_length(ifr), - M_IFDESCR, M_WAITOK | M_ZERO); + descrbuf = if_allocdescr(ifr_buffer_get_length(ifr), M_WAITOK); error = copyin(ifr_buffer_get_buffer(ifr), descrbuf, ifr_buffer_get_length(ifr) - 1); if (error) { @@ -4163,6 +4162,13 @@ if_setdescr(if_t ifp, char *descrbuf) if_freedescr(odescrbuf); } +char * +if_allocdescr(size_t sz, int malloc_flag) +{ + malloc_flag &= (M_WAITOK | M_NOWAIT); + return (malloc(sz, M_IFDESCR, M_ZERO | malloc_flag)); +} + void if_freedescr(char *descrbuf) { diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 6738f00a4f08..c0f7de44dc55 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -709,6 +709,7 @@ int if_setcapenablebit(if_t ifp, int setcap, int clearcap); int if_getcapenable(if_t ifp); const char *if_getdname(if_t ifp); void if_setdescr(if_t ifp, char *descrbuf); +char *if_allocdescr(size_t sz, int malloc_flag); void if_freedescr(char *descrbuf); int if_setdev(if_t ifp, void *dev); int if_setdrvflagbits(if_t ifp, int if_setflags, int clear_flags);