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

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