non-busybox dhcp clients (was: PATCH: ifupdown.c, udhcpc, and standalone shell)

Eric Spakman E.Spakman at inter.nl.net
Tue Oct 3 18:43:11 UTC 2006


Hi Gabriel,

That would make me and the LEAF project very happy ;-)

Regards,
Eric


> On Mon, Oct 02, 2006 at 10:57:02PM +0200, Denis Vlasenko wrote:
>
>> Applied.
>> Please send diff -u patch next time.
>>
>
> Denis,
>
>
> Thanks -- this works fine for me now.
>
>
> As for Eric, I guess what would *really* make him happy is something
> like this:
>
> #ifdef CONFIG_APP_UDHCPC
> execute built-in udhcpc only #else
> go down the list of hardcoded clients, and don't give any warnings #endif
>
>
> So, I've included a patch against svn 16294 which causes ifupdown to
> do just that. I don't mind it, it would make Eric happy :) so unless you
> object to #ifdef's or, more importantly, the return of hardcoded paths,
> please apply it...
>
> Thanks,
> Gabriel
>
>
>
> diff -NarU5 busybox-svn-16294.orig/networking/ifupdown.c
> busybox-svn-16294/networking/ifupdown.c ---
> busybox-svn-16294.orig/networking/ifupdown.c	2006-10-03
> 13:01:04.000000000 -0400
> +++ busybox-svn-16294/networking/ifupdown.c	2006-10-03 13:42:30.000000000
> -0400
> @@ -448,47 +448,66 @@
> result += execute("ifconfig %iface% down", ifd, exec); #endif
> return ((result == 2) ? 2 : 0); }
>
>
> +#ifndef CONFIG_APP_UDHCPC
> +/* only needed for hardcoded dhcp client checks if udhcpc not built in */
>  +static int execable(char *program)
> +{
> +    struct stat buf;
> +    if (stat(program, &buf) == 0 &&
> +		S_ISREG(buf.st_mode) && (S_IXUSR & buf.st_mode)) return 1;
> +    return 0;
> +}
> +#endif
> +
> static int dhcp_up(struct interface_defn_t *ifd, execfn *exec) {
> -	if (execute("udhcpc -R -n -p /var/run/udhcpc.%iface%.pid -i %iface% "
> -			"[[-H %hostname%]] [[-c %clientid%]] [[-s %script%]]", ifd, exec))
> -		return 1;
> -
> -	/* 2006-09-30: The following are deprecated, and should eventually be
> -	 * removed. For non-busybox (i.e., other than udhcpc) clients, use
> -	 * 'iface foo inet manual' in /etc/network/interfaces, and supply
> -	 * start/stop commands explicitly via up/down. */
> -
> -	if (execute("pump -i %iface% [[-h %hostname%]] [[-l %leasehours%]]",
> -			ifd, exec)) return 1;
> -	if (execute("dhclient -pf /var/run/dhclient.%iface%.pid %iface%",
> -			ifd, exec)) return 1;
> -	if (execute("dhcpcd [[-h %hostname%]] [[-i %vendor%]] [[-I %clientid%]]
> "
> -			"[[-l %leasetime%]] %iface%", ifd, exec)) return 1;
> -
> +#ifdef CONFIG_APP_UDHCPC
> +	return execute("udhcpc -R -n -p /var/run/udhcpc.%iface%.pid "
> +			"-i %iface% [[-H %hostname%]] [[-c %clientid%]] [[-s %script%]]",
> +			ifd, exec);
> +#else
> +	if (execable("/sbin/udhcpc"))
> +		return execute("/sbin/udhcpc -R -n -p /var/run/udhcpc.%iface%.pid "
> +			"-i %iface% [[-H %hostname%]] [[-c %clientid%]] [[-s %script%]]",
> +			ifd, exec);
> +	if (execable("/sbin/pump"))
> +		return execute("pump -i %iface% [[-h %hostname%]] [[-l %leasehours%]]",
>  +			ifd, exec);
> +	if (execable("/sbin/dhclient"))
> +		return execute("dhclient -pf /var/run/dhclient.%iface%.pid %iface%",
> +			ifd, exec);
> +	if (execable("/sbin/dhcpcd"))
> +		return execute("dhcpcd [[-h %hostname%]] [[-i %vendor%]] "
> +			"[[-I %clientid%]] [[-l %leasetime%]] %iface%",
> +			ifd, exec);
> +	bb_error_msg("No dhcp clients found.");
> return 0; +#endif
> }
>
>
> static int dhcp_down(struct interface_defn_t *ifd, execfn *exec) {
> -	if (execute("kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null",
> -			ifd, exec)) return 1;
> -
> -	/* 2006-09-30: The following are deprecated, and should eventually be
> -	 * removed. For non-busybox (i.e., other than udhcpc) clients, use
> -	 * 'iface foo inet manual' in /etc/network/interfaces, and supply
> -	 * start/stop commands explicitly via up/down. */
> -
> -	if (execute("pump -i %iface% -k", ifd, exec)) return 1;
> -	if (execute("kill -9 `cat /var/run/dhclient.%iface%.pid` 2>/dev/null",
> -			ifd, exec)) return 1;
> -	if (execute("dhcpcd -k %iface%", ifd, exec)) return 1;
> -
> +#ifdef CONFIG_APP_UDHCPC
> +	return execute("kill -TERM "
> +			"`cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
> +#else
> +	if (execable("/sbin/udhcpc"))
> +		return execute("kill -TERM "
> +			"`cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
> +	if (execable("/sbin/pump"))
> +		return execute("pump -i %iface% -k", ifd, exec);
> +	if (execable("/sbin/dhclient"))
> +		return execute("kill -9 "
> +			"`cat /var/run/dhclient.%iface%.pid` 2>/dev/null", ifd, exec);
> +	if (execable("/sbin/dhcpcd"))
> +		return execute("dhcpcd -k %iface%", ifd, exec);
> +	bb_error_msg("No dhcp clients found. Using static interface shutdown.");
>  return static_down(ifd, exec); +#endif
> }
>
>
> static int manual_up_down(struct interface_defn_t *ifd, execfn *exec) {
> return 1;
>





More information about the busybox mailing list