PATCH: ifupdown.c, udhcpc, and standalone shell

Eric Spakman E.Spakman at inter.nl.net
Thu Sep 28 21:39:07 UTC 2006


Hi Gabriel,
>

> Here's my proposal:
>
>
> static int dhcp_up(struct interface_defn_t *ifd, execfn *exec) {
> int i;
>
> for (i = 0; i < ifd->n_options; i++) { if (strcmp(ifd->option[i].name,
> "dhcp-start-cmd") == 0) {
> return execute(ifd->option[i].value, ifd, exec); }
> }
>
>
> /* old calls for "blessed" clients may or may not go here for
> backward compatibility */
>
> return 0; }
>
>
> static int dhcp_down(struct interface_defn_t *ifd, execfn *exec) {
> int i;
>
> for (i = 0; i < ifd->n_options; i++) { if (strcmp(ifd->option[i].name,
> "dhcp-stop-cmd") == 0) {
> return execute(ifd->option[i].value, ifd, exec); }
> }
>
>
> /* old calls for "blessed" clients may or may not go here for
> backward compatibility */
>
> return static_down(ifd, exec); }
>
>
> My /etc/network/interfaces file looks like this:
>
>
> auto lo iface lo inet loopback
>
> auto eth0 iface eth0 inet dhcp dhcp-start-cmd udhcpc -s
> /etc/network/udhcpc.script -n -p /var/run/udhcpc.%iface%.pid -i %iface%
> [[-H %hostname%]] [[-c %clientid%]]
> dhcp-stop-cmd kill -USR2 `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null ;
> sleep 2 ; kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null
>
> This also solves my other problem (that I hate having udhcpc look for
> its script in /usr/share/udhcpc/default.script). Now I can simply pass '-s
> path/to/script' in /etc/network/interfaces...
>
> The old 'Let's all go down the list of blessed clients' code may or
> may not be included for backward compatibility...
>
> I've attached my version of ifupdown.c.gz, check it out and let me
> know if it's palatable :)
>

That looks pretty complicated from an users point of view and I also think
it's not necessary. Why not keep the current dhcp code as is (before the
patch) and implement a "manual" method (like in the upstream code):

+static int manual_up_down(struct interface_defn_t *ifd, execfn *exec)
+{
+       return(1);
+}
+
 static struct method_t methods[] =
 {
        { "wvdial", wvdial_up, wvdial_down, },
@@ -607,6 +612,7 @@
        { "bootp", bootp_up, static_down, },
        { "dhcp", dhcp_up, dhcp_down, },
        { "loopback", loopback_up, loopback_down, },
+       { "manual", manual_up_down, manual_up_down, },
 };

In this manual mode you can call your own dhcp client scripting (like your
example). This can also be used for other things than dhcp, so is a more
generic solution.


> Cheers,
> Gabriel
>
Cheers,
Eric





More information about the busybox mailing list