All of lore.kernel.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH maint] batman-adv: fix soft-interface MTU computation
@ 2014-01-21 10:22 Antonio Quartulli
  2014-01-21 10:31 ` Antonio Quartulli
  2014-01-21 18:43 ` Russell Senior
  0 siblings, 2 replies; 35+ messages in thread
From: Antonio Quartulli @ 2014-01-21 10:22 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli

The current MTU computation always returns a value
smaller than 1500bytes even if the real interfaces
have an MTU large enough to compensate the batman-adv
overhead.

Fix the computation by properly returning the highest
admitted value.

Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
---

This patch is missing a Reported-by clause because I did not have
"russell"'s email address at hand.

Will be added later before being merged.

Cheers,


 hard-interface.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/hard-interface.c b/hard-interface.c
index 6792e03..0eb0b3b 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -244,7 +244,7 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
 {
 	struct batadv_priv *bat_priv = netdev_priv(soft_iface);
 	const struct batadv_hard_iface *hard_iface;
-	int min_mtu = ETH_DATA_LEN;
+	int min_mtu = INT_MAX;
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
@@ -259,8 +259,6 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
 	}
 	rcu_read_unlock();
 
-	atomic_set(&bat_priv->packet_size_max, min_mtu);
-
 	if (atomic_read(&bat_priv->fragmentation) == 0)
 		goto out;
 
@@ -271,13 +269,21 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
 	min_mtu = min_t(int, min_mtu, BATADV_FRAG_MAX_FRAG_SIZE);
 	min_mtu -= sizeof(struct batadv_frag_packet);
 	min_mtu *= BATADV_FRAG_MAX_FRAGMENTS;
-	atomic_set(&bat_priv->packet_size_max, min_mtu);
-
-	/* with fragmentation enabled we can fragment external packets easily */
-	min_mtu = min_t(int, min_mtu, ETH_DATA_LEN);
 
 out:
-	return min_mtu - batadv_max_header_len();
+	/* report to the other components the maximum amount of bytes that
+	 * batman-adv can send over the wire (without considering the payload
+	 * overhead). For example, this value is used by TT to compute the
+	 * maximum local table table size
+	 */
+	atomic_set(&bat_priv->packet_size_max, min_mtu);
+
+	/* the real soft-interface MTU is computed by removing the payload
+	 * overhead from the maximum amount of bytes that was just computed.
+	 *
+	 * However batman-adv does not support MTUs bigger than ETH_DATA_LEN
+	 */
+	return min_t(int, min_mtu - batadv_max_header_len(), ETH_DATA_LEN);
 }
 
 /* adjusts the MTU if a new interface with a smaller MTU appeared. */
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2014-02-13  7:23 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-21 10:22 [B.A.T.M.A.N.] [PATCH maint] batman-adv: fix soft-interface MTU computation Antonio Quartulli
2014-01-21 10:31 ` Antonio Quartulli
2014-01-27  7:57   ` Marek Lindner
2014-01-21 18:43 ` Russell Senior
2014-01-21 19:00   ` Antonio Quartulli
2014-01-22  6:04   ` Russell Senior
2014-01-22  7:03     ` Antonio Quartulli
2014-01-22  7:04     ` [B.A.T.M.A.N.] memleak (Was: [PATCH maint] batman-adv: fix soft-interface MTU computation) Antonio Quartulli
2014-01-22  7:37     ` [B.A.T.M.A.N.] [PATCH maint] batman-adv: fix soft-interface MTU computation Daniel
2014-01-22 17:45       ` [B.A.T.M.A.N.] batman-adv: memory leak? Russell Senior
2014-01-22 17:46         ` Antonio Quartulli
2014-01-22 19:18           ` Russell Senior
2014-01-22 20:49           ` cmsv
2014-01-22 23:57             ` Russell Senior
2014-01-23  0:10               ` cmsv
2014-01-23  3:35                 ` Daniel
2014-01-26 12:57                   ` Daniel
2014-01-26 14:21                     ` Antonio Quartulli
2014-01-26 14:24                       ` [B.A.T.M.A.N.] [PATCH maint] batman-adv: release vlan object after checking the CRC Antonio Quartulli
2014-01-27 18:43                         ` Russell Senior
2014-01-26 16:05                       ` [B.A.T.M.A.N.] batman-adv: memory leak? cmsv
2014-01-26 16:07                         ` Antonio Quartulli
2014-01-26 16:13                           ` Antonio Quartulli
2014-01-27 17:55                             ` cmsv
2014-01-28  1:21                               ` Russell Senior
2014-01-28  1:30                                 ` cmsv
2014-01-29  8:10                                   ` Russell Senior
2014-01-29 21:48                                     ` cmsv
2014-02-08  3:08                                       ` cmsv
2014-02-08 10:53                                         ` Felix Fietkau
2014-02-12  7:23                                         ` Antonio Quartulli
2014-02-12 10:40                                           ` cmsv
2014-02-12 11:41                                             ` Antonio Quartulli
2014-02-13  0:55                                               ` cmsv
2014-02-13  7:23                                                 ` Antonio Quartulli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.