aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMarek Lindner <lindner_marek@yahoo.de>2013-05-08 01:31:59 -0400
committerAntonio Quartulli <antonio@meshcoding.com>2013-10-12 11:17:09 -0400
commit411d6ed93a5d0601980d3e5ce75de07c98e3a7de (patch)
tree00a52bc5c70d465129c85d48e52ced2186649660 /net
parent0bf84c160a4b3b75bb911b79c3972f64dfb0b039 (diff)
batman-adv: consider network coding overhead when calculating required mtu
The module prints a warning when the MTU on the hard interface is too small to transfer payload traffic without fragmentation. The required MTU is calculated based on the encapsulation header size. If network coding is compild into the module its header size is taken into account as well. Signed-off-by: Marek Lindner <lindner_marek@yahoo.de> Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Diffstat (limited to 'net')
-rw-r--r--net/batman-adv/hard-interface.c19
-rw-r--r--net/batman-adv/main.c25
-rw-r--r--net/batman-adv/main.h1
-rw-r--r--net/batman-adv/soft-interface.c2
-rw-r--r--net/batman-adv/types.h7
5 files changed, 37 insertions, 17 deletions
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 004017c523fa..d564af295db4 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -269,9 +269,10 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
269 const struct batadv_priv *bat_priv = netdev_priv(soft_iface); 269 const struct batadv_priv *bat_priv = netdev_priv(soft_iface);
270 const struct batadv_hard_iface *hard_iface; 270 const struct batadv_hard_iface *hard_iface;
271 /* allow big frames if all devices are capable to do so 271 /* allow big frames if all devices are capable to do so
272 * (have MTU > 1500 + BAT_HEADER_LEN) 272 * (have MTU > 1500 + batadv_max_header_len())
273 */ 273 */
274 int min_mtu = ETH_DATA_LEN; 274 int min_mtu = ETH_DATA_LEN;
275 int max_header_len = batadv_max_header_len();
275 276
276 if (atomic_read(&bat_priv->fragmentation)) 277 if (atomic_read(&bat_priv->fragmentation))
277 goto out; 278 goto out;
@@ -285,8 +286,7 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
285 if (hard_iface->soft_iface != soft_iface) 286 if (hard_iface->soft_iface != soft_iface)
286 continue; 287 continue;
287 288
288 min_mtu = min_t(int, 289 min_mtu = min_t(int, hard_iface->net_dev->mtu - max_header_len,
289 hard_iface->net_dev->mtu - BATADV_HEADER_LEN,
290 min_mtu); 290 min_mtu);
291 } 291 }
292 rcu_read_unlock(); 292 rcu_read_unlock();
@@ -380,6 +380,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
380 struct batadv_priv *bat_priv; 380 struct batadv_priv *bat_priv;
381 struct net_device *soft_iface, *master; 381 struct net_device *soft_iface, *master;
382 __be16 ethertype = htons(ETH_P_BATMAN); 382 __be16 ethertype = htons(ETH_P_BATMAN);
383 int max_header_len = batadv_max_header_len();
383 int ret; 384 int ret;
384 385
385 if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) 386 if (hard_iface->if_status != BATADV_IF_NOT_IN_USE)
@@ -448,18 +449,18 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
448 hard_iface->net_dev->name); 449 hard_iface->net_dev->name);
449 450
450 if (atomic_read(&bat_priv->fragmentation) && 451 if (atomic_read(&bat_priv->fragmentation) &&
451 hard_iface->net_dev->mtu < ETH_DATA_LEN + BATADV_HEADER_LEN) 452 hard_iface->net_dev->mtu < ETH_DATA_LEN + max_header_len)
452 batadv_info(hard_iface->soft_iface, 453 batadv_info(hard_iface->soft_iface,
453 "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to %zi would solve the problem.\n", 454 "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to %i would solve the problem.\n",
454 hard_iface->net_dev->name, hard_iface->net_dev->mtu, 455 hard_iface->net_dev->name, hard_iface->net_dev->mtu,
455 ETH_DATA_LEN + BATADV_HEADER_LEN); 456 ETH_DATA_LEN + max_header_len);
456 457
457 if (!atomic_read(&bat_priv->fragmentation) && 458 if (!atomic_read(&bat_priv->fragmentation) &&
458 hard_iface->net_dev->mtu < ETH_DATA_LEN + BATADV_HEADER_LEN) 459 hard_iface->net_dev->mtu < ETH_DATA_LEN + max_header_len)
459 batadv_info(hard_iface->soft_iface, 460 batadv_info(hard_iface->soft_iface,
460 "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. If you experience problems getting traffic through try increasing the MTU to %zi.\n", 461 "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. If you experience problems getting traffic through try increasing the MTU to %i.\n",
461 hard_iface->net_dev->name, hard_iface->net_dev->mtu, 462 hard_iface->net_dev->name, hard_iface->net_dev->mtu,
462 ETH_DATA_LEN + BATADV_HEADER_LEN); 463 ETH_DATA_LEN + max_header_len);
463 464
464 if (batadv_hardif_is_iface_up(hard_iface)) 465 if (batadv_hardif_is_iface_up(hard_iface))
465 batadv_hardif_activate_interface(hard_iface); 466 batadv_hardif_activate_interface(hard_iface);
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 519138e32fe6..7f3a5c426615 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -256,6 +256,31 @@ out:
256} 256}
257 257
258/** 258/**
259 * batadv_max_header_len - calculate maximum encapsulation overhead for a
260 * payload packet
261 *
262 * Return the maximum encapsulation overhead in bytes.
263 */
264int batadv_max_header_len(void)
265{
266 int header_len = 0;
267
268 header_len = max_t(int, header_len,
269 sizeof(struct batadv_unicast_packet));
270 header_len = max_t(int, header_len,
271 sizeof(struct batadv_unicast_4addr_packet));
272 header_len = max_t(int, header_len,
273 sizeof(struct batadv_bcast_packet));
274
275#ifdef CONFIG_BATMAN_ADV_NC
276 header_len = max_t(int, header_len,
277 sizeof(struct batadv_coded_packet));
278#endif
279
280 return header_len;
281}
282
283/**
259 * batadv_skb_set_priority - sets skb priority according to packet content 284 * batadv_skb_set_priority - sets skb priority according to packet content
260 * @skb: the packet to be sent 285 * @skb: the packet to be sent
261 * @offset: offset to the packet content 286 * @offset: offset to the packet content
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 6a74a4225326..54c13d51edbe 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -191,6 +191,7 @@ void batadv_mesh_free(struct net_device *soft_iface);
191int batadv_is_my_mac(struct batadv_priv *bat_priv, const uint8_t *addr); 191int batadv_is_my_mac(struct batadv_priv *bat_priv, const uint8_t *addr);
192struct batadv_hard_iface * 192struct batadv_hard_iface *
193batadv_seq_print_text_primary_if_get(struct seq_file *seq); 193batadv_seq_print_text_primary_if_get(struct seq_file *seq);
194int batadv_max_header_len(void);
194void batadv_skb_set_priority(struct sk_buff *skb, int offset); 195void batadv_skb_set_priority(struct sk_buff *skb, int offset);
195int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, 196int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
196 struct packet_type *ptype, 197 struct packet_type *ptype,
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 87e7e4ed216d..15c7237f427b 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -626,7 +626,7 @@ static void batadv_softif_init_early(struct net_device *dev)
626 */ 626 */
627 dev->mtu = ETH_DATA_LEN; 627 dev->mtu = ETH_DATA_LEN;
628 /* reserve more space in the skbuff for our header */ 628 /* reserve more space in the skbuff for our header */
629 dev->hard_header_len = BATADV_HEADER_LEN; 629 dev->hard_header_len = batadv_max_header_len();
630 630
631 /* generate random address */ 631 /* generate random address */
632 eth_hw_addr_random(dev); 632 eth_hw_addr_random(dev);
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index d517d5dde6ad..5cbb0d09a9b5 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -24,13 +24,6 @@
24#include "bitarray.h" 24#include "bitarray.h"
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26 26
27/**
28 * Maximum overhead for the encapsulation for a payload packet
29 */
30#define BATADV_HEADER_LEN \
31 (ETH_HLEN + max(sizeof(struct batadv_unicast_packet), \
32 sizeof(struct batadv_bcast_packet)))
33
34#ifdef CONFIG_BATMAN_ADV_DAT 27#ifdef CONFIG_BATMAN_ADV_DAT
35 28
36/* batadv_dat_addr_t is the type used for all DHT addresses. If it is changed, 29/* batadv_dat_addr_t is the type used for all DHT addresses. If it is changed,