All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@meshcoding.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
	Marek Lindner <mareklindner@neomailbox.ch>,
	Antonio Quartulli <antonio@meshcoding.com>
Subject: [B.A.T.M.A.N.] [PATCH 01/10] batman-adv: fix soft-interface MTU computation
Date: Mon, 17 Feb 2014 21:48:40 +0100	[thread overview]
Message-ID: <1392670129-2498-2-git-send-email-antonio@meshcoding.com> (raw)
In-Reply-To: <1392670129-2498-1-git-send-email-antonio@meshcoding.com>

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.

Introduced by a19d3d85e1b854e4a483a55d740a42458085560d
("batman-adv: limit local translation table max size")

Reported-by: Russell Senior <russell@personaltelco.net>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
 net/batman-adv/hard-interface.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 3d417d3..b851cc5 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -241,7 +241,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) {
@@ -256,8 +256,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;
 
@@ -268,13 +266,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


WARNING: multiple messages have this Message-ID (diff)
From: Antonio Quartulli <antonio@meshcoding.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
	Antonio Quartulli <antonio@meshcoding.com>,
	Marek Lindner <mareklindner@neomailbox.ch>
Subject: [PATCH 01/10] batman-adv: fix soft-interface MTU computation
Date: Mon, 17 Feb 2014 21:48:40 +0100	[thread overview]
Message-ID: <1392670129-2498-2-git-send-email-antonio@meshcoding.com> (raw)
In-Reply-To: <1392670129-2498-1-git-send-email-antonio@meshcoding.com>

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.

Introduced by a19d3d85e1b854e4a483a55d740a42458085560d
("batman-adv: limit local translation table max size")

Reported-by: Russell Senior <russell@personaltelco.net>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
 net/batman-adv/hard-interface.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 3d417d3..b851cc5 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -241,7 +241,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) {
@@ -256,8 +256,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;
 
@@ -268,13 +266,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

  reply	other threads:[~2014-02-17 20:48 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-17 20:48 [B.A.T.M.A.N.] [PATCH 00/10] pull request net: batman-adv 2014-02-17 Antonio Quartulli
2014-02-17 20:48 ` Antonio Quartulli
2014-02-17 20:48 ` Antonio Quartulli [this message]
2014-02-17 20:48   ` [PATCH 01/10] batman-adv: fix soft-interface MTU computation Antonio Quartulli
2014-02-17 21:13   ` [B.A.T.M.A.N.] " David Miller
2014-02-17 21:13     ` David Miller
2014-02-18  6:44     ` [B.A.T.M.A.N.] " Antonio Quartulli
2014-02-18 18:22       ` David Miller
2014-02-18 18:22         ` David Miller
2014-02-18 20:41       ` David Miller
2014-02-18 20:41         ` David Miller
2014-02-18 20:57         ` Antonio Quartulli
2014-02-18 20:57           ` Antonio Quartulli
2014-02-17 20:48 ` [B.A.T.M.A.N.] [PATCH 02/10] batman-adv: fix TT-TVLV parsing on OGM reception Antonio Quartulli
2014-02-17 20:48   ` Antonio Quartulli
2014-02-17 20:48 ` [B.A.T.M.A.N.] [PATCH 03/10] batman-adv: release vlan object after checking the CRC Antonio Quartulli
2014-02-17 20:48   ` Antonio Quartulli
2014-02-17 20:48 ` [B.A.T.M.A.N.] [PATCH 04/10] batman-adv: properly check pskb_may_pull return value Antonio Quartulli
2014-02-17 20:48   ` Antonio Quartulli
2014-02-17 20:48 ` [B.A.T.M.A.N.] [PATCH 05/10] batman-adv: avoid potential race condition when adding a new neighbour Antonio Quartulli
2014-02-17 20:48   ` Antonio Quartulli
2014-02-17 20:48 ` [B.A.T.M.A.N.] [PATCH 06/10] batman-adv: fix potential orig_node reference leak Antonio Quartulli
2014-02-17 20:48   ` Antonio Quartulli
2014-02-17 20:48 ` [B.A.T.M.A.N.] [PATCH 07/10] batman-adv: fix TT CRC computation by ensuring byte order Antonio Quartulli
2014-02-17 20:48   ` Antonio Quartulli
2014-02-17 20:48 ` [B.A.T.M.A.N.] [PATCH 08/10] batman-adv: free skb on TVLV parsing success Antonio Quartulli
2014-02-17 20:48   ` Antonio Quartulli
2014-02-17 20:48 ` [B.A.T.M.A.N.] [PATCH 09/10] batman-adv: avoid double free when orig_node initialization fails Antonio Quartulli
2014-02-17 20:48   ` Antonio Quartulli
2014-02-17 20:48 ` [B.A.T.M.A.N.] [PATCH 10/10] batman-adv: fix potential kernel paging error for unicast transmissions Antonio Quartulli
2014-02-17 20:48   ` Antonio Quartulli
2014-02-21  7:47 ` [B.A.T.M.A.N.] [PATCH 00/10] pull request net: batman-adv 2014-02-17 Antonio Quartulli
2014-02-21  7:47   ` Antonio Quartulli
2014-02-25 20:36   ` [B.A.T.M.A.N.] " David Miller
2014-02-25 20:36     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392670129-2498-2-git-send-email-antonio@meshcoding.com \
    --to=antonio@meshcoding.com \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=mareklindner@neomailbox.ch \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.