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 02/10] batman-adv: Adding jittering methods for ndp
Date: Tue, 14 Dec 2010 10:58:08 +0100 [thread overview]
Message-ID: <1292320696-11983-3-git-send-email-linus.luessing@ascom.ch> (raw)
In-Reply-To: <1292320696-11983-1-git-send-email-linus.luessing@ascom.ch>
This patch adds a function for fetching and jittering an ndp interval
from batman-if structure. Needed later for timing the neighbor discovery
packets.
Signed-off-by: Linus Lüssing <linus.luessing@ascom.ch>
---
hard-interface.c | 2 +-
routing.c | 2 +-
send.c | 18 +++++++++++++-----
send.h | 3 ++-
types.h | 1 +
5 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/hard-interface.c b/hard-interface.c
index 784c475..da7b9a9 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -360,7 +360,7 @@ int hardif_enable_interface(struct batman_if *batman_if, char *iface_name)
batman_if->net_dev->name);
/* begin scheduling originator messages on that interface */
- schedule_own_packet(batman_if);
+ schedule_own_ogm_packet(batman_if);
out:
return 0;
diff --git a/routing.c b/routing.c
index a9406ba..7ebb631 100644
--- a/routing.c
+++ b/routing.c
@@ -561,7 +561,7 @@ void receive_bat_packet(struct ethhdr *ethhdr,
if (batman_packet_ogm->packet_type != BAT_PACKET_OGM)
return;
- /* could be changed by schedule_own_packet() */
+ /* could be changed by schedule_own_ogm_packet() */
if_incoming_seqno = atomic_read(&if_incoming->seqno);
has_directlink_flag = (batman_packet_ogm->flags & DIRECTLINK ? 1 : 0);
diff --git a/send.c b/send.c
index eb9c1e3..910411c 100644
--- a/send.c
+++ b/send.c
@@ -40,8 +40,16 @@ static uint8_t hop_penalty(const uint8_t tq, struct bat_priv *bat_priv)
return (tq * (TQ_MAX_VALUE - hop_penalty)) / (TQ_MAX_VALUE);
}
-/* when do we schedule our own packet to be sent */
-static unsigned long own_send_time(struct bat_priv *bat_priv)
+/* when do we schedule our own neighbor discovery packet to be sent */
+unsigned long own_ndp_send_time(struct batman_if *batman_if)
+{
+ return jiffies + msecs_to_jiffies(
+ atomic_read(&batman_if->ndp_interval) -
+ JITTER + (random32() % 2*JITTER));
+}
+
+/* when do we schedule our own originator packet to be sent */
+static unsigned long own_ogm_send_time(struct bat_priv *bat_priv)
{
return jiffies + msecs_to_jiffies(
atomic_read(&bat_priv->orig_interval) -
@@ -243,7 +251,7 @@ static void rebuild_batman_packet_ogm(struct bat_priv *bat_priv,
}
}
-void schedule_own_packet(struct batman_if *batman_if)
+void schedule_own_ogm_packet(struct batman_if *batman_if)
{
struct bat_priv *bat_priv = netdev_priv(batman_if->soft_iface);
unsigned long send_time;
@@ -296,7 +304,7 @@ void schedule_own_packet(struct batman_if *batman_if)
atomic_inc(&batman_if->seqno);
slide_own_bcast_window(batman_if);
- send_time = own_send_time(bat_priv);
+ send_time = own_ogm_send_time(bat_priv);
add_bat_packet_to_list(bat_priv,
batman_if->packet_buff,
batman_if->packet_len,
@@ -513,7 +521,7 @@ void send_outstanding_bat_packet(struct work_struct *work)
* shutting down
*/
if (forw_packet->own)
- schedule_own_packet(forw_packet->if_incoming);
+ schedule_own_ogm_packet(forw_packet->if_incoming);
out:
/* don't count own packet */
diff --git a/send.h b/send.h
index acf59e7..b626ddf 100644
--- a/send.h
+++ b/send.h
@@ -27,7 +27,8 @@
int send_skb_packet(struct sk_buff *skb,
struct batman_if *batman_if,
uint8_t *dst_addr);
-void schedule_own_packet(struct batman_if *batman_if);
+unsigned long own_ndp_send_time(struct batman_if *batman_if);
+void schedule_own_ogm_packet(struct batman_if *batman_if);
void schedule_forward_packet(struct orig_node *orig_node,
struct ethhdr *ethhdr,
struct batman_packet_ogm *batman_packet_ogm,
diff --git a/types.h b/types.h
index 1d00849..8921e20 100644
--- a/types.h
+++ b/types.h
@@ -47,6 +47,7 @@ struct batman_if {
struct packet_type batman_adv_ptype;
struct net_device *soft_iface;
struct rcu_head rcu;
+ atomic_t ndp_interval;
};
/**
--
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 ` Linus Lüssing [this message]
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 ` [B.A.T.M.A.N.] [PATCH 06/10] batman-adv: Purge outdated ndp neighbours Linus Lüssing
2010-12-28 14:09 ` 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 02/10] batman-adv: Adding jittering methods for ndp 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-3-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