From patchwork Tue Dec 7 14:39:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 640 Return-Path: Received: from rubicon.hasler.ascom.ch (rubicon.hasler.ascom.ch [139.79.129.1]) by open-mesh.org (Postfix) with ESMTPS id 3CE901545AF for ; Tue, 7 Dec 2010 15:39:29 +0100 (CET) Received: from eiger.ma.tech.ascom.ch (eiger.ma.tech.ascom.ch [139.79.100.1]) by rubicon.hasler.ascom.ch (8.14.4/8.14.4) with ESMTP id oB7EdSr1027744; Tue, 7 Dec 2010 15:39:28 +0100 (MET) Received: from [139.79.100.248] (helo=localhost) by eiger.ma.tech.ascom.ch with esmtp (Exim 3.16 #1) id 1PPyhS-0005u8-00; Tue, 07 Dec 2010 15:39:26 +0100 From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Tue, 7 Dec 2010 15:39:30 +0100 Message-Id: <1291732778-27441-3-git-send-email-linus.luessing@ascom.ch> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1291732778-27441-1-git-send-email-linus.luessing@ascom.ch> References: <1291732778-27441-1-git-send-email-linus.luessing@ascom.ch> Cc: =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [B.A.T.M.A.N.] [PATCH 02/10] batman-adv: Adding jittering methods for ndp X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Dec 2010 14:39:30 -0000 This patch adds a function for fetching and jittering an ndp interval from batman-if structure. Needed later for timing the neighbor discovery packets. --- 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; }; /**