blob: 8ab4e51adc444c2efb33fc91c5edffdb11cc4e03 [file] [log] [blame]
Denis Vlasenko6dd333d2007-08-25 22:16:04 +00001This document is meant to convince you to not use ifup/ifdown.
2
3
4The general problem with ifupdown is that it is "copulated in vertical
5fashion" by design. It tries to do the job of shell script in C,
6and this is invariably doomed to fail. You need ifup/ifdown
7to be adaptable by local admins, and C is an extremely poor choice
8for that.
9
10We are doomed to have problems with ifup/ifdown. Just look as this code:
11
12static const struct dhcp_client_t ext_dhcp_clients[] = {
Denys Vlasenkob4d03512010-07-26 12:47:36 +020013 { "dhcpcd", "<up cmd>", "<down cmd>" },
14 { "dhclient", ........ },
15 { "pump", ........ },
16 { "udhcpc", ........ },
Denis Vlasenko6dd333d2007-08-25 22:16:04 +000017};
18
19static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
20{
21#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
Denys Vlasenkob4d03512010-07-26 12:47:36 +020022 int i ;
23 for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) {
24 if (exists_execable(ext_dhcp_clients[i].name))
25 return execute(ext_dhcp_clients[i].stopcmd, ifd, exec);
26 }
27 bb_error_msg("no dhcp clients found, using static interface shutdown");
28 return static_down(ifd, exec);
Denys Vlasenko4662de02009-12-11 02:21:10 +010029#elif ENABLE_UDHCPC
Denys Vlasenkob4d03512010-07-26 12:47:36 +020030 return execute("kill "
31 "`cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
Denis Vlasenko6dd333d2007-08-25 22:16:04 +000032#else
Denys Vlasenkob4d03512010-07-26 12:47:36 +020033 return 0; /* no dhcp support */
Denis Vlasenko6dd333d2007-08-25 22:16:04 +000034#endif
35}
36
37How the hell it is supposed to work reliably this way? Just imagine that
38admin is using pump and ifup/ifdown. It works. Then, for whatever reason,
39admin installs dhclient, but does NOT use it. ifdown will STOP WORKING,
40just because it will see installed dhclient binary in e.g. /usr/bin/dhclient!
41This is stupid.
42
43I seriously urge people to not use ifup/ifdown.
44Use something less brain damaged.