Project

General

Profile

Actions

Bug #3306

closed

Bug #3305: CBSD: Add NVMM support in DragonFly BSD

Add description support for ifconfig(8)

Added by tuxillo over 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Userland
Target version:
Start date:
11/12/2021
Due date:
% Done:

100%

Estimated time:

Description

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

OpenBSD also has a similar capability1, as NetBSD as well2

Thanks!
__

1 https://man.openbsd.org/ifconfig.8

2 https://man.netbsd.org/ifconfig.8


Files

01-if-descr.patch (11.7 KB) 01-if-descr.patch tuxillo, 11/12/2021 04:49 PM
01-if-descr.aly.diff (11.8 KB) 01-if-descr.aly.diff updated if description patch liweitianux, 11/15/2021 02:02 AM
Actions #1

Updated by tuxillo over 2 years ago

Preliminary patch, can you please review it @dillon, @sepherosa?

Actions #2

Updated by dillon over 2 years ago

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.

-Matt

Actions #3

Updated by liweitianux over 2 years 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.

Cheers,
Aaron

Actions #4

Updated by tuxillo almost 2 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 50 to 100
Actions #5

Updated by tuxillo almost 2 years ago

@dillon, I've gone ahead and pushed the modified version from aly to the repo. The buffer to set the description is allocated with M_ZERO so I thought it was good enough. @aly, thanks I've pushed the patch with your mods.

Actions

Also available in: Atom PDF