0011-netifd-ubus-add-interface-method-to-trigger-renew-event.patch 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Wed, 12 Apr 2017 02:31:12 +0200
  3. Subject: netifd: ubus: add interface method to trigger renew event
  4. diff --git a/package/network/config/netifd/patches/0001-ubus-add-interface-method-to-trigger-renew-event.patch b/package/network/config/netifd/patches/0001-ubus-add-interface-method-to-trigger-renew-event.patch
  5. new file mode 100644
  6. index 0000000000000000000000000000000000000000..1f59498d421b7e1d3e76a1a38f604181d11c4649
  7. --- /dev/null
  8. +++ b/package/network/config/netifd/patches/0001-ubus-add-interface-method-to-trigger-renew-event.patch
  9. @@ -0,0 +1,73 @@
  10. +From 8b39c2fce4c1da3f3dcd4c6fd305c124714839e8 Mon Sep 17 00:00:00 2001
  11. +Message-Id: <8b39c2fce4c1da3f3dcd4c6fd305c124714839e8.1491956920.git.mschiffer@universe-factory.net>
  12. +From: Matthias Schiffer <mschiffer@universe-factory.net>
  13. +Date: Wed, 12 Apr 2017 02:25:33 +0200
  14. +Subject: [PATCH] ubus: add interface method to trigger renew event
  15. +
  16. +proto-shell handlers may implement all kinds of renew handlers, there
  17. +should be a way to explicitly trigger such a renew.
  18. +
  19. +Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
  20. +---
  21. + interface.c | 8 ++++++++
  22. + interface.h | 1 +
  23. + ubus.c | 14 ++++++++++++++
  24. + 3 files changed, 23 insertions(+)
  25. +
  26. +--- a/interface.c
  27. ++++ b/interface.c
  28. +@@ -1076,6 +1076,14 @@ interface_set_down(struct interface *ifa
  29. + return 0;
  30. + }
  31. +
  32. ++int interface_renew(struct interface *iface)
  33. ++{
  34. ++ if (iface->state == IFS_TEARDOWN || iface->state == IFS_DOWN)
  35. ++ return -1;
  36. ++
  37. ++ return interface_proto_event(iface->proto, PROTO_CMD_RENEW, false);
  38. ++}
  39. ++
  40. + void
  41. + interface_start_pending(void)
  42. + {
  43. +--- a/interface.h
  44. ++++ b/interface.h
  45. +@@ -184,6 +184,7 @@ void interface_set_available(struct inte
  46. + int interface_set_up(struct interface *iface);
  47. + int interface_set_down(struct interface *iface);
  48. + void __interface_set_down(struct interface *iface, bool force);
  49. ++int interface_renew(struct interface *iface);
  50. +
  51. + void interface_set_main_dev(struct interface *iface, struct device *dev);
  52. + void interface_set_l3_dev(struct interface *iface, struct device *dev);
  53. +--- a/ubus.c
  54. ++++ b/ubus.c
  55. +@@ -376,6 +376,19 @@ netifd_handle_down(struct ubus_context *
  56. + return 0;
  57. + }
  58. +
  59. ++static int
  60. ++netifd_handle_renew(struct ubus_context *ctx, struct ubus_object *obj,
  61. ++ struct ubus_request_data *req, const char *method,
  62. ++ struct blob_attr *msg)
  63. ++{
  64. ++ struct interface *iface;
  65. ++
  66. ++ iface = container_of(obj, struct interface, ubus);
  67. ++ interface_renew(iface);
  68. ++
  69. ++ return 0;
  70. ++}
  71. ++
  72. + static void
  73. + netifd_add_interface_errors(struct blob_buf *b, struct interface *iface)
  74. + {
  75. +@@ -912,6 +925,7 @@ netifd_handle_set_data(struct ubus_conte
  76. + static struct ubus_method iface_object_methods[] = {
  77. + { .name = "up", .handler = netifd_handle_up },
  78. + { .name = "down", .handler = netifd_handle_down },
  79. ++ { .name = "renew", .handler = netifd_handle_renew },
  80. + { .name = "status", .handler = netifd_handle_status },
  81. + { .name = "prepare", .handler = netifd_handle_iface_prepare },
  82. + { .name = "dump", .handler = netifd_handle_dump },