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 13/13] batman-adv: Add sequence number and duplicate checks for unicasts_safe
Date: Tue, 15 Feb 2011 18:12:28 +0100 [thread overview]
Message-ID: <1297789948-16948-14-git-send-email-linus.luessing@ascom.ch> (raw)
In-Reply-To: <1297789948-16948-1-git-send-email-linus.luessing@ascom.ch>
With the new redundant bonding mode a node might receive a unicast_safe
packet more than once. Therefore duplicate checks on any unicast_safe
packet need to be performed before further processing.
Signed-off-by: Linus Lüssing <linus.luessing@ascom.ch>
---
originator.c | 3 +++
routing.c | 14 +++++++++++++-
types.h | 2 ++
3 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/batman-adv/originator.c b/batman-adv/originator.c
index 4845421..7dc090c 100644
--- a/batman-adv/originator.c
+++ b/batman-adv/originator.c
@@ -204,6 +204,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)
INIT_LIST_HEAD(&orig_node->bond_list);
spin_lock_init(&orig_node->ogm_cnt_lock);
spin_lock_init(&orig_node->bcast_seqno_lock);
+ spin_lock_init(&orig_node->ucast_safe_seqno_lock);
spin_lock_init(&orig_node->neigh_list_lock);
kref_init(&orig_node->refcount);
@@ -213,6 +214,8 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)
orig_node->hna_buff = NULL;
orig_node->bcast_seqno_state.seqno_reset = jiffies - 1
- msecs_to_jiffies(RESET_PROTECTION_MS);
+ orig_node->ucast_safe_seqno_state.seqno_reset = jiffies - 1
+ - msecs_to_jiffies(RESET_PROTECTION_MS);
orig_node->batman_seqno_reset = jiffies - 1
- msecs_to_jiffies(RESET_PROTECTION_MS);
diff --git a/batman-adv/routing.c b/batman-adv/routing.c
index afbeef8..f92e5d3 100644
--- a/batman-adv/routing.c
+++ b/batman-adv/routing.c
@@ -1439,13 +1439,25 @@ int recv_ucast_safe_packet(struct sk_buff *skb, struct batman_if *recv_if)
struct unicast_packet_safe *unicast_packet;
struct orig_node *orig_node;
int hdr_size = sizeof(struct unicast_packet);
- int bonding_mode;
+ int ret, bonding_mode;
if (check_unicast_packet(skb, hdr_size) < 0)
return NET_RX_DROP;
unicast_packet = (struct unicast_packet_safe *)skb->data;
+ orig_node = hash_find_orig(bat_priv, unicast_packet->orig);
+ if (!orig_node)
+ return NET_RX_DROP;
+
+ ret = check_duplicate(bat_priv, ntohl(unicast_packet->seqno),
+ &orig_node->ucast_safe_seqno_state,
+ &orig_node->ucast_safe_seqno_lock);
+
+ kref_put(&orig_node->refcount, orig_node_free_ref);
+ if (ret == NET_RX_DROP)
+ return NET_RX_DROP;
+
/* packet for me */
if (is_my_mac(unicast_packet->dest)) {
unicast_safe_to_unicast(skb);
diff --git a/batman-adv/types.h b/batman-adv/types.h
index 5a2035a..d0ab22f 100644
--- a/batman-adv/types.h
+++ b/batman-adv/types.h
@@ -91,11 +91,13 @@ struct orig_node {
struct bat_priv *bat_priv;
unsigned long last_frag_packet;
struct seqno_state bcast_seqno_state;
+ struct seqno_state ucast_safe_seqno_state;
spinlock_t ogm_cnt_lock; /* protects: bcast_own, bcast_own_sum,
* neigh_node->real_bits,
* neigh_node->real_packet_count */
spinlock_t bcast_seqno_lock; /* protects bcast_bits,
* last_bcast_seqno */
+ spinlock_t ucast_safe_seqno_lock; /* protects ucast_safe_seqno_state */
atomic_t bond_candidates;
struct list_head bond_list;
};
--
1.7.2.3
prev parent reply other threads:[~2011-02-15 17:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-15 17:12 [B.A.T.M.A.N.] Redundancy bonding mode patches, v1 Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 01/13] batman-adv: Remove unused hdr_size variable in route_unicast_packet() Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 02/13] batman-adv: Add explicit batman header structure Linus Lüssing
2011-02-16 6:08 ` Andrew Lunn
2011-02-16 15:05 ` Linus Luessing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 03/13] batman-adv: Unify TTL handling Linus Lüssing
2011-02-16 6:16 ` Andrew Lunn
2011-02-16 14:42 ` Linus Luessing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 04/13] batman-adv: Make route_unicast_packet() packet_type independent Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 05/13] batman-adv: Add rcu-refcount wrapper for orig_node hash_find() Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 06/13] batman-adv: Use route_unicast_packet() for sending own unicast packets Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 07/13] batman-adv: Avoid redundant hash_find() call for " Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 08/13] batman-adv: Use packet lists for unicast packet sending Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 09/13] batman-adv: Add sysfs option for enabling redundant bonding mode Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 10/13] batman-adv: Adding redundant bonding mode transmission Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 11/13] batman-adv: Adding unicast_safe packet reception Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 12/13] batman-adv: Generic sequence number checking for data packets Linus Lüssing
2011-02-15 17:12 ` Linus Lüssing [this message]
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=1297789948-16948-14-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