Bug 14136

Summary: udhcpc.script file cannot assign a right action to hook files
Product: Busybox Reporter: wangwangqi2011
Component: NetworkingAssignee: unassigned
Status: NEW ---    
Severity: major CC: busybox-cvs
Priority: P5    
Version: 1.33.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description wangwangqi2011 2021-08-16 03:07:46 UTC
When passing `bound` or `renew` parameter to udhcpc.script, these parameters are wiped out before hooking files with them. So an empty string passed to these hooked files, which failed to configure some necessary parameters.

Following are some detailed info:

Version of Buildroot: 2021.02.2
Version of Busybox: 1.33.0

File Location: package/busybox/udhcpc.script

Description: The DHCP action is empty after the 'deconfig'. Actually, it should be 'bound'(or 'renew'). As a result, the hook operation at the end of this script will not pass the right parameters to the relevant files.
 
Cause: When the condition of Line.67 is true, then Line.75 will change '$@', after the Line.78 shifts all the parameters, the '$@' becomes empty. At last, an empty '$@' is passed to the hook operation, which will cause problems.

Fix: At first, store the '$@' to a variable and at last, use the variable instead of '$@' to get the action parameter. 

Serial Logs from GCP:
Starting network: udhcpc: started, v1.33.0
DHCP action="deconfig" with variables 
udhcpc: sending discover
udhcpc: sending select for **.**.**.**
udhcpc: lease of **.**.**.** obtained, lease time *****
deleting routers
route: SIOCADDRT: Invalid argument
adding dns **.**.**.**
DHCP action="" with variables 
OK

From the above log, we can see obviously that the DHCP action is an empty string, which should be 'bound' or 'renew'.