0002-batman-adv-introduce-no_rebroadcast-option.patch 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Thu, 2 Apr 2015 20:24:14 +0200
  3. Subject: batman-adv: introduce 'no_rebroadcast' option
  4. diff --git a/batman-adv/files/lib/netifd/proto/batadv.sh b/batman-adv/files/lib/netifd/proto/batadv.sh
  5. index 632a209..01f567f 100644
  6. --- a/batman-adv/files/lib/netifd/proto/batadv.sh
  7. +++ b/batman-adv/files/lib/netifd/proto/batadv.sh
  8. @@ -6,16 +6,19 @@ init_proto "$@"
  9. proto_batadv_init_config() {
  10. proto_config_add_string "mesh"
  11. + proto_config_add_string "mesh_no_rebroadcast"
  12. }
  13. proto_batadv_setup() {
  14. local config="$1"
  15. local iface="$2"
  16. - local mesh
  17. - json_get_vars mesh
  18. + local mesh mesh_no_rebroadcast
  19. + json_get_vars mesh mesh_no_rebroadcast
  20. echo "$mesh" > "/sys/class/net/$iface/batman_adv/mesh_iface"
  21. + [ -n "$mesh_no_rebroadcast" ] && echo "$mesh_no_rebroadcast" > "/sys/class/net/$iface/batman_adv/no_rebroadcast"
  22. +
  23. proto_init_update "$iface" 1
  24. proto_send_update "$config"
  25. }
  26. diff --git a/batman-adv/patches/0001-batman-adv-introduce-no_rebroadcast-option.patch b/batman-adv/patches/0001-batman-adv-introduce-no_rebroadcast-option.patch
  27. new file mode 100644
  28. index 0000000..9fc9426
  29. --- /dev/null
  30. +++ b/batman-adv/patches/0001-batman-adv-introduce-no_rebroadcast-option.patch
  31. @@ -0,0 +1,172 @@
  32. +From 5ba3f1eac041857deabe39432fdfe1a584bbdd81 Mon Sep 17 00:00:00 2001
  33. +Message-Id: <5ba3f1eac041857deabe39432fdfe1a584bbdd81.1420645650.git.mschiffer@universe-factory.net>
  34. +From: =?UTF-8?q?Linus=20L=C3=BCssing?= <linus.luessing@web.de>
  35. +Date: Tue, 24 Sep 2013 04:36:27 +0200
  36. +Subject: [PATCH] batman-adv: introduce 'no_rebroadcast' option
  37. +MIME-Version: 1.0
  38. +Content-Type: text/plain; charset=UTF-8
  39. +Content-Transfer-Encoding: 8bit
  40. +
  41. +This patch introduces a new sysfs option named "no_rebroadcast" on
  42. +a per hard interface basis. It allows manually enabling a split-horizon
  43. +like behaviour for the layer 2 multicast payload frames, in that
  44. +incoming multicast payload frames on such a hard interface are only
  45. +being rebroadcasted on all interfaces except the incoming one instead
  46. +of being rebroadcasted on all interfaces.
  47. +
  48. +Such an option should only be enabled if you are certain that these
  49. +rebroadcasts are unnecessary. This is usually the case for instance
  50. +for point-to-point wifi longshots or wired links.
  51. +
  52. +This option can especially safe a significant amount of upload overhead
  53. +if the neighbourhood on a link is rather large, for instance in some
  54. +transitive, symmetric VPN configurations.
  55. +
  56. +Using this option wrongly will break your mesh network, use this option
  57. +wisely and at your own risk!
  58. +
  59. +Signed-off-by: Linus Lüssing <linus.luessing@web.de>
  60. +---
  61. + hard-interface.c | 2 ++
  62. + send.c | 4 ++++
  63. + sysfs-class-net-batman-adv | 10 ++++++++
  64. + sysfs.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++
  65. + types.h | 1 +
  66. + 5 files changed, 76 insertions(+)
  67. +
  68. +--- a/hard-interface.c
  69. ++++ b/hard-interface.c
  70. +@@ -592,6 +592,8 @@ batadv_hardif_add_interface(struct net_d
  71. + /* extra reference for return */
  72. + atomic_set(&hard_iface->refcount, 2);
  73. +
  74. ++ atomic_set(&hard_iface->no_rebroadcast, 0);
  75. ++
  76. + batadv_check_known_mac_addr(hard_iface->net_dev);
  77. + list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list);
  78. +
  79. +--- a/send.c
  80. ++++ b/send.c
  81. +@@ -513,6 +513,10 @@ static void batadv_send_outstanding_bcas
  82. + if (forw_packet->num_packets >= hard_iface->num_bcasts)
  83. + continue;
  84. +
  85. ++ if (atomic_read(&hard_iface->no_rebroadcast) &&
  86. ++ forw_packet->skb->dev == hard_iface->net_dev)
  87. ++ continue;
  88. ++
  89. + /* send a copy of the saved skb */
  90. + skb1 = skb_clone(forw_packet->skb, GFP_ATOMIC);
  91. + if (skb1)
  92. +--- a/sysfs-class-net-batman-adv
  93. ++++ b/sysfs-class-net-batman-adv
  94. +@@ -13,3 +13,13 @@ Description:
  95. + displays the batman mesh interface this <iface>
  96. + currently is associated with.
  97. +
  98. ++What: /sys/class/net/<iface>/batman-adv/no_rebroadcast
  99. ++Date: Sep 2013
  100. ++Contact: Linus Lüssing <linus.luessing@web.de>
  101. ++Description:
  102. ++ With this option set incoming multicast payload frames on
  103. ++ <iface> are not being rebroadcasted on <iface> again. This
  104. ++ option should be set on links which are known to be transitive
  105. ++ and symmetric only, for instance point-to-point wifi longshots
  106. ++ or wired links. Using this option wrongly is going to
  107. ++ break your mesh network, use at your own risk!
  108. +--- a/sysfs.c
  109. ++++ b/sysfs.c
  110. +@@ -110,6 +110,17 @@ struct batadv_attribute batadv_attr_vlan
  111. + .store = _store, \
  112. + }
  113. +
  114. ++/* Use this, if you have customized show and store functions
  115. ++ * for hard interface attrs
  116. ++ */
  117. ++#define BATADV_ATTR_HIF(_name, _mode, _show, _store) \
  118. ++struct batadv_attribute batadv_attr_hif_##_name = { \
  119. ++ .attr = {.name = __stringify(_name), \
  120. ++ .mode = _mode }, \
  121. ++ .show = _show, \
  122. ++ .store = _store, \
  123. ++};
  124. ++
  125. + /* Use this, if you have customized show and store functions */
  126. + #define BATADV_ATTR(_name, _mode, _show, _store) \
  127. + struct batadv_attribute batadv_attr_##_name = { \
  128. +@@ -220,6 +231,52 @@ ssize_t batadv_show_vlan_##_name(struct
  129. + static BATADV_ATTR_VLAN(_name, _mode, batadv_show_vlan_##_name, \
  130. + batadv_store_vlan_##_name)
  131. +
  132. ++#define BATADV_ATTR_HIF_STORE_BOOL(_name, _post_func) \
  133. ++ssize_t batadv_store_hif_##_name(struct kobject *kobj, \
  134. ++ struct attribute *attr, char *buff, \
  135. ++ size_t count) \
  136. ++{ \
  137. ++ struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
  138. ++ struct batadv_hard_iface *hard_iface; \
  139. ++ size_t res; \
  140. ++ \
  141. ++ hard_iface = batadv_hardif_get_by_netdev(net_dev); \
  142. ++ if (!hard_iface) \
  143. ++ return 0; \
  144. ++ \
  145. ++ res = __batadv_store_bool_attr(buff, count, _post_func, \
  146. ++ attr, &hard_iface->_name, \
  147. ++ hard_iface->soft_iface); \
  148. ++ batadv_hardif_free_ref(hard_iface); \
  149. ++ return res; \
  150. ++}
  151. ++
  152. ++#define BATADV_ATTR_HIF_SHOW_BOOL(_name) \
  153. ++ssize_t batadv_show_hif_##_name(struct kobject *kobj, \
  154. ++ struct attribute *attr, char *buff) \
  155. ++{ \
  156. ++ struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
  157. ++ struct batadv_hard_iface *hard_iface; \
  158. ++ size_t res; \
  159. ++ \
  160. ++ hard_iface = batadv_hardif_get_by_netdev(net_dev); \
  161. ++ if (!hard_iface) \
  162. ++ return 0; \
  163. ++ \
  164. ++ res = sprintf(buff, "%s\n", \
  165. ++ atomic_read(&hard_iface->_name) == 0 ? \
  166. ++ "disabled" : "enabled"); \
  167. ++ batadv_hardif_free_ref(hard_iface); \
  168. ++ return res; \
  169. ++}
  170. ++
  171. ++/* Use this, if you are going to turn a [name] in the vlan struct on or off */
  172. ++#define BATADV_ATTR_HIF_BOOL(_name, _mode, _post_func) \
  173. ++ static BATADV_ATTR_HIF_STORE_BOOL(_name, _post_func) \
  174. ++ static BATADV_ATTR_HIF_SHOW_BOOL(_name) \
  175. ++ static BATADV_ATTR_HIF(_name, _mode, batadv_show_hif_##_name, \
  176. ++ batadv_store_hif_##_name)
  177. ++
  178. + static int batadv_store_bool_attr(char *buff, size_t count,
  179. + struct net_device *net_dev,
  180. + const char *attr_name, atomic_t *attr)
  181. +@@ -843,10 +900,12 @@ static ssize_t batadv_show_iface_status(
  182. + static BATADV_ATTR(mesh_iface, S_IRUGO | S_IWUSR, batadv_show_mesh_iface,
  183. + batadv_store_mesh_iface);
  184. + static BATADV_ATTR(iface_status, S_IRUGO, batadv_show_iface_status, NULL);
  185. ++BATADV_ATTR_HIF_BOOL(no_rebroadcast, S_IRUGO | S_IWUSR, NULL);
  186. +
  187. + static struct batadv_attribute *batadv_batman_attrs[] = {
  188. + &batadv_attr_mesh_iface,
  189. + &batadv_attr_iface_status,
  190. ++ &batadv_attr_hif_no_rebroadcast,
  191. + NULL,
  192. + };
  193. +
  194. +--- a/types.h
  195. ++++ b/types.h
  196. +@@ -101,6 +101,7 @@ struct batadv_hard_iface {
  197. + struct batadv_hard_iface_bat_iv bat_iv;
  198. + struct work_struct cleanup_work;
  199. + struct dentry *debug_dir;
  200. ++ atomic_t no_rebroadcast;
  201. + };
  202. +
  203. + /**