Skip to content

Commit 04252c4

Browse files
ecsvFishwaldo
authored andcommitted
batman-adv: Don't increase MTU when set by user
commit d8e42a2 upstream. If the user set an MTU value, it usually means that there are special requirements for the MTU. But if an interface gots activated, the MTU was always recalculated and then the user set value was overwritten. The only reason why this user set value has to be overwritten, is when the MTU has to be decreased because batman-adv is not able to transfer packets with the user specified size. Fixes: c6c8fea ("net: Add batman-adv meshing protocol") Cc: stable@vger.kernel.org Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9de5b3f commit 04252c4

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

net/batman-adv/hard-interface.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,19 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
627627
*/
628628
void batadv_update_min_mtu(struct net_device *soft_iface)
629629
{
630-
dev_set_mtu(soft_iface, batadv_hardif_min_mtu(soft_iface));
630+
struct batadv_priv *bat_priv = netdev_priv(soft_iface);
631+
int limit_mtu;
632+
int mtu;
633+
634+
mtu = batadv_hardif_min_mtu(soft_iface);
635+
636+
if (bat_priv->mtu_set_by_user)
637+
limit_mtu = bat_priv->mtu_set_by_user;
638+
else
639+
limit_mtu = ETH_DATA_LEN;
640+
641+
mtu = min(mtu, limit_mtu);
642+
dev_set_mtu(soft_iface, mtu);
631643

632644
/* Check if the local translate table should be cleaned up to match a
633645
* new (and smaller) MTU.

net/batman-adv/soft-interface.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,14 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)
154154

155155
static int batadv_interface_change_mtu(struct net_device *dev, int new_mtu)
156156
{
157+
struct batadv_priv *bat_priv = netdev_priv(dev);
158+
157159
/* check ranges */
158160
if (new_mtu < 68 || new_mtu > batadv_hardif_min_mtu(dev))
159161
return -EINVAL;
160162

161163
dev->mtu = new_mtu;
164+
bat_priv->mtu_set_by_user = new_mtu;
162165

163166
return 0;
164167
}

net/batman-adv/types.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,12 @@ struct batadv_priv {
15461546
/** @soft_iface: net device which holds this struct as private data */
15471547
struct net_device *soft_iface;
15481548

1549+
/**
1550+
* @mtu_set_by_user: MTU was set once by user
1551+
* protected by rtnl_lock
1552+
*/
1553+
int mtu_set_by_user;
1554+
15491555
/**
15501556
* @bat_counters: mesh internal traffic statistic counters (see
15511557
* batadv_counters)

0 commit comments

Comments
 (0)