From: "Linus Lüssing" <linus.luessing@ascom.ch>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: "Linus Lüssing" <linus.luessing@ascom.ch>
Subject: [B.A.T.M.A.N.] [PATCH 06/10] batman-adv: Purge outdated ndp neighbours
Date: Tue, 14 Dec 2010 10:58:12 +0100 [thread overview]
Message-ID: <1292320696-11983-7-git-send-email-linus.luessing@ascom.ch> (raw)
In-Reply-To: <1292320696-11983-1-git-send-email-linus.luessing@ascom.ch>
If no new packet has been received from a neighbour for a while, then
delete it from memory.
Signed-off-by: Linus Lüssing <linus.luessing@ascom.ch>
---
ndp.c | 25 +++++++++++++++++++++++++
ndp.h | 1 +
originator.c | 2 ++
3 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/ndp.c b/ndp.c
index 408dd70..80b30f1 100644
--- a/ndp.c
+++ b/ndp.c
@@ -184,6 +184,31 @@ static struct neigh_node *ndp_create_neighbor(uint8_t my_tq, uint32_t seqno,
return neigh_node;
}
+void ndp_purge_neighbors(void)
+{
+ struct neigh_node *neigh_node, *neigh_node_tmp;
+ struct batman_if *batman_if;
+
+ rcu_read_lock();
+ list_for_each_entry_rcu(batman_if, &if_list, list) {
+ if (batman_if->if_status != IF_ACTIVE)
+ continue;
+
+ spin_lock_bh(&batman_if->neigh_list_lock);
+ list_for_each_entry_safe(neigh_node, neigh_node_tmp,
+ &batman_if->neigh_list, list) {
+ if (time_before(jiffies,
+ neigh_node->last_valid + PURGE_TIMEOUT * HZ))
+ continue;
+
+ list_del(&neigh_node->list);
+ kfree(neigh_node);
+ }
+ spin_unlock_bh(&batman_if->neigh_list_lock);
+ }
+ rcu_read_unlock();
+}
+
int ndp_update_neighbor(uint8_t my_tq, uint32_t seqno,
struct batman_if *batman_if, uint8_t *neigh_addr)
{
diff --git a/ndp.h b/ndp.h
index 35146ce..5679f36 100644
--- a/ndp.h
+++ b/ndp.h
@@ -7,5 +7,6 @@ void ndp_free(struct batman_if *batman_if);
uint8_t ndp_fetch_tq(struct batman_packet_ndp *packet,
uint8_t *my_if_addr);
+void ndp_purge_neighbors(void);
int ndp_update_neighbor(uint8_t my_tq, uint32_t seqno,
struct batman_if *batman_if, uint8_t *neigh_addr);
diff --git a/originator.c b/originator.c
index 89ec021..ad31bf7 100644
--- a/originator.c
+++ b/originator.c
@@ -22,6 +22,7 @@
/* increase the reference counter for this originator */
#include "main.h"
+#include "ndp.h"
#include "originator.h"
#include "hash.h"
#include "translation-table.h"
@@ -307,6 +308,7 @@ static void purge_orig(struct work_struct *work)
container_of(delayed_work, struct bat_priv, orig_work);
_purge_orig(bat_priv);
+ ndp_purge_neighbors();
start_purge_timer(bat_priv);
}
--
1.7.1
next prev parent reply other threads:[~2010-12-14 9:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-14 9:58 [B.A.T.M.A.N.] NDP patches v3 Linus Lüssing
2010-12-14 9:58 ` [B.A.T.M.A.N.] [PATCH 01/10] batman-adv: Creating new neighbor discovery packet Linus Lüssing
2010-12-21 17:39 ` Marek Lindner
2010-12-21 18:01 ` Andrew Lunn
2010-12-14 9:58 ` [B.A.T.M.A.N.] [PATCH 02/10] batman-adv: Adding jittering methods for ndp Linus Lüssing
2010-12-14 9:58 ` [B.A.T.M.A.N.] [PATCH 03/10] batman-adv: Adding workqueue for new ndp packets Linus Lüssing
2010-12-21 23:52 ` Marek Lindner
2010-12-14 9:58 ` [B.A.T.M.A.N.] [PATCH 04/10] batman-adv: Send neighbor discovery packets Linus Lüssing
2010-12-22 13:43 ` Marek Lindner
2010-12-14 9:58 ` [B.A.T.M.A.N.] [PATCH 05/10] batman-adv: Creating neighbor structures, updating LQs Linus Lüssing
2010-12-15 17:09 ` [B.A.T.M.A.N.] linearize skb earlier Linus Lüssing
2010-12-15 17:09 ` [B.A.T.M.A.N.] [PATCHv2 05/10] batman-adv: Creating neighbor structures, updating LQs Linus Lüssing
2010-12-28 13:59 ` Marek Lindner
2010-12-14 9:58 ` Linus Lüssing [this message]
2010-12-28 14:09 ` [B.A.T.M.A.N.] [PATCH 06/10] batman-adv: Purge outdated ndp neighbours Marek Lindner
2010-12-14 9:58 ` [B.A.T.M.A.N.] [PATCH 07/10] batman-adv: Adding ndp debugfs output Linus Lüssing
2010-12-14 9:58 ` [B.A.T.M.A.N.] [PATCH 08/10] batman-adv: Adding batman_if specific sysfs wrapper macros for UINT Linus Lüssing
2010-12-28 15:14 ` Marek Lindner
2010-12-14 9:58 ` [B.A.T.M.A.N.] [PATCH 09/10] batman-adv: Adding sysfs parameter for ndp interval Linus Lüssing
2010-12-14 9:58 ` [B.A.T.M.A.N.] [PATCH 10/10] batman-adv: Use local tq values determined by NDP on OGMs Linus Lüssing
-- strict thread matches above, loose matches on Subject: below --
2010-12-07 14:39 [B.A.T.M.A.N.] NDP patches, first draft Linus Lüssing
2010-12-07 14:39 ` [B.A.T.M.A.N.] [PATCH 06/10] batman-adv: Purge outdated ndp neighbours Linus Lüssing
2010-12-09 9:23 ` Linus Lüssing
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=1292320696-11983-7-git-send-email-linus.luessing@ascom.ch \
--to=linus.luessing@ascom.ch \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox