Small updates to SR to get it to ignore devices not configured as routers

Change-Id: I2c0f695af1a6eab10607a8117faae5f6161a66d9
This commit is contained in:
Jonathan Hart 2017-11-30 18:23:42 -08:00
parent 003213301f
commit 8ca2bc0447
4 changed files with 43 additions and 42 deletions

View File

@ -271,12 +271,9 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
} }
byte msgType = dhcp6Payload.getMsgType(); byte msgType = dhcp6Payload.getMsgType();
log.warn("msgType is {}", msgType);
ConnectPoint inPort = context.inPacket().receivedFrom(); ConnectPoint inPort = context.inPacket().receivedFrom();
if (inPort == null) {
log.warn("incommin ConnectPoint is null");
}
Set<Interface> receivingInterfaces = interfaceService.getInterfacesByPort(inPort); Set<Interface> receivingInterfaces = interfaceService.getInterfacesByPort(inPort);
//ignore the packets if dhcp client interface is not configured on onos. //ignore the packets if dhcp client interface is not configured on onos.
if (receivingInterfaces.isEmpty()) { if (receivingInterfaces.isEmpty()) {

View File

@ -191,29 +191,29 @@ public class DefaultRoutingHandler {
updatedEcmpSpgMap = new HashMap<>(); updatedEcmpSpgMap = new HashMap<>();
Set<EdgePair> edgePairs = new HashSet<>(); Set<EdgePair> edgePairs = new HashSet<>();
Set<ArrayList<DeviceId>> routeChanges = new HashSet<>(); Set<ArrayList<DeviceId>> routeChanges = new HashSet<>();
for (Device dstSw : srManager.deviceService.getDevices()) { for (DeviceId dstSw : srManager.deviceConfiguration.getRouters()) {
EcmpShortestPathGraph ecmpSpgUpdated = EcmpShortestPathGraph ecmpSpgUpdated =
new EcmpShortestPathGraph(dstSw.id(), srManager); new EcmpShortestPathGraph(dstSw, srManager);
updatedEcmpSpgMap.put(dstSw.id(), ecmpSpgUpdated); updatedEcmpSpgMap.put(dstSw, ecmpSpgUpdated);
DeviceId pairDev = getPairDev(dstSw.id()); DeviceId pairDev = getPairDev(dstSw);
if (pairDev != null) { if (pairDev != null) {
// pairDev may not be available yet, but we still need to add // pairDev may not be available yet, but we still need to add
ecmpSpgUpdated = new EcmpShortestPathGraph(pairDev, srManager); ecmpSpgUpdated = new EcmpShortestPathGraph(pairDev, srManager);
updatedEcmpSpgMap.put(pairDev, ecmpSpgUpdated); 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) { if (ret == null) {
continue; continue;
} }
Set<DeviceId> devsToProcess = Sets.newHashSet(dstSw.id(), ret); Set<DeviceId> devsToProcess = Sets.newHashSet(dstSw, ret);
// To do a full reroute, assume all routes have changed // To do a full reroute, assume all routes have changed
for (DeviceId dev : devsToProcess) { for (DeviceId dev : devsToProcess) {
for (Device targetSw : srManager.deviceService.getDevices()) { for (DeviceId targetSw : srManager.deviceConfiguration.getRouters()) {
if (targetSw.id().equals(dev)) { if (targetSw.equals(dev)) {
continue; continue;
} }
routeChanges.add(Lists.newArrayList(targetSw.id(), dev)); routeChanges.add(Lists.newArrayList(targetSw, dev));
} }
} }
} }

View File

@ -15,23 +15,11 @@
*/ */
package org.onosproject.segmentrouting; 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.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 com.google.common.collect.Sets;
import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Component;
@ -121,10 +109,21 @@ import org.onosproject.store.service.WallClockTimestamp;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.google.common.collect.HashMultimap; import java.util.Collections;
import com.google.common.collect.ImmutableMap; import java.util.HashSet;
import com.google.common.collect.Maps; import java.util.List;
import com.google.common.collect.Multimap; 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 com.google.common.base.Preconditions.checkState;
import static org.onlab.packet.Ethernet.TYPE_ARP; import static org.onlab.packet.Ethernet.TYPE_ARP;
@ -581,9 +580,8 @@ public class SegmentRoutingManager implements SegmentRoutingService {
@Override @Override
public Map<DeviceId, Set<IpPrefix>> getDeviceSubnetMap() { public Map<DeviceId, Set<IpPrefix>> getDeviceSubnetMap() {
Map<DeviceId, Set<IpPrefix>> deviceSubnetMap = Maps.newHashMap(); Map<DeviceId, Set<IpPrefix>> deviceSubnetMap = Maps.newHashMap();
deviceService.getAvailableDevices().forEach(device -> { deviceConfiguration.getRouters().forEach(device ->
deviceSubnetMap.put(device.id(), deviceConfiguration.getSubnets(device.id())); deviceSubnetMap.put(device, deviceConfiguration.getSubnets(device)));
});
return deviceSubnetMap; return deviceSubnetMap;
} }

View File

@ -27,18 +27,19 @@ import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix; import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress; import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId; 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.ConnectPoint;
import org.onosproject.net.host.InterfaceIpAddress;
import org.onosproject.net.DeviceId; import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber; 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.onosproject.segmentrouting.SegmentRoutingManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -126,7 +127,9 @@ public class DeviceConfiguration implements DeviceProperties {
// Read gatewayIps and subnets from port subject. Ignore suppressed ports. // Read gatewayIps and subnets from port subject. Ignore suppressed ports.
Set<ConnectPoint> portSubjects = srManager.cfgService Set<ConnectPoint> portSubjects = srManager.cfgService
.getSubjects(ConnectPoint.class, InterfaceConfig.class); .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 = InterfaceConfig config =
srManager.cfgService.getConfig(subject, InterfaceConfig.class); srManager.cfgService.getConfig(subject, InterfaceConfig.class);
Set<Interface> networkInterfaces; Set<Interface> networkInterfaces;
@ -181,6 +184,9 @@ public class DeviceConfiguration implements DeviceProperties {
}); });
} }
public Collection<DeviceId> getRouters() {
return deviceConfigMap.keySet();
}
@Override @Override
public boolean isConfigured(DeviceId deviceId) { public boolean isConfigured(DeviceId deviceId) {