Committed by
Ray Milkey
[CORD-313] Handles uncaught exceptions when device is not configured
Includes following minor changes
- Move DeviceConfiguration and DeviceProperties to config package
- Create DeviceConfigNotFoundException
Change-Id: I32455d88c712bb65cd7f71dab9472ae003303de2
Showing
15 changed files
with
312 additions
and
104 deletions
| ... | @@ -31,6 +31,8 @@ import org.onosproject.net.packet.DefaultOutboundPacket; | ... | @@ -31,6 +31,8 @@ import org.onosproject.net.packet.DefaultOutboundPacket; |
| 31 | import org.onosproject.net.packet.InboundPacket; | 31 | import org.onosproject.net.packet.InboundPacket; |
| 32 | import org.onosproject.net.HostId; | 32 | import org.onosproject.net.HostId; |
| 33 | import org.onosproject.net.packet.OutboundPacket; | 33 | import org.onosproject.net.packet.OutboundPacket; |
| 34 | +import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; | ||
| 35 | +import org.onosproject.segmentrouting.config.DeviceConfiguration; | ||
| 34 | import org.slf4j.Logger; | 36 | import org.slf4j.Logger; |
| 35 | import org.slf4j.LoggerFactory; | 37 | import org.slf4j.LoggerFactory; |
| 36 | 38 | ||
| ... | @@ -140,9 +142,16 @@ public class ArpHandler { | ... | @@ -140,9 +142,16 @@ public class ArpHandler { |
| 140 | * @param inPort in-port | 142 | * @param inPort in-port |
| 141 | */ | 143 | */ |
| 142 | public void sendArpRequest(DeviceId deviceId, IpAddress targetAddress, ConnectPoint inPort) { | 144 | public void sendArpRequest(DeviceId deviceId, IpAddress targetAddress, ConnectPoint inPort) { |
| 143 | - | 145 | + byte[] senderMacAddress; |
| 144 | - byte[] senderMacAddress = config.getDeviceMac(deviceId).toBytes(); | 146 | + byte[] senderIpAddress; |
| 145 | - byte[] senderIpAddress = config.getRouterIp(deviceId).toOctets(); | 147 | + |
| 148 | + try { | ||
| 149 | + senderMacAddress = config.getDeviceMac(deviceId).toBytes(); | ||
| 150 | + senderIpAddress = config.getRouterIp(deviceId).toOctets(); | ||
| 151 | + } catch (DeviceConfigNotFoundException e) { | ||
| 152 | + log.warn(e.getMessage() + " Aborting sendArpRequest."); | ||
| 153 | + return; | ||
| 154 | + } | ||
| 146 | 155 | ||
| 147 | ARP arpRequest = new ARP(); | 156 | ARP arpRequest = new ARP(); |
| 148 | arpRequest.setHardwareType(ARP.HW_TYPE_ETHERNET) | 157 | arpRequest.setHardwareType(ARP.HW_TYPE_ETHERNET) | ... | ... |
| ... | @@ -23,6 +23,8 @@ import org.onlab.packet.IpPrefix; | ... | @@ -23,6 +23,8 @@ import org.onlab.packet.IpPrefix; |
| 23 | import org.onosproject.net.Device; | 23 | import org.onosproject.net.Device; |
| 24 | import org.onosproject.net.DeviceId; | 24 | import org.onosproject.net.DeviceId; |
| 25 | import org.onosproject.net.Link; | 25 | import org.onosproject.net.Link; |
| 26 | +import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; | ||
| 27 | +import org.onosproject.segmentrouting.config.DeviceConfiguration; | ||
| 26 | import org.slf4j.Logger; | 28 | import org.slf4j.Logger; |
| 27 | import org.slf4j.LoggerFactory; | 29 | import org.slf4j.LoggerFactory; |
| 28 | 30 | ||
| ... | @@ -449,7 +451,20 @@ public class DefaultRoutingHandler { | ... | @@ -449,7 +451,20 @@ public class DefaultRoutingHandler { |
| 449 | 451 | ||
| 450 | // If both target switch and dest switch are edge routers, then set IP | 452 | // If both target switch and dest switch are edge routers, then set IP |
| 451 | // rule for both subnet and router IP. | 453 | // rule for both subnet and router IP. |
| 452 | - if (config.isEdgeDevice(targetSw) && config.isEdgeDevice(destSw)) { | 454 | + boolean targetIsEdge; |
| 455 | + boolean destIsEdge; | ||
| 456 | + Ip4Address destRouterIp; | ||
| 457 | + | ||
| 458 | + try { | ||
| 459 | + targetIsEdge = config.isEdgeDevice(targetSw); | ||
| 460 | + destIsEdge = config.isEdgeDevice(destSw); | ||
| 461 | + destRouterIp = config.getRouterIp(destSw); | ||
| 462 | + } catch (DeviceConfigNotFoundException e) { | ||
| 463 | + log.warn(e.getMessage() + " Aborting populateEcmpRoutingRulePartial."); | ||
| 464 | + return false; | ||
| 465 | + } | ||
| 466 | + | ||
| 467 | + if (targetIsEdge && destIsEdge) { | ||
| 453 | Set<Ip4Prefix> subnets = config.getSubnets(destSw); | 468 | Set<Ip4Prefix> subnets = config.getSubnets(destSw); |
| 454 | log.debug("* populateEcmpRoutingRulePartial in device {} towards {} for subnets {}", | 469 | log.debug("* populateEcmpRoutingRulePartial in device {} towards {} for subnets {}", |
| 455 | targetSw, destSw, subnets); | 470 | targetSw, destSw, subnets); |
| ... | @@ -461,7 +476,7 @@ public class DefaultRoutingHandler { | ... | @@ -461,7 +476,7 @@ public class DefaultRoutingHandler { |
| 461 | return false; | 476 | return false; |
| 462 | } | 477 | } |
| 463 | 478 | ||
| 464 | - Ip4Address routerIp = config.getRouterIp(destSw); | 479 | + Ip4Address routerIp = destRouterIp; |
| 465 | IpPrefix routerIpPrefix = IpPrefix.valueOf(routerIp, IpPrefix.MAX_INET_MASK_LENGTH); | 480 | IpPrefix routerIpPrefix = IpPrefix.valueOf(routerIp, IpPrefix.MAX_INET_MASK_LENGTH); |
| 466 | log.debug("* populateEcmpRoutingRulePartial in device {} towards {} for router IP {}", | 481 | log.debug("* populateEcmpRoutingRulePartial in device {} towards {} for router IP {}", |
| 467 | targetSw, destSw, routerIpPrefix); | 482 | targetSw, destSw, routerIpPrefix); |
| ... | @@ -471,8 +486,8 @@ public class DefaultRoutingHandler { | ... | @@ -471,8 +486,8 @@ public class DefaultRoutingHandler { |
| 471 | } | 486 | } |
| 472 | 487 | ||
| 473 | // If the target switch is an edge router, then set IP rules for the router IP. | 488 | // If the target switch is an edge router, then set IP rules for the router IP. |
| 474 | - } else if (config.isEdgeDevice(targetSw)) { | 489 | + } else if (targetIsEdge) { |
| 475 | - Ip4Address routerIp = config.getRouterIp(destSw); | 490 | + Ip4Address routerIp = destRouterIp; |
| 476 | IpPrefix routerIpPrefix = IpPrefix.valueOf(routerIp, IpPrefix.MAX_INET_MASK_LENGTH); | 491 | IpPrefix routerIpPrefix = IpPrefix.valueOf(routerIp, IpPrefix.MAX_INET_MASK_LENGTH); |
| 477 | log.debug("* populateEcmpRoutingRulePartial in device {} towards {} for router IP {}", | 492 | log.debug("* populateEcmpRoutingRulePartial in device {} towards {} for router IP {}", |
| 478 | targetSw, destSw, routerIpPrefix); | 493 | targetSw, destSw, routerIpPrefix); | ... | ... |
| ... | @@ -28,6 +28,8 @@ import org.onosproject.net.flow.TrafficTreatment; | ... | @@ -28,6 +28,8 @@ import org.onosproject.net.flow.TrafficTreatment; |
| 28 | import org.onosproject.net.packet.DefaultOutboundPacket; | 28 | import org.onosproject.net.packet.DefaultOutboundPacket; |
| 29 | import org.onosproject.net.packet.InboundPacket; | 29 | import org.onosproject.net.packet.InboundPacket; |
| 30 | import org.onosproject.net.packet.OutboundPacket; | 30 | import org.onosproject.net.packet.OutboundPacket; |
| 31 | +import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; | ||
| 32 | +import org.onosproject.segmentrouting.config.DeviceConfiguration; | ||
| 31 | import org.slf4j.Logger; | 33 | import org.slf4j.Logger; |
| 32 | import org.slf4j.LoggerFactory; | 34 | import org.slf4j.LoggerFactory; |
| 33 | 35 | ||
| ... | @@ -71,7 +73,13 @@ public class IcmpHandler { | ... | @@ -71,7 +73,13 @@ public class IcmpHandler { |
| 71 | Ip4Address destinationAddress = | 73 | Ip4Address destinationAddress = |
| 72 | Ip4Address.valueOf(ipv4.getDestinationAddress()); | 74 | Ip4Address.valueOf(ipv4.getDestinationAddress()); |
| 73 | Set<Ip4Address> gatewayIpAddresses = config.getPortIPs(deviceId); | 75 | Set<Ip4Address> gatewayIpAddresses = config.getPortIPs(deviceId); |
| 74 | - Ip4Address routerIp = config.getRouterIp(deviceId); | 76 | + Ip4Address routerIp; |
| 77 | + try { | ||
| 78 | + routerIp = config.getRouterIp(deviceId); | ||
| 79 | + } catch (DeviceConfigNotFoundException e) { | ||
| 80 | + log.warn(e.getMessage() + " Aborting processPacketIn."); | ||
| 81 | + return; | ||
| 82 | + } | ||
| 75 | IpPrefix routerIpPrefix = IpPrefix.valueOf(routerIp, IpPrefix.MAX_INET_MASK_LENGTH); | 83 | IpPrefix routerIpPrefix = IpPrefix.valueOf(routerIp, IpPrefix.MAX_INET_MASK_LENGTH); |
| 76 | Ip4Address routerIpAddress = routerIpPrefix.getIp4Prefix().address(); | 84 | Ip4Address routerIpAddress = routerIpPrefix.getIp4Prefix().address(); |
| 77 | 85 | ... | ... |
| ... | @@ -26,6 +26,8 @@ import org.onosproject.net.flow.TrafficTreatment; | ... | @@ -26,6 +26,8 @@ import org.onosproject.net.flow.TrafficTreatment; |
| 26 | import org.onosproject.net.packet.DefaultOutboundPacket; | 26 | import org.onosproject.net.packet.DefaultOutboundPacket; |
| 27 | import org.onosproject.net.packet.InboundPacket; | 27 | import org.onosproject.net.packet.InboundPacket; |
| 28 | import org.onosproject.net.packet.OutboundPacket; | 28 | import org.onosproject.net.packet.OutboundPacket; |
| 29 | +import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; | ||
| 30 | +import org.onosproject.segmentrouting.config.DeviceConfiguration; | ||
| 29 | import org.slf4j.Logger; | 31 | import org.slf4j.Logger; |
| 30 | import org.slf4j.LoggerFactory; | 32 | import org.slf4j.LoggerFactory; |
| 31 | 33 | ||
| ... | @@ -127,13 +129,19 @@ public class IpHandler { | ... | @@ -127,13 +129,19 @@ public class IpHandler { |
| 127 | 129 | ||
| 128 | for (IPv4 ipPacket : ipPacketQueue.get(destIpAddress)) { | 130 | for (IPv4 ipPacket : ipPacketQueue.get(destIpAddress)) { |
| 129 | Ip4Address destAddress = Ip4Address.valueOf(ipPacket.getDestinationAddress()); | 131 | Ip4Address destAddress = Ip4Address.valueOf(ipPacket.getDestinationAddress()); |
| 130 | - if (ipPacket != null && config.inSameSubnet(deviceId, destAddress)) { | 132 | + if (config.inSameSubnet(deviceId, destAddress)) { |
| 131 | ipPacket.setTtl((byte) (ipPacket.getTtl() - 1)); | 133 | ipPacket.setTtl((byte) (ipPacket.getTtl() - 1)); |
| 132 | ipPacket.setChecksum((short) 0); | 134 | ipPacket.setChecksum((short) 0); |
| 133 | for (Host dest: srManager.hostService.getHostsByIp(destIpAddress)) { | 135 | for (Host dest: srManager.hostService.getHostsByIp(destIpAddress)) { |
| 134 | Ethernet eth = new Ethernet(); | 136 | Ethernet eth = new Ethernet(); |
| 135 | eth.setDestinationMACAddress(dest.mac()); | 137 | eth.setDestinationMACAddress(dest.mac()); |
| 138 | + try { | ||
| 136 | eth.setSourceMACAddress(config.getDeviceMac(deviceId)); | 139 | eth.setSourceMACAddress(config.getDeviceMac(deviceId)); |
| 140 | + } catch (DeviceConfigNotFoundException e) { | ||
| 141 | + log.warn(e.getMessage() | ||
| 142 | + + " Skipping forwardPackets for this destination."); | ||
| 143 | + continue; | ||
| 144 | + } | ||
| 137 | eth.setEtherType(Ethernet.TYPE_IPV4); | 145 | eth.setEtherType(Ethernet.TYPE_IPV4); |
| 138 | eth.setPayload(ipPacket); | 146 | eth.setPayload(ipPacket); |
| 139 | 147 | ... | ... |
| ... | @@ -27,6 +27,7 @@ import org.onosproject.net.flow.TrafficSelector; | ... | @@ -27,6 +27,7 @@ import org.onosproject.net.flow.TrafficSelector; |
| 27 | import org.onosproject.net.flowobjective.DefaultForwardingObjective; | 27 | import org.onosproject.net.flowobjective.DefaultForwardingObjective; |
| 28 | import org.onosproject.net.flowobjective.FlowObjectiveService; | 28 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
| 29 | import org.onosproject.net.flowobjective.ForwardingObjective; | 29 | import org.onosproject.net.flowobjective.ForwardingObjective; |
| 30 | +import org.onosproject.segmentrouting.config.DeviceConfiguration; | ||
| 30 | import org.onosproject.store.service.EventuallyConsistentMap; | 31 | import org.onosproject.store.service.EventuallyConsistentMap; |
| 31 | import org.slf4j.Logger; | 32 | import org.slf4j.Logger; |
| 32 | 33 | ... | ... |
| ... | @@ -22,6 +22,8 @@ import org.onlab.packet.IpPrefix; | ... | @@ -22,6 +22,8 @@ import org.onlab.packet.IpPrefix; |
| 22 | import org.onlab.packet.MacAddress; | 22 | import org.onlab.packet.MacAddress; |
| 23 | import org.onlab.packet.MplsLabel; | 23 | import org.onlab.packet.MplsLabel; |
| 24 | import org.onlab.packet.VlanId; | 24 | import org.onlab.packet.VlanId; |
| 25 | +import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; | ||
| 26 | +import org.onosproject.segmentrouting.config.DeviceConfiguration; | ||
| 25 | import org.onosproject.segmentrouting.grouphandler.NeighborSet; | 27 | import org.onosproject.segmentrouting.grouphandler.NeighborSet; |
| 26 | import org.onosproject.net.DeviceId; | 28 | import org.onosproject.net.DeviceId; |
| 27 | import org.onosproject.net.Link; | 29 | import org.onosproject.net.Link; |
| ... | @@ -103,6 +105,14 @@ public class RoutingRulePopulator { | ... | @@ -103,6 +105,14 @@ public class RoutingRulePopulator { |
| 103 | */ | 105 | */ |
| 104 | public void populateIpRuleForHost(DeviceId deviceId, Ip4Address hostIp, | 106 | public void populateIpRuleForHost(DeviceId deviceId, Ip4Address hostIp, |
| 105 | MacAddress hostMac, PortNumber outPort) { | 107 | MacAddress hostMac, PortNumber outPort) { |
| 108 | + MacAddress deviceMac; | ||
| 109 | + try { | ||
| 110 | + deviceMac = config.getDeviceMac(deviceId); | ||
| 111 | + } catch (DeviceConfigNotFoundException e) { | ||
| 112 | + log.warn(e.getMessage() + " Aborting populateIpRuleForHost."); | ||
| 113 | + return; | ||
| 114 | + } | ||
| 115 | + | ||
| 106 | TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder(); | 116 | TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder(); |
| 107 | TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder(); | 117 | TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder(); |
| 108 | 118 | ||
| ... | @@ -111,7 +121,7 @@ public class RoutingRulePopulator { | ... | @@ -111,7 +121,7 @@ public class RoutingRulePopulator { |
| 111 | 121 | ||
| 112 | tbuilder.deferred() | 122 | tbuilder.deferred() |
| 113 | .setEthDst(hostMac) | 123 | .setEthDst(hostMac) |
| 114 | - .setEthSrc(config.getDeviceMac(deviceId)) | 124 | + .setEthSrc(deviceMac) |
| 115 | .setOutput(outPort); | 125 | .setOutput(outPort); |
| 116 | 126 | ||
| 117 | TrafficTreatment treatment = tbuilder.build(); | 127 | TrafficTreatment treatment = tbuilder.build(); |
| ... | @@ -167,6 +177,13 @@ public class RoutingRulePopulator { | ... | @@ -167,6 +177,13 @@ public class RoutingRulePopulator { |
| 167 | public boolean populateIpRuleForRouter(DeviceId deviceId, | 177 | public boolean populateIpRuleForRouter(DeviceId deviceId, |
| 168 | IpPrefix ipPrefix, DeviceId destSw, | 178 | IpPrefix ipPrefix, DeviceId destSw, |
| 169 | Set<DeviceId> nextHops) { | 179 | Set<DeviceId> nextHops) { |
| 180 | + int segmentId; | ||
| 181 | + try { | ||
| 182 | + segmentId = config.getSegmentId(destSw); | ||
| 183 | + } catch (DeviceConfigNotFoundException e) { | ||
| 184 | + log.warn(e.getMessage() + " Aborting populateIpRuleForRouter."); | ||
| 185 | + return false; | ||
| 186 | + } | ||
| 170 | 187 | ||
| 171 | TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder(); | 188 | TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder(); |
| 172 | TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder(); | 189 | TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder(); |
| ... | @@ -183,7 +200,7 @@ public class RoutingRulePopulator { | ... | @@ -183,7 +200,7 @@ public class RoutingRulePopulator { |
| 183 | ns = new NeighborSet(nextHops); | 200 | ns = new NeighborSet(nextHops); |
| 184 | } else { | 201 | } else { |
| 185 | tbuilder.deferred().copyTtlOut(); | 202 | tbuilder.deferred().copyTtlOut(); |
| 186 | - ns = new NeighborSet(nextHops, config.getSegmentId(destSw)); | 203 | + ns = new NeighborSet(nextHops, segmentId); |
| 187 | } | 204 | } |
| 188 | 205 | ||
| 189 | TrafficTreatment treatment = tbuilder.build(); | 206 | TrafficTreatment treatment = tbuilder.build(); |
| ... | @@ -227,19 +244,26 @@ public class RoutingRulePopulator { | ... | @@ -227,19 +244,26 @@ public class RoutingRulePopulator { |
| 227 | */ | 244 | */ |
| 228 | public boolean populateMplsRule(DeviceId deviceId, DeviceId destSwId, | 245 | public boolean populateMplsRule(DeviceId deviceId, DeviceId destSwId, |
| 229 | Set<DeviceId> nextHops) { | 246 | Set<DeviceId> nextHops) { |
| 247 | + int segmentId; | ||
| 248 | + try { | ||
| 249 | + segmentId = config.getSegmentId(destSwId); | ||
| 250 | + } catch (DeviceConfigNotFoundException e) { | ||
| 251 | + log.warn(e.getMessage() + " Aborting populateMplsRule."); | ||
| 252 | + return false; | ||
| 253 | + } | ||
| 230 | 254 | ||
| 231 | TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder(); | 255 | TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder(); |
| 232 | List<ForwardingObjective.Builder> fwdObjBuilders = new ArrayList<>(); | 256 | List<ForwardingObjective.Builder> fwdObjBuilders = new ArrayList<>(); |
| 233 | 257 | ||
| 234 | // TODO Handle the case of Bos == false | 258 | // TODO Handle the case of Bos == false |
| 235 | - sbuilder.matchMplsLabel(MplsLabel.mplsLabel(config.getSegmentId(destSwId))); | 259 | + sbuilder.matchMplsLabel(MplsLabel.mplsLabel(segmentId)); |
| 236 | sbuilder.matchEthType(Ethernet.MPLS_UNICAST); | 260 | sbuilder.matchEthType(Ethernet.MPLS_UNICAST); |
| 237 | 261 | ||
| 238 | // If the next hop is the destination router, do PHP | 262 | // If the next hop is the destination router, do PHP |
| 239 | if (nextHops.size() == 1 && destSwId.equals(nextHops.toArray()[0])) { | 263 | if (nextHops.size() == 1 && destSwId.equals(nextHops.toArray()[0])) { |
| 240 | log.debug("populateMplsRule: Installing MPLS forwarding objective for " | 264 | log.debug("populateMplsRule: Installing MPLS forwarding objective for " |
| 241 | + "label {} in switch {} with PHP", | 265 | + "label {} in switch {} with PHP", |
| 242 | - config.getSegmentId(destSwId), | 266 | + segmentId, |
| 243 | deviceId); | 267 | deviceId); |
| 244 | 268 | ||
| 245 | ForwardingObjective.Builder fwdObjBosBuilder = | 269 | ForwardingObjective.Builder fwdObjBosBuilder = |
| ... | @@ -264,7 +288,7 @@ public class RoutingRulePopulator { | ... | @@ -264,7 +288,7 @@ public class RoutingRulePopulator { |
| 264 | } else { | 288 | } else { |
| 265 | log.debug("Installing MPLS forwarding objective for " | 289 | log.debug("Installing MPLS forwarding objective for " |
| 266 | + "label {} in switch {} without PHP", | 290 | + "label {} in switch {} without PHP", |
| 267 | - config.getSegmentId(destSwId), | 291 | + segmentId, |
| 268 | deviceId); | 292 | deviceId); |
| 269 | 293 | ||
| 270 | ForwardingObjective.Builder fwdObjBosBuilder = | 294 | ForwardingObjective.Builder fwdObjBosBuilder = |
| ... | @@ -310,9 +334,21 @@ public class RoutingRulePopulator { | ... | @@ -310,9 +334,21 @@ public class RoutingRulePopulator { |
| 310 | Set<DeviceId> nextHops, | 334 | Set<DeviceId> nextHops, |
| 311 | boolean phpRequired, | 335 | boolean phpRequired, |
| 312 | boolean isBos) { | 336 | boolean isBos) { |
| 313 | - | ||
| 314 | ForwardingObjective.Builder fwdBuilder = DefaultForwardingObjective | 337 | ForwardingObjective.Builder fwdBuilder = DefaultForwardingObjective |
| 315 | .builder().withFlag(ForwardingObjective.Flag.SPECIFIC); | 338 | .builder().withFlag(ForwardingObjective.Flag.SPECIFIC); |
| 339 | + DeviceId nextHop = (DeviceId) nextHops.toArray()[0]; | ||
| 340 | + | ||
| 341 | + boolean isEdge; | ||
| 342 | + MacAddress srcMac; | ||
| 343 | + MacAddress dstMac; | ||
| 344 | + try { | ||
| 345 | + isEdge = config.isEdgeDevice(deviceId); | ||
| 346 | + srcMac = config.getDeviceMac(deviceId); | ||
| 347 | + dstMac = config.getDeviceMac(nextHop); | ||
| 348 | + } catch (DeviceConfigNotFoundException e) { | ||
| 349 | + log.warn(e.getMessage() + " Aborting getMplsForwardingObjective"); | ||
| 350 | + return null; | ||
| 351 | + } | ||
| 316 | 352 | ||
| 317 | TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder(); | 353 | TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder(); |
| 318 | 354 | ||
| ... | @@ -329,16 +365,15 @@ public class RoutingRulePopulator { | ... | @@ -329,16 +365,15 @@ public class RoutingRulePopulator { |
| 329 | tbuilder.deferred().decMplsTtl(); | 365 | tbuilder.deferred().decMplsTtl(); |
| 330 | } | 366 | } |
| 331 | 367 | ||
| 332 | - if (!isECMPSupportedInTransitRouter() && !config.isEdgeDevice(deviceId)) { | 368 | + if (!isECMPSupportedInTransitRouter() && !isEdge) { |
| 333 | PortNumber port = selectOnePort(deviceId, nextHops); | 369 | PortNumber port = selectOnePort(deviceId, nextHops); |
| 334 | - DeviceId nextHop = (DeviceId) nextHops.toArray()[0]; | ||
| 335 | if (port == null) { | 370 | if (port == null) { |
| 336 | log.warn("No link from {} to {}", deviceId, nextHops); | 371 | log.warn("No link from {} to {}", deviceId, nextHops); |
| 337 | return null; | 372 | return null; |
| 338 | } | 373 | } |
| 339 | tbuilder.deferred() | 374 | tbuilder.deferred() |
| 340 | - .setEthSrc(config.getDeviceMac(deviceId)) | 375 | + .setEthSrc(srcMac) |
| 341 | - .setEthDst(config.getDeviceMac(nextHop)) | 376 | + .setEthDst(dstMac) |
| 342 | .setOutput(port); | 377 | .setOutput(port); |
| 343 | fwdBuilder.withTreatment(tbuilder.build()); | 378 | fwdBuilder.withTreatment(tbuilder.build()); |
| 344 | } else { | 379 | } else { |
| ... | @@ -372,15 +407,27 @@ public class RoutingRulePopulator { | ... | @@ -372,15 +407,27 @@ public class RoutingRulePopulator { |
| 372 | public void populateRouterMacVlanFilters(DeviceId deviceId) { | 407 | public void populateRouterMacVlanFilters(DeviceId deviceId) { |
| 373 | log.debug("Installing per-port filtering objective for untagged " | 408 | log.debug("Installing per-port filtering objective for untagged " |
| 374 | + "packets in device {}", deviceId); | 409 | + "packets in device {}", deviceId); |
| 410 | + | ||
| 411 | + MacAddress deviceMac; | ||
| 412 | + try { | ||
| 413 | + deviceMac = config.getDeviceMac(deviceId); | ||
| 414 | + } catch (DeviceConfigNotFoundException e) { | ||
| 415 | + log.warn(e.getMessage() + " Aborting populateRouterMacVlanFilters."); | ||
| 416 | + return; | ||
| 417 | + } | ||
| 418 | + | ||
| 375 | for (Port port : srManager.deviceService.getPorts(deviceId)) { | 419 | for (Port port : srManager.deviceService.getPorts(deviceId)) { |
| 376 | if (port.number().toLong() > 0 && port.number().toLong() < OFPP_MAX) { | 420 | if (port.number().toLong() > 0 && port.number().toLong() < OFPP_MAX) { |
| 377 | Ip4Prefix portSubnet = config.getPortSubnet(deviceId, port.number()); | 421 | Ip4Prefix portSubnet = config.getPortSubnet(deviceId, port.number()); |
| 378 | VlanId assignedVlan = (portSubnet == null) | 422 | VlanId assignedVlan = (portSubnet == null) |
| 379 | ? VlanId.vlanId(SegmentRoutingManager.ASSIGNED_VLAN_NO_SUBNET) | 423 | ? VlanId.vlanId(SegmentRoutingManager.ASSIGNED_VLAN_NO_SUBNET) |
| 380 | : srManager.getSubnetAssignedVlanId(deviceId, portSubnet); | 424 | : srManager.getSubnetAssignedVlanId(deviceId, portSubnet); |
| 425 | + | ||
| 426 | + | ||
| 427 | + | ||
| 381 | FilteringObjective.Builder fob = DefaultFilteringObjective.builder(); | 428 | FilteringObjective.Builder fob = DefaultFilteringObjective.builder(); |
| 382 | fob.withKey(Criteria.matchInPort(port.number())) | 429 | fob.withKey(Criteria.matchInPort(port.number())) |
| 383 | - .addCondition(Criteria.matchEthDst(config.getDeviceMac(deviceId))) | 430 | + .addCondition(Criteria.matchEthDst(deviceMac)) |
| 384 | .addCondition(Criteria.matchVlanId(VlanId.NONE)); | 431 | .addCondition(Criteria.matchVlanId(VlanId.NONE)); |
| 385 | // vlan assignment is valid only if this instance is master | 432 | // vlan assignment is valid only if this instance is master |
| 386 | if (srManager.mastershipService.isLocalMaster(deviceId)) { | 433 | if (srManager.mastershipService.isLocalMaster(deviceId)) { |
| ... | @@ -405,6 +452,14 @@ public class RoutingRulePopulator { | ... | @@ -405,6 +452,14 @@ public class RoutingRulePopulator { |
| 405 | * @param deviceId the switch dpid for the router | 452 | * @param deviceId the switch dpid for the router |
| 406 | */ | 453 | */ |
| 407 | public void populateRouterIpPunts(DeviceId deviceId) { | 454 | public void populateRouterIpPunts(DeviceId deviceId) { |
| 455 | + Ip4Address routerIp; | ||
| 456 | + try { | ||
| 457 | + routerIp = config.getRouterIp(deviceId); | ||
| 458 | + } catch (DeviceConfigNotFoundException e) { | ||
| 459 | + log.warn(e.getMessage() + " Aborting populateRouterIpPunts."); | ||
| 460 | + return; | ||
| 461 | + } | ||
| 462 | + | ||
| 408 | if (!srManager.mastershipService.isLocalMaster(deviceId)) { | 463 | if (!srManager.mastershipService.isLocalMaster(deviceId)) { |
| 409 | log.debug("Not installing port-IP punts - not the master for dev:{} ", | 464 | log.debug("Not installing port-IP punts - not the master for dev:{} ", |
| 410 | deviceId); | 465 | deviceId); |
| ... | @@ -412,7 +467,7 @@ public class RoutingRulePopulator { | ... | @@ -412,7 +467,7 @@ public class RoutingRulePopulator { |
| 412 | } | 467 | } |
| 413 | ForwardingObjective.Builder puntIp = DefaultForwardingObjective.builder(); | 468 | ForwardingObjective.Builder puntIp = DefaultForwardingObjective.builder(); |
| 414 | Set<Ip4Address> allIps = new HashSet<Ip4Address>(config.getPortIPs(deviceId)); | 469 | Set<Ip4Address> allIps = new HashSet<Ip4Address>(config.getPortIPs(deviceId)); |
| 415 | - allIps.add(config.getRouterIp(deviceId)); | 470 | + allIps.add(routerIp); |
| 416 | for (Ip4Address ipaddr : allIps) { | 471 | for (Ip4Address ipaddr : allIps) { |
| 417 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | 472 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
| 418 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); | 473 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); | ... | ... |
| ... | @@ -38,6 +38,8 @@ import org.onosproject.net.config.NetworkConfigEvent; | ... | @@ -38,6 +38,8 @@ import org.onosproject.net.config.NetworkConfigEvent; |
| 38 | import org.onosproject.net.config.NetworkConfigRegistry; | 38 | import org.onosproject.net.config.NetworkConfigRegistry; |
| 39 | import org.onosproject.net.config.NetworkConfigListener; | 39 | import org.onosproject.net.config.NetworkConfigListener; |
| 40 | import org.onosproject.net.config.basics.SubjectFactories; | 40 | import org.onosproject.net.config.basics.SubjectFactories; |
| 41 | +import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; | ||
| 42 | +import org.onosproject.segmentrouting.config.DeviceConfiguration; | ||
| 41 | import org.onosproject.segmentrouting.config.SegmentRoutingConfig; | 43 | import org.onosproject.segmentrouting.config.SegmentRoutingConfig; |
| 42 | import org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler; | 44 | import org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler; |
| 43 | import org.onosproject.segmentrouting.grouphandler.NeighborSet; | 45 | import org.onosproject.segmentrouting.grouphandler.NeighborSet; |
| ... | @@ -553,7 +555,10 @@ public class SegmentRoutingManager implements SegmentRoutingService { | ... | @@ -553,7 +555,10 @@ public class SegmentRoutingManager implements SegmentRoutingService { |
| 553 | 555 | ||
| 554 | private void processLinkAdded(Link link) { | 556 | private void processLinkAdded(Link link) { |
| 555 | log.debug("A new link {} was added", link.toString()); | 557 | log.debug("A new link {} was added", link.toString()); |
| 556 | - | 558 | + if (!deviceConfiguration.isConfigured(link.src().deviceId())) { |
| 559 | + log.warn("Source device of this link is not configured."); | ||
| 560 | + return; | ||
| 561 | + } | ||
| 557 | //Irrespective whether the local is a MASTER or not for this device, | 562 | //Irrespective whether the local is a MASTER or not for this device, |
| 558 | //create group handler instance and push default TTP flow rules. | 563 | //create group handler instance and push default TTP flow rules. |
| 559 | //Because in a multi-instance setup, instances can initiate | 564 | //Because in a multi-instance setup, instances can initiate |
| ... | @@ -596,7 +601,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { | ... | @@ -596,7 +601,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { |
| 596 | 601 | ||
| 597 | private void processDeviceAdded(Device device) { | 602 | private void processDeviceAdded(Device device) { |
| 598 | log.debug("A new device with ID {} was added", device.id()); | 603 | log.debug("A new device with ID {} was added", device.id()); |
| 599 | - if (deviceConfiguration == null) { | 604 | + if (deviceConfiguration == null || !deviceConfiguration.isConfigured(device.id())) { |
| 600 | log.warn("Device configuration uploading. Device {} will be " | 605 | log.warn("Device configuration uploading. Device {} will be " |
| 601 | + "processed after config completes.", device.id()); | 606 | + "processed after config completes.", device.id()); |
| 602 | return; | 607 | return; |
| ... | @@ -608,7 +613,9 @@ public class SegmentRoutingManager implements SegmentRoutingService { | ... | @@ -608,7 +613,9 @@ public class SegmentRoutingManager implements SegmentRoutingService { |
| 608 | // to the switch). To handle this, a default-group-handler instance is necessary | 613 | // to the switch). To handle this, a default-group-handler instance is necessary |
| 609 | // per switch. | 614 | // per switch. |
| 610 | if (groupHandlerMap.get(device.id()) == null) { | 615 | if (groupHandlerMap.get(device.id()) == null) { |
| 611 | - DefaultGroupHandler groupHandler = DefaultGroupHandler. | 616 | + DefaultGroupHandler groupHandler; |
| 617 | + try { | ||
| 618 | + groupHandler = DefaultGroupHandler. | ||
| 612 | createGroupHandler(device.id(), | 619 | createGroupHandler(device.id(), |
| 613 | appId, | 620 | appId, |
| 614 | deviceConfiguration, | 621 | deviceConfiguration, |
| ... | @@ -616,6 +623,10 @@ public class SegmentRoutingManager implements SegmentRoutingService { | ... | @@ -616,6 +623,10 @@ public class SegmentRoutingManager implements SegmentRoutingService { |
| 616 | flowObjectiveService, | 623 | flowObjectiveService, |
| 617 | nsNextObjStore, | 624 | nsNextObjStore, |
| 618 | subnetNextObjStore); | 625 | subnetNextObjStore); |
| 626 | + } catch (DeviceConfigNotFoundException e) { | ||
| 627 | + log.warn(e.getMessage() + " Aborting processDeviceAdded."); | ||
| 628 | + return; | ||
| 629 | + } | ||
| 619 | groupHandlerMap.put(device.id(), groupHandler); | 630 | groupHandlerMap.put(device.id(), groupHandler); |
| 620 | // Also, in some cases, drivers may need extra | 631 | // Also, in some cases, drivers may need extra |
| 621 | // information to process rules (eg. Router IP/MAC); and so, we send | 632 | // information to process rules (eg. Router IP/MAC); and so, we send |
| ... | @@ -667,12 +678,20 @@ public class SegmentRoutingManager implements SegmentRoutingService { | ... | @@ -667,12 +678,20 @@ public class SegmentRoutingManager implements SegmentRoutingService { |
| 667 | // to the switch). To handle this, a default-group-handler instance is necessary | 678 | // to the switch). To handle this, a default-group-handler instance is necessary |
| 668 | // per switch. | 679 | // per switch. |
| 669 | if (groupHandlerMap.get(device.id()) == null) { | 680 | if (groupHandlerMap.get(device.id()) == null) { |
| 670 | - DefaultGroupHandler groupHandler = DefaultGroupHandler | 681 | + DefaultGroupHandler groupHandler; |
| 671 | - .createGroupHandler(device.id(), appId, | 682 | + try { |
| 672 | - deviceConfiguration, linkService, | 683 | + groupHandler = DefaultGroupHandler. |
| 684 | + createGroupHandler(device.id(), | ||
| 685 | + appId, | ||
| 686 | + deviceConfiguration, | ||
| 687 | + linkService, | ||
| 673 | flowObjectiveService, | 688 | flowObjectiveService, |
| 674 | nsNextObjStore, | 689 | nsNextObjStore, |
| 675 | subnetNextObjStore); | 690 | subnetNextObjStore); |
| 691 | + } catch (DeviceConfigNotFoundException e) { | ||
| 692 | + log.warn(e.getMessage() + " Aborting configureNetwork."); | ||
| 693 | + return; | ||
| 694 | + } | ||
| 676 | groupHandlerMap.put(device.id(), groupHandler); | 695 | groupHandlerMap.put(device.id(), groupHandler); |
| 677 | 696 | ||
| 678 | // Also, in some cases, drivers may need extra | 697 | // Also, in some cases, drivers may need extra | ... | ... |
| ... | @@ -18,6 +18,7 @@ package org.onosproject.segmentrouting; | ... | @@ -18,6 +18,7 @@ package org.onosproject.segmentrouting; |
| 18 | import org.onosproject.net.DeviceId; | 18 | import org.onosproject.net.DeviceId; |
| 19 | import org.onosproject.net.Link; | 19 | import org.onosproject.net.Link; |
| 20 | import org.onosproject.net.link.LinkService; | 20 | import org.onosproject.net.link.LinkService; |
| 21 | +import org.onosproject.segmentrouting.config.DeviceConfiguration; | ||
| 21 | import org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler; | 22 | import org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler; |
| 22 | import org.onosproject.segmentrouting.grouphandler.NeighborSet; | 23 | import org.onosproject.segmentrouting.grouphandler.NeighborSet; |
| 23 | import org.onosproject.store.service.EventuallyConsistentMap; | 24 | import org.onosproject.store.service.EventuallyConsistentMap; | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2014-2015 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | +package org.onosproject.segmentrouting.config; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * Signals that an error occurred during reading device configuration. | ||
| 21 | + */ | ||
| 22 | +public class DeviceConfigNotFoundException extends Exception { | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * Creates a new ConfigNotFoundException with the given message. | ||
| 26 | + * | ||
| 27 | + * @param message exception message | ||
| 28 | + */ | ||
| 29 | + public DeviceConfigNotFoundException(String message) { | ||
| 30 | + super(message); | ||
| 31 | + } | ||
| 32 | +} |
| ... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package org.onosproject.segmentrouting; | 16 | +package org.onosproject.segmentrouting.config; |
| 17 | 17 | ||
| 18 | import com.google.common.collect.ImmutableSet; | 18 | import com.google.common.collect.ImmutableSet; |
| 19 | import com.google.common.collect.Lists; | 19 | import com.google.common.collect.Lists; |
| ... | @@ -26,9 +26,7 @@ import org.onosproject.incubator.net.intf.Interface; | ... | @@ -26,9 +26,7 @@ import org.onosproject.incubator.net.intf.Interface; |
| 26 | import org.onosproject.net.ConnectPoint; | 26 | import org.onosproject.net.ConnectPoint; |
| 27 | import org.onosproject.net.config.NetworkConfigRegistry; | 27 | import org.onosproject.net.config.NetworkConfigRegistry; |
| 28 | import org.onosproject.net.host.InterfaceIpAddress; | 28 | import org.onosproject.net.host.InterfaceIpAddress; |
| 29 | -import org.onosproject.segmentrouting.config.SegmentRoutingConfig; | ||
| 30 | import org.onosproject.segmentrouting.config.SegmentRoutingConfig.AdjacencySid; | 29 | import org.onosproject.segmentrouting.config.SegmentRoutingConfig.AdjacencySid; |
| 31 | -import org.onosproject.segmentrouting.grouphandler.DeviceProperties; | ||
| 32 | import org.onosproject.net.DeviceId; | 30 | import org.onosproject.net.DeviceId; |
| 33 | import org.onosproject.net.PortNumber; | 31 | import org.onosproject.net.PortNumber; |
| 34 | import org.slf4j.Logger; | 32 | import org.slf4j.Logger; |
| ... | @@ -126,23 +124,20 @@ public class DeviceConfiguration implements DeviceProperties { | ... | @@ -126,23 +124,20 @@ public class DeviceConfiguration implements DeviceProperties { |
| 126 | }); | 124 | }); |
| 127 | } | 125 | } |
| 128 | 126 | ||
| 129 | - /** | ||
| 130 | - * Returns the Node segment id of a segment router. | ||
| 131 | - * | ||
| 132 | - * @param deviceId device identifier | ||
| 133 | - * @return segment id | ||
| 134 | - */ | ||
| 135 | @Override | 127 | @Override |
| 136 | - public int getSegmentId(DeviceId deviceId) { | 128 | + public boolean isConfigured(DeviceId deviceId) { |
| 129 | + return deviceConfigMap.get(deviceId) != null; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + @Override | ||
| 133 | + public int getSegmentId(DeviceId deviceId) throws DeviceConfigNotFoundException { | ||
| 137 | SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); | 134 | SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); |
| 138 | if (srinfo != null) { | 135 | if (srinfo != null) { |
| 139 | log.trace("getSegmentId for device{} is {}", deviceId, srinfo.nodeSid); | 136 | log.trace("getSegmentId for device{} is {}", deviceId, srinfo.nodeSid); |
| 140 | return srinfo.nodeSid; | 137 | return srinfo.nodeSid; |
| 141 | } else { | 138 | } else { |
| 142 | - log.warn("getSegmentId for device {} " | 139 | + String message = "getSegmentId fails for device: " + deviceId + "."; |
| 143 | - + "throwing IllegalStateException " | 140 | + throw new DeviceConfigNotFoundException(message); |
| 144 | - + "because device does not exist in config", deviceId); | ||
| 145 | - throw new IllegalStateException(); | ||
| 146 | } | 141 | } |
| 147 | } | 142 | } |
| 148 | 143 | ||
| ... | @@ -180,71 +175,42 @@ public class DeviceConfiguration implements DeviceProperties { | ... | @@ -180,71 +175,42 @@ public class DeviceConfiguration implements DeviceProperties { |
| 180 | return -1; | 175 | return -1; |
| 181 | } | 176 | } |
| 182 | 177 | ||
| 183 | - /** | ||
| 184 | - * Returns the router mac of a segment router. | ||
| 185 | - * | ||
| 186 | - * @param deviceId device identifier | ||
| 187 | - * @return router mac address | ||
| 188 | - */ | ||
| 189 | @Override | 178 | @Override |
| 190 | - public MacAddress getDeviceMac(DeviceId deviceId) { | 179 | + public MacAddress getDeviceMac(DeviceId deviceId) throws DeviceConfigNotFoundException { |
| 191 | SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); | 180 | SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); |
| 192 | if (srinfo != null) { | 181 | if (srinfo != null) { |
| 193 | log.trace("getDeviceMac for device{} is {}", deviceId, srinfo.mac); | 182 | log.trace("getDeviceMac for device{} is {}", deviceId, srinfo.mac); |
| 194 | return srinfo.mac; | 183 | return srinfo.mac; |
| 195 | } else { | 184 | } else { |
| 196 | - log.warn("getDeviceMac for device {} " | 185 | + String message = "getDeviceMac fails for device: " + deviceId + "."; |
| 197 | - + "throwing IllegalStateException " | 186 | + throw new DeviceConfigNotFoundException(message); |
| 198 | - + "because device does not exist in config", deviceId); | ||
| 199 | - throw new IllegalStateException(); | ||
| 200 | } | 187 | } |
| 201 | } | 188 | } |
| 202 | 189 | ||
| 203 | - /** | 190 | + @Override |
| 204 | - * Returns the router ip address of a segment router. | 191 | + public Ip4Address getRouterIp(DeviceId deviceId) throws DeviceConfigNotFoundException { |
| 205 | - * | ||
| 206 | - * @param deviceId device identifier | ||
| 207 | - * @return router ip address | ||
| 208 | - */ | ||
| 209 | - public Ip4Address getRouterIp(DeviceId deviceId) { | ||
| 210 | SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); | 192 | SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); |
| 211 | if (srinfo != null) { | 193 | if (srinfo != null) { |
| 212 | log.trace("getDeviceIp for device{} is {}", deviceId, srinfo.ip); | 194 | log.trace("getDeviceIp for device{} is {}", deviceId, srinfo.ip); |
| 213 | return srinfo.ip; | 195 | return srinfo.ip; |
| 214 | } else { | 196 | } else { |
| 215 | - log.warn("getRouterIp for device {} " | 197 | + String message = "getRouterIp fails for device: " + deviceId + "."; |
| 216 | - + "throwing IllegalStateException " | 198 | + throw new DeviceConfigNotFoundException(message); |
| 217 | - + "because device does not exist in config", deviceId); | ||
| 218 | - throw new IllegalStateException(); | ||
| 219 | } | 199 | } |
| 220 | } | 200 | } |
| 221 | 201 | ||
| 222 | - /** | ||
| 223 | - * Indicates if the segment router is a edge router or | ||
| 224 | - * a core/backbone router. | ||
| 225 | - * | ||
| 226 | - * @param deviceId device identifier | ||
| 227 | - * @return boolean | ||
| 228 | - */ | ||
| 229 | @Override | 202 | @Override |
| 230 | - public boolean isEdgeDevice(DeviceId deviceId) { | 203 | + public boolean isEdgeDevice(DeviceId deviceId) throws DeviceConfigNotFoundException { |
| 231 | SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); | 204 | SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); |
| 232 | if (srinfo != null) { | 205 | if (srinfo != null) { |
| 233 | log.trace("isEdgeDevice for device{} is {}", deviceId, srinfo.isEdge); | 206 | log.trace("isEdgeDevice for device{} is {}", deviceId, srinfo.isEdge); |
| 234 | return srinfo.isEdge; | 207 | return srinfo.isEdge; |
| 235 | } else { | 208 | } else { |
| 236 | - log.warn("isEdgeDevice for device {} " | 209 | + String message = "isEdgeDevice fails for device: " + deviceId + "."; |
| 237 | - + "throwing IllegalStateException " | 210 | + throw new DeviceConfigNotFoundException(message); |
| 238 | - + "because device does not exist in config", deviceId); | ||
| 239 | - throw new IllegalStateException(); | ||
| 240 | } | 211 | } |
| 241 | } | 212 | } |
| 242 | 213 | ||
| 243 | - /** | ||
| 244 | - * Returns the node segment ids of all configured segment routers. | ||
| 245 | - * | ||
| 246 | - * @return list of node segment ids | ||
| 247 | - */ | ||
| 248 | @Override | 214 | @Override |
| 249 | public List<Integer> getAllDeviceSegmentIds() { | 215 | public List<Integer> getAllDeviceSegmentIds() { |
| 250 | return allSegmentIds; | 216 | return allSegmentIds; | ... | ... |
| ... | @@ -13,11 +13,12 @@ | ... | @@ -13,11 +13,12 @@ |
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package org.onosproject.segmentrouting.grouphandler; | 16 | +package org.onosproject.segmentrouting.config; |
| 17 | 17 | ||
| 18 | import java.util.List; | 18 | import java.util.List; |
| 19 | import java.util.Map; | 19 | import java.util.Map; |
| 20 | 20 | ||
| 21 | +import org.onlab.packet.Ip4Address; | ||
| 21 | import org.onlab.packet.Ip4Prefix; | 22 | import org.onlab.packet.Ip4Prefix; |
| 22 | import org.onlab.packet.MacAddress; | 23 | import org.onlab.packet.MacAddress; |
| 23 | import org.onosproject.net.DeviceId; | 24 | import org.onosproject.net.DeviceId; |
| ... | @@ -30,28 +31,48 @@ import org.onosproject.net.PortNumber; | ... | @@ -30,28 +31,48 @@ import org.onosproject.net.PortNumber; |
| 30 | */ | 31 | */ |
| 31 | public interface DeviceProperties { | 32 | public interface DeviceProperties { |
| 32 | /** | 33 | /** |
| 34 | + * Checks if the device is configured. | ||
| 35 | + * | ||
| 36 | + * @param deviceId device identifier | ||
| 37 | + * @return true if the device is configured | ||
| 38 | + */ | ||
| 39 | + boolean isConfigured(DeviceId deviceId); | ||
| 40 | + | ||
| 41 | + /** | ||
| 33 | * Returns the segment id of a device to be used in group creation. | 42 | * Returns the segment id of a device to be used in group creation. |
| 34 | * | 43 | * |
| 35 | * @param deviceId device identifier | 44 | * @param deviceId device identifier |
| 45 | + * @throws DeviceConfigNotFoundException if the device configuration is not found | ||
| 36 | * @return segment id of a device | 46 | * @return segment id of a device |
| 37 | */ | 47 | */ |
| 38 | - int getSegmentId(DeviceId deviceId); | 48 | + int getSegmentId(DeviceId deviceId) throws DeviceConfigNotFoundException; |
| 39 | 49 | ||
| 40 | /** | 50 | /** |
| 41 | * Returns the Mac address of a device to be used in group creation. | 51 | * Returns the Mac address of a device to be used in group creation. |
| 42 | * | 52 | * |
| 43 | * @param deviceId device identifier | 53 | * @param deviceId device identifier |
| 54 | + * @throws DeviceConfigNotFoundException if the device configuration is not found | ||
| 44 | * @return mac address of a device | 55 | * @return mac address of a device |
| 45 | */ | 56 | */ |
| 46 | - MacAddress getDeviceMac(DeviceId deviceId); | 57 | + MacAddress getDeviceMac(DeviceId deviceId) throws DeviceConfigNotFoundException; |
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * Returns the router ip address of a segment router. | ||
| 61 | + * | ||
| 62 | + * @param deviceId device identifier | ||
| 63 | + * @throws DeviceConfigNotFoundException if the device configuration is not found | ||
| 64 | + * @return router ip address | ||
| 65 | + */ | ||
| 66 | + Ip4Address getRouterIp(DeviceId deviceId) throws DeviceConfigNotFoundException; | ||
| 47 | 67 | ||
| 48 | /** | 68 | /** |
| 49 | * Indicates whether a device is edge device or transit/core device. | 69 | * Indicates whether a device is edge device or transit/core device. |
| 50 | * | 70 | * |
| 51 | * @param deviceId device identifier | 71 | * @param deviceId device identifier |
| 72 | + * @throws DeviceConfigNotFoundException if the device configuration is not found | ||
| 52 | * @return boolean | 73 | * @return boolean |
| 53 | */ | 74 | */ |
| 54 | - boolean isEdgeDevice(DeviceId deviceId); | 75 | + boolean isEdgeDevice(DeviceId deviceId) throws DeviceConfigNotFoundException; |
| 55 | 76 | ||
| 56 | /** | 77 | /** |
| 57 | * Returns all segment IDs to be considered in building auto | 78 | * Returns all segment IDs to be considered in building auto | ... | ... |
| ... | @@ -24,6 +24,7 @@ import org.onosproject.net.DeviceId; | ... | @@ -24,6 +24,7 @@ import org.onosproject.net.DeviceId; |
| 24 | import org.onosproject.net.Link; | 24 | import org.onosproject.net.Link; |
| 25 | import org.onosproject.net.flowobjective.FlowObjectiveService; | 25 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
| 26 | import org.onosproject.net.link.LinkService; | 26 | import org.onosproject.net.link.LinkService; |
| 27 | +import org.onosproject.segmentrouting.config.DeviceProperties; | ||
| 27 | import org.onosproject.store.service.EventuallyConsistentMap; | 28 | import org.onosproject.store.service.EventuallyConsistentMap; |
| 28 | 29 | ||
| 29 | /** | 30 | /** | ... | ... |
| ... | @@ -48,6 +48,8 @@ import org.onosproject.net.flowobjective.ObjectiveError; | ... | @@ -48,6 +48,8 @@ import org.onosproject.net.flowobjective.ObjectiveError; |
| 48 | import org.onosproject.net.group.DefaultGroupKey; | 48 | import org.onosproject.net.group.DefaultGroupKey; |
| 49 | import org.onosproject.net.group.GroupKey; | 49 | import org.onosproject.net.group.GroupKey; |
| 50 | import org.onosproject.net.link.LinkService; | 50 | import org.onosproject.net.link.LinkService; |
| 51 | +import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; | ||
| 52 | +import org.onosproject.segmentrouting.config.DeviceProperties; | ||
| 51 | import org.onosproject.store.service.EventuallyConsistentMap; | 53 | import org.onosproject.store.service.EventuallyConsistentMap; |
| 52 | import org.slf4j.Logger; | 54 | import org.slf4j.Logger; |
| 53 | 55 | ||
| ... | @@ -63,9 +65,9 @@ public class DefaultGroupHandler { | ... | @@ -63,9 +65,9 @@ public class DefaultGroupHandler { |
| 63 | protected final ApplicationId appId; | 65 | protected final ApplicationId appId; |
| 64 | protected final DeviceProperties deviceConfig; | 66 | protected final DeviceProperties deviceConfig; |
| 65 | protected final List<Integer> allSegmentIds; | 67 | protected final List<Integer> allSegmentIds; |
| 66 | - protected final int nodeSegmentId; | 68 | + protected int nodeSegmentId = -1; |
| 67 | - protected final boolean isEdgeRouter; | 69 | + protected boolean isEdgeRouter = false; |
| 68 | - protected final MacAddress nodeMacAddr; | 70 | + protected MacAddress nodeMacAddr = null; |
| 69 | protected LinkService linkService; | 71 | protected LinkService linkService; |
| 70 | protected FlowObjectiveService flowObjectiveService; | 72 | protected FlowObjectiveService flowObjectiveService; |
| 71 | 73 | ||
| ... | @@ -99,10 +101,15 @@ public class DefaultGroupHandler { | ... | @@ -99,10 +101,15 @@ public class DefaultGroupHandler { |
| 99 | this.appId = checkNotNull(appId); | 101 | this.appId = checkNotNull(appId); |
| 100 | this.deviceConfig = checkNotNull(config); | 102 | this.deviceConfig = checkNotNull(config); |
| 101 | this.linkService = checkNotNull(linkService); | 103 | this.linkService = checkNotNull(linkService); |
| 102 | - allSegmentIds = checkNotNull(config.getAllDeviceSegmentIds()); | 104 | + this.allSegmentIds = checkNotNull(config.getAllDeviceSegmentIds()); |
| 103 | - nodeSegmentId = config.getSegmentId(deviceId); | 105 | + try { |
| 104 | - isEdgeRouter = config.isEdgeDevice(deviceId); | 106 | + this.nodeSegmentId = config.getSegmentId(deviceId); |
| 105 | - nodeMacAddr = checkNotNull(config.getDeviceMac(deviceId)); | 107 | + this.isEdgeRouter = config.isEdgeDevice(deviceId); |
| 108 | + this.nodeMacAddr = checkNotNull(config.getDeviceMac(deviceId)); | ||
| 109 | + } catch (DeviceConfigNotFoundException e) { | ||
| 110 | + log.warn(e.getMessage() | ||
| 111 | + + " Skipping value assignment in DefaultGroupHandler"); | ||
| 112 | + } | ||
| 106 | this.flowObjectiveService = flowObjService; | 113 | this.flowObjectiveService = flowObjService; |
| 107 | this.nsNextObjStore = nsNextObjStore; | 114 | this.nsNextObjStore = nsNextObjStore; |
| 108 | this.subnetNextObjStore = subnetNextObjStore; | 115 | this.subnetNextObjStore = subnetNextObjStore; |
| ... | @@ -122,6 +129,7 @@ public class DefaultGroupHandler { | ... | @@ -122,6 +129,7 @@ public class DefaultGroupHandler { |
| 122 | * @param flowObjService flow objective service object | 129 | * @param flowObjService flow objective service object |
| 123 | * @param nsNextObjStore NeighborSet next objective store map | 130 | * @param nsNextObjStore NeighborSet next objective store map |
| 124 | * @param subnetNextObjStore subnet next objective store map | 131 | * @param subnetNextObjStore subnet next objective store map |
| 132 | + * @throws DeviceConfigNotFoundException if the device configuration is not found | ||
| 125 | * @return default group handler type | 133 | * @return default group handler type |
| 126 | */ | 134 | */ |
| 127 | public static DefaultGroupHandler createGroupHandler(DeviceId deviceId, | 135 | public static DefaultGroupHandler createGroupHandler(DeviceId deviceId, |
| ... | @@ -133,7 +141,9 @@ public class DefaultGroupHandler { | ... | @@ -133,7 +141,9 @@ public class DefaultGroupHandler { |
| 133 | NeighborSetNextObjectiveStoreKey, | 141 | NeighborSetNextObjectiveStoreKey, |
| 134 | Integer> nsNextObjStore, | 142 | Integer> nsNextObjStore, |
| 135 | EventuallyConsistentMap<SubnetNextObjectiveStoreKey, | 143 | EventuallyConsistentMap<SubnetNextObjectiveStoreKey, |
| 136 | - Integer> subnetNextObjStore) { | 144 | + Integer> subnetNextObjStore) |
| 145 | + throws DeviceConfigNotFoundException { | ||
| 146 | + // handle possible exception in the caller | ||
| 137 | if (config.isEdgeDevice(deviceId)) { | 147 | if (config.isEdgeDevice(deviceId)) { |
| 138 | return new DefaultEdgeGroupHandler(deviceId, appId, config, | 148 | return new DefaultEdgeGroupHandler(deviceId, appId, config, |
| 139 | linkService, | 149 | linkService, |
| ... | @@ -176,6 +186,14 @@ public class DefaultGroupHandler { | ... | @@ -176,6 +186,14 @@ public class DefaultGroupHandler { |
| 176 | return; | 186 | return; |
| 177 | } | 187 | } |
| 178 | 188 | ||
| 189 | + MacAddress dstMac; | ||
| 190 | + try { | ||
| 191 | + dstMac = deviceConfig.getDeviceMac(newLink.dst().deviceId()); | ||
| 192 | + } catch (DeviceConfigNotFoundException e) { | ||
| 193 | + log.warn(e.getMessage() + " Aborting linkUp."); | ||
| 194 | + return; | ||
| 195 | + } | ||
| 196 | + | ||
| 179 | log.debug("Device {} linkUp at local port {} to neighbor {}", deviceId, | 197 | log.debug("Device {} linkUp at local port {} to neighbor {}", deviceId, |
| 180 | newLink.src().port(), newLink.dst().deviceId()); | 198 | newLink.src().port(), newLink.dst().deviceId()); |
| 181 | addNeighborAtPort(newLink.dst().deviceId(), | 199 | addNeighborAtPort(newLink.dst().deviceId(), |
| ... | @@ -202,8 +220,7 @@ public class DefaultGroupHandler { | ... | @@ -202,8 +220,7 @@ public class DefaultGroupHandler { |
| 202 | TrafficTreatment.Builder tBuilder = | 220 | TrafficTreatment.Builder tBuilder = |
| 203 | DefaultTrafficTreatment.builder(); | 221 | DefaultTrafficTreatment.builder(); |
| 204 | tBuilder.setOutput(newLink.src().port()) | 222 | tBuilder.setOutput(newLink.src().port()) |
| 205 | - .setEthDst(deviceConfig.getDeviceMac( | 223 | + .setEthDst(dstMac) |
| 206 | - newLink.dst().deviceId())) | ||
| 207 | .setEthSrc(nodeMacAddr); | 224 | .setEthSrc(nodeMacAddr); |
| 208 | if (ns.getEdgeLabel() != NeighborSet.NO_EDGE_LABEL) { | 225 | if (ns.getEdgeLabel() != NeighborSet.NO_EDGE_LABEL) { |
| 209 | tBuilder.pushMpls() | 226 | tBuilder.pushMpls() |
| ... | @@ -242,6 +259,15 @@ public class DefaultGroupHandler { | ... | @@ -242,6 +259,15 @@ public class DefaultGroupHandler { |
| 242 | log.warn("portDown: unknown port"); | 259 | log.warn("portDown: unknown port"); |
| 243 | return; | 260 | return; |
| 244 | } | 261 | } |
| 262 | + | ||
| 263 | + MacAddress dstMac; | ||
| 264 | + try { | ||
| 265 | + dstMac = deviceConfig.getDeviceMac(portDeviceMap.get(port)); | ||
| 266 | + } catch (DeviceConfigNotFoundException e) { | ||
| 267 | + log.warn(e.getMessage() + " Aborting portDown."); | ||
| 268 | + return; | ||
| 269 | + } | ||
| 270 | + | ||
| 245 | log.debug("Device {} portDown {} to neighbor {}", deviceId, port, | 271 | log.debug("Device {} portDown {} to neighbor {}", deviceId, port, |
| 246 | portDeviceMap.get(port)); | 272 | portDeviceMap.get(port)); |
| 247 | /*Set<NeighborSet> nsSet = computeImpactedNeighborsetForPortEvent(portDeviceMap | 273 | /*Set<NeighborSet> nsSet = computeImpactedNeighborsetForPortEvent(portDeviceMap |
| ... | @@ -263,8 +289,8 @@ public class DefaultGroupHandler { | ... | @@ -263,8 +289,8 @@ public class DefaultGroupHandler { |
| 263 | TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment | 289 | TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment |
| 264 | .builder(); | 290 | .builder(); |
| 265 | tBuilder.setOutput(port) | 291 | tBuilder.setOutput(port) |
| 266 | - .setEthDst(deviceConfig.getDeviceMac(portDeviceMap | 292 | + .setEthDst(dstMac) |
| 267 | - .get(port))).setEthSrc(nodeMacAddr); | 293 | + .setEthSrc(nodeMacAddr); |
| 268 | if (ns.getEdgeLabel() != NeighborSet.NO_EDGE_LABEL) { | 294 | if (ns.getEdgeLabel() != NeighborSet.NO_EDGE_LABEL) { |
| 269 | tBuilder.pushMpls().setMpls(MplsLabel.mplsLabel(ns | 295 | tBuilder.pushMpls().setMpls(MplsLabel.mplsLabel(ns |
| 270 | .getEdgeLabel())); | 296 | .getEdgeLabel())); |
| ... | @@ -432,7 +458,15 @@ public class DefaultGroupHandler { | ... | @@ -432,7 +458,15 @@ public class DefaultGroupHandler { |
| 432 | } | 458 | } |
| 433 | 459 | ||
| 434 | private boolean isSegmentIdSameAsNodeSegmentId(DeviceId deviceId, int sId) { | 460 | private boolean isSegmentIdSameAsNodeSegmentId(DeviceId deviceId, int sId) { |
| 435 | - return (deviceConfig.getSegmentId(deviceId) == sId); | 461 | + int segmentId; |
| 462 | + try { | ||
| 463 | + segmentId = deviceConfig.getSegmentId(deviceId); | ||
| 464 | + } catch (DeviceConfigNotFoundException e) { | ||
| 465 | + log.warn(e.getMessage() + " Aborting isSegmentIdSameAsNodeSegmentId."); | ||
| 466 | + return false; | ||
| 467 | + } | ||
| 468 | + | ||
| 469 | + return segmentId == sId; | ||
| 436 | } | 470 | } |
| 437 | 471 | ||
| 438 | protected List<Integer> getSegmentIdsTobePairedWithNeighborSet(Set<DeviceId> neighbors) { | 472 | protected List<Integer> getSegmentIdsTobePairedWithNeighborSet(Set<DeviceId> neighbors) { |
| ... | @@ -487,11 +521,19 @@ public class DefaultGroupHandler { | ... | @@ -487,11 +521,19 @@ public class DefaultGroupHandler { |
| 487 | return; | 521 | return; |
| 488 | } | 522 | } |
| 489 | 523 | ||
| 524 | + MacAddress deviceMac; | ||
| 525 | + try { | ||
| 526 | + deviceMac = deviceConfig.getDeviceMac(d); | ||
| 527 | + } catch (DeviceConfigNotFoundException e) { | ||
| 528 | + log.warn(e.getMessage() + " Aborting createGroupsFromNeighborsets."); | ||
| 529 | + return; | ||
| 530 | + } | ||
| 531 | + | ||
| 490 | for (PortNumber sp : devicePortMap.get(d)) { | 532 | for (PortNumber sp : devicePortMap.get(d)) { |
| 491 | TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment | 533 | TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment |
| 492 | .builder(); | 534 | .builder(); |
| 493 | tBuilder.setOutput(sp) | 535 | tBuilder.setOutput(sp) |
| 494 | - .setEthDst(deviceConfig.getDeviceMac(d)) | 536 | + .setEthDst(deviceMac) |
| 495 | .setEthSrc(nodeMacAddr); | 537 | .setEthSrc(nodeMacAddr); |
| 496 | if (ns.getEdgeLabel() != NeighborSet.NO_EDGE_LABEL) { | 538 | if (ns.getEdgeLabel() != NeighborSet.NO_EDGE_LABEL) { |
| 497 | tBuilder.pushMpls().setMpls(MplsLabel.mplsLabel(ns | 539 | tBuilder.pushMpls().setMpls(MplsLabel.mplsLabel(ns | ... | ... |
| ... | @@ -23,6 +23,8 @@ import org.onosproject.net.DeviceId; | ... | @@ -23,6 +23,8 @@ import org.onosproject.net.DeviceId; |
| 23 | import org.onosproject.net.Link; | 23 | import org.onosproject.net.Link; |
| 24 | import org.onosproject.net.flowobjective.FlowObjectiveService; | 24 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
| 25 | import org.onosproject.net.link.LinkService; | 25 | import org.onosproject.net.link.LinkService; |
| 26 | +import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; | ||
| 27 | +import org.onosproject.segmentrouting.config.DeviceProperties; | ||
| 26 | import org.onosproject.store.service.EventuallyConsistentMap; | 28 | import org.onosproject.store.service.EventuallyConsistentMap; |
| 27 | 29 | ||
| 28 | /** | 30 | /** |
| ... | @@ -171,7 +173,15 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler { | ... | @@ -171,7 +173,15 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler { |
| 171 | if (deviceSubSet.size() > 1) { | 173 | if (deviceSubSet.size() > 1) { |
| 172 | boolean avoidEdgeRouterPairing = true; | 174 | boolean avoidEdgeRouterPairing = true; |
| 173 | for (DeviceId device : deviceSubSet) { | 175 | for (DeviceId device : deviceSubSet) { |
| 174 | - if (!deviceConfig.isEdgeDevice(device)) { | 176 | + boolean isEdge; |
| 177 | + try { | ||
| 178 | + isEdge = deviceConfig.isEdgeDevice(device); | ||
| 179 | + } catch (DeviceConfigNotFoundException e) { | ||
| 180 | + log.warn(e.getMessage() + " Skipping filterEdgeRouterOnlyPairings on this device."); | ||
| 181 | + continue; | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + if (!isEdge) { | ||
| 175 | avoidEdgeRouterPairing = false; | 185 | avoidEdgeRouterPairing = false; |
| 176 | break; | 186 | break; |
| 177 | } | 187 | } | ... | ... |
| ... | @@ -24,8 +24,11 @@ import java.util.HashMap; | ... | @@ -24,8 +24,11 @@ import java.util.HashMap; |
| 24 | import java.util.Iterator; | 24 | import java.util.Iterator; |
| 25 | import java.util.List; | 25 | import java.util.List; |
| 26 | 26 | ||
| 27 | +import org.onlab.packet.MacAddress; | ||
| 27 | import org.onlab.packet.MplsLabel; | 28 | import org.onlab.packet.MplsLabel; |
| 28 | import org.onosproject.core.ApplicationId; | 29 | import org.onosproject.core.ApplicationId; |
| 30 | +import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; | ||
| 31 | +import org.onosproject.segmentrouting.config.DeviceProperties; | ||
| 29 | import org.onosproject.segmentrouting.grouphandler.GroupBucketIdentifier.BucketOutputType; | 32 | import org.onosproject.segmentrouting.grouphandler.GroupBucketIdentifier.BucketOutputType; |
| 30 | import org.onosproject.store.service.EventuallyConsistentMap; | 33 | import org.onosproject.store.service.EventuallyConsistentMap; |
| 31 | import org.onosproject.net.DeviceId; | 34 | import org.onosproject.net.DeviceId; |
| ... | @@ -105,11 +108,19 @@ public class PolicyGroupHandler extends DefaultGroupHandler { | ... | @@ -105,11 +108,19 @@ public class PolicyGroupHandler extends DefaultGroupHandler { |
| 105 | PolicyGroupIdentifier(id, | 108 | PolicyGroupIdentifier(id, |
| 106 | Collections.singletonList(param), | 109 | Collections.singletonList(param), |
| 107 | Collections.singletonList(bucketId)); | 110 | Collections.singletonList(bucketId)); |
| 111 | + MacAddress neighborEthDst; | ||
| 112 | + try { | ||
| 113 | + neighborEthDst = deviceConfig.getDeviceMac(neighbor); | ||
| 114 | + } catch (DeviceConfigNotFoundException e) { | ||
| 115 | + log.warn(e.getMessage() | ||
| 116 | + + " Skipping createPolicyGroupChain for this label."); | ||
| 117 | + continue; | ||
| 118 | + } | ||
| 119 | + | ||
| 108 | TrafficTreatment.Builder tBuilder = | 120 | TrafficTreatment.Builder tBuilder = |
| 109 | DefaultTrafficTreatment.builder(); | 121 | DefaultTrafficTreatment.builder(); |
| 110 | tBuilder.setOutput(sp) | 122 | tBuilder.setOutput(sp) |
| 111 | - .setEthDst(deviceConfig. | 123 | + .setEthDst(neighborEthDst) |
| 112 | - getDeviceMac(neighbor)) | ||
| 113 | .setEthSrc(nodeMacAddr) | 124 | .setEthSrc(nodeMacAddr) |
| 114 | .pushMpls() | 125 | .pushMpls() |
| 115 | .setMpls(MplsLabel.mplsLabel(label)); | 126 | .setMpls(MplsLabel.mplsLabel(label)); |
| ... | @@ -168,14 +179,23 @@ public class PolicyGroupHandler extends DefaultGroupHandler { | ... | @@ -168,14 +179,23 @@ public class PolicyGroupHandler extends DefaultGroupHandler { |
| 168 | 179 | ||
| 169 | if (fullyResolved) { | 180 | if (fullyResolved) { |
| 170 | List<GroupBucket> outBuckets = new ArrayList<>(); | 181 | List<GroupBucket> outBuckets = new ArrayList<>(); |
| 171 | - for (GroupBucketIdentifier bucketId:bucketIds) { | 182 | + for (GroupBucketIdentifier bucketId : bucketIds) { |
| 172 | DeviceId neighbor = portDeviceMap. | 183 | DeviceId neighbor = portDeviceMap. |
| 173 | get(bucketId.outPort()); | 184 | get(bucketId.outPort()); |
| 185 | + | ||
| 186 | + MacAddress neighborEthDst; | ||
| 187 | + try { | ||
| 188 | + neighborEthDst = deviceConfig.getDeviceMac(neighbor); | ||
| 189 | + } catch (DeviceConfigNotFoundException e) { | ||
| 190 | + log.warn(e.getMessage() | ||
| 191 | + + " Skipping createPolicyGroupChain for this bucketId."); | ||
| 192 | + continue; | ||
| 193 | + } | ||
| 194 | + | ||
| 174 | TrafficTreatment.Builder tBuilder = | 195 | TrafficTreatment.Builder tBuilder = |
| 175 | DefaultTrafficTreatment.builder(); | 196 | DefaultTrafficTreatment.builder(); |
| 176 | tBuilder.setOutput(bucketId.outPort()) | 197 | tBuilder.setOutput(bucketId.outPort()) |
| 177 | - .setEthDst(deviceConfig. | 198 | + .setEthDst(neighborEthDst) |
| 178 | - getDeviceMac(neighbor)) | ||
| 179 | .setEthSrc(nodeMacAddr); | 199 | .setEthSrc(nodeMacAddr); |
| 180 | if (bucketId.label() != NeighborSet.NO_EDGE_LABEL) { | 200 | if (bucketId.label() != NeighborSet.NO_EDGE_LABEL) { |
| 181 | tBuilder.pushMpls() | 201 | tBuilder.pushMpls() | ... | ... |
-
Please register or login to post a comment