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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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/1001-batman-adv-introduce-no_rebroadcast-option.patch b/batman-adv/patches/1001-batman-adv-introduce-no_rebroadcast-option.patch
  27. new file mode 100644
  28. index 0000000..3324102
  29. --- /dev/null
  30. +++ b/batman-adv/patches/1001-batman-adv-introduce-no_rebroadcast-option.patch
  31. @@ -0,0 +1,185 @@
  32. +From bb9feeed3b49a55034cce90be996b11cd095b1ce Mon Sep 17 00:00:00 2001
  33. +Message-Id: <bb9feeed3b49a55034cce90be996b11cd095b1ce.1454958586.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 1/2] 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. + .../ABI/testing/sysfs-class-net-batman-adv | 10 ++++
  62. + net/batman-adv/hard-interface.c | 2 +
  63. + net/batman-adv/send.c | 4 ++
  64. + net/batman-adv/sysfs.c | 59 ++++++++++++++++++++++
  65. + net/batman-adv/types.h | 1 +
  66. + 5 files changed, 76 insertions(+)
  67. +
  68. +diff --git a/Documentation/ABI/testing/sysfs-class-net-batman-adv b/Documentation/ABI/testing/sysfs-class-net-batman-adv
  69. +index 7f34a95..cf7fe00 100644
  70. +--- a/Documentation/ABI/testing/sysfs-class-net-batman-adv
  71. ++++ b/Documentation/ABI/testing/sysfs-class-net-batman-adv
  72. +@@ -13,3 +13,13 @@ Description:
  73. + displays the batman mesh interface this <iface>
  74. + currently is associated with.
  75. +
  76. ++What: /sys/class/net/<iface>/batman-adv/no_rebroadcast
  77. ++Date: Sep 2013
  78. ++Contact: Linus Lüssing <linus.luessing@web.de>
  79. ++Description:
  80. ++ With this option set incoming multicast payload frames on
  81. ++ <iface> are not being rebroadcasted on <iface> again. This
  82. ++ option should be set on links which are known to be transitive
  83. ++ and symmetric only, for instance point-to-point wifi longshots
  84. ++ or wired links. Using this option wrongly is going to
  85. ++ break your mesh network, use at your own risk!
  86. +diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
  87. +index aea4d06..66a703d 100644
  88. +--- a/net/batman-adv/hard-interface.c
  89. ++++ b/net/batman-adv/hard-interface.c
  90. +@@ -657,6 +657,8 @@ batadv_hardif_add_interface(struct net_device *net_dev)
  91. + /* extra reference for return */
  92. + atomic_set(&hard_iface->refcount, 2);
  93. +
  94. ++ atomic_set(&hard_iface->no_rebroadcast, 0);
  95. ++
  96. + batadv_check_known_mac_addr(hard_iface->net_dev);
  97. + list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list);
  98. +
  99. +diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
  100. +index c188f46..145f7cb 100644
  101. +--- a/net/batman-adv/send.c
  102. ++++ b/net/batman-adv/send.c
  103. +@@ -535,6 +535,10 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work)
  104. + if (forw_packet->num_packets >= hard_iface->num_bcasts)
  105. + continue;
  106. +
  107. ++ if (atomic_read(&hard_iface->no_rebroadcast) &&
  108. ++ forw_packet->skb->dev == hard_iface->net_dev)
  109. ++ continue;
  110. ++
  111. + /* send a copy of the saved skb */
  112. + skb1 = skb_clone(forw_packet->skb, GFP_ATOMIC);
  113. + if (skb1)
  114. +diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
  115. +index f38d7b7..600633c 100644
  116. +--- a/net/batman-adv/sysfs.c
  117. ++++ b/net/batman-adv/sysfs.c
  118. +@@ -131,6 +131,17 @@ struct batadv_attribute batadv_attr_vlan_##_name = { \
  119. + .store = _store, \
  120. + }
  121. +
  122. ++/* Use this, if you have customized show and store functions
  123. ++ * for hard interface attrs
  124. ++ */
  125. ++#define BATADV_ATTR_HIF(_name, _mode, _show, _store) \
  126. ++struct batadv_attribute batadv_attr_hif_##_name = { \
  127. ++ .attr = {.name = __stringify(_name), \
  128. ++ .mode = _mode }, \
  129. ++ .show = _show, \
  130. ++ .store = _store, \
  131. ++};
  132. ++
  133. + /* Use this, if you have customized show and store functions */
  134. + #define BATADV_ATTR(_name, _mode, _show, _store) \
  135. + struct batadv_attribute batadv_attr_##_name = { \
  136. +@@ -241,6 +252,52 @@ ssize_t batadv_show_vlan_##_name(struct kobject *kobj, \
  137. + static BATADV_ATTR_VLAN(_name, _mode, batadv_show_vlan_##_name, \
  138. + batadv_store_vlan_##_name)
  139. +
  140. ++#define BATADV_ATTR_HIF_STORE_BOOL(_name, _post_func) \
  141. ++ssize_t batadv_store_hif_##_name(struct kobject *kobj, \
  142. ++ struct attribute *attr, char *buff, \
  143. ++ size_t count) \
  144. ++{ \
  145. ++ struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
  146. ++ struct batadv_hard_iface *hard_iface; \
  147. ++ size_t res; \
  148. ++ \
  149. ++ hard_iface = batadv_hardif_get_by_netdev(net_dev); \
  150. ++ if (!hard_iface) \
  151. ++ return 0; \
  152. ++ \
  153. ++ res = __batadv_store_bool_attr(buff, count, _post_func, \
  154. ++ attr, &hard_iface->_name, \
  155. ++ hard_iface->soft_iface); \
  156. ++ batadv_hardif_free_ref(hard_iface); \
  157. ++ return res; \
  158. ++}
  159. ++
  160. ++#define BATADV_ATTR_HIF_SHOW_BOOL(_name) \
  161. ++ssize_t batadv_show_hif_##_name(struct kobject *kobj, \
  162. ++ struct attribute *attr, char *buff) \
  163. ++{ \
  164. ++ struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
  165. ++ struct batadv_hard_iface *hard_iface; \
  166. ++ size_t res; \
  167. ++ \
  168. ++ hard_iface = batadv_hardif_get_by_netdev(net_dev); \
  169. ++ if (!hard_iface) \
  170. ++ return 0; \
  171. ++ \
  172. ++ res = sprintf(buff, "%s\n", \
  173. ++ atomic_read(&hard_iface->_name) == 0 ? \
  174. ++ "disabled" : "enabled"); \
  175. ++ batadv_hardif_free_ref(hard_iface); \
  176. ++ return res; \
  177. ++}
  178. ++
  179. ++/* Use this, if you are going to turn a [name] in the vlan struct on or off */
  180. ++#define BATADV_ATTR_HIF_BOOL(_name, _mode, _post_func) \
  181. ++ static BATADV_ATTR_HIF_STORE_BOOL(_name, _post_func) \
  182. ++ static BATADV_ATTR_HIF_SHOW_BOOL(_name) \
  183. ++ static BATADV_ATTR_HIF(_name, _mode, batadv_show_hif_##_name, \
  184. ++ batadv_store_hif_##_name)
  185. ++
  186. + static int batadv_store_bool_attr(char *buff, size_t count,
  187. + struct net_device *net_dev,
  188. + const char *attr_name, atomic_t *attr,
  189. +@@ -870,10 +927,12 @@ static ssize_t batadv_show_iface_status(struct kobject *kobj,
  190. + static BATADV_ATTR(mesh_iface, S_IRUGO | S_IWUSR, batadv_show_mesh_iface,
  191. + batadv_store_mesh_iface);
  192. + static BATADV_ATTR(iface_status, S_IRUGO, batadv_show_iface_status, NULL);
  193. ++BATADV_ATTR_HIF_BOOL(no_rebroadcast, S_IRUGO | S_IWUSR, NULL);
  194. +
  195. + static struct batadv_attribute *batadv_batman_attrs[] = {
  196. + &batadv_attr_mesh_iface,
  197. + &batadv_attr_iface_status,
  198. ++ &batadv_attr_hif_no_rebroadcast,
  199. + NULL,
  200. + };
  201. +
  202. +diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
  203. +index 5e8c8df..913f104 100644
  204. +--- a/net/batman-adv/types.h
  205. ++++ b/net/batman-adv/types.h
  206. +@@ -120,6 +120,7 @@ struct batadv_hard_iface {
  207. + struct hlist_head neigh_list;
  208. + /* neigh_list_lock protects: neigh_list */
  209. + spinlock_t neigh_list_lock;
  210. ++ atomic_t no_rebroadcast;
  211. + };
  212. +
  213. + /**
  214. +--
  215. +2.7.0
  216. +