Page MenuHomeFreeBSD

ifconfig(8): show parent device for USB Ethernet interfaces
AcceptedPublic

Authored by lwhsu on Thu, Aug 20, 9:29 PM.
Tags
None
Referenced Files
F169285478: D59060.id.diff
Tue, Sep 1, 3:22 AM
F169253323: D59060.id185170.diff
Tue, Sep 1, 1:48 AM
F169242896: D59060.id184616.diff
Tue, Sep 1, 1:04 AM
F169172143: D59060.id.diff
Mon, Aug 31, 4:46 PM
F169170723: D59060.id184616.diff
Mon, Aug 31, 4:34 PM
F169125696: D59060.diff
Mon, Aug 31, 12:21 PM
Unknown Object (File)
Mon, Aug 31, 6:11 AM
Unknown Object (File)
Mon, Aug 31, 2:56 AM

Details

Reviewers
aokblast
Group Reviewers
USB
Summary
ifconfig(8): show parent device for USB Ethernet interfaces

Report net.ue.<unit>.%parent as "parent interface", consistent with
wlan(4):

  # ifconfig ue0
  ue0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
          ether 00:00:5e:00:53:2a
          inet 192.0.2.10/24 broadcast 192.0.2.255
          parent interface: ure0
          media: Ethernet autoselect (2500Base-T <full-duplex>)
          status: active

Sponsored by:	The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 76194
Build 73077: arc lint + arc unit

Event Timeline

lwhsu requested review of this revision.Thu, Aug 20, 9:29 PM

Just leaving this here... I think we also need an uether.4 man page listing all the ue drivers and that the drivers can .Xr? @ziaee any opinion on that?

Both ifvlan.c and ifieee80211.c have a dedicated ioctl to call for this.
I think it might be time to make this something more generic in ifconfig then if we start growing a "parent interface: " printf line duplication.

In D59060#1354644, @bz wrote:

Both ifvlan.c and ifieee80211.c have a dedicated ioctl to call for this.
I think it might be time to make this something more generic in ifconfig then if we start growing a "parent interface: " printf line duplication.

Yes, I think so too. The long term solution is probably netlink. We have IFLA_PARENT_DEV_NAME in the header, but there seems no implementation yet. That would also avoid adding one more ioctl.

Once we have it, ifconfig can print this line in one place, and we can migrate vlan/wlan/ue to it. There is already a "TODO: convert to netlink" comment in status_nl() in ifconfig_netlink.c.

This patch does not add any new kernel interface, but only reads an existing sysctl. It should be the easiest one to migrate later. I also looked into ifvlan.c and ifieee80211.c to see if it is possible to share some code, but the only common part is the printf. vlan prints it in the middle of a line and ieee80211 uses LINE_CHECK. I feel sharing a helper would not save much for now.

I am currently working on some USB Ethernet improvements, and this patch helps me develop and debug them. I am happy to come back later and look at making this generic in ifconfig.

aokblast added inline comments.
sbin/ifconfig/ifue.c
38

It is fine but compiler can optimize strlen to __builtin_strlen so maybe it is fine to use strlen directly.

42

Maybe strtol instead of manually implemeting this?

54

Why this is sizeof(parent)? parentlen should return the correct size?

This revision now requires changes to proceed.Mon, Aug 24, 1:47 AM
sbin/ifconfig/ifue.c
38

yeah this is just my personal preference, I am also fine with strlen().

42

after discussion, we can fold with other codes with sscanf().

54

Was trying to be defensive, but after checking the sysctl code more I believe this line can be just removed. parent will be NULL-terminated on success, or sysctlbyname() will return non-zero.

revise after discussing with aokblast.

In D59060#1354642, @bz wrote:

Just leaving this here... I think we also need an uether.4 man page listing all the ue drivers and that the drivers can .Xr? @ziaee any opinion on that?

  1. Yes, absolutely!
  2. I would think it should be ue.4 mlinked to if_ue?

Thanks for tagging me!

sbin/ifconfig/ifue.c
1

Nit: This hyphen was for a long abandoned project that never worked, it has been removed from all of our style guides.

Also this seems like it could be very helpful

LG for implementation part.

sbin/ifconfig/ifue.c
54

No, what you did is.

parent[sizeof(parent) - 1]: abcd........\0

what we actually want is

parent[returned_size]: abcd\0.

But since you have removed the code...

This revision is now accepted and ready to land.Thu, Aug 27, 2:06 AM