aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/hard-interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/batman-adv/hard-interface.c')
-rw-r--r--net/batman-adv/hard-interface.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 57c2a19dcb5c..b851cc580853 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors: 1/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors:
2 * 2 *
3 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
4 * 4 *
@@ -12,9 +12,7 @@
12 * General Public License for more details. 12 * General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software 15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA
18 */ 16 */
19 17
20#include "main.h" 18#include "main.h"
@@ -25,6 +23,7 @@
25#include "translation-table.h" 23#include "translation-table.h"
26#include "routing.h" 24#include "routing.h"
27#include "sysfs.h" 25#include "sysfs.h"
26#include "debugfs.h"
28#include "originator.h" 27#include "originator.h"
29#include "hash.h" 28#include "hash.h"
30#include "bridge_loop_avoidance.h" 29#include "bridge_loop_avoidance.h"
@@ -88,15 +87,13 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev)
88 return false; 87 return false;
89 88
90 /* recurse over the parent device */ 89 /* recurse over the parent device */
91 parent_dev = dev_get_by_index(&init_net, net_dev->iflink); 90 parent_dev = __dev_get_by_index(&init_net, net_dev->iflink);
92 /* if we got a NULL parent_dev there is something broken.. */ 91 /* if we got a NULL parent_dev there is something broken.. */
93 if (WARN(!parent_dev, "Cannot find parent device")) 92 if (WARN(!parent_dev, "Cannot find parent device"))
94 return false; 93 return false;
95 94
96 ret = batadv_is_on_batman_iface(parent_dev); 95 ret = batadv_is_on_batman_iface(parent_dev);
97 96
98 if (parent_dev)
99 dev_put(parent_dev);
100 return ret; 97 return ret;
101} 98}
102 99
@@ -244,7 +241,7 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
244{ 241{
245 struct batadv_priv *bat_priv = netdev_priv(soft_iface); 242 struct batadv_priv *bat_priv = netdev_priv(soft_iface);
246 const struct batadv_hard_iface *hard_iface; 243 const struct batadv_hard_iface *hard_iface;
247 int min_mtu = ETH_DATA_LEN; 244 int min_mtu = INT_MAX;
248 245
249 rcu_read_lock(); 246 rcu_read_lock();
250 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { 247 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
@@ -259,8 +256,6 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
259 } 256 }
260 rcu_read_unlock(); 257 rcu_read_unlock();
261 258
262 atomic_set(&bat_priv->packet_size_max, min_mtu);
263
264 if (atomic_read(&bat_priv->fragmentation) == 0) 259 if (atomic_read(&bat_priv->fragmentation) == 0)
265 goto out; 260 goto out;
266 261
@@ -271,13 +266,21 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
271 min_mtu = min_t(int, min_mtu, BATADV_FRAG_MAX_FRAG_SIZE); 266 min_mtu = min_t(int, min_mtu, BATADV_FRAG_MAX_FRAG_SIZE);
272 min_mtu -= sizeof(struct batadv_frag_packet); 267 min_mtu -= sizeof(struct batadv_frag_packet);
273 min_mtu *= BATADV_FRAG_MAX_FRAGMENTS; 268 min_mtu *= BATADV_FRAG_MAX_FRAGMENTS;
274 atomic_set(&bat_priv->packet_size_max, min_mtu);
275
276 /* with fragmentation enabled we can fragment external packets easily */
277 min_mtu = min_t(int, min_mtu, ETH_DATA_LEN);
278 269
279out: 270out:
280 return min_mtu - batadv_max_header_len(); 271 /* report to the other components the maximum amount of bytes that
272 * batman-adv can send over the wire (without considering the payload
273 * overhead). For example, this value is used by TT to compute the
274 * maximum local table table size
275 */
276 atomic_set(&bat_priv->packet_size_max, min_mtu);
277
278 /* the real soft-interface MTU is computed by removing the payload
279 * overhead from the maximum amount of bytes that was just computed.
280 *
281 * However batman-adv does not support MTUs bigger than ETH_DATA_LEN
282 */
283 return min_t(int, min_mtu - batadv_max_header_len(), ETH_DATA_LEN);
281} 284}
282 285
283/* adjusts the MTU if a new interface with a smaller MTU appeared. */ 286/* adjusts the MTU if a new interface with a smaller MTU appeared. */
@@ -541,6 +544,7 @@ static void batadv_hardif_remove_interface_finish(struct work_struct *work)
541 hard_iface = container_of(work, struct batadv_hard_iface, 544 hard_iface = container_of(work, struct batadv_hard_iface,
542 cleanup_work); 545 cleanup_work);
543 546
547 batadv_debugfs_del_hardif(hard_iface);
544 batadv_sysfs_del_hardif(&hard_iface->hardif_obj); 548 batadv_sysfs_del_hardif(&hard_iface->hardif_obj);
545 batadv_hardif_free_ref(hard_iface); 549 batadv_hardif_free_ref(hard_iface);
546} 550}
@@ -571,6 +575,11 @@ batadv_hardif_add_interface(struct net_device *net_dev)
571 hard_iface->net_dev = net_dev; 575 hard_iface->net_dev = net_dev;
572 hard_iface->soft_iface = NULL; 576 hard_iface->soft_iface = NULL;
573 hard_iface->if_status = BATADV_IF_NOT_IN_USE; 577 hard_iface->if_status = BATADV_IF_NOT_IN_USE;
578
579 ret = batadv_debugfs_add_hardif(hard_iface);
580 if (ret)
581 goto free_sysfs;
582
574 INIT_LIST_HEAD(&hard_iface->list); 583 INIT_LIST_HEAD(&hard_iface->list);
575 INIT_WORK(&hard_iface->cleanup_work, 584 INIT_WORK(&hard_iface->cleanup_work,
576 batadv_hardif_remove_interface_finish); 585 batadv_hardif_remove_interface_finish);
@@ -587,6 +596,8 @@ batadv_hardif_add_interface(struct net_device *net_dev)
587 596
588 return hard_iface; 597 return hard_iface;
589 598
599free_sysfs:
600 batadv_sysfs_del_hardif(&hard_iface->hardif_obj);
590free_if: 601free_if:
591 kfree(hard_iface); 602 kfree(hard_iface);
592release_dev: 603release_dev: