Index: source/ariba/overlay/modules/chord/Chord.cpp
===================================================================
--- source/ariba/overlay/modules/chord/Chord.cpp	(revision 5752)
+++ source/ariba/overlay/modules/chord/Chord.cpp	(revision 5756)
@@ -58,4 +58,6 @@
 	// create routing table
 	this->table = new chord_routing_table(_nodeid, 2);
+
+	// init counters
 	orphan_removal_counter = 0;
 	discovery_count = 0;
@@ -97,4 +99,12 @@
 	if (link.isUnspecified()) return 0;
 	return baseoverlay.sendMessage(msg, link);
+}
+
+const LinkID& Chord::get_next_hop( const NodeID& id ) const {
+	BOOST_FOREACH( const back_route& br, back_routes )
+		if (br.id==id) return br.link;
+	const route_item* item = table->get_next_hop(id);
+	if (item==NULL) return LinkID::UNSPECIFIED;
+	return item->info;
 }
 
@@ -112,6 +122,6 @@
 
 	// get next hop
-	const route_item* item = table->get_next_hop(destination);
-	if (item!=NULL && !item->info.isUnspecified()) send(&cmsg, item->info);
+	LinkID next_link = get_next_hop(destination);
+	if (!next_link.isUnspecified()) send(&cmsg, next_link);
 }
 
@@ -179,8 +189,8 @@
 void Chord::routeMessage(const NodeID& destnode, Message* msg) {
 	// get next hop
-	const route_item* item = table->get_next_hop(destnode);
+	LinkID next_link = get_next_hop(destnode);
 
 	// message for this node? yes-> delegate to base overlay
-	if (item->id == nodeid || destnode == nodeid)
+	if (destnode == nodeid)
 		baseoverlay.incomingRouteMessage( msg, LinkID::UNSPECIFIED, nodeid );
 
@@ -188,5 +198,5 @@
 		ChordMessage cmsg(ChordMessage::route, nodeid, destnode);
 		cmsg.encapsulate(msg);
-		send(&cmsg, item->info);
+		send(&cmsg, next_link);
 	}
 }
@@ -203,13 +213,5 @@
 /// @see OverlayInterface.h
 const LinkID& Chord::getNextLinkId( const NodeID& id ) const {
-	// get next hop
-	const route_item* item = table->get_next_hop(id);
-
-	// returns a unspecified id when this is itself
-	if (item == NULL || item->id == nodeid)
-		return LinkID::UNSPECIFIED;
-
-	/// return routing info
-	return item->info;
+	return get_next_hop(id);
 }
 
@@ -306,16 +308,23 @@
 	case M::route: {
 		// find next hop
-		const route_item* item = table->get_next_hop(m->getDestination());
+		LinkID next_link = get_next_hop(m->getDestination());
+
+		// add to back-routes
+		back_route br;
+		br.id = m->getSource();
+		br.link = link;
+		br.lastseen = time(NULL);
+		back_routes.push_back(br);
 
 		// next hop == myself?
 		if (m->getDestination() == nodeid) { // yes-> route to base overlay
 			logging_debug("Send message to baseoverlay");
-			baseoverlay.incomingRouteMessage( m, item->info, remote );
+			baseoverlay.incomingRouteMessage( m, next_link, remote );
 		}
 		// no-> route to next hop
 		else {
-			logging_debug("Route chord message to "
-				<< item->id.toString() << " (destination=" << m->getDestination() << ")");
-			send(m, item->info);
+//			logging_debug("Route chord message to "
+//				<< item->id.toString() << " (destination=" << m->getDestination() << ")");
+			send(m, next_link);
 		}
 		break;
@@ -376,9 +385,8 @@
 			else {
 				// find next hop
-				const route_item* item = table->get_next_hop(m->getDestination());
-				if (item == NULL || item->id == nodeid) break;
-				logging_debug("routing discovery message to " <<
-						item->id.toString() );
-				send(m, item->info);
+				LinkID next_link = get_next_hop(m->getDestination());
+			//	logging_debug("routing discovery message to " <<
+			//			linkitem->id.toString() );
+				send(m, next_link);
 			}
 			break;
@@ -465,4 +473,5 @@
 		orphan_removal_counter++;
 		if (orphan_removal_counter <0 || orphan_removal_counter >= 4) {
+			back_routes.clear();
 			logging_info("Running orphan removal");
 			orphan_removal_counter = 0;
Index: source/ariba/overlay/modules/chord/Chord.h
===================================================================
--- source/ariba/overlay/modules/chord/Chord.h	(revision 5752)
+++ source/ariba/overlay/modules/chord/Chord.h	(revision 5756)
@@ -80,4 +80,14 @@
 	int discovery_count;
 
+	class back_route {
+	public:
+		NodeID id;
+		LinkID link;
+		time_t lastseen;
+	};
+	vector<back_route> back_routes;
+
+	const LinkID& get_next_hop( const NodeID& id ) const;
+
 	// helper: sets up a link using the "base overlay"
 	LinkID setup( const EndpointDescriptor& endp,
