WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Busybox udhcpc sometimes fails to connect to modern router  (Read 185 times)

Offline polikuo

  • Sr. Member
  • ****
  • Posts: 414
Busybox udhcpc sometimes fails to connect to modern router
« on: October 16, 2020, 10:50:57 PM »
Hi, I'm not sure if this belongs in TCB or TCE issue.  :-\
Since I'm using piCore beta release, it could be in there, too.

Anyway, I have a relatively modern router: TP-LINK Mesh WDR7650

It refuses to assign an IP address to piCore from time to time.

Manually type
Code: [Select]
sudo pkill udhcpc
sudo udhcpc eth0
would start an endless request loop.

This behavior never happens on older routers.

A TCB busybox issue maybe ?

Not sure about the other architectures.

When I switch to Raspbian, the network is back to normal.

Then I see they're using a different DHCP client.

I download the source and compile it.

Using this client, I manage to resolve the network problem.

If I were to submit this extension, what value should I choose for "--localstatedir" in configure ?

The default path is /var (It creates empty directory /var/db/dhcpcd for later use)

Should I use /usr/local/var instead ?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 12490
Re: Busybox udhcpc sometimes fails to connect to modern router
« Reply #1 on: October 16, 2020, 11:19:52 PM »
Please use /var

Offline polikuo

  • Sr. Member
  • ****
  • Posts: 414
Re: Busybox udhcpc sometimes fails to connect to modern router
« Reply #2 on: October 17, 2020, 03:32:12 AM »
Please use /var

Hi, before I submit the thing.

There's an option, "--privsepuser", in the configure script.

The default value is "dhcpcd".

When you start the client, it returns: [no such user dhcpcd]
Quote
CFLAGS='-march=armv8-a+crc -mtune=cortex-a72 -Os -pipe' LDFLAGS='-Wl,-O1' ./configure --prefix='/usr/local' --libexecdir='/usr/local/lib/dhcpcd'
Code: [Select]
tc@box:~$ sudo /tmp/dhcpcd/usr/local/sbin/dhcpcd
no such user dhcpcd
main: control_open: Connection refused
dhcpcd-9.3.1 starting
DUID 00:01:00:01:27:1d:77:30:dc:a6:32:37:c7:eb
eth0: IAID 32:37:c7:eb
eth0: rebinding lease of 192.168.0.101
eth0: leased 192.168.0.101 for 7200 seconds
eth0: adding route to 192.168.0.0/24
eth0: adding default route via 192.168.0.1
forked to background, child pid 9294
tc@box:~$
The process is forked to background.

I recompiled with "--privsepuser=tc":
Quote
CFLAGS='-march=armv8-a+crc -mtune=cortex-a72 -Os -pipe' LDFLAGS='-Wl,-O1' ./configure --prefix='/usr/local' --libexecdir='/usr/local/lib/dhcpcd' --privsepuser='tc'
Code: [Select]
tc@box:~$ sudo /tmp/usrtc/usr/local/sbin/dhcpcd
dhcpcd-9.3.1 starting
DUID 00:01:00:01:27:1d:77:30:dc:a6:32:37:c7:eb
eth0: IAID 32:37:c7:eb
ps_ctl_listen: read: Success

The process is NOT backgrounded.
The console hangs.

Does it has anything to do with openssh "sshd privsep" ?
I think I've seen it somewhere.

What should I do ?
Please advice.
« Last Edit: October 17, 2020, 03:33:57 AM by polikuo »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 8223
Re: Busybox udhcpc sometimes fails to connect to modern router
« Reply #3 on: October 17, 2020, 04:53:44 AM »
Hi polikuo
If you look at at  /etc/init.d/dhcp.sh  you'll see that Roberts included this at the end of his command:
Code: [Select]
/dev/null 2>&1 &

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 8223
Re: Busybox udhcpc sometimes fails to connect to modern router
« Reply #4 on: October 17, 2020, 05:01:55 AM »
Hi polikuo
Hi, I'm not sure if this belongs in TCB or TCE issue.  :-\
Since I'm using piCore beta release, it could be in there, too.
Since it's part of  busybox  TCB Bugs sounds appropriate. If you find only piCore Beta is affected, it can be moved later on.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 634
Re: Busybox udhcpc sometimes fails to connect to modern router
« Reply #5 on: October 17, 2020, 05:41:42 AM »
Normally privesep needs to point to a user with no login shell.

