Committed by
Gerrit Code Review
Fixing a couple of NPEs
Change-Id: I19b5a2787b26e67e05640f6c64a13b58f2dc089a
Showing
5 changed files
with
40 additions
and
22 deletions
| ... | @@ -24,7 +24,6 @@ import org.onlab.packet.VlanId; | ... | @@ -24,7 +24,6 @@ import org.onlab.packet.VlanId; |
| 24 | import org.onosproject.net.ConnectPoint; | 24 | import org.onosproject.net.ConnectPoint; |
| 25 | import org.onosproject.net.DeviceId; | 25 | import org.onosproject.net.DeviceId; |
| 26 | import org.onosproject.net.Host; | 26 | import org.onosproject.net.Host; |
| 27 | -import org.onosproject.net.PortNumber; | ||
| 28 | import org.onosproject.net.flow.DefaultTrafficTreatment; | 27 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 29 | import org.onosproject.net.flow.TrafficTreatment; | 28 | import org.onosproject.net.flow.TrafficTreatment; |
| 30 | import org.onosproject.net.packet.DefaultOutboundPacket; | 29 | import org.onosproject.net.packet.DefaultOutboundPacket; |
| ... | @@ -88,10 +87,7 @@ public class ArpHandler { | ... | @@ -88,10 +87,7 @@ public class ArpHandler { |
| 88 | ARP arp = (ARP) ethernet.getPayload(); | 87 | ARP arp = (ARP) ethernet.getPayload(); |
| 89 | 88 | ||
| 90 | ConnectPoint connectPoint = pkt.receivedFrom(); | 89 | ConnectPoint connectPoint = pkt.receivedFrom(); |
| 91 | - PortNumber inPort = connectPoint.port(); | ||
| 92 | DeviceId deviceId = connectPoint.deviceId(); | 90 | DeviceId deviceId = connectPoint.deviceId(); |
| 93 | - byte[] senderMacAddressByte = arp.getSenderHardwareAddress(); | ||
| 94 | - Ip4Address hostIpAddress = Ip4Address.valueOf(arp.getSenderProtocolAddress()); | ||
| 95 | if (arp.getOpCode() == ARP.OP_REQUEST) { | 91 | if (arp.getOpCode() == ARP.OP_REQUEST) { |
| 96 | handleArpRequest(deviceId, connectPoint, ethernet); | 92 | handleArpRequest(deviceId, connectPoint, ethernet); |
| 97 | } else { | 93 | } else { |
| ... | @@ -254,15 +250,23 @@ public class ArpHandler { | ... | @@ -254,15 +250,23 @@ public class ArpHandler { |
| 254 | ((ARP) packet.getPayload()).getTargetProtocolAddress() | 250 | ((ARP) packet.getPayload()).getTargetProtocolAddress() |
| 255 | ); | 251 | ); |
| 256 | 252 | ||
| 257 | - srManager.deviceConfiguration.getSubnetPortsMap(inPort.deviceId()).forEach((subnet, ports) -> { | 253 | + try { |
| 258 | - if (subnet.contains(targetProtocolAddress)) { | 254 | + srManager.deviceConfiguration |
| 259 | - ports.stream() | 255 | + .getSubnetPortsMap(inPort.deviceId()).forEach((subnet, ports) -> { |
| 260 | - .filter(port -> port != inPort.port()) | 256 | + if (subnet.contains(targetProtocolAddress)) { |
| 261 | - .forEach(port -> { | 257 | + ports.stream() |
| 262 | - removeVlanAndForward(packet, new ConnectPoint(inPort.deviceId(), port)); | 258 | + .filter(port -> port != inPort.port()) |
| 263 | - }); | 259 | + .forEach(port -> { |
| 264 | - } | 260 | + removeVlanAndForward(packet, |
| 265 | - }); | 261 | + new ConnectPoint(inPort.deviceId(), port)); |
| 262 | + }); | ||
| 263 | + } | ||
| 264 | + }); | ||
| 265 | + } catch (DeviceConfigNotFoundException e) { | ||
| 266 | + log.warn(e.getMessage() | ||
| 267 | + + " Cannot flood in subnet as device config not available" | ||
| 268 | + + " for device: " + inPort.deviceId()); | ||
| 269 | + } | ||
| 266 | } | 270 | } |
| 267 | 271 | ||
| 268 | /** | 272 | /** | ... | ... |
| ... | @@ -564,6 +564,8 @@ public class DefaultRoutingHandler { | ... | @@ -564,6 +564,8 @@ public class DefaultRoutingHandler { |
| 564 | 564 | ||
| 565 | public void purgeEcmpGraph(DeviceId deviceId) { | 565 | public void purgeEcmpGraph(DeviceId deviceId) { |
| 566 | currentEcmpSpgMap.remove(deviceId); | 566 | currentEcmpSpgMap.remove(deviceId); |
| 567 | - updatedEcmpSpgMap.remove(deviceId); | 567 | + if (updatedEcmpSpgMap != null) { |
| 568 | + updatedEcmpSpgMap.remove(deviceId); | ||
| 569 | + } | ||
| 568 | } | 570 | } |
| 569 | } | 571 | } | ... | ... |
| ... | @@ -264,12 +264,16 @@ public class DeviceConfiguration implements DeviceProperties { | ... | @@ -264,12 +264,16 @@ public class DeviceConfiguration implements DeviceProperties { |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | @Override | 266 | @Override |
| 267 | - public Map<Ip4Prefix, List<PortNumber>> getSubnetPortsMap(DeviceId deviceId) { | 267 | + public Map<Ip4Prefix, List<PortNumber>> getSubnetPortsMap(DeviceId deviceId) |
| 268 | - Map<Ip4Prefix, List<PortNumber>> subnetPortMap = new HashMap<>(); | 268 | + throws DeviceConfigNotFoundException { |
| 269 | - | 269 | + SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); |
| 270 | + if (srinfo == null) { | ||
| 271 | + String message = "getSubnetPortsMap fails for device: " + deviceId + "."; | ||
| 272 | + throw new DeviceConfigNotFoundException(message); | ||
| 273 | + } | ||
| 270 | // Construct subnet-port mapping from port-subnet mapping | 274 | // Construct subnet-port mapping from port-subnet mapping |
| 271 | - SetMultimap<PortNumber, Ip4Prefix> portSubnetMap = | 275 | + SetMultimap<PortNumber, Ip4Prefix> portSubnetMap = srinfo.subnets; |
| 272 | - this.deviceConfigMap.get(deviceId).subnets; | 276 | + Map<Ip4Prefix, List<PortNumber>> subnetPortMap = new HashMap<>(); |
| 273 | 277 | ||
| 274 | portSubnetMap.entries().forEach(entry -> { | 278 | portSubnetMap.entries().forEach(entry -> { |
| 275 | PortNumber port = entry.getKey(); | 279 | PortNumber port = entry.getKey(); | ... | ... |
| ... | @@ -93,8 +93,10 @@ public interface DeviceProperties { | ... | @@ -93,8 +93,10 @@ public interface DeviceProperties { |
| 93 | * | 93 | * |
| 94 | * @param deviceId device identifier | 94 | * @param deviceId device identifier |
| 95 | * @return a map that contains all subnet-to-ports mapping of given device | 95 | * @return a map that contains all subnet-to-ports mapping of given device |
| 96 | + * @throws DeviceConfigNotFoundException | ||
| 96 | */ | 97 | */ |
| 97 | - Map<Ip4Prefix, List<PortNumber>> getSubnetPortsMap(DeviceId deviceId); | 98 | + Map<Ip4Prefix, List<PortNumber>> getSubnetPortsMap(DeviceId deviceId) |
| 99 | + throws DeviceConfigNotFoundException; | ||
| 98 | 100 | ||
| 99 | /** | 101 | /** |
| 100 | * Returns the VLAN cross-connect configuration. | 102 | * Returns the VLAN cross-connect configuration. | ... | ... |
| ... | @@ -677,8 +677,14 @@ public class DefaultGroupHandler { | ... | @@ -677,8 +677,14 @@ public class DefaultGroupHandler { |
| 677 | * Creates broadcast groups for all ports in the same configured subnet. | 677 | * Creates broadcast groups for all ports in the same configured subnet. |
| 678 | */ | 678 | */ |
| 679 | public void createGroupsFromSubnetConfig() { | 679 | public void createGroupsFromSubnetConfig() { |
| 680 | - Map<Ip4Prefix, List<PortNumber>> subnetPortMap = | 680 | + Map<Ip4Prefix, List<PortNumber>> subnetPortMap; |
| 681 | - this.deviceConfig.getSubnetPortsMap(this.deviceId); | 681 | + try { |
| 682 | + subnetPortMap = this.deviceConfig.getSubnetPortsMap(this.deviceId); | ||
| 683 | + } catch (DeviceConfigNotFoundException e) { | ||
| 684 | + log.warn(e.getMessage() | ||
| 685 | + + " Not creating broadcast groups for device: " + deviceId); | ||
| 686 | + return; | ||
| 687 | + } | ||
| 682 | // Construct a broadcast group for each subnet | 688 | // Construct a broadcast group for each subnet |
| 683 | subnetPortMap.forEach((subnet, ports) -> { | 689 | subnetPortMap.forEach((subnet, ports) -> { |
| 684 | SubnetNextObjectiveStoreKey key = | 690 | SubnetNextObjectiveStoreKey key = | ... | ... |
-
Please register or login to post a comment