Committed by
Gerrit Code Review
cord-646, Addressed the Comments for Patch set1
Change-Id: I2a77b86e2fe4c28fb72c807e7903569ff530030f
Showing
1 changed file
with
34 additions
and
0 deletions
... | @@ -67,6 +67,7 @@ import java.util.List; | ... | @@ -67,6 +67,7 @@ import java.util.List; |
67 | import java.util.Map; | 67 | import java.util.Map; |
68 | import java.util.Optional; | 68 | import java.util.Optional; |
69 | import java.util.Set; | 69 | import java.util.Set; |
70 | +import java.util.stream.Collectors; | ||
70 | 71 | ||
71 | import static com.google.common.base.Preconditions.checkState; | 72 | import static com.google.common.base.Preconditions.checkState; |
72 | import static org.slf4j.LoggerFactory.getLogger; | 73 | import static org.slf4j.LoggerFactory.getLogger; |
... | @@ -566,11 +567,41 @@ public class ControlPlaneRedirectManager { | ... | @@ -566,11 +567,41 @@ public class ControlPlaneRedirectManager { |
566 | 2000 * prefix.prefixLength() + MIN_IP_PRIORITY : | 567 | 2000 * prefix.prefixLength() + MIN_IP_PRIORITY : |
567 | 500 * prefix.prefixLength() + MIN_IP_PRIORITY; | 568 | 500 * prefix.prefixLength() + MIN_IP_PRIORITY; |
568 | } | 569 | } |
570 | + | ||
571 | + /** | ||
572 | + * Update the flows comparing previous event and current event. | ||
573 | + * | ||
574 | + * @param prevIntf the previous interface event | ||
575 | + * @param intf the current occured update envent | ||
576 | + **/ | ||
577 | + private void updateInterface(Interface prevIntf, Interface intf) { | ||
578 | + if (!prevIntf.vlan().equals(intf.vlan()) || !prevIntf.mac().equals(intf)) { | ||
579 | + removeInterface(prevIntf); | ||
580 | + provisionInterface(intf); | ||
581 | + } else { | ||
582 | + List<InterfaceIpAddress> removeIps = | ||
583 | + prevIntf.ipAddressesList().stream() | ||
584 | + .filter(pre -> !intf.ipAddressesList().contains(pre)) | ||
585 | + .collect(Collectors.toList()); | ||
586 | + List<InterfaceIpAddress> addIps = | ||
587 | + intf.ipAddressesList().stream() | ||
588 | + .filter(cur -> !prevIntf.ipAddressesList().contains(cur)) | ||
589 | + .collect(Collectors.toList()); | ||
590 | + // removing flows with match parameters present in previous subject | ||
591 | + modifyBasicInterfaceForwarding(new Interface(prevIntf.name(), prevIntf.connectPoint(), | ||
592 | + removeIps, prevIntf.mac(), prevIntf.vlan()), false); | ||
593 | + // adding flows with match parameters present in event subject | ||
594 | + modifyBasicInterfaceForwarding(new Interface(intf.name(), intf.connectPoint(), | ||
595 | + addIps, intf.mac(), intf.vlan()), true); | ||
596 | + } | ||
597 | + } | ||
598 | + | ||
569 | private class InternalInterfaceListener implements InterfaceListener { | 599 | private class InternalInterfaceListener implements InterfaceListener { |
570 | 600 | ||
571 | @Override | 601 | @Override |
572 | public void event(InterfaceEvent event) { | 602 | public void event(InterfaceEvent event) { |
573 | Interface intf = event.subject(); | 603 | Interface intf = event.subject(); |
604 | + Interface prevIntf = event.prevSubject(); | ||
574 | switch (event.type()) { | 605 | switch (event.type()) { |
575 | case INTERFACE_ADDED: | 606 | case INTERFACE_ADDED: |
576 | if (intf != null && !intf.connectPoint().equals(controlPlaneConnectPoint)) { | 607 | if (intf != null && !intf.connectPoint().equals(controlPlaneConnectPoint)) { |
... | @@ -578,6 +609,9 @@ public class ControlPlaneRedirectManager { | ... | @@ -578,6 +609,9 @@ public class ControlPlaneRedirectManager { |
578 | } | 609 | } |
579 | break; | 610 | break; |
580 | case INTERFACE_UPDATED: | 611 | case INTERFACE_UPDATED: |
612 | + if (intf != null && !intf.connectPoint().equals(controlPlaneConnectPoint)) { | ||
613 | + updateInterface(prevIntf, intf); | ||
614 | + } | ||
581 | break; | 615 | break; |
582 | case INTERFACE_REMOVED: | 616 | case INTERFACE_REMOVED: |
583 | if (intf != null && !intf.connectPoint().equals(controlPlaneConnectPoint)) { | 617 | if (intf != null && !intf.connectPoint().equals(controlPlaneConnectPoint)) { | ... | ... |
-
Please register or login to post a comment