*/
protected void pushBidirectionalVipRoutes(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx, IPClient client, LBMember member) {
// borrowed code from Forwarding to retrieve src and dst device entities
// Check if we have the location of the destination
IDevice srcDevice = null;
IDevice dstDevice = null;
// retrieve all known devices
Collection<? extends IDevice> allDevices = deviceManager
.getAllDevices();
for (IDevice d : allDevices) {
for (int j = 0; j < d.getIPv4Addresses().length; j++) {
if (srcDevice == null && client.ipAddress == d.getIPv4Addresses()[j])
srcDevice = d;
if (dstDevice == null && member.address == d.getIPv4Addresses()[j]) {
dstDevice = d;
member.macString = dstDevice.getMACAddressString();
}
if (srcDevice != null && dstDevice != null)
break;
}
}
// srcDevice and/or dstDevice is null, no route can be pushed
if (srcDevice == null || dstDevice == null) return;
Long srcIsland = topology.getL2DomainId(sw.getId());
if (srcIsland == null) {
log.debug("No openflow island found for source {}/{}",
sw.getStringId(), pi.getInPort());
return;
}
// Validate that we have a destination known on the same island
// Validate that the source and destination are not on the same switchport
boolean on_same_island = false;
boolean on_same_if = false;
for (SwitchPort dstDap : dstDevice.getAttachmentPoints()) {
long dstSwDpid = dstDap.getSwitchDPID();
Long dstIsland = topology.getL2DomainId(dstSwDpid);
if ((dstIsland != null) && dstIsland.equals(srcIsland)) {
on_same_island = true;
if ((sw.getId() == dstSwDpid) &&
(pi.getInPort() == dstDap.getPort())) {
on_same_if = true;
}
break;
}
}
if (!on_same_island) {
// Flood since we don't know the dst device
if (log.isTraceEnabled()) {
log.trace("No first hop island found for destination " +
"device {}, Action = flooding", dstDevice);
}
return;
}
if (on_same_if) {
if (log.isTraceEnabled()) {
log.trace("Both source and destination are on the same " +
"switch/port {}/{}, Action = NOP",
sw.toString(), pi.getInPort());
}
return;
}
// Install all the routes where both src and dst have attachment
// points. Since the lists are stored in sorted order we can
// traverse the attachment points in O(m+n) time
SwitchPort[] srcDaps = srcDevice.getAttachmentPoints();
Arrays.sort(srcDaps, clusterIdComparator);
SwitchPort[] dstDaps = dstDevice.getAttachmentPoints();
Arrays.sort(dstDaps, clusterIdComparator);
int iSrcDaps = 0, iDstDaps = 0;
// following Forwarding's same routing routine, retrieve both in-bound and out-bound routes for