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
This commit is contained in:
parent
6f9c622690
commit
984b27d879
10
sys/net/if.c
10
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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user