224-atm_hotplug.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. Index: linux-2.4.35.4/include/linux/atmdev.h
  2. ===================================================================
  3. --- linux-2.4.35.4.orig/include/linux/atmdev.h
  4. +++ linux-2.4.35.4/include/linux/atmdev.h
  5. @@ -400,6 +400,7 @@ extern rwlock_t vcc_sklist_lock;
  6. struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops,
  7. int number,atm_dev_flags_t *flags); /* number == -1: pick first available */
  8. struct atm_dev *atm_dev_lookup(int number);
  9. +void atm_dev_set_link_status(struct atm_dev *dev, int status);
  10. void atm_dev_deregister(struct atm_dev *dev);
  11. void shutdown_atm_dev(struct atm_dev *dev);
  12. void vcc_insert_socket(struct sock *sk);
  13. Index: linux-2.4.35.4/net/atm/resources.c
  14. ===================================================================
  15. --- linux-2.4.35.4.orig/net/atm/resources.c
  16. +++ linux-2.4.35.4/net/atm/resources.c
  17. @@ -10,6 +10,7 @@
  18. #include <linux/sonet.h>
  19. #include <linux/kernel.h> /* for barrier */
  20. #include <linux/module.h>
  21. +#include <linux/kmod.h>
  22. #include <linux/bitops.h>
  23. #include <net/sock.h> /* for struct sock */
  24. #include <asm/segment.h> /* for get_fs_long and put_fs_long */
  25. @@ -70,6 +71,44 @@ struct atm_dev *atm_dev_lookup(int numbe
  26. return dev;
  27. }
  28. +#ifdef CONFIG_HOTPLUG
  29. +static void atm_run_sbin_hotplug(struct atm_dev *dev, char *action)
  30. +{
  31. + char *argv[3], *envp[5], ifname[12 + IFNAMSIZ], atmname[255], action_str[32];
  32. + int i;
  33. +
  34. + sprintf(ifname, "INTERFACE=atm%d", dev->number);
  35. + sprintf(atmname, "ATMDRIVER=%s", dev->type);
  36. + sprintf(action_str, "ACTION=%s", action);
  37. +
  38. + i = 0;
  39. + argv[i++] = hotplug_path;
  40. + argv[i++] = "net";
  41. + argv[i] = 0;
  42. +
  43. + i = 0;
  44. + /* minimal command environment */
  45. + envp [i++] = "HOME=/";
  46. + envp [i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
  47. + envp [i++] = ifname;
  48. + envp [i++] = atmname;
  49. + envp [i++] = action_str;
  50. + envp [i] = 0;
  51. +
  52. + return call_usermodehelper(argv [0], argv, envp);
  53. +}
  54. +#endif
  55. +
  56. +void atm_dev_set_link_status(struct atm_dev *dev, int status)
  57. +{
  58. +#ifdef CONFIG_HOTPLUG
  59. + if (status)
  60. + atm_run_sbin_hotplug(dev, "up");
  61. + else
  62. + atm_run_sbin_hotplug(dev, "down");
  63. +#endif
  64. +}
  65. +
  66. struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops,
  67. int number, atm_dev_flags_t *flags)
  68. {
  69. @@ -123,7 +162,10 @@ struct atm_dev *atm_dev_register(const c
  70. }
  71. }
  72. #endif
  73. -
  74. +#ifdef CONFIG_HOTPLUG
  75. + atm_run_sbin_hotplug(dev, "register");
  76. +#endif
  77. +
  78. return dev;
  79. }
  80. @@ -131,6 +173,10 @@ struct atm_dev *atm_dev_register(const c
  81. void atm_dev_deregister(struct atm_dev *dev)
  82. {
  83. unsigned long warning_time;
  84. +
  85. +#ifdef CONFIG_HOTPLUG
  86. + atm_run_sbin_hotplug(dev, "unregister");
  87. +#endif
  88. #ifdef CONFIG_PROC_FS
  89. if (dev->ops->proc_read)
  90. @@ -399,6 +445,7 @@ done:
  91. }
  92. +EXPORT_SYMBOL(atm_dev_set_link_status);
  93. EXPORT_SYMBOL(atm_dev_register);
  94. EXPORT_SYMBOL(atm_dev_deregister);
  95. EXPORT_SYMBOL(atm_dev_lookup);