Use “nobody”.

Offline polikuo

  • Sr. Member
  • ****
  • Posts: 414
Re: Busybox udhcpc sometimes fails to connect to modern router
« Reply #6 on: October 17, 2020, 05:47:14 AM »
Code: [Select]
/dev/null 2>&1 &

Sure, I know that it's forked, but if the router assigns an IP, udhcpc will background itself.

Try it yourself, kill the running udhcp, then start it again without '&'
Code: [Select]
tc@box:~$ sudo udhcpc
udhcpc: started, v1.31.1
udhcpc: sending discover
udhcpc: sending select for 192.168.0.101
udhcpc: lease of 192.168.0.101 obtained, lease time 7200
deleting routers
route: SIOCDELRT: No such process
adding dns 192.168.1.1
adding dns 192.168.0.1
tc@box:~$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=115 time=11.945 ms
64 bytes from 8.8.8.8: seq=1 ttl=115 time=8.994 ms
64 bytes from 8.8.8.8: seq=2 ttl=115 time=9.137 ms
^C
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 8.994/10.025/11.945 ms

Offline polikuo

  • Sr. Member
  • ****
  • Posts: 414
Re: Busybox udhcpc sometimes fails to connect to modern router
« Reply #7 on: October 17, 2020, 06:09:32 AM »
Normally privesep needs to point to a user with no login shell.

Use “nobody”.

I think it's working ?

Code: [Select]
root@box:~# pkill udhcpc
root@box:~# dhcpcd
refusing chroot: nobody: /nonexistent
dhcpcd-9.3.1 starting
DUID 00:01:00:01:27:1d:a7:f6:dc:a6:32:37:c7:eb
eth0: IAID 32:37:c7:eb
eth0: soliciting a DHCP lease
eth0: offered 192.168.0.101 from 192.168.0.1
eth0: leased 192.168.0.101 for 7200 seconds
eth0: adding route to 192.168.0.0/24
eth0: adding default route via 192.168.0.1
forked to background, child pid 6774
root@box:~# ifconfig
eth0      Link encap:Ethernet  HWaddr DC:A6:32:37:C7:EB 
          inet addr:192.168.0.101  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:251 errors:0 dropped:0 overruns:0 frame:0
          TX packets:83 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:19725 (19.2 KiB)  TX bytes:5996 (5.8 KiB)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:200 (200.0 B)  TX bytes:200 (200.0 B)

root@box:~# ping -c 3 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=115 time=11.520 ms
64 bytes from 8.8.8.8: seq=1 ttl=115 time=10.977 ms
64 bytes from 8.8.8.8: seq=2 ttl=115 time=11.002 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 10.977/11.166/11.520 ms
root@box:~#

If you think my configs are OK, then I'll mail it.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 634
Re: Busybox udhcpc sometimes fails to connect to modern router
« Reply #8 on: October 17, 2020, 08:09:56 AM »
I might have steered you wrong.  Looking at the source https://roy.marples.name/cgit/dhcpcd.git/tree/src/privsep.c#n85

That printed message would mean in init error.  Looks like it needs a user that can spawn a chroot environment.   The requirements are not clear.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10289
Re: Busybox udhcpc sometimes fails to connect to modern router
« Reply #9 on: October 17, 2020, 10:03:29 AM »
For busybox bugs, since bb is easy to build, you could try git busybox, and if it still happens report a bug to them.
The only barriers that can stop you are the ones you create yourself.

Offline polikuo

  • Sr. Member
  • ****
  • Posts: 414
Re: Busybox udhcpc sometimes fails to connect to modern router
« Reply #10 on: October 17, 2020, 07:08:09 PM »
I might have steered you wrong.  Looking at the source https://roy.marples.name/cgit/dhcpcd.git/tree/src/privsep.c#n85

That printed message would mean in init error.  Looks like it needs a user that can spawn a chroot environment.   The requirements are not clear.

I have no idea what privesep do, but I found this on LFS

Have a look at the Installation of dhcpcd section

Do you know what they're doing there ? (groupadd, useradd, chown)

Does 'nobody' meets the requirement ?

On the other hand, I can just '--disable-privsep' when configuring and forget about it altogether  :P