Project

General

Profile

Feature #365 ยป v1-0001-batman-adv-Add-support-for-jumbo-frames.patch

Sven Eckelmann, 07/19/2023 07:59 AM

View differences:

net/batman-adv/hard-interface.c
/**
* batadv_hardif_min_mtu() - Calculate maximum MTU for soft interface
* @soft_iface: netdev struct of the soft interface
* @max_mtu: limit for maximum returned MTU
*
* Return: MTU for the soft-interface (limited by the minimal MTU of all active
* slave interfaces)
*/
int batadv_hardif_min_mtu(struct net_device *soft_iface)
int batadv_hardif_min_mtu(struct net_device *soft_iface, unsigned int max_mtu)
{
struct batadv_priv *bat_priv = netdev_priv(soft_iface);
const struct batadv_hard_iface *hard_iface;
......
/* 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);
return min_t(int, min_mtu - batadv_max_header_len(), max_mtu);
}
/**
......
*/
void batadv_update_min_mtu(struct net_device *soft_iface)
{
soft_iface->mtu = batadv_hardif_min_mtu(soft_iface);
soft_iface->mtu = batadv_hardif_min_mtu(soft_iface, soft_iface->mtu);
/* Check if the local translate table should be cleaned up to match a
* new (and smaller) MTU.
......
hard_iface->net_dev->name);
if (atomic_read(&bat_priv->fragmentation) &&
hard_iface->net_dev->mtu < ETH_DATA_LEN + max_header_len)
hard_iface->net_dev->mtu < BATADV_MAX_MTU + max_header_len)
batadv_info(hard_iface->soft_iface,
"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",
hard_iface->net_dev->name, hard_iface->net_dev->mtu,
ETH_DATA_LEN + max_header_len);
BATADV_MAX_MTU + max_header_len);
if (!atomic_read(&bat_priv->fragmentation) &&
hard_iface->net_dev->mtu < ETH_DATA_LEN + max_header_len)
hard_iface->net_dev->mtu < BATADV_MAX_MTU + max_header_len)
batadv_info(hard_iface->soft_iface,
"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",
hard_iface->net_dev->name, hard_iface->net_dev->mtu,
ETH_DATA_LEN + max_header_len);
BATADV_MAX_MTU + max_header_len);
if (batadv_hardif_is_iface_up(hard_iface))
batadv_hardif_activate_interface(hard_iface);
net/batman-adv/hard-interface.h
int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
struct net_device *soft_iface);
void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface);
int batadv_hardif_min_mtu(struct net_device *soft_iface);
int batadv_hardif_min_mtu(struct net_device *soft_iface, unsigned int max_mtu);
void batadv_update_min_mtu(struct net_device *soft_iface);
void batadv_hardif_release(struct kref *ref);
int batadv_hardif_no_broadcast(struct batadv_hard_iface *if_outgoing,
net/batman-adv/main.h
#define BATADV_THROUGHPUT_MAX_VALUE 0xFFFFFFFF
#define BATADV_JITTER 20
#define BATADV_MAX_MTU (ETH_MAX_MTU - batadv_max_header_len())
/* Time To Live of broadcast messages */
#define BATADV_TTL 50
net/batman-adv/soft-interface.c
static int batadv_interface_change_mtu(struct net_device *dev, int new_mtu)
{
/* check ranges */
if (new_mtu < 68 || new_mtu > batadv_hardif_min_mtu(dev))
if (new_mtu < ETH_MIN_MTU)
return -EINVAL;
if (new_mtu > batadv_hardif_min_mtu(dev, BATADV_MAX_MTU))
return -EINVAL;
dev->mtu = new_mtu;
......
atomic_set(&bat_priv->log_level, 0);
#endif
atomic_set(&bat_priv->fragmentation, 1);
atomic_set(&bat_priv->packet_size_max, ETH_DATA_LEN);
atomic_set(&bat_priv->packet_size_max, BATADV_MAX_MTU);
atomic_set(&bat_priv->bcast_queue_left, BATADV_BCAST_QUEUE_LEN);
atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
......
* have not been initialized yet
*/
dev->mtu = ETH_DATA_LEN;
dev->max_mtu = BATADV_MAX_MTU;
/* generate random address */
eth_hw_addr_random(dev);
    (1-1/1)