0096-netifd-Fix-triggering-of-interface-update-event.patch 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. From: Jan-Philipp Litza <janphilipp@litza.de>
  2. Date: Fri, 10 Mar 2017 00:21:24 +0100
  3. Subject: netifd: Fix triggering of interface update event
  4. In case the keep flag is set in proto_shell_update_link no interface
  5. update event is triggered when IPv4/6 addresses/routes/... are updated
  6. as the proto_event callback is not called due to keep being set.
  7. Unconditionally call the proto_event callback handler in proto_shell_update_link
  8. but let the proto_event callback handler; in this case interface_proto_event_cb,
  9. decide which actions need to be taken dependant on the interface state.
  10. In case the interface is already in the up state trigger an update event
  11. only if the interface updated flag actually indicates either an IP address/
  12. route/data change; before interface update events were actually sent wihtout
  13. any parameter change.
  14. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
  15. diff --git a/package/network/config/netifd/patches/001-interface-fix-triggering-of-interface-update-event.patch b/package/network/config/netifd/patches/001-interface-fix-triggering-of-interface-update-event.patch
  16. new file mode 100644
  17. index 0000000000000000000000000000000000000000..9eda2f59ea016cbbd370ad5d3589891c1ac7d18b
  18. --- /dev/null
  19. +++ b/package/network/config/netifd/patches/001-interface-fix-triggering-of-interface-update-event.patch
  20. @@ -0,0 +1,97 @@
  21. +From b8ef742bd04ebef324ae11aee56c6e1d2cb7e0ad Mon Sep 17 00:00:00 2001
  22. +From: Hans Dedecker <dedeckeh@gmail.com>
  23. +Date: Wed, 2 Nov 2016 09:22:10 +0100
  24. +Subject: [PATCH] interface: Fix triggering of interface update event
  25. +
  26. +In case the keep flag is set in proto_shell_update_link no interface
  27. +update event is triggered when IPv4/6 addresses/routes/... are updated
  28. +as the proto_event callback is not called due to keep being set.
  29. +
  30. +Unconditionally call the proto_event callback handler in proto_shell_update_link
  31. +but let the proto_event callback handler; in this case interface_proto_event_cb,
  32. +decide which actions need to be taken dependant on the interface state.
  33. +
  34. +In case the interface is already in the up state trigger an update event
  35. +only if the interface updated flag actually indicates either an IP address/
  36. +route/data change; before interface update events were actually sent wihtout
  37. +any parameter change.
  38. +
  39. +Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
  40. +---
  41. + interface.c | 9 ++++++---
  42. + interface.h | 2 +-
  43. + proto-shell.c | 7 +++----
  44. + 3 files changed, 10 insertions(+), 8 deletions(-)
  45. +
  46. +diff --git a/interface.c b/interface.c
  47. +index 5870422..a014111 100644
  48. +--- a/interface.c
  49. ++++ b/interface.c
  50. +@@ -693,7 +693,8 @@ interface_proto_event_cb(struct interface_proto_state *state, enum interface_pro
  51. + switch (ev) {
  52. + case IFPEV_UP:
  53. + if (iface->state != IFS_SETUP) {
  54. +- interface_event(iface, IFEV_UPDATE);
  55. ++ if (iface->state == IFS_UP && iface->updated)
  56. ++ interface_event(iface, IFEV_UPDATE);
  57. + return;
  58. + }
  59. +
  60. +@@ -1091,10 +1092,12 @@ set_config_state(struct interface *iface, enum interface_config_state s)
  61. + }
  62. +
  63. + void
  64. +-interface_update_start(struct interface *iface)
  65. ++interface_update_start(struct interface *iface, const bool keep_old)
  66. + {
  67. + iface->updated = 0;
  68. +- interface_ip_update_start(&iface->proto_ip);
  69. ++
  70. ++ if (!keep_old)
  71. ++ interface_ip_update_start(&iface->proto_ip);
  72. + }
  73. +
  74. + void
  75. +diff --git a/interface.h b/interface.h
  76. +index aa2085d..7d5b309 100644
  77. +--- a/interface.h
  78. ++++ b/interface.h
  79. +@@ -199,7 +199,7 @@ void interface_add_error(struct interface *iface, const char *subsystem,
  80. + int interface_add_data(struct interface *iface, const struct blob_attr *data);
  81. + int interface_parse_data(struct interface *iface, const struct blob_attr *attr);
  82. +
  83. +-void interface_update_start(struct interface *iface);
  84. ++void interface_update_start(struct interface *iface, const bool keep_old);
  85. + void interface_update_complete(struct interface *iface);
  86. +
  87. + void interface_start_pending(void);
  88. +diff --git a/proto-shell.c b/proto-shell.c
  89. +index 998a44c..ef56aa8 100644
  90. +--- a/proto-shell.c
  91. ++++ b/proto-shell.c
  92. +@@ -538,10 +538,10 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data,
  93. + return UBUS_STATUS_UNKNOWN_ERROR;
  94. +
  95. + device_set_present(dev, true);
  96. +-
  97. +- interface_update_start(iface);
  98. + }
  99. +
  100. ++ interface_update_start(iface, keep);
  101. ++
  102. + proto_apply_ip_settings(iface, data, addr_ext);
  103. +
  104. + if ((cur = tb[NOTIFY_ROUTES]) != NULL)
  105. +@@ -562,8 +562,7 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data,
  106. + interface_update_complete(state->proto.iface);
  107. +
  108. + if ((state->sm != S_SETUP_ABORT) && (state->sm != S_TEARDOWN)) {
  109. +- if (!keep)
  110. +- state->proto.proto_event(&state->proto, IFPEV_UP);
  111. ++ state->proto.proto_event(&state->proto, IFPEV_UP);
  112. + state->sm = S_IDLE;
  113. + }
  114. +
  115. +--
  116. +2.1.4
  117. +