All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antonio Quartulli <ordex@autistici.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCHv7 6/7] batman-adv: Distributed ARP Table - increase default soft_iface ARP table timeout
Date: Sun, 26 Feb 2012 19:23:22 +0100	[thread overview]
Message-ID: <1330280603-25510-7-git-send-email-ordex@autistici.org> (raw)
In-Reply-To: <1330280603-25510-1-git-send-email-ordex@autistici.org>

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>
---
 distributed-arp-table.c |   19 +++++++++++++++++++
 distributed-arp-table.h |    1 +
 main.h                  |    3 +++
 soft-interface.c        |    2 ++
 4 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/distributed-arp-table.c b/distributed-arp-table.c
index 148481e..0eac80c 100644
--- a/distributed-arp-table.c
+++ b/distributed-arp-table.c
@@ -23,6 +23,7 @@
 #include <linux/if_arp.h>
 /* needed to use arp_tbl */
 #include <net/arp.h>
+#include <linux/inetdevice.h>
 
 #include "main.h"
 #include "distributed-arp-table.h"
@@ -559,3 +560,21 @@ bool dat_drop_broadcast_packet(struct bat_priv *bat_priv,
 	}
 	return false;
 }
+
+void arp_change_timeout(struct net_device *soft_iface, const char *name)
+{
+	struct in_device *in_dev = in_dev_get(soft_iface);
+	if (!in_dev) {
+		pr_err("Unable to set ARP parameters for the batman interface "
+		       "'%s'\n", name);
+		return;
+	}
+
+	/* 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);
+}
diff --git a/distributed-arp-table.h b/distributed-arp-table.h
index 21c5d5e..235b2a4 100644
--- a/distributed-arp-table.h
+++ b/distributed-arp-table.h
@@ -47,6 +47,7 @@ bool dat_snoop_incoming_arp_reply(struct bat_priv *bat_priv,
 				  struct sk_buff *skb, int hdr_size);
 bool dat_drop_broadcast_packet(struct bat_priv *bat_priv,
 			       struct forw_packet *forw_packet);
+void arp_change_timeout(struct net_device *soft_iface, const char *name);
 
 /* hash function to choose an entry in a hash table of given size */
 /* hash algorithm from http://en.wikipedia.org/wiki/Hash_table */
diff --git a/main.h b/main.h
index 24dca8e..cf03674 100644
--- a/main.h
+++ b/main.h
@@ -71,6 +71,9 @@
 #define ARP_REQ_DELAY 250
 /* numbers of originator to contact for any PUT/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 LOG_BUF_LEN 8192	  /* has to be a power of 2 */
 
diff --git a/soft-interface.c b/soft-interface.c
index 0a78feb..8b68e01 100644
--- a/soft-interface.c
+++ b/soft-interface.c
@@ -381,6 +381,8 @@ struct net_device *softif_create(const char *name)
 		goto free_soft_iface;
 	}
 
+	arp_change_timeout(soft_iface, name);
+
 	bat_priv = netdev_priv(soft_iface);
 
 	atomic_set(&bat_priv->aggregated_ogms, 1);
-- 
1.7.3.4


  parent reply	other threads:[~2012-02-26 18:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-26 18:23 [B.A.T.M.A.N.] [PATCHv7 0/7] Distributed ARP Table Antonio Quartulli
2012-02-26 18:23 ` [B.A.T.M.A.N.] [PATCHv7 1/7] batman-adv: add UNICAST_4ADDR packet type Antonio Quartulli
2012-02-27 11:07   ` Marek Lindner
2012-02-26 18:23 ` [B.A.T.M.A.N.] [PATCHv7 2/7] batman-adv: add a new log level for DAT/ARP debugging Antonio Quartulli
2012-02-27 11:10   ` Marek Lindner
2012-02-26 18:23 ` [B.A.T.M.A.N.] [PATCHv7 3/7] batman-adv: Distributed ARP Table - create DHT helper functions Antonio Quartulli
2012-02-27 11:12   ` Marek Lindner
2012-02-26 18:23 ` [B.A.T.M.A.N.] [PATCHv7 4/7] batman-adv: Distributed ARP Table - add ARP parsing functions Antonio Quartulli
2012-02-27 11:16   ` Marek Lindner
2012-02-26 18:23 ` [B.A.T.M.A.N.] [PATCHv7 5/7] batman-adv: Distributed ARP Table - add snooping functions for ARP messages Antonio Quartulli
2012-02-27 11:19   ` Marek Lindner
2012-02-26 18:23 ` Antonio Quartulli [this message]
2012-02-27 11:22   ` [B.A.T.M.A.N.] [PATCHv7 6/7] batman-adv: Distributed ARP Table - increase default soft_iface ARP table timeout Marek Lindner
2012-02-26 18:23 ` [B.A.T.M.A.N.] [PATCHv7 7/7] batman-adv: Distributed ARP Table - add compile option Antonio Quartulli
2012-02-27 11:28   ` Marek Lindner

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=1330280603-25510-7-git-send-email-ordex@autistici.org \
    --to=ordex@autistici.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.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.