Bug #3305: CBSD: Add NVMM support in DragonFly BSD
Add description support for ifconfig(8)
Is there a chance the 'ifconfig NIC description XXX' functionality
will sync with the FreeBSD ? This is a fairly popular option.
# ifconfig vlan1 description vm1-vlan ifconfig: description: bad value
The ioctl code in the kernel needs to ensure that the buffer is zero-terminated, or it needs to zero-terminate the buffer itself, that it stores in if_description. Otherwise the strlen() on the read side will overrun the buffer if userland intentionally sets a description that is not zero-terminated.
Updated by liweitianux 11 months ago
Hi tuxillo. Thank you for the work.
I've reviewed the patch and tweaked it a bit. Attached is the new patch, and you can diff to see the difference.
The main change is to the description ioctl(SIOCGIFDESCR) and print part. According to the manpage and actual implementation, if the supplied buffer is too small, then ioctl(SIOCGIFDESCR) returns an error. It looks to me the code in ifconfig.c is having issues. I fixed it (but not yet tested).
Another minor issue is that I'm not sure returning ENOMSG is a good choice. This errno is seldomly used, and I think that case is just normal (no description set), so it's fine to just return 0.
- Status changed from In Progress to Closed
- % Done changed from 50 to 100
Applied in changeset dragonflybsd|f6994c54d4ef3b530f323130b6d2a46ec6805672.