After an instance migration or failover some nodes will
have stale routing information and these will continue to send traffic
to the old node. This is detected by ganeti-nld on the old node.

This patch adds the capability to look up the source node based on the
source instance IP.

Signed-off-by: Balazs Lecz <[email protected]>
---
 daemons/ganeti-nld |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/daemons/ganeti-nld b/daemons/ganeti-nld
index efdf11a..0beafe5 100755
--- a/daemons/ganeti-nld
+++ b/daemons/ganeti-nld
@@ -388,12 +388,36 @@ class MisroutedPacketHandler(object):
     self.instance_node_maps = instance_node_maps
 
   def __call__(self, i, nflog_payload):
+    # Look up the source IP in the instance->node maps. If found, it means the
+    # packet came from an instance in one of our clusters, which means the
+    # node it's running on has stale routing information, so we have to
+    # notify that node.
     ip_packet = ip.disassemble(nflog_payload.get_data())
-    logging.debug("misrouted packet detected. source IP: %s", ip_packet.src)
+
+    source_cluster = None
+    source_link = None
+    source_node = None
+    for cluster, cluster_map in self.instance_node_maps.iteritems():
+      for link, link_map in cluster_map.iteritems():
+        source_node = link_map.get(ip_packet.src, None)
+        if source_node:
+          source_cluster = cluster
+          source_link = link
+          break
+
+    if source_node:
+      # TODO: send notification to this node
+      logging.debug("misrouted packet detected."
+                    " [cluster: %s] [node: %s] [link: %s] [source: %s]",
+                    source_cluster, source_node, source_link,
+                    ip_packet.src)
+    else:
+      logging.debug("misrouted packet detected. [source: %s]",
+                    ip_packet.src)
+
     # TODO: notify the endpoint(s) via an NLD request (preferably by iterating
     #       over the private IPs of the endpoints)
-    # TODO: look up the source IP in the peer list and if found, notify the
-    #       relevant node
+
     return 1
 
 
-- 
1.6.6.2

Reply via email to