701-reload_config_inline.patch 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. From: Felix Fietkau <[email protected]>
  2. Date: Fri, 26 May 2023 10:23:59 +0200
  3. Subject: [PATCH] Add ucode support, use ucode for the main ubus object #2
  4. This implements vastly improved dynamic configuration reload support.
  5. It can handle configuration changes on individual wifi interfaces, as well
  6. as adding/removing interfaces.
  7. --- a/hostapd/config_file.c
  8. +++ b/hostapd/config_file.c
  9. @@ -4983,7 +4983,14 @@ struct hostapd_config * hostapd_config_r
  10. int errors = 0;
  11. size_t i;
  12. - f = fopen(fname, "r");
  13. + if (!strncmp(fname, "data:", 5)) {
  14. + f = fmemopen((void *)(fname + 5), strlen(fname + 5), "r");
  15. + fname = "<inline>";
  16. + } else {
  17. + f = fopen(fname, "r");
  18. + }
  19. + wpa_printf(MSG_INFO, "Configuration file: Reading configuration file '%s'",
  20. + fname);
  21. if (f == NULL) {
  22. wpa_printf(MSG_ERROR, "Could not open configuration file '%s' "
  23. "for reading.", fname);
  24. --- a/wpa_supplicant/config_file.c
  25. +++ b/wpa_supplicant/config_file.c
  26. @@ -390,8 +390,13 @@ struct wpa_config * wpa_config_read(cons
  27. while (identity_tail && identity_tail->next)
  28. identity_tail = identity_tail->next;
  29. + if (!strncmp(name, "data:", 5)) {
  30. + f = fmemopen((void *)(name + 5), strlen(name + 5), "r");
  31. + name = "<inline>";
  32. + } else {
  33. + f = fopen(name, "r");
  34. + }
  35. wpa_printf(MSG_DEBUG, "Reading configuration file '%s'", name);
  36. - f = fopen(name, "r");
  37. if (f == NULL) {
  38. wpa_printf(MSG_ERROR, "Failed to open config file '%s', "
  39. "error: %s", name, strerror(errno));
  40. --- a/hostapd/main.c
  41. +++ b/hostapd/main.c
  42. @@ -406,7 +406,11 @@ hostapd_interface_init(struct hapd_inter
  43. struct hostapd_iface *iface;
  44. int k;
  45. - wpa_printf(MSG_DEBUG, "Configuration file: %s", config_fname);
  46. + if (!strncmp(config_fname, "data:", 5)) {
  47. + wpa_printf(MSG_DEBUG, "Configuration file: %s", "<inline>");
  48. + } else {
  49. + wpa_printf(MSG_DEBUG, "Configuration file: %s", config_fname);
  50. + }
  51. iface = hostapd_init(interfaces, config_fname);
  52. if (!iface)
  53. return NULL;
  54. --- a/src/ap/hostapd.c
  55. +++ b/src/ap/hostapd.c
  56. @@ -3399,8 +3399,13 @@ hostapd_interface_init_bss(struct hapd_i
  57. }
  58. }
  59. - wpa_printf(MSG_INFO, "Configuration file: %s (phy %s)%s",
  60. - config_fname, phy, iface ? "" : " --> new PHY");
  61. + if (!strncmp(config_fname, "data:", 5)) {
  62. + wpa_printf(MSG_INFO, "Configuration file: %s (phy %s)%s",
  63. + "<inline>", phy, iface ? "" : " --> new PHY");
  64. + } else {
  65. + wpa_printf(MSG_INFO, "Configuration file: %s (phy %s)%s",
  66. + config_fname, phy, iface ? "" : " --> new PHY");
  67. + }
  68. conf = interfaces->config_read_cb(config_fname);
  69. if (!conf)