- log.trace("Punted IP pkt from {}, sending bcast ARP event...", dIP);
- /*
- * unknown destination host, initiate bcast ARP request
- */
- arpRequestReplyEvent.put(new ARPRequest(dIP, subnet), false);
- return;
+ // If packet is sent to the default gw (us), ignore it for now
+ if (subnet.getNetworkAddress().equals(dIP)) {
+ log.trace("Ignore IP packet destined to default gw");
+ return;
+ }
+
+ // see if we know about the host
+ // Hosttracker hosts db key implementation
+ IHostId id = HostIdFactory.create(dIP, null);
+ HostNodeConnector host = hostTracker.hostFind(id);
+
+ if (host == null) {
+ // if we don't, know about the host, try to find it
+ log.trace("Punted IP pkt to {}, sending bcast ARP event...", dIP);
+ /*
+ * unknown destination host, initiate bcast ARP request
+ */
+ arpRequestReplyEvent.put(new ARPRequest(dIP, subnet), false);
+
+ } else if (routing == null || routing.getRoute(p.getNode(), host.getnodeconnectorNode()) != null) {
+ /*
+ * if IRouting is available, make sure that this packet can get it's
+ * destination normally before teleporting it there. If it's not
+ * available, then assume it's reachable.
+ *
+ * TODO: come up with a way to do this in the absence of IRouting
+ */
+
+ log.trace("forwarding punted IP pkt to {} received at {}", dIP, p);
+
+ /*
+ * if we know where the host is and there's a path from where this
+ * packet was punted to where the host is, then deliver it to the
+ * host for now
+ */
+ NodeConnector nc = host.getnodeConnector();
+
+ // re-encode the Ethernet packet (the parent of the IPv4 packet)
+ RawPacket rp = this.dataPacketService.encodeDataPacket(pkt.getParent());
+ rp.setOutgoingNodeConnector(nc);
+ this.dataPacketService.transmitDataPacket(rp);
+ } else {
+ log.trace("ignoring punted IP pkt to {} because there is no route from {}", dIP, p);
+ }