diff --git a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java index 7c5c762274..3df889f2b3 100644 --- a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java +++ b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java @@ -271,12 +271,9 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider { } byte msgType = dhcp6Payload.getMsgType(); - log.warn("msgType is {}", msgType); ConnectPoint inPort = context.inPacket().receivedFrom(); - if (inPort == null) { - log.warn("incommin ConnectPoint is null"); - } + Set receivingInterfaces = interfaceService.getInterfacesByPort(inPort); //ignore the packets if dhcp client interface is not configured on onos. if (receivingInterfaces.isEmpty()) { diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java index 5014811ad9..9844106096 100644 --- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java +++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java @@ -191,29 +191,29 @@ public class DefaultRoutingHandler { updatedEcmpSpgMap = new HashMap<>(); Set edgePairs = new HashSet<>(); Set> routeChanges = new HashSet<>(); - for (Device dstSw : srManager.deviceService.getDevices()) { + for (DeviceId dstSw : srManager.deviceConfiguration.getRouters()) { EcmpShortestPathGraph ecmpSpgUpdated = - new EcmpShortestPathGraph(dstSw.id(), srManager); - updatedEcmpSpgMap.put(dstSw.id(), ecmpSpgUpdated); - DeviceId pairDev = getPairDev(dstSw.id()); + new EcmpShortestPathGraph(dstSw, srManager); + updatedEcmpSpgMap.put(dstSw, ecmpSpgUpdated); + DeviceId pairDev = getPairDev(dstSw); if (pairDev != null) { // pairDev may not be available yet, but we still need to add ecmpSpgUpdated = new EcmpShortestPathGraph(pairDev, srManager); updatedEcmpSpgMap.put(pairDev, ecmpSpgUpdated); - edgePairs.add(new EdgePair(dstSw.id(), pairDev)); + edgePairs.add(new EdgePair(dstSw, pairDev)); } - DeviceId ret = shouldHandleRouting(dstSw.id()); + DeviceId ret = shouldHandleRouting(dstSw); if (ret == null) { continue; } - Set devsToProcess = Sets.newHashSet(dstSw.id(), ret); + Set devsToProcess = Sets.newHashSet(dstSw, ret); // To do a full reroute, assume all routes have changed for (DeviceId dev : devsToProcess) { - for (Device targetSw : srManager.deviceService.getDevices()) { - if (targetSw.id().equals(dev)) { + for (DeviceId targetSw : srManager.deviceConfiguration.getRouters()) { + if (targetSw.equals(dev)) { continue; } - routeChanges.add(Lists.newArrayList(targetSw.id(), dev)); + routeChanges.add(Lists.newArrayList(targetSw, dev)); } } } diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java index 1d1cc4ee2d..a9c2f04282 100644 --- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java +++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java @@ -15,23 +15,11 @@ */ package org.onosproject.segmentrouting; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.stream.Collectors; - import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; import com.google.common.collect.Sets; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; @@ -121,10 +109,21 @@ import org.onosproject.store.service.WallClockTimestamp; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; -import com.google.common.collect.Multimap; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; import static com.google.common.base.Preconditions.checkState; import static org.onlab.packet.Ethernet.TYPE_ARP; @@ -581,9 +580,8 @@ public class SegmentRoutingManager implements SegmentRoutingService { @Override public Map> getDeviceSubnetMap() { Map> deviceSubnetMap = Maps.newHashMap(); - deviceService.getAvailableDevices().forEach(device -> { - deviceSubnetMap.put(device.id(), deviceConfiguration.getSubnets(device.id())); - }); + deviceConfiguration.getRouters().forEach(device -> + deviceSubnetMap.put(device, deviceConfiguration.getSubnets(device))); return deviceSubnetMap; } diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java index 321cf40cf2..b7d32a1fe6 100644 --- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java +++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java @@ -27,18 +27,19 @@ import org.onlab.packet.IpAddress; import org.onlab.packet.IpPrefix; import org.onlab.packet.MacAddress; import org.onlab.packet.VlanId; -import org.onosproject.net.config.ConfigException; -import org.onosproject.net.config.basics.InterfaceConfig; -import org.onosproject.net.intf.Interface; import org.onosproject.net.ConnectPoint; -import org.onosproject.net.host.InterfaceIpAddress; import org.onosproject.net.DeviceId; import org.onosproject.net.PortNumber; +import org.onosproject.net.config.ConfigException; +import org.onosproject.net.config.basics.InterfaceConfig; +import org.onosproject.net.host.InterfaceIpAddress; +import org.onosproject.net.intf.Interface; import org.onosproject.segmentrouting.SegmentRoutingManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -126,7 +127,9 @@ public class DeviceConfiguration implements DeviceProperties { // Read gatewayIps and subnets from port subject. Ignore suppressed ports. Set portSubjects = srManager.cfgService .getSubjects(ConnectPoint.class, InterfaceConfig.class); - portSubjects.stream().filter(subject -> !isSuppressedPort(subject)).forEach(subject -> { + portSubjects.stream() + .filter(subject -> deviceConfigMap.containsKey(subject.deviceId())) + .filter(subject -> !isSuppressedPort(subject)).forEach(subject -> { InterfaceConfig config = srManager.cfgService.getConfig(subject, InterfaceConfig.class); Set networkInterfaces; @@ -181,6 +184,9 @@ public class DeviceConfiguration implements DeviceProperties { }); } + public Collection getRouters() { + return deviceConfigMap.keySet(); + } @Override public boolean isConfigured(DeviceId deviceId) {