[v4,6/7] batman-adv: Distributed ARP Table - increase default soft_iface ARP table timeout
Commit Message
The default timeout value for ARP entries belonging to any soft_iface
ARP table has been incremented by a factor 4. This is necessary because the DHT
will store several network entries in the soft_iface ARP table.
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
main.h | 4 ++++
soft-interface.c | 17 +++++++++++++++++
2 files changed, 21 insertions(+), 0 deletions(-)
@@ -69,6 +69,10 @@
/* numbers of originator to contact for any STORE/GET DHT operation */
#define DHT_CANDIDATES_NUM 3
+/* Factor which default ARP timeout values of the soft_iface table are
+ * multiplied by */
+#define ARP_TIMEOUT_FACTOR 4
+
#define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE)
#define LOG_BUF_LEN 8192 /* has to be a power of 2 */
@@ -36,6 +36,7 @@
#include <linux/ethtool.h>
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
+#include <linux/inetdevice.h>
#include "unicast.h"
@@ -825,6 +826,7 @@ static void interface_setup(struct net_device *dev)
struct net_device *softif_create(const char *name)
{
struct net_device *soft_iface;
+ struct in_device *in_dev;
struct bat_priv *bat_priv;
int ret;
@@ -840,6 +842,21 @@ struct net_device *softif_create(const char *name)
goto free_soft_iface;
}
+ in_dev = in_dev_get(soft_iface);
+ if (!in_dev) {
+ pr_err("Unable to set ARP parameters for the batman interface "
+ "'%s'\n", name);
+ goto free_soft_iface;
+ }
+
+ /* Introduce a delay in the ARP state-machine transactions. Entries
+ * will be kept in the ARP table for the default time multiplied by 4 */
+ in_dev->arp_parms->base_reachable_time *= ARP_TIMEOUT_FACTOR;
+ in_dev->arp_parms->gc_staletime *= ARP_TIMEOUT_FACTOR;
+ in_dev->arp_parms->reachable_time *= ARP_TIMEOUT_FACTOR;
+
+ in_dev_put(in_dev);
+
bat_priv = netdev_priv(soft_iface);
atomic_set(&bat_priv->aggregated_ogms, 1);