Committed by
Gerrit Code Review
Fix for SDN-IP installing wrong point-to-point intents.
Fixes ONOS-2514. Change-Id: I0d3d6012daa8dd2a45707a58cf6e745314f6dc24
Showing
6 changed files
with
43 additions
and
17 deletions
| ... | @@ -90,6 +90,14 @@ public interface RoutingConfigurationService { | ... | @@ -90,6 +90,14 @@ public interface RoutingConfigurationService { |
| 90 | Interface getInterface(ConnectPoint connectPoint); | 90 | Interface getInterface(ConnectPoint connectPoint); |
| 91 | 91 | ||
| 92 | /** | 92 | /** |
| 93 | + * Retrieves the interface associated with the given IP address. | ||
| 94 | + * | ||
| 95 | + * @param ip IP address of the interface | ||
| 96 | + * @return the interface | ||
| 97 | + */ | ||
| 98 | + Interface getInterface(IpAddress ip); | ||
| 99 | + | ||
| 100 | + /** | ||
| 93 | * Retrieves the interface that matches the given IP address. Matching | 101 | * Retrieves the interface that matches the given IP address. Matching |
| 94 | * means that the IP address is in one of the interface's assigned subnets. | 102 | * means that the IP address is in one of the interface's assigned subnets. |
| 95 | * | 103 | * | ... | ... |
| ... | @@ -63,6 +63,20 @@ public class HostToInterfaceAdaptor { | ... | @@ -63,6 +63,20 @@ public class HostToInterfaceAdaptor { |
| 63 | return null; | 63 | return null; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | + public Interface getInterface(IpAddress ip) { | ||
| 67 | + Set<PortAddresses> portAddresses = hostService.getAddressBindings(); | ||
| 68 | + | ||
| 69 | + for (PortAddresses portAddress : portAddresses) { | ||
| 70 | + for (InterfaceIpAddress portIp : portAddress.ipAddresses()) { | ||
| 71 | + if (portIp.ipAddress().equals(ip)) { | ||
| 72 | + return new Interface(portAddress); | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + return null; | ||
| 78 | + } | ||
| 79 | + | ||
| 66 | public Interface getMatchingInterface(IpAddress ipAddress) { | 80 | public Interface getMatchingInterface(IpAddress ipAddress) { |
| 67 | checkNotNull(ipAddress); | 81 | checkNotNull(ipAddress); |
| 68 | 82 | ... | ... |
| ... | @@ -159,6 +159,11 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService { | ... | @@ -159,6 +159,11 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService { |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | @Override | 161 | @Override |
| 162 | + public Interface getInterface(IpAddress ip) { | ||
| 163 | + return hostAdaptor.getInterface(ip); | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + @Override | ||
| 162 | public Interface getMatchingInterface(IpAddress ipAddress) { | 167 | public Interface getMatchingInterface(IpAddress ipAddress) { |
| 163 | return hostAdaptor.getMatchingInterface(ipAddress); | 168 | return hostAdaptor.getMatchingInterface(ipAddress); |
| 164 | } | 169 | } | ... | ... |
| ... | @@ -173,7 +173,8 @@ public class HostToInterfaceAdaptorTest { | ... | @@ -173,7 +173,8 @@ public class HostToInterfaceAdaptorTest { |
| 173 | */ | 173 | */ |
| 174 | @Test(expected = NullPointerException.class) | 174 | @Test(expected = NullPointerException.class) |
| 175 | public void testGetInterfaceNull() { | 175 | public void testGetInterfaceNull() { |
| 176 | - adaptor.getInterface(null); | 176 | + ConnectPoint c = null; |
| 177 | + adaptor.getInterface(c); | ||
| 177 | } | 178 | } |
| 178 | 179 | ||
| 179 | /** | 180 | /** | ... | ... |
| ... | @@ -139,24 +139,22 @@ public class PeerConnectivityManager { | ... | @@ -139,24 +139,22 @@ public class PeerConnectivityManager { |
| 139 | List<InterfaceAddress> interfaceAddresses = | 139 | List<InterfaceAddress> interfaceAddresses = |
| 140 | bgpSpeaker.interfaceAddresses(); | 140 | bgpSpeaker.interfaceAddresses(); |
| 141 | 141 | ||
| 142 | - Interface peerInterface = configService.getInterface( | ||
| 143 | - bgpPeer.connectPoint()); | ||
| 144 | - | ||
| 145 | - if (peerInterface == null) { | ||
| 146 | - log.error("No interface found for peer {}", bgpPeer.ipAddress()); | ||
| 147 | - return intents; | ||
| 148 | - } | ||
| 149 | - | ||
| 150 | IpAddress bgpdAddress = null; | 142 | IpAddress bgpdAddress = null; |
| 151 | for (InterfaceAddress interfaceAddress : interfaceAddresses) { | 143 | for (InterfaceAddress interfaceAddress : interfaceAddresses) { |
| 152 | - if (interfaceAddress.connectPoint().equals(peerInterface.connectPoint())) { | 144 | + Interface peerInterface = configService.getInterface(interfaceAddress.ipAddress()); |
| 153 | - for (InterfaceIpAddress interfaceIpAddress : peerInterface.ipAddresses()) { | 145 | + if (peerInterface == null) { |
| 154 | - // Only add intents where the peer and ONOS's addresses are | 146 | + continue; |
| 155 | - // in the same subnet | 147 | + } |
| 156 | - if (interfaceIpAddress.subnetAddress().contains(bgpPeer.ipAddress())) { | 148 | + |
| 157 | - bgpdAddress = interfaceAddress.ipAddress(); | 149 | + for (InterfaceIpAddress interfaceIpAddress : peerInterface.ipAddresses()) { |
| 158 | - } | 150 | + // Only add intents where the peer and ONOS's addresses are |
| 151 | + // in the same subnet | ||
| 152 | + if (interfaceIpAddress.subnetAddress().contains(bgpPeer.ipAddress())) { | ||
| 153 | + bgpdAddress = interfaceAddress.ipAddress(); | ||
| 154 | + break; | ||
| 159 | } | 155 | } |
| 156 | + } | ||
| 157 | + if (bgpdAddress != null) { | ||
| 160 | break; | 158 | break; |
| 161 | } | 159 | } |
| 162 | } | 160 | } |
| ... | @@ -167,7 +165,7 @@ public class PeerConnectivityManager { | ... | @@ -167,7 +165,7 @@ public class PeerConnectivityManager { |
| 167 | } | 165 | } |
| 168 | 166 | ||
| 169 | IpAddress bgpdPeerAddress = bgpPeer.ipAddress(); | 167 | IpAddress bgpdPeerAddress = bgpPeer.ipAddress(); |
| 170 | - ConnectPoint bgpdPeerConnectPoint = peerInterface.connectPoint(); | 168 | + ConnectPoint bgpdPeerConnectPoint = bgpPeer.connectPoint(); |
| 171 | 169 | ||
| 172 | if (bgpdAddress.version() != bgpdPeerAddress.version()) { | 170 | if (bgpdAddress.version() != bgpdPeerAddress.version()) { |
| 173 | return intents; | 171 | return intents; | ... | ... |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment