# DHCP through USB-Hub with attached RJ45



## mahashakti89 (May 10, 2018)

Hi,
Running FreeBSD-11.1 on a recent laptop, ASUS, seems to work fine, except when I try to get a DHCP lease through a USB-Hub with attached RJ45.
I get following error message at the end of the boot : 

```
usb_alloc_device: set address 5 failed (USB_ERR_TIMEOUT, ignored)                                                        
usbd_setup_device_desc: getting device descriptor at addr 5 failed, USB_ERR_TIMEOUT                            
usbd_req_re_enumerate: addr=5, set address failed! (USB_ERR_TIMEOUT, ignored)                                   
usbd_setup_device_desc: getting device descriptor at addr 5 failed, USB_ERR_TIMEOUT                            
usbd_req_re_enumerate: addr=5, set address failed! (USB_ERR_TIMEOUT, ignored)                                   
usbd_setup_device_desc: getting device descriptor at addr 5 failed, USB_ERR_TIMEOUT                            
usbd_req_re_enumerate: addr=5, set address failed! (USB_ERR_TIMEOUT, ignored)                                   
usbd_setup_device_desc: getting device descriptor at addr 5 failed, USB_ERR_TIMEOUT                            
usbd_req_re_enumerate: addr=5, set address failed! (USB_ERR_TIMEOUT, ignored)                                   
usbd_setup_device_desc: getting device descriptor at addr 5 failed, USB_ERR_TIMEOUT                            
ugen0.5: <Unknown > at usbus0 (disconnected)                                                                                    
uhub_reattach_port: could not allocate new device                                                                               
ugen0.5: <VIA Labs, Inc. USB3.0 Hub> at usbus0                                                                                  
uhub2 on uhub0                                                                                                                  
uhub2: <VIA Labs, Inc. USB3.0 Hub, class 9/0, rev 3.00/3.45, addr 5> on usbus0
#uhub2 on uhub0                                                                                                                 
uhub2: <VIA Labs, Inc. USB3.0 Hub, class 9/0, rev 3.00/3.45, addr 5> on usbus0                                          
uhub2: 4 ports with 4 removable, self powered                                                                                   
ugen0.6: <Realtek USB 101001000 LAN> at usbus0                                                                                  
ums0 on uhub0                                                                                                                   
ums0: <Logitech USB Receiver, class 0/0, rev 2.00/12.03, addr 1> on usbus0                                               
ums0: 16 buttons and [XYZT] coordinates ID=2                                                                                    
uhid0 on uhub0                                                                                                                  
uhid0: <Logitech USB Receiver, class 0/0, rev 2.00/12.03, addr 1> on usbus0                                               
cdce0 on uhub2                                                                                                                  
cdce0: <CDC Communications Control> on usbus0                                                                                   
ue0: <USB Ethernet> on cdce0                                                                                                   
ue0: Ethernet address: 00:e0:4c:68:12:85
```

DHCP is not working .... The only way to get a lease is to unplug the hub , to plug it again and then `dhclient  ue0` works ...
Is there another solution ??
Regards


----------



## Phishfry (May 10, 2018)

Looks like ue0 shows up OK?

Maybe you should try /etc/rc.d/netwait and add some delay before dhclient starts..
The interface may need additional time to come up for USB network devices.
Here are the netwait options you can use in your /etc/rc.conf

```
### Network link/usability verification options
netwait_enable="NO"        # Enable rc.d/netwait (or NO)
#netwait_ip=""            # Wait for ping response from any IP in this list.
netwait_timeout="60"        # Total number of seconds to perform pings.
#netwait_if=""            # Wait for active link on each intf in this list.
netwait_if_timeout="30"        # Total number of seconds to monitor link state.
```

So you would want:
netwait_enable="YES"
netwait_if="ue0"
netwait_timeout="60"


----------



## mahashakti89 (May 10, 2018)

Thanks for the tip, but it won't work.  I get following error message:


> Interface got link  Waiting for the default route interface[ ....../QUOTE] but nothing.
> I tried to set the the default router through /etc/rc.conf but same result
> Regards


----------



## Phishfry (May 10, 2018)

Your whole method of connecting the USB Ethernet dongle to your USB Hub is not how I would do it.
I would connect your USB Ethernet directly to a USB Port on the laptop.
Are you limited to one USB port on your laptop? If not directly connect.
I am surprised it works at all through the hub.

The messages look like something USB is crashing which is why I am surprised the interface comes up at all.
The way the error messages are before your interface comes up is strange too.

Have you looked to see what kind of USB hub 'quirks" are available?
https://www.freebsd.org/cgi/man.cgi?query=usb_quirk&sektion=4&n=1


----------



## ralphbsz (May 11, 2018)

Agree with Phishfry.  The DHCP problems are probably caused by ethernet issues.  The ethernet issues are probably caused by the known USB problems.  Trying to fix DHCP or ethernet while the basic USB layer is unreliable or sick seems foolish.

Since your USB error messages look scary, I conclude that your whole USB subsystem seems a bit sick.  This can be caused by lack of power: each USB port can only deliver limited power, and if you use a non-powered old fashioned USB hub, it may not know how to partition the power to all the attached device.

The first order of business is to get rid of USB error messages.  Use the `usbconfig` to see what is attached, and how much power it uses.  Then I would try some combinations and permutations of how to attach things.  Perhaps plug the most power-hungry accessories directly into a USB port.  Or see whether you can find a powered USB hub.  Get your USB layer to work perfectly and without error messages.  Once that's done, we'll work on DHCP (and most likely, then it will work perfectly).


----------



## Phishfry (May 11, 2018)

Funny you mention power.
This quirk stood out to me for that same reason:

     UQ_POWER_CLAIM
         hub lies about power status

I am not sure if this quirk is for the motherboard ICH USB hub or for external hub devices.

I did not even consider that there are non-powered USB hubs. With my Arm dealings I only own powered hubs.
I agree, that a powered hub is an absolute must for anything but low power devices like thumbdrives.


----------



## mahashakti89 (May 11, 2018)

The RJ45 is integrated in the USB-HUB. I have to connect the hub - USB Type C- to get DHCP working. I agree that USB is the origin of the trouble.
Basing on uour suggestions I will dig futher when I am back home.
Regards


----------



## balanga (May 11, 2018)

What does lsusb() and ifconfig() show when you have the USB hub first connected?

Does `dmesg` provide any clues?


----------



## mahashakti89 (May 12, 2018)

`dmesg | grep USB`

```
usbus0: waiting for BIOS to give up control
usbus0 on xhci0
usbus0: 5.0Gbps Super Speed USB v3.0
ugen0.1: <0x8086 XHCI root HUB> at usbus0
uhub0: <0x8086 XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus0
ugen0.2: <Logitech USB Receiver> at usbus0
ukbd0: <Logitech USB Receiver, class 0/0, rev 2.00/12.03, addr 1> on usbus0
ugen0.3: <Chicony Electronics Co.,Ltd. USB2.0 HD UVC WebCam> at usbus0
ugen0.4: <VIA Labs, Inc. USB2.0 Hub> at usbus0
uhub1: <VIA Labs, Inc. USB2.0 Hub, class 9/0, rev 2.10/3.44, addr 3> on usbus0
ugen0.5: <vendor 0x8087 product 0x0a2a> at usbus0
ugen0.6: <VIA Labs, Inc. USB3.0 Hub> at usbus0
uhub2: <VIA Labs, Inc. USB3.0 Hub, class 9/0, rev 3.00/3.45, addr 5> on usbus0
ugen0.7: <Realtek USB 101001000 LAN> at usbus0
ums0: <Logitech USB Receiver, class 0/0, rev 2.00/12.03, addr 1> on usbus0
uhid0: <Logitech USB Receiver, class 0/0, rev 2.00/12.03, addr 1> on usbus0
ubt0: <vendor 0x8087 product 0x0a2a, class 224/1, rev 2.01/0.01, addr 4> on usbus0
cdce0: <CDC Communications Control> on usbus0
```

and

1. just after boot sequence
`usbconfig`

```
ugen0.1: <0x8086 XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.2: <Logitech USB Receiver> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (98mA)
ugen0.3: <Chicony Electronics Co.,Ltd. USB2.0 HD UVC WebCam> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)
ugen0.4: <VIA Labs, Inc. USB2.0 Hub> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen0.5: <vendor 0x8087 product 0x0a2a> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.6: <VIA Labs, Inc. USB3.0 Hub> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.7: <Realtek USB 101001000 LAN> at usbus0, cfg=1 md=HOST spd=SUPER (5.0Gbps) pwr=ON (64mA)
```

2. after unplugging and repluging the hub
`usbconfig`

```
ugen0.1: <0x8086 XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.2: <Logitech USB Receiver> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (98mA)
ugen0.3: <Chicony Electronics Co.,Ltd. USB2.0 HD UVC WebCam> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)
ugen0.5: <vendor 0x8087 product 0x0a2a> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.4: <VIA Labs, Inc. USB3.0 Hub> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.6: <Realtek USB 101001000 LAN> at usbus0, cfg=1 md=HOST spd=SUPER (5.0Gbps) pwr=ON (64mA)
ugen0.7: <VIA Labs, Inc. USB2.0 Hub> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
```

Regards


----------



## Phishfry (May 12, 2018)

Silly question but why are you using USB Ethernet?
Is the laptops onboard ethernet broken or are you needing 2 interfaces?


----------



## Phishfry (May 12, 2018)

Looking at the output it appears that ugen 0.6 and ugen 0.7 reverse themselves.
I am assuming that this device has a separate USB2 hub and USB3 hub looking at the output.
So VIA Labs is the hub right?? Realtek is the ethernet. Intel chipset in use?
Maybe you need to work on devd and make the USB3 hub launch first like the hot plug output you show(ugen 0.4)..
Perhaps the Realtek hangs off the USB3 bus(Looking at the spd=SUPER (5.0Gbps)).


----------



## ronaldlees (May 12, 2018)

I seem to have troubles with some of the regular Realtek adapters I've used recently.  In your case you're using a non-regular one, so I'd think troubles might be amplified.  Back in the bad old days I used a lot of cheapo 8139, which were "OK" - but I don't find that to be the case anymore with the newer sets.  Just a personal opinion based on the randomly selected devices I happen to have, when used with my usual assortment of arcane operating systems.   Whenever I need to do USB/Ethernet I use something with the ASIX chipsets. They put all the USB and Ethernet components into one ASIC.  The drivers seem to work fine on both Linux and FreeBSD.  Is there any reason you absolutely *need* to use that hub?

BTW, on a laptop it's a very good idea to use a USB/Ethernet adapter.  Your ISP could possibly collect hardware addresses (depends on which ISP), and those could be used to track you if you've always used built-in adapters.  It's a good idea to shield your native device, and use a separate WiFi adapter for home use - for the same reason.


----------



## mahashakti89 (May 12, 2018)

Phishfry said:


> Silly question but why are you using USB Ethernet?
> Is the laptops onboard ethernet broken or are you needing 2 interfaces?


There is no RJ45 on the laptop. I have to use the hub.

Regards


----------



## mahashakti89 (May 12, 2018)

ronaldlees said:


> I seem to have troubles with some of the regular Realtek adapters I've used recently.  In your case you're using a non-regular one, so I'd think troubles might be amplified.  Back in the bad old days I used a lot of cheapo 8139, which were "OK" - but I don't find that to be the case anymore with the newer sets.  Just a personal opinion based on the randomly selected devices I happen to have, when used with my usual assortment of arcane operating systems.   Whenever I need to do USB/Ethernet I use something with the ASIX chipsets. They put all the USB and Ethernet components into one ASIC.  The drivers seem to work fine on both Linux and FreeBSD.  Is there any reason you absolutely *need* to use that hub?



Looking for ASIX chipsets ... Any particular brand to recommend ?

Regards


----------



## tingo (May 13, 2018)

usb-hubs-with-extras come in different variants, some work better than others. As with other usb devices, you won't know which until you plug it into a machine. Here is the /var/log/messages output from one:

```
May 13 14:52:18 kg-z30b kernel: ugen0.5: <GenesysLogic USB2.0 Hub> at usbus0
May 13 14:52:18 kg-z30b kernel: uhub2 on uhub0
May 13 14:52:18 kg-z30b kernel: uhub2: <GenesysLogic USB2.0 Hub, class 9/0, rev 2.10/92.24, addr 4> on usbus0
May 13 14:52:18 kg-z30b kernel: uhub2: MTT enabled
May 13 14:52:18 kg-z30b kernel: uhub2: 4 ports with 1 removable, self powered
May 13 14:52:19 kg-z30b kernel: ugen0.6: <Realtek USB 10100 LAN> at usbus0
May 13 14:52:20 kg-z30b kernel: ugen0.7: <GenesysLogic USB3.0 Hub> at usbus0
May 13 14:52:20 kg-z30b kernel: uhub3 on uhub0
May 13 14:52:20 kg-z30b kernel: uhub3: <GenesysLogic> on usbus0
May 13 14:52:20 kg-z30b kernel: uhub3: 4 ports with 1 removable, self powered
May 13 14:52:20 kg-z30b kernel: ure0 on uhub2
May 13 14:52:20 kg-z30b kernel: ure0: <Realtek USB 10100 LAN, class 0/0, rev 2.10/20.00, addr 5> on usbus0
May 13 14:52:20 kg-z30b root: Unknown USB device: vendor 0x04f2 product 0xb3b2 bus uhub0
May 13 14:52:20 kg-z30b root: Unknown USB device: vendor 0x04f2 product 0xb3b2 bus uhub0
May 13 14:52:21 kg-z30b kernel: miibus0: <MII bus> on ure0
May 13 14:52:21 kg-z30b kernel: rlphy0: <RTL8201E 10/100 media interface> PHY 0 on miibus0
May 13 14:52:21 kg-z30b kernel: rlphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
May 13 14:52:21 kg-z30b kernel: ue0: <USB Ethernet> on ure0
May 13 14:52:21 kg-z30b kernel: ue0: Ethernet address: 00:e0:4c:36:08:f8
May 13 14:52:21 kg-z30b kernel: ue0: link state changed to DOWN
```
it has 3 usb ports and a Ethernet port on it. It is labeled

```
USB Multi-function Lan Adapter
USB Ethernet and 3.0 HUB
YS-LAN37 RT8152B
```
The machine runs

```
root@kg-z30b# uname -a
FreeBSD kg-z30b.kg4.no 11.2-PRERELEASE FreeBSD 11.2-PRERELEASE #2 r333274: Sun May  6 01:03:11 CEST 2018
     root@kg-z30b.kg4.no:/usr/obj/usr/src/sys/GENERIC  amd64
```
HTH


----------



## mahashakti89 (May 13, 2018)

Thanks for your answer .... I will give it a try.

Regards


----------

