ifupdown_design.txt 1.5 KB

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