b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH 1/5] Rename 'tq_avg' field of struct 'neigh_node' in 'tq'.
@ 2011-11-17 15:53 Daniele Furlan
  2011-11-17 15:53 ` [B.A.T.M.A.N.] [PATCH 2/5] Introduce sequence number recording of ogm received from neighbours Daniele Furlan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Daniele Furlan @ 2011-11-17 15:53 UTC (permalink / raw)
  To: b.a.t.m.a.n

 This patch rename the 'tq_avg' field of struct 'neigh_node' in 'tq'.
 This will reflect the absence of an averaging of tq values.

Signed-off-by: Daniele Furlan <daniele.furlan@gmail.com>
---
 bat_iv_ogm.c     |   20 ++++++++++----------
 gateway_client.c |   36 ++++++++++++++++++------------------
 originator.c     |    8 ++++----
 routing.c        |    4 ++--
 types.h          |    2 +-
 vis.c            |    8 ++++----
 6 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index 3512e25..d39938c 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -468,7 +468,7 @@ static void bat_ogm_forward(struct orig_node *orig_node,
 {
 	struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
 	struct neigh_node *router;
-	uint8_t in_tq, in_ttl, tq_avg = 0;
+	uint8_t in_tq, in_ttl, tq = 0;
 	uint8_t tt_num_changes;
 
 	if (batman_ogm_packet->ttl <= 1) {
@@ -487,17 +487,17 @@ static void bat_ogm_forward(struct orig_node *orig_node,
 
 	/* rebroadcast tq of our best ranking neighbor to ensure the rebroadcast
 	 * of our best tq value */
-	if (router && router->tq_avg != 0) {
+	if (router && router->tq != 0) {
 
 		/* rebroadcast ogm of best ranking neighbor as is */
 		if (!compare_eth(router->addr, ethhdr->h_source)) {
-			batman_ogm_packet->tq = router->tq_avg;
+			batman_ogm_packet->tq = router->tq;
 
 			if (router->last_ttl)
 				batman_ogm_packet->ttl = router->last_ttl - 1;
 		}
 
-		tq_avg = router->tq_avg;
+		tq = router->tq;
 	}
 
 	if (router)
@@ -507,9 +507,9 @@ static void bat_ogm_forward(struct orig_node *orig_node,
 	batman_ogm_packet->tq = hop_penalty(batman_ogm_packet->tq, bat_priv);
 
 	bat_dbg(DBG_BATMAN, bat_priv,
-		"Forwarding packet: tq_orig: %i, tq_avg: %i, "
+		"Forwarding packet: tq_orig: %i, tq: %i, "
 		"tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n",
-		in_tq, tq_avg, batman_ogm_packet->tq, in_ttl - 1,
+		in_tq, tq, batman_ogm_packet->tq, in_ttl - 1,
 		batman_ogm_packet->ttl);
 
 	batman_ogm_packet->seqno = htonl(batman_ogm_packet->seqno);
@@ -607,7 +607,7 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv,
 		spin_lock_bh(&tmp_neigh_node->tq_lock);
 		ring_buffer_set(tmp_neigh_node->tq_recv,
 				&tmp_neigh_node->tq_index, 0);
-		tmp_neigh_node->tq_avg =
+		tmp_neigh_node->tq =
 			ring_buffer_avg(tmp_neigh_node->tq_recv);
 		spin_unlock_bh(&tmp_neigh_node->tq_lock);
 	}
@@ -638,7 +638,7 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv,
 	ring_buffer_set(neigh_node->tq_recv,
 			&neigh_node->tq_index,
 			batman_ogm_packet->tq);
-	neigh_node->tq_avg = ring_buffer_avg(neigh_node->tq_recv);
+	neigh_node->tq = ring_buffer_avg(neigh_node->tq_recv);
 	spin_unlock_bh(&neigh_node->tq_lock);
 
 	if (!is_duplicate) {
@@ -655,12 +655,12 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv,
 		goto update_tt;
 
 	/* if this neighbor does not offer a better TQ we won't consider it */
-	if (router && (router->tq_avg > neigh_node->tq_avg))
+	if (router && (router->tq > neigh_node->tq))
 		goto update_tt;
 
 	/* if the TQ is the same and the link not more symmetric we
 	 * won't consider it either */
-	if (router && (neigh_node->tq_avg == router->tq_avg)) {
+	if (router && (neigh_node->tq == router->tq)) {
 		orig_node_tmp = router->orig_node;
 		spin_lock_bh(&orig_node_tmp->ogm_cnt_lock);
 		bcast_own_sum_orig =
diff --git a/gateway_client.c b/gateway_client.c
index 9373a14..f84fc2d 100644
--- a/gateway_client.c
+++ b/gateway_client.c
@@ -134,14 +134,14 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv)
 			gw_bandwidth_to_kbit(gw_node->orig_node->gw_flags,
 					     &down, &up);
 
-			tmp_gw_factor = (router->tq_avg * router->tq_avg *
+			tmp_gw_factor = (router->tq * router->tq *
 					 down * 100 * 100) /
 					 (TQ_LOCAL_WINDOW_SIZE *
 					 TQ_LOCAL_WINDOW_SIZE * 64);
 
 			if ((tmp_gw_factor > max_gw_factor) ||
 			    ((tmp_gw_factor == max_gw_factor) &&
-			     (router->tq_avg > max_tq))) {
+			     (router->tq > max_tq))) {
 				if (curr_gw)
 					gw_node_free_ref(curr_gw);
 				curr_gw = gw_node;
@@ -157,7 +157,7 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv)
 			  *     soon as a better gateway appears which has
 			  *     $routing_class more tq points)
 			  **/
-			if (router->tq_avg > max_tq) {
+			if (router->tq > max_tq) {
 				if (curr_gw)
 					gw_node_free_ref(curr_gw);
 				curr_gw = gw_node;
@@ -166,8 +166,8 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv)
 			break;
 		}
 
-		if (router->tq_avg > max_tq)
-			max_tq = router->tq_avg;
+		if (router->tq > max_tq)
+			max_tq = router->tq;
 
 		if (tmp_gw_factor > max_gw_factor)
 			max_gw_factor = tmp_gw_factor;
@@ -226,7 +226,7 @@ void gw_election(struct bat_priv *bat_priv)
 			"Adding route to gateway %pM (gw_flags: %i, tq: %i)\n",
 			next_gw->orig_node->orig,
 			next_gw->orig_node->gw_flags,
-			router->tq_avg);
+			router->tq);
 		throw_uevent(bat_priv, UEV_GW, UEV_ADD, gw_addr);
 	} else {
 		bat_dbg(DBG_BATMAN, bat_priv,
@@ -234,7 +234,7 @@ void gw_election(struct bat_priv *bat_priv)
 			"(gw_flags: %i, tq: %i)\n",
 			next_gw->orig_node->orig,
 			next_gw->orig_node->gw_flags,
-			router->tq_avg);
+			router->tq);
 		throw_uevent(bat_priv, UEV_GW, UEV_CHANGE, gw_addr);
 	}
 
@@ -253,7 +253,7 @@ void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node)
 {
 	struct orig_node *curr_gw_orig;
 	struct neigh_node *router_gw = NULL, *router_orig = NULL;
-	uint8_t gw_tq_avg, orig_tq_avg;
+	uint8_t gw_tq, orig_tq;
 
 	curr_gw_orig = gw_get_selected_orig(bat_priv);
 	if (!curr_gw_orig)
@@ -271,11 +271,11 @@ void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node)
 	if (!router_orig)
 		goto out;
 
-	gw_tq_avg = router_gw->tq_avg;
-	orig_tq_avg = router_orig->tq_avg;
+	gw_tq = router_gw->tq;
+	orig_tq = router_orig->tq;
 
 	/* the TQ value has to be better */
-	if (orig_tq_avg < gw_tq_avg)
+	if (orig_tq < gw_tq)
 		goto out;
 
 	/**
@@ -283,13 +283,13 @@ void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node)
 	 * greater the TQ value of the new gateway must be
 	 **/
 	if ((atomic_read(&bat_priv->gw_sel_class) > 3) &&
-	    (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_sel_class)))
+	    (orig_tq - gw_tq < atomic_read(&bat_priv->gw_sel_class)))
 		goto out;
 
 	bat_dbg(DBG_BATMAN, bat_priv,
 		"Restarting gateway selection: better gateway found (tq curr: "
 		"%i, tq new: %i)\n",
-		gw_tq_avg, orig_tq_avg);
+		gw_tq, orig_tq);
 
 deselect:
 	gw_deselect(bat_priv);
@@ -448,7 +448,7 @@ static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq,
 	ret = seq_printf(seq, "%s %pM (%3i) %pM [%10s]: %3i - %i%s/%i%s\n",
 			 (curr_gw == gw_node ? "=>" : "  "),
 			 gw_node->orig_node->orig,
-			 router->tq_avg, router->addr,
+			 router->tq, router->addr,
 			 router->if_incoming->net_dev->name,
 			 gw_node->orig_node->gw_flags,
 			 (down > 2048 ? down / 1024 : down),
@@ -647,7 +647,7 @@ bool gw_out_of_range(struct bat_priv *bat_priv,
 	struct gw_node *curr_gw = NULL;
 	bool ret, out_of_range = false;
 	unsigned int header_len = 0;
-	uint8_t curr_tq_avg;
+	uint8_t curr_tq;
 
 	ret = gw_is_dhcp_target(skb, &header_len);
 	if (!ret)
@@ -669,7 +669,7 @@ bool gw_out_of_range(struct bat_priv *bat_priv,
 	case GW_MODE_SERVER:
 		/* If we are a GW then we are our best GW. We can artificially
 		 * set the tq towards ourself as the maximum value */
-		curr_tq_avg = TQ_MAX_VALUE;
+		curr_tq = TQ_MAX_VALUE;
 		break;
 	case GW_MODE_CLIENT:
 		curr_gw = gw_get_selected_gw_node(bat_priv);
@@ -687,7 +687,7 @@ bool gw_out_of_range(struct bat_priv *bat_priv,
 		if (!neigh_curr)
 			goto out;
 
-		curr_tq_avg = neigh_curr->tq_avg;
+		curr_tq = neigh_curr->tq;
 		break;
 	case GW_MODE_OFF:
 	default:
@@ -698,7 +698,7 @@ bool gw_out_of_range(struct bat_priv *bat_priv,
 	if (!!neigh_old)
 		goto out;
 
-	if (curr_tq_avg - neigh_old->tq_avg > GW_THRESHOLD)
+	if (curr_tq - neigh_old->tq > GW_THRESHOLD)
 		out_of_range = true;
 
 out:
diff --git a/originator.c b/originator.c
index 0bc2045..99ede46 100644
--- a/originator.c
+++ b/originator.c
@@ -312,7 +312,7 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv,
 			neigh_node_free_ref(neigh_node);
 		} else {
 			if ((!*best_neigh_node) ||
-			    (neigh_node->tq_avg > (*best_neigh_node)->tq_avg))
+			    (neigh_node->tq > (*best_neigh_node)->tq))
 				*best_neigh_node = neigh_node;
 		}
 	}
@@ -448,7 +448,7 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
 			if (!neigh_node)
 				continue;
 
-			if (neigh_node->tq_avg == 0)
+			if (neigh_node->tq == 0)
 				goto next;
 
 			last_seen_secs = jiffies_to_msecs(jiffies -
@@ -458,7 +458,7 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
 
 			seq_printf(seq, "%pM %4i.%03is   (%3i) %pM [%10s]:",
 				   orig_node->orig, last_seen_secs,
-				   last_seen_msecs, neigh_node->tq_avg,
+				   last_seen_msecs, neigh_node->tq,
 				   neigh_node->addr,
 				   neigh_node->if_incoming->net_dev->name);
 
@@ -466,7 +466,7 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
 						 &orig_node->neigh_list, list) {
 				seq_printf(seq, " %pM (%3i)",
 					   neigh_node_tmp->addr,
-					   neigh_node_tmp->tq_avg);
+					   neigh_node_tmp->tq);
 			}
 
 			seq_printf(seq, "\n");
diff --git a/routing.c b/routing.c
index ef24a72..d76867e 100644
--- a/routing.c
+++ b/routing.c
@@ -160,7 +160,7 @@ void bonding_candidate_add(struct orig_node *orig_node,
 		goto candidate_del;
 
 	/* ... and is good enough to be considered */
-	if (neigh_node->tq_avg < router->tq_avg - BONDING_TQ_THRESHOLD)
+	if (neigh_node->tq < router->tq - BONDING_TQ_THRESHOLD)
 		goto candidate_del;
 
 	/**
@@ -552,7 +552,7 @@ static struct neigh_node *find_ifalter_router(struct orig_node *primary_orig,
 		/* if we don't have a router yet
 		 * or this one is better, choose it. */
 		if ((!router) ||
-		    (tmp_neigh_node->tq_avg > router->tq_avg)) {
+		    (tmp_neigh_node->tq > router->tq)) {
 			/* decrement refcount of
 			 * previously selected router */
 			if (router)
diff --git a/types.h b/types.h
index e9eb043..84b9c59 100644
--- a/types.h
+++ b/types.h
@@ -127,7 +127,7 @@ struct neigh_node {
 	uint8_t real_packet_count;
 	uint8_t tq_recv[TQ_GLOBAL_WINDOW_SIZE];
 	uint8_t tq_index;
-	uint8_t tq_avg;
+	uint8_t tq;
 	uint8_t last_ttl;
 	struct list_head bonding_list;
 	unsigned long last_valid;
diff --git a/vis.c b/vis.c
index cc3b9f2..6e155a4 100644
--- a/vis.c
+++ b/vis.c
@@ -572,8 +572,8 @@ static int find_best_vis_server(struct bat_priv *bat_priv,
 				continue;
 
 			if ((orig_node->flags & VIS_SERVER) &&
-			    (router->tq_avg > best_tq)) {
-				best_tq = router->tq_avg;
+			    (router->tq > best_tq)) {
+				best_tq = router->tq;
 				memcpy(packet->target_orig, orig_node->orig,
 				       ETH_ALEN);
 			}
@@ -644,7 +644,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
 			if (router->if_incoming->if_status != IF_ACTIVE)
 				goto next;
 
-			if (router->tq_avg < 1)
+			if (router->tq < 1)
 				goto next;
 
 			/* fill one entry into buffer. */
@@ -654,7 +654,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
 			       router->if_incoming->net_dev->dev_addr,
 			       ETH_ALEN);
 			memcpy(entry->dest, orig_node->orig, ETH_ALEN);
-			entry->quality = router->tq_avg;
+			entry->quality = router->tq;
 			packet->entries++;
 
 next:
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [B.A.T.M.A.N.] [PATCH 2/5] Introduce sequence number recording of ogm received from neighbours.
  2011-11-17 15:53 [B.A.T.M.A.N.] [PATCH 1/5] Rename 'tq_avg' field of struct 'neigh_node' in 'tq' Daniele Furlan
@ 2011-11-17 15:53 ` Daniele Furlan
  2011-11-17 15:53 ` [B.A.T.M.A.N.] [PATCH 3/5] Remove TQ global window and tq averaging Daniele Furlan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Daniele Furlan @ 2011-11-17 15:53 UTC (permalink / raw)
  To: b.a.t.m.a.n

 The introduction of sequence number recording of ogm received from neighbours allows
 to introduce a control on ogm seqence number gap to identify broken paths
 substituing the method based on global window.

Signed-off-by: Daniele Furlan <daniele.furlan@gmail.com>
---
 bat_iv_ogm.c |    5 +++++
 types.h      |    2 ++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index d39938c..bdb4f1a 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -865,6 +865,11 @@ static int bat_ogm_update_seqnos(const struct ethhdr *ethhdr,
 		else
 			set_mark = 0;
 
+		/* update last originator seqno received from this neighbour */
+		if ((set_mark) && 
+			(batman_ogm_packet->seqno > tmp_neigh_node->last_seqno))
+			tmp_neigh_node->last_seqno = batman_ogm_packet->seqno;
+
 		/* if the window moved, set the update flag. */
 		need_update |= bit_get_packet(bat_priv,
 					      tmp_neigh_node->real_bits,
diff --git a/types.h b/types.h
index 84b9c59..910ce85 100644
--- a/types.h
+++ b/types.h
@@ -120,6 +120,7 @@ struct gw_node {
 /**
  *	neigh_node
  *	@last_valid: when last packet via this neighbor was received
+ *	@last_seqno: last originator seqno received via this neighbor
  */
 struct neigh_node {
 	struct hlist_node list;
@@ -128,6 +129,7 @@ struct neigh_node {
 	uint8_t tq_recv[TQ_GLOBAL_WINDOW_SIZE];
 	uint8_t tq_index;
 	uint8_t tq;
+	uint32_t last_seqno;
 	uint8_t last_ttl;
 	struct list_head bonding_list;
 	unsigned long last_valid;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [B.A.T.M.A.N.] [PATCH 3/5] Remove TQ global window and tq averaging.
  2011-11-17 15:53 [B.A.T.M.A.N.] [PATCH 1/5] Rename 'tq_avg' field of struct 'neigh_node' in 'tq' Daniele Furlan
  2011-11-17 15:53 ` [B.A.T.M.A.N.] [PATCH 2/5] Introduce sequence number recording of ogm received from neighbours Daniele Furlan
@ 2011-11-17 15:53 ` Daniele Furlan
  2011-11-17 15:53 ` [B.A.T.M.A.N.] [PATCH 4/5] Change ogm forwarding rules Daniele Furlan
  2011-11-17 15:53 ` [B.A.T.M.A.N.] [PATCH 5/5] Remove unnecessary code Daniele Furlan
  3 siblings, 0 replies; 5+ messages in thread
From: Daniele Furlan @ 2011-11-17 15:53 UTC (permalink / raw)
  To: b.a.t.m.a.n

 This patch remove TQ global window and tq averaging, only the latest tq
 value is maintained, this is necessary to guarantee metric monotonicity
 necessary to ensure loop-freeness.
 This patch remove also unused ring_buffer.c and ring_buffer.h files.

Signed-off-by: Daniele Furlan <daniele.furlan@gmail.com>
---
 Makefile.kbuild |    1 -
 bat_iv_ogm.c    |   21 +++++++--------------
 main.h          |    2 +-
 ring_buffer.c   |   52 ----------------------------------------------------
 ring_buffer.h   |   28 ----------------------------
 types.h         |    2 --
 6 files changed, 8 insertions(+), 98 deletions(-)
 delete mode 100644 ring_buffer.c
 delete mode 100644 ring_buffer.h

diff --git a/Makefile.kbuild b/Makefile.kbuild
index bd7e93c..ee83b89 100644
--- a/Makefile.kbuild
+++ b/Makefile.kbuild
@@ -43,7 +43,6 @@ batman-adv-y += hash.o
 batman-adv-y += icmp_socket.o
 batman-adv-y += main.o
 batman-adv-y += originator.o
-batman-adv-y += ring_buffer.o
 batman-adv-y += routing.o
 batman-adv-y += send.o
 batman-adv-y += soft-interface.o
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index bdb4f1a..9f6cc9b 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -22,7 +22,6 @@
 #include "main.h"
 #include "bat_ogm.h"
 #include "translation-table.h"
-#include "ring_buffer.h"
 #include "originator.h"
 #include "routing.h"
 #include "gateway_common.h"
@@ -604,12 +603,11 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv,
 		if (is_duplicate)
 			continue;
 
-		spin_lock_bh(&tmp_neigh_node->tq_lock);
-		ring_buffer_set(tmp_neigh_node->tq_recv,
-				&tmp_neigh_node->tq_index, 0);
-		tmp_neigh_node->tq =
-			ring_buffer_avg(tmp_neigh_node->tq_recv);
-		spin_unlock_bh(&tmp_neigh_node->tq_lock);
+		/* if not received more than TQ_MAX_SEQNO_GAP OGM from neighbour
+		 * set its tq to 0 */
+		if ((batman_ogm_packet->seqno - tmp_neigh_node->last_seqno) >
+		    												TQ_MAX_SEQNO_GAP)
+			tmp_neigh_node->tq = 0;
 	}
 
 	if (!neigh_node) {
@@ -633,13 +631,8 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv,
 
 	orig_node->flags = batman_ogm_packet->flags;
 	neigh_node->last_valid = jiffies;
-
-	spin_lock_bh(&neigh_node->tq_lock);
-	ring_buffer_set(neigh_node->tq_recv,
-			&neigh_node->tq_index,
-			batman_ogm_packet->tq);
-	neigh_node->tq = ring_buffer_avg(neigh_node->tq_recv);
-	spin_unlock_bh(&neigh_node->tq_lock);
+	/* update tq of neighbour */
+	neigh_node->tq = batman_ogm_packet->tq;
 
 	if (!is_duplicate) {
 		orig_node->last_ttl = batman_ogm_packet->ttl;
diff --git a/main.h b/main.h
index 464439f..a778388 100644
--- a/main.h
+++ b/main.h
@@ -49,7 +49,7 @@
 #define TQ_LOCAL_WINDOW_SIZE 64
 #define TT_REQUEST_TIMEOUT 3 /* seconds we have to keep pending tt_req */
 
-#define TQ_GLOBAL_WINDOW_SIZE 5
+#define TQ_MAX_SEQNO_GAP 5 /* max ogm loss before declaring a path broken */
 #define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1
 #define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1
 #define TQ_TOTAL_BIDRECT_LIMIT 1
diff --git a/ring_buffer.c b/ring_buffer.c
deleted file mode 100644
index f1ccfa7..0000000
--- a/ring_buffer.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors:
- *
- * Marek Lindner
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- *
- */
-
-#include "main.h"
-#include "ring_buffer.h"
-
-void ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index, uint8_t value)
-{
-	lq_recv[*lq_index] = value;
-	*lq_index = (*lq_index + 1) % TQ_GLOBAL_WINDOW_SIZE;
-}
-
-uint8_t ring_buffer_avg(const uint8_t lq_recv[])
-{
-	const uint8_t *ptr;
-	uint16_t count = 0, i = 0, sum = 0;
-
-	ptr = lq_recv;
-
-	while (i < TQ_GLOBAL_WINDOW_SIZE) {
-		if (*ptr != 0) {
-			count++;
-			sum += *ptr;
-		}
-
-		i++;
-		ptr++;
-	}
-
-	if (count == 0)
-		return 0;
-
-	return (uint8_t)(sum / count);
-}
diff --git a/ring_buffer.h b/ring_buffer.h
deleted file mode 100644
index 7cdfe62..0000000
--- a/ring_buffer.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors:
- *
- * Marek Lindner
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- *
- */
-
-#ifndef _NET_BATMAN_ADV_RING_BUFFER_H_
-#define _NET_BATMAN_ADV_RING_BUFFER_H_
-
-void ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index, uint8_t value);
-uint8_t ring_buffer_avg(const uint8_t lq_recv[]);
-
-#endif /* _NET_BATMAN_ADV_RING_BUFFER_H_ */
diff --git a/types.h b/types.h
index 910ce85..2006277 100644
--- a/types.h
+++ b/types.h
@@ -126,8 +126,6 @@ struct neigh_node {
 	struct hlist_node list;
 	uint8_t addr[ETH_ALEN];
 	uint8_t real_packet_count;
-	uint8_t tq_recv[TQ_GLOBAL_WINDOW_SIZE];
-	uint8_t tq_index;
 	uint8_t tq;
 	uint32_t last_seqno;
 	uint8_t last_ttl;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [B.A.T.M.A.N.]  [PATCH 4/5] Change ogm forwarding rules
  2011-11-17 15:53 [B.A.T.M.A.N.] [PATCH 1/5] Rename 'tq_avg' field of struct 'neigh_node' in 'tq' Daniele Furlan
  2011-11-17 15:53 ` [B.A.T.M.A.N.] [PATCH 2/5] Introduce sequence number recording of ogm received from neighbours Daniele Furlan
  2011-11-17 15:53 ` [B.A.T.M.A.N.] [PATCH 3/5] Remove TQ global window and tq averaging Daniele Furlan
@ 2011-11-17 15:53 ` Daniele Furlan
  2011-11-17 15:53 ` [B.A.T.M.A.N.] [PATCH 5/5] Remove unnecessary code Daniele Furlan
  3 siblings, 0 replies; 5+ messages in thread
From: Daniele Furlan @ 2011-11-17 15:53 UTC (permalink / raw)
  To: b.a.t.m.a.n

 This patch changes ogm forwarding rules in order to guarantee loop-freeness.
 Now only the ogm coming from the current router is forwarded.
 The tq substitution with the router tq is deleted, ogm coming
 from sub-optimal path, they are simply discarded.

Signed-off-by: Daniele Furlan <daniele.furlan@gmail.com>
---
 bat_iv_ogm.c |   45 +++++++++++++++++++--------------------------
 1 files changed, 19 insertions(+), 26 deletions(-)

diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index 9f6cc9b..ec7265a 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -466,8 +466,7 @@ static void bat_ogm_forward(struct orig_node *orig_node,
 			    int directlink, struct hard_iface *if_incoming)
 {
 	struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
-	struct neigh_node *router;
-	uint8_t in_tq, in_ttl, tq = 0;
+	uint8_t in_tq, in_ttl;
 	uint8_t tt_num_changes;
 
 	if (batman_ogm_packet->ttl <= 1) {
@@ -475,8 +474,6 @@ static void bat_ogm_forward(struct orig_node *orig_node,
 		return;
 	}
 
-	router = orig_node_get_router(orig_node);
-
 	in_tq = batman_ogm_packet->tq;
 	in_ttl = batman_ogm_packet->ttl;
 	tt_num_changes = batman_ogm_packet->tt_num_changes;
@@ -484,31 +481,13 @@ static void bat_ogm_forward(struct orig_node *orig_node,
 	batman_ogm_packet->ttl--;
 	memcpy(batman_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN);
 
-	/* rebroadcast tq of our best ranking neighbor to ensure the rebroadcast
-	 * of our best tq value */
-	if (router && router->tq != 0) {
-
-		/* rebroadcast ogm of best ranking neighbor as is */
-		if (!compare_eth(router->addr, ethhdr->h_source)) {
-			batman_ogm_packet->tq = router->tq;
-
-			if (router->last_ttl)
-				batman_ogm_packet->ttl = router->last_ttl - 1;
-		}
-
-		tq = router->tq;
-	}
-
-	if (router)
-		neigh_node_free_ref(router);
-
 	/* apply hop penalty */
 	batman_ogm_packet->tq = hop_penalty(batman_ogm_packet->tq, bat_priv);
 
 	bat_dbg(DBG_BATMAN, bat_priv,
-		"Forwarding packet: tq_orig: %i, tq: %i, "
+		"Forwarding packet: tq_orig: %i, "
 		"tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n",
-		in_tq, tq, batman_ogm_packet->tq, in_ttl - 1,
+		in_tq, batman_ogm_packet->tq, in_ttl - 1,
 		batman_ogm_packet->ttl);
 
 	batman_ogm_packet->seqno = htonl(batman_ogm_packet->seqno);
@@ -897,6 +876,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
 	struct hard_iface *hard_iface;
 	struct orig_node *orig_neigh_node, *orig_node;
 	struct neigh_node *router = NULL, *router_router = NULL;
+	struct neigh_node *new_router = NULL;
 	struct neigh_node *orig_neigh_router = NULL;
 	int has_directlink_flag;
 	int is_my_addr = 0, is_my_orig = 0, is_my_oldorig = 0;
@@ -1113,9 +1093,20 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
 		goto out_neigh;
 	}
 
-	if (is_duplicate) {
+	/* old packet */
+	if (orig_node->last_real_seqno > batman_ogm_packet->seqno) {
+		bat_dbg(DBG_BATMAN, bat_priv,
+			"Drop packet: old packet received\n");
+		goto out_neigh;
+	}
+	
+	/* get router after updates */
+	new_router = orig_node_get_router(orig_node);
+
+	/* forward only ogm coming from current router */
+	if (compare_eth(new_router->addr, ethhdr->h_source) == 0) {
 		bat_dbg(DBG_BATMAN, bat_priv,
-			"Drop packet: duplicate packet received\n");
+			"Drop packet: not received via current router\n");
 		goto out_neigh;
 	}
 
@@ -1133,6 +1124,8 @@ out:
 		neigh_node_free_ref(router_router);
 	if (orig_neigh_router)
 		neigh_node_free_ref(orig_neigh_router);
+	if (new_router)
+		neigh_node_free_ref(new_router);
 
 	orig_node_free_ref(orig_node);
 }
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [B.A.T.M.A.N.]  [PATCH 5/5] Remove unnecessary code
  2011-11-17 15:53 [B.A.T.M.A.N.] [PATCH 1/5] Rename 'tq_avg' field of struct 'neigh_node' in 'tq' Daniele Furlan
                   ` (2 preceding siblings ...)
  2011-11-17 15:53 ` [B.A.T.M.A.N.] [PATCH 4/5] Change ogm forwarding rules Daniele Furlan
@ 2011-11-17 15:53 ` Daniele Furlan
  3 siblings, 0 replies; 5+ messages in thread
From: Daniele Furlan @ 2011-11-17 15:53 UTC (permalink / raw)
  To: b.a.t.m.a.n

 This patch remove the now unnecessary code that avoid temporary routing loops
 since new forwading rules guarantees loop-freeness so it becomes useless.

Signed-off-by: Daniele Furlan <daniele.furlan@gmail.com>
---
 bat_iv_ogm.c |   21 ---------------------
 1 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index ec7265a..f76a38c 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -875,7 +875,6 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
 	struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
 	struct hard_iface *hard_iface;
 	struct orig_node *orig_neigh_node, *orig_node;
-	struct neigh_node *router = NULL, *router_router = NULL;
 	struct neigh_node *new_router = NULL;
 	struct neigh_node *orig_neigh_router = NULL;
 	int has_directlink_flag;
@@ -1025,22 +1024,6 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
 		goto out;
 	}
 
-	router = orig_node_get_router(orig_node);
-	if (router)
-		router_router = orig_node_get_router(router->orig_node);
-
-	/* avoid temporary routing loops */
-	if (router && router_router &&
-	    (compare_eth(router->addr, batman_ogm_packet->prev_sender)) &&
-	    !(compare_eth(batman_ogm_packet->orig,
-			  batman_ogm_packet->prev_sender)) &&
-	    (compare_eth(router->addr, router_router->addr))) {
-		bat_dbg(DBG_BATMAN, bat_priv,
-			"Drop packet: ignoring all rebroadcast packets that "
-			"may make me loop (sender: %pM)\n", ethhdr->h_source);
-		goto out;
-	}
-
 	/* if sender is a direct neighbor the sender mac equals
 	 * originator mac */
 	orig_neigh_node = (is_single_hop_neigh ?
@@ -1118,10 +1101,6 @@ out_neigh:
 	if ((orig_neigh_node) && (!is_single_hop_neigh))
 		orig_node_free_ref(orig_neigh_node);
 out:
-	if (router)
-		neigh_node_free_ref(router);
-	if (router_router)
-		neigh_node_free_ref(router_router);
 	if (orig_neigh_router)
 		neigh_node_free_ref(orig_neigh_router);
 	if (new_router)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-17 15:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-17 15:53 [B.A.T.M.A.N.] [PATCH 1/5] Rename 'tq_avg' field of struct 'neigh_node' in 'tq' Daniele Furlan
2011-11-17 15:53 ` [B.A.T.M.A.N.] [PATCH 2/5] Introduce sequence number recording of ogm received from neighbours Daniele Furlan
2011-11-17 15:53 ` [B.A.T.M.A.N.] [PATCH 3/5] Remove TQ global window and tq averaging Daniele Furlan
2011-11-17 15:53 ` [B.A.T.M.A.N.] [PATCH 4/5] Change ogm forwarding rules Daniele Furlan
2011-11-17 15:53 ` [B.A.T.M.A.N.] [PATCH 5/5] Remove unnecessary code Daniele Furlan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).