From 5267503eee5def895378621a59978226bbc6c06d Mon Sep 17 00:00:00 2001 From: Srinivasan Ramasubramanian <srini@bigswitch.com> Date: Mon, 10 Sep 2012 17:32:49 -0700 Subject: [PATCH] Bug fix: when an attachment point from packet-in (newAP) does not replace the already known attachment point (oldAP), then we need to put newAP in the oldAPlist for possibly flagging it as duplicate in the future. Earlier, we were adding the already known attachment point in the list. --- .../devicemanager/internal/Device.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/floodlightcontroller/devicemanager/internal/Device.java b/src/main/java/net/floodlightcontroller/devicemanager/internal/Device.java index aaa3a5629..be2ef2672 100755 --- a/src/main/java/net/floodlightcontroller/devicemanager/internal/Device.java +++ b/src/main/java/net/floodlightcontroller/devicemanager/internal/Device.java @@ -292,9 +292,6 @@ entity.getLastSeenTimestamp().getTime()); protected boolean updateAttachmentPoint() { boolean moved = false; - List<AttachmentPoint> oldAPList = new ArrayList<AttachmentPoint>(); - if (oldAPs != null) oldAPList.addAll(oldAPs); - List<AttachmentPoint> apList = new ArrayList<AttachmentPoint>(); if (attachmentPoints != null) apList.addAll(attachmentPoints); Map<Long, AttachmentPoint> newMap = getAPMap(apList); @@ -309,6 +306,8 @@ entity.getLastSeenTimestamp().getTime()); new ArrayList<AttachmentPoint>(); if (newMap != null) newAPList.addAll(newMap.values()); this.attachmentPoints = newAPList; + log.debug("DEVICE_MOVE: Old AttachmentPoints: {}," + + "New AttachmentPoints: {}", apList, newAPList); } // Set the oldAPs to null. @@ -347,6 +346,7 @@ entity.getLastSeenTimestamp().getTime()); newAP = oldAPList.remove(index); newAP.setLastSeen(lastSeen); this.oldAPs = oldAPList; + log.debug("DEVICE_MOVE: OldAPs changed for device: {}", oldAPList); } // newAP now contains the new attachment point. @@ -356,6 +356,7 @@ entity.getLastSeenTimestamp().getTime()); if (apMap == null || apMap.isEmpty()) { apList.add(newAP); attachmentPoints = apList; + log.debug("DEVICE_MOVE: First attachmentpoint point for device: {}", apList); return true; } @@ -368,6 +369,8 @@ entity.getLastSeenTimestamp().getTime()); apList.addAll(apMap.values()); apList.add(newAP); this.attachmentPoints = apList; + log.debug("DEVICE_MOVE: First access point in L2 domain. {}", + apList); return true; // new AP found on an L2 island. } @@ -388,6 +391,8 @@ entity.getLastSeenTimestamp().getTime()); apMap.put(id, newAP); this.attachmentPoints = new ArrayList<AttachmentPoint>(apMap.values()); + log.debug("DEVICE_MOVED: Attachment point changed to: {}," + + "putting previous in oldAP: {}", newAP, oldAP); oldAPList = new ArrayList<AttachmentPoint>(); if (oldAPs != null) oldAPList.addAll(oldAPs); @@ -395,9 +400,13 @@ entity.getLastSeenTimestamp().getTime()); this.oldAPs = oldAPList; return true; // attachment point changed. } else { + // retain oldAP as is. Put the newAP in oldAPs for flagging + // possible duplicates. oldAPList = new ArrayList<AttachmentPoint>(); if (oldAPs != null) oldAPList.addAll(oldAPs); - oldAPList.add(oldAP); + oldAPList.add(newAP); + log.debug("DEVICE_MOVED: New attachment point {} does not" + + " replace already existing one {}.", newAP, oldAP); this.oldAPs = oldAPList; } @@ -516,6 +525,8 @@ entity.getLastSeenTimestamp().getTime()); if (!includeError) return sp.toArray(new SwitchPort[sp.size()]); + log.debug("DEVICE_APS: Getting all attachment points: APs: {}, oldAPs: {}", + this.attachmentPoints, this.oldAPs); List<AttachmentPoint> oldAPList; oldAPList = new ArrayList<AttachmentPoint>(); @@ -535,6 +546,7 @@ entity.getLastSeenTimestamp().getTime()); sp.add(swport); } } + log.debug("DEVICE_APS: Duplicate APs: {}", sp); return sp.toArray(new SwitchPort[sp.size()]); } -- GitLab