git: 984b27d879e1 - main - net: add if_allocdescr() to permit updating iface description from the kernel
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 01 Dec 2022 11:32:07 UTC
The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=984b27d879e14d88834ddfb7b9f9a4c40a84c492 commit 984b27d879e14d88834ddfb7b9f9a4c40a84c492 Author: Alexander V. Chernikov <melifaro@FreeBSD.org> AuthorDate: 2022-11-30 13:49:07 +0000 Commit: Alexander V. Chernikov <melifaro@FreeBSD.org> CommitDate: 2022-12-01 11:31:36 +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 --- 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 7446fb492436..8333c85b5eb1 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -2610,8 +2610,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) { @@ -4273,6 +4272,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 ce36beadcfd5..859abf8fc089 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -740,6 +740,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);