aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/providers
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/providers')
-rw-r--r--framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LLDPLinkProvider.java196
-rw-r--r--framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LinkDiscovery.java12
-rw-r--r--framework/src/onos/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/LLDPLinkProviderTest.java144
-rw-r--r--framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java65
-rw-r--r--framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilder.java22
-rw-r--r--framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer10.java6
-rw-r--r--framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java36
-rw-r--r--framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/NewAdaptiveFlowStatsCollector.java26
-rw-r--r--framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java22
-rw-r--r--framework/src/onos/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupBucketEntryBuilder.java4
-rw-r--r--framework/src/onos/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java2
-rw-r--r--framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/OvsdbHostProvider.java4
12 files changed, 384 insertions, 155 deletions
diff --git a/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LLDPLinkProvider.java b/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LLDPLinkProvider.java
index a840f856..98442033 100644
--- a/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LLDPLinkProvider.java
+++ b/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LLDPLinkProvider.java
@@ -27,6 +27,7 @@ import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.packet.Ethernet;
import org.onosproject.cfg.ComponentConfigService;
+import org.onosproject.cluster.ClusterService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.mastership.MastershipEvent;
@@ -37,6 +38,7 @@ import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.LinkKey;
import org.onosproject.net.Port;
+import org.onosproject.net.config.NetworkConfigRegistry;
import org.onosproject.net.device.DeviceEvent;
import org.onosproject.net.device.DeviceListener;
import org.onosproject.net.device.DeviceService;
@@ -60,6 +62,7 @@ import java.io.IOException;
import java.util.Dictionary;
import java.util.EnumSet;
import java.util.Map;
+import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService;
@@ -86,6 +89,10 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
"Settings: enabled={}, useBDDP={}, probeRate={}, " +
"staleLinkAge={}, lldpSuppression={}";
+ // When a Device/Port has this annotation, do not send out LLDP/BDDP
+ public static final String NO_LLDP = "no-lldp";
+
+
private final Logger log = getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -109,6 +116,12 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ComponentConfigService cfgService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ClusterService clusterService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected NetworkConfigRegistry cfgRegistry;
+
private LinkProviderService providerService;
private ScheduledExecutorService executor;
@@ -207,7 +220,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
newLldpSuppression = isNullOrEmpty(s) ? DEFAULT_LLDP_SUPPRESSION_CONFIG : s;
} catch (NumberFormatException e) {
- log.warn(e.getMessage());
+ log.warn("Component configuration had invalid values", e);
newEnabled = enabled;
newUseBddp = useBDDP;
newProbeRate = probeRate;
@@ -227,6 +240,14 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
enable();
} else if (wasEnabled && !enabled) {
disable();
+ } else {
+ // reflect changes in suppression rules to discovery helpers
+ // FIXME: After migrating to Network Configuration Subsystem,
+ // it should be possible to update only changed subset
+ if (enabled) {
+ // update all discovery helper state
+ loadDevices();
+ }
}
log.info(FORMAT, enabled, useBDDP, probeRate, staleLinkAge, lldpSuppression);
@@ -277,31 +298,96 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
* Loads available devices and registers their ports to be probed.
*/
private void loadDevices() {
- for (Device device : deviceService.getAvailableDevices()) {
- if (rules.isSuppressed(device)) {
- log.debug("LinkDiscovery from {} disabled by configuration", device.id());
- continue;
- }
- LinkDiscovery ld = new LinkDiscovery(device, context);
- discoverers.put(device.id(), ld);
- addPorts(ld, device.id());
+ deviceService.getAvailableDevices()
+ .forEach(d -> updateDevice(d)
+ .ifPresent(ld -> updatePorts(ld, d.id())));
+ }
+
+ /**
+ * Updates discovery helper for specified device.
+ *
+ * Adds and starts a discovery helper for specified device if enabled,
+ * calls {@link #removeDevice(DeviceId)} otherwise.
+ *
+ * @param device device to add
+ * @return discovery helper if discovery is enabled for the device
+ */
+ private Optional<LinkDiscovery> updateDevice(Device device) {
+ if (rules.isSuppressed(device)) {
+ log.trace("LinkDiscovery from {} disabled by configuration", device.id());
+ removeDevice(device.id());
+ return Optional.empty();
+ }
+ LinkDiscovery ld = discoverers.computeIfAbsent(device.id(),
+ did -> new LinkDiscovery(device, context));
+ if (ld.isStopped()) {
+ ld.start();
}
+ return Optional.of(ld);
}
/**
- * Adds ports of the specified device to the specified discovery helper.
+ * Removes after stopping discovery helper for specified device.
+ * @param deviceId device to remove
*/
- private void addPorts(LinkDiscovery discoverer, DeviceId deviceId) {
- for (Port p : deviceService.getPorts(deviceId)) {
- if (rules.isSuppressed(p)) {
- continue;
- }
- if (!p.number().isLogical()) {
- discoverer.addPort(p);
- }
+ private void removeDevice(final DeviceId deviceId) {
+ discoverers.computeIfPresent(deviceId, (did, ld) -> {
+ ld.stop();
+ providerService.linksVanished(deviceId);
+ return null;
+ });
+
+ }
+
+ /**
+ * Updates ports of the specified device to the specified discovery helper.
+ */
+ private void updatePorts(LinkDiscovery discoverer, DeviceId deviceId) {
+ deviceService.getPorts(deviceId).forEach(p -> updatePort(discoverer, p));
+ }
+
+ /**
+ * Updates discovery helper state of the specified port.
+ *
+ * Adds a port to the discovery helper if up and discovery is enabled,
+ * or calls {@link #removePort(Port)} otherwise.
+ */
+ private void updatePort(LinkDiscovery discoverer, Port port) {
+ if (rules.isSuppressed(port)) {
+ log.trace("LinkDiscovery from {} disabled by configuration", port);
+ removePort(port);
+ return;
+ }
+
+ // check if enabled and turn off discovery?
+ if (!port.isEnabled()) {
+ removePort(port);
+ return;
+ }
+
+ if (!port.number().isLogical()) {
+ discoverer.addPort(port);
}
}
+ /**
+ * Removes a port from the specified discovery helper.
+ * @param port the port
+ */
+ private void removePort(Port port) {
+ if (port.element() instanceof Device) {
+ Device d = (Device) port.element();
+ LinkDiscovery ld = discoverers.get(d.id());
+ if (ld != null) {
+ ld.removePort(port.number());
+ }
+
+ ConnectPoint point = new ConnectPoint(d.id(), port.number());
+ providerService.linksVanished(point);
+ } else {
+ log.warn("Attempted to remove non-Device port", port);
+ }
+ }
/**
* Loads LLDP suppression rules.
@@ -317,7 +403,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
// default rule to suppress ROADM to maintain compatibility
rules = new SuppressionRules(ImmutableSet.of(),
EnumSet.of(Device.Type.ROADM),
- ImmutableMap.of());
+ ImmutableMap.of(NO_LLDP, SuppressionRules.ANY_VALUE));
}
// should refresh discoverers when we need dynamic reconfiguration
@@ -367,10 +453,9 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
log.debug("Device {} doesn't exist, or isn't there yet", deviceId);
return;
}
- if (rules.isSuppressed(device)) {
- return;
+ if (clusterService.getLocalNode().id().equals(event.roleInfo().master())) {
+ updateDevice(device).ifPresent(ld -> updatePorts(ld, device.id()));
}
- discoverers.computeIfAbsent(deviceId, k -> new LinkDiscovery(device, context));
}
}
@@ -381,7 +466,6 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
private class InternalDeviceListener implements DeviceListener {
@Override
public void event(DeviceEvent event) {
- LinkDiscovery ld;
Device device = event.subject();
Port port = event.port();
if (device == null) {
@@ -393,73 +477,33 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
switch (event.type()) {
case DEVICE_ADDED:
case DEVICE_UPDATED:
- synchronized (discoverers) {
- ld = discoverers.get(deviceId);
- if (ld == null) {
- if (rules != null && rules.isSuppressed(device)) {
- log.debug("LinkDiscovery from {} disabled by configuration", device.id());
- return;
- }
- log.debug("Device added ({}) {}", event.type(), deviceId);
- discoverers.put(deviceId, new LinkDiscovery(device, context));
- } else {
- if (ld.isStopped()) {
- log.debug("Device restarted ({}) {}", event.type(), deviceId);
- ld.start();
- }
- }
- }
+ updateDevice(device).ifPresent(ld -> updatePorts(ld, deviceId));
break;
case PORT_ADDED:
case PORT_UPDATED:
if (port.isEnabled()) {
- ld = discoverers.get(deviceId);
- if (ld == null) {
- return;
- }
- if (rules.isSuppressed(port)) {
- log.debug("LinkDiscovery from {}@{} disabled by configuration",
- port.number(), device.id());
- return;
- }
- if (!port.number().isLogical()) {
- log.debug("Port added {}", port);
- ld.addPort(port);
- }
+ updateDevice(device).ifPresent(ld -> updatePort(ld, port));
} else {
log.debug("Port down {}", port);
- ConnectPoint point = new ConnectPoint(deviceId, port.number());
- providerService.linksVanished(point);
+ removePort(port);
}
break;
case PORT_REMOVED:
log.debug("Port removed {}", port);
- ConnectPoint point = new ConnectPoint(deviceId, port.number());
- providerService.linksVanished(point);
-
+ removePort(port);
break;
case DEVICE_REMOVED:
case DEVICE_SUSPENDED:
log.debug("Device removed {}", deviceId);
- ld = discoverers.get(deviceId);
- if (ld == null) {
- return;
- }
- ld.stop();
- providerService.linksVanished(deviceId);
+ removeDevice(deviceId);
break;
case DEVICE_AVAILABILITY_CHANGED:
- ld = discoverers.get(deviceId);
- if (ld == null) {
- return;
- }
if (deviceService.isAvailable(deviceId)) {
log.debug("Device up {}", deviceId);
- ld.start();
+ updateDevice(device);
} else {
- providerService.linksVanished(deviceId);
log.debug("Device down {}", deviceId);
- ld.stop();
+ removeDevice(deviceId);
}
break;
case PORT_STATS_UPDATED:
@@ -508,17 +552,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
}
// check what deviceService sees, to see if we are missing anything
try {
- for (Device dev : deviceService.getDevices()) {
- if (rules.isSuppressed(dev)) {
- continue;
- }
- DeviceId did = dev.id();
- synchronized (discoverers) {
- LinkDiscovery ld = discoverers
- .computeIfAbsent(did, k -> new LinkDiscovery(dev, context));
- addPorts(ld, did);
- }
- }
+ loadDevices();
} catch (Exception e) {
// Catch all exceptions to avoid task being suppressed
log.error("Exception thrown during synchronization process", e);
diff --git a/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LinkDiscovery.java b/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LinkDiscovery.java
index 8cdfd50f..7dc9aed0 100644
--- a/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LinkDiscovery.java
+++ b/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LinkDiscovery.java
@@ -61,7 +61,7 @@ class LinkDiscovery implements TimerTask {
private final ONOSLLDP lldpPacket;
private final Ethernet ethPacket;
- private Ethernet bddpEth;
+ private final Ethernet bddpEth;
private Timeout timeout;
private volatile boolean isStopped;
@@ -126,7 +126,7 @@ class LinkDiscovery implements TimerTask {
}
/**
- * Add physical port port to discovery process.
+ * Add physical port to discovery process.
* Send out initial LLDP and label it as slow port.
*
* @param port the port
@@ -141,6 +141,14 @@ class LinkDiscovery implements TimerTask {
}
/**
+ * removed physical port from discovery process.
+ * @param port the port number
+ */
+ void removePort(PortNumber port) {
+ ports.remove(port.toLong());
+ }
+
+ /**
* Handles an incoming LLDP packet. Creates link in topology and adds the
* link for staleness tracking.
*
diff --git a/framework/src/onos/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/LLDPLinkProviderTest.java b/framework/src/onos/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/LLDPLinkProviderTest.java
index b4b7b7b6..6070b857 100644
--- a/framework/src/onos/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/LLDPLinkProviderTest.java
+++ b/framework/src/onos/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/LLDPLinkProviderTest.java
@@ -16,6 +16,7 @@
package org.onosproject.provider.lldp.impl;
import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.junit.After;
@@ -32,7 +33,9 @@ import org.onosproject.core.CoreService;
import org.onosproject.core.DefaultApplicationId;
import org.onosproject.mastership.MastershipListener;
import org.onosproject.mastership.MastershipService;
+import org.onosproject.net.Annotations;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultDevice;
import org.onosproject.net.DefaultPort;
import org.onosproject.net.Device;
@@ -73,6 +76,7 @@ public class LLDPLinkProviderTest {
private static final DeviceId DID1 = DeviceId.deviceId("of:0000000000000001");
private static final DeviceId DID2 = DeviceId.deviceId("of:0000000000000002");
+ private static final DeviceId DID3 = DeviceId.deviceId("of:0000000000000003");
private static Port pd1;
private static Port pd2;
@@ -133,10 +137,35 @@ public class LLDPLinkProviderTest {
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID1));
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_REMOVED, DID1));
- assertTrue("Discoverer is not gone", provider.discoverers.get(DID1).isStopped());
+ final LinkDiscovery linkDiscovery = provider.discoverers.get(DID1);
+ if (linkDiscovery != null) {
+ // If LinkDiscovery helper is there after DEVICE_REMOVED,
+ // it should be stopped
+ assertTrue("Discoverer is not stopped", linkDiscovery.isStopped());
+ }
assertTrue("Device is not gone.", vanishedDpid(DID1));
}
+ /**
+ * Checks that links on a reconfigured switch are properly removed.
+ */
+ @Test
+ public void switchSuppressed() {
+ // add device to stub DeviceService
+ deviceService.putDevice(device(DID3));
+ deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID3));
+
+ assertFalse("Device not added", provider.discoverers.isEmpty());
+
+ // update device in stub DeviceService with suppression config
+ deviceService.putDevice(device(DID3, DefaultAnnotations.builder()
+ .set(LLDPLinkProvider.NO_LLDP, "true")
+ .build()));
+ deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_UPDATED, DID3));
+
+ assertTrue("Links on suppressed Device was expected to vanish.", vanishedDpid(DID3));
+ }
+
@Test
public void portUp() {
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID1));
@@ -152,27 +181,101 @@ public class LLDPLinkProviderTest {
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID1));
deviceListener.event(portEvent(DeviceEvent.Type.PORT_ADDED, DID1, port(DID1, 1, false)));
-
-
assertFalse("Port added to discoverer",
provider.discoverers.get(DID1).containsPort(1L));
assertTrue("Port is not gone.", vanishedPort(1L));
}
@Test
+ public void portRemoved() {
+ deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID1));
+ deviceListener.event(portEvent(DeviceEvent.Type.PORT_ADDED, DID1, port(DID1, 3, true)));
+ deviceListener.event(portEvent(DeviceEvent.Type.PORT_REMOVED, DID1, port(DID1, 3, true)));
+
+ assertTrue("Port is not gone.", vanishedPort(3L));
+ assertFalse("Port was not removed from discoverer",
+ provider.discoverers.get(DID1).containsPort(3L));
+ }
+
+ /**
+ * Checks that discovery on reconfigured switch are properly restarted.
+ */
+ @Test
+ public void portSuppressedByDeviceConfig() {
+
+ /// When Device is configured with suppression:ON, Port also is same
+
+ // add device in stub DeviceService with suppression configured
+ deviceService.putDevice(device(DID3, DefaultAnnotations.builder()
+ .set(LLDPLinkProvider.NO_LLDP, "true")
+ .build()));
+ deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID3));
+
+ // non-suppressed port added to suppressed device
+ final long portno3 = 3L;
+ deviceService.putPorts(DID3, port(DID3, portno3, true));
+ deviceListener.event(portEvent(DeviceEvent.Type.PORT_ADDED, DID3, port(DID3, portno3, true)));
+
+ // discovery on device is expected to be stopped
+ LinkDiscovery linkDiscovery = provider.discoverers.get(DID3);
+ if (linkDiscovery != null) {
+ assertTrue("Discovery expected to be stopped", linkDiscovery.isStopped());
+ }
+
+ /// When Device is reconfigured without suppression:OFF,
+ /// Port should be included for discovery
+
+ // update device in stub DeviceService without suppression configured
+ deviceService.putDevice(device(DID3));
+ // update the Port in stub DeviceService. (Port has reference to Device)
+ deviceService.putPorts(DID3, port(DID3, portno3, true));
+ deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_UPDATED, DID3));
+
+ // discovery should come back on
+ assertFalse("Discoverer is expected to start", provider.discoverers.get(DID3).isStopped());
+ assertTrue("Discoverer should contain the port there", provider.discoverers.get(DID3).containsPort(portno3));
+ }
+
+ /**
+ * Checks that discovery on reconfigured port are properly restarted.
+ */
+ @Test
+ public void portSuppressedByPortConfig() {
+ // add device in stub DeviceService without suppression configured
+ deviceService.putDevice(device(DID3));
+ deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID3));
+
+ // suppressed port added to non-suppressed device
+ final long portno3 = 3L;
+ final Port port3 = port(DID3, portno3, true,
+ DefaultAnnotations.builder()
+ .set(LLDPLinkProvider.NO_LLDP, "true")
+ .build());
+ deviceService.putPorts(DID3, port3);
+ deviceListener.event(portEvent(DeviceEvent.Type.PORT_ADDED, DID3, port3));
+
+ // discovery helper should be there turned on
+ assertFalse("Discoverer is expected to start", provider.discoverers.get(DID3).isStopped());
+ assertFalse("Discoverer should not contain the port there",
+ provider.discoverers.get(DID3).containsPort(portno3));
+ }
+
+ @Test
public void portUnknown() {
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID1));
- deviceListener.event(portEvent(DeviceEvent.Type.PORT_ADDED, DID2, port(DID2, 1, false)));
+ // Note: DID3 hasn't been added to TestDeviceService, but only port is added
+ deviceListener.event(portEvent(DeviceEvent.Type.PORT_ADDED, DID3, port(DID3, 1, false)));
assertNull("DeviceId exists",
- provider.discoverers.get(DID2));
+ provider.discoverers.get(DID3));
}
@Test
public void unknownPktCtx() {
- PacketContext pktCtx = new TestPacketContext(deviceService.getDevice(DID2));
+ // Note: DID3 hasn't been added to TestDeviceService
+ PacketContext pktCtx = new TestPacketContext(device(DID3));
testProcessor.process(pktCtx);
assertFalse("Context should still be free", pktCtx.isHandled());
@@ -206,6 +309,16 @@ public class LLDPLinkProviderTest {
}
+ private DefaultDevice device(DeviceId did) {
+ return new DefaultDevice(ProviderId.NONE, did, Device.Type.SWITCH,
+ "TESTMF", "TESTHW", "TESTSW", "TESTSN", new ChassisId());
+ }
+
+ private DefaultDevice device(DeviceId did, Annotations annotations) {
+ return new DefaultDevice(ProviderId.NONE, did, Device.Type.SWITCH,
+ "TESTMF", "TESTHW", "TESTSW", "TESTSN", new ChassisId(), annotations);
+ }
+
@SuppressWarnings(value = { "unused" })
private DeviceEvent portEvent(DeviceEvent.Type type, DeviceId did, PortNumber port) {
return new DeviceEvent(type, deviceService.getDevice(did),
@@ -221,6 +334,10 @@ public class LLDPLinkProviderTest {
PortNumber.portNumber(port), enabled);
}
+ private Port port(DeviceId did, long port, boolean enabled, Annotations annotations) {
+ return new DefaultPort(deviceService.getDevice(did),
+ PortNumber.portNumber(port), enabled, annotations);
+ }
private boolean vanishedDpid(DeviceId... dids) {
for (int i = 0; i < dids.length; i++) {
@@ -384,10 +501,9 @@ public class LLDPLinkProviderTest {
private class TestDeviceService extends DeviceServiceAdapter {
- private Map<DeviceId, Device> devices = new HashMap<>();
+ private final Map<DeviceId, Device> devices = new HashMap<>();
private final ArrayListMultimap<DeviceId, Port> ports =
ArrayListMultimap.create();
-
public TestDeviceService() {
Device d1 = new DefaultDevice(ProviderId.NONE, DID1, Device.Type.SWITCH,
"TESTMF", "TESTHW", "TESTSW", "TESTSN", new ChassisId());
@@ -395,7 +511,6 @@ public class LLDPLinkProviderTest {
"TESTMF", "TESTHW", "TESTSW", "TESTSN", new ChassisId());
devices.put(DID1, d1);
devices.put(DID2, d2);
-
pd1 = new DefaultPort(d1, PortNumber.portNumber(1), true);
pd2 = new DefaultPort(d1, PortNumber.portNumber(2), true);
pd3 = new DefaultPort(d2, PortNumber.portNumber(1), true);
@@ -405,6 +520,15 @@ public class LLDPLinkProviderTest {
ports.putAll(DID2, Lists.newArrayList(pd3, pd4));
}
+ private void putDevice(Device device) {
+ DeviceId deviceId = device.id();
+ devices.put(deviceId, device);
+ }
+
+ private void putPorts(DeviceId did, Port...ports) {
+ this.ports.putAll(did, Lists.newArrayList(ports));
+ }
+
@Override
public int getDeviceCount() {
return devices.values().size();
@@ -412,7 +536,7 @@ public class LLDPLinkProviderTest {
@Override
public Iterable<Device> getDevices() {
- return Collections.emptyList();
+ return ImmutableList.copyOf(devices.values());
}
@Override
diff --git a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java
index 1039d049..4d5b6b28 100644
--- a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java
+++ b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java
@@ -15,15 +15,7 @@
*/
package org.onosproject.provider.of.flow.impl;
-import static org.onosproject.net.flow.criteria.Criteria.matchLambda;
-import static org.onosproject.net.flow.criteria.Criteria.matchOchSignalType;
-import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupChannelSpacing;
-import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupGridType;
-import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupOchSignalType;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.List;
-
+import com.google.common.collect.Lists;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip4Prefix;
import org.onlab.packet.Ip6Address;
@@ -36,6 +28,11 @@ import org.onosproject.core.DefaultGroupId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Lambda;
import org.onosproject.net.PortNumber;
+import org.onosproject.net.driver.DefaultDriverData;
+import org.onosproject.net.driver.DefaultDriverHandler;
+import org.onosproject.net.driver.Driver;
+import org.onosproject.net.driver.DriverHandler;
+import org.onosproject.net.driver.DriverService;
import org.onosproject.net.flow.DefaultFlowEntry;
import org.onosproject.net.flow.DefaultFlowRule;
import org.onosproject.net.flow.DefaultTrafficSelector;
@@ -47,6 +44,7 @@ import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.openflow.controller.Dpid;
+import org.onosproject.openflow.controller.ExtensionInterpreter;
import org.projectfloodlight.openflow.protocol.OFFlowMod;
import org.projectfloodlight.openflow.protocol.OFFlowRemoved;
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry;
@@ -55,13 +53,13 @@ import org.projectfloodlight.openflow.protocol.action.OFActionCircuit;
import org.projectfloodlight.openflow.protocol.action.OFActionExperimenter;
import org.projectfloodlight.openflow.protocol.action.OFActionGroup;
import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
-import org.projectfloodlight.openflow.protocol.action.OFActionSetQueue;
import org.projectfloodlight.openflow.protocol.action.OFActionPopMpls;
import org.projectfloodlight.openflow.protocol.action.OFActionSetDlDst;
import org.projectfloodlight.openflow.protocol.action.OFActionSetDlSrc;
import org.projectfloodlight.openflow.protocol.action.OFActionSetField;
import org.projectfloodlight.openflow.protocol.action.OFActionSetNwDst;
import org.projectfloodlight.openflow.protocol.action.OFActionSetNwSrc;
+import org.projectfloodlight.openflow.protocol.action.OFActionSetQueue;
import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanPcp;
import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanVid;
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
@@ -75,7 +73,6 @@ import org.projectfloodlight.openflow.protocol.oxm.OFOxm;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic;
import org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13;
import org.projectfloodlight.openflow.types.CircuitSignalID;
-import org.projectfloodlight.openflow.types.EthType;
import org.projectfloodlight.openflow.types.IPv4Address;
import org.projectfloodlight.openflow.types.IPv6Address;
import org.projectfloodlight.openflow.types.Masked;
@@ -87,7 +84,14 @@ import org.projectfloodlight.openflow.types.U8;
import org.projectfloodlight.openflow.types.VlanPcp;
import org.slf4j.Logger;
-import com.google.common.collect.Lists;
+import java.util.List;
+
+import static org.onosproject.net.flow.criteria.Criteria.matchLambda;
+import static org.onosproject.net.flow.criteria.Criteria.matchOchSignalType;
+import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupChannelSpacing;
+import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupGridType;
+import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupOchSignalType;
+import static org.slf4j.LoggerFactory.getLogger;
public class FlowEntryBuilder {
private final Logger log = getLogger(getClass());
@@ -108,7 +112,9 @@ public class FlowEntryBuilder {
private final FlowType type;
- public FlowEntryBuilder(Dpid dpid, OFFlowStatsEntry entry) {
+ private final DriverService driverService;
+
+ public FlowEntryBuilder(Dpid dpid, OFFlowStatsEntry entry, DriverService driverService) {
this.stat = entry;
this.match = entry.getMatch();
this.instructions = getInstructions(entry);
@@ -116,9 +122,10 @@ public class FlowEntryBuilder {
this.removed = null;
this.flowMod = null;
this.type = FlowType.STAT;
+ this.driverService = driverService;
}
- public FlowEntryBuilder(Dpid dpid, OFFlowRemoved removed) {
+ public FlowEntryBuilder(Dpid dpid, OFFlowRemoved removed, DriverService driverService) {
this.match = removed.getMatch();
this.removed = removed;
@@ -127,10 +134,10 @@ public class FlowEntryBuilder {
this.stat = null;
this.flowMod = null;
this.type = FlowType.REMOVED;
-
+ this.driverService = driverService;
}
- public FlowEntryBuilder(Dpid dpid, OFFlowMod fm) {
+ public FlowEntryBuilder(Dpid dpid, OFFlowMod fm, DriverService driverService) {
this.match = fm.getMatch();
this.dpid = dpid;
this.instructions = getInstructions(fm);
@@ -138,6 +145,7 @@ public class FlowEntryBuilder {
this.flowMod = fm;
this.stat = null;
this.removed = null;
+ this.driverService = driverService;
}
public FlowEntry build(FlowEntryState... state) {
@@ -309,7 +317,7 @@ public class FlowEntryBuilder {
break;
case SET_FIELD:
OFActionSetField setField = (OFActionSetField) act;
- handleSetField(builder, setField.getField());
+ handleSetField(builder, setField);
break;
case POP_MPLS:
OFActionPopMpls popMpls = (OFActionPopMpls) act;
@@ -365,7 +373,8 @@ public class FlowEntryBuilder {
}
- private void handleSetField(TrafficTreatment.Builder builder, OFOxm<?> oxm) {
+ private void handleSetField(TrafficTreatment.Builder builder, OFActionSetField action) {
+ OFOxm<?> oxm = action.getField();
switch (oxm.getMatchField().id) {
case VLAN_PCP:
@SuppressWarnings("unchecked")
@@ -434,6 +443,13 @@ public class FlowEntryBuilder {
OFOxm<TransportPort> udpsrc = (OFOxm<TransportPort>) oxm;
builder.setUdpSrc(TpPort.tpPort(udpsrc.getValue().getPort()));
break;
+ case TUNNEL_IPV4_DST:
+ DriverHandler driver = getDriver(dpid);
+ ExtensionInterpreter interpreter = driver.behaviour(ExtensionInterpreter.class);
+ if (interpreter != null) {
+ builder.extension(interpreter.mapAction(action), DeviceId.deviceId(Dpid.uri(dpid)));
+ }
+ break;
case ARP_OP:
case ARP_SHA:
case ARP_SPA:
@@ -520,11 +536,7 @@ public class FlowEntryBuilder {
break;
case ETH_TYPE:
int ethType = match.get(MatchField.ETH_TYPE).getValue();
- if (ethType == EthType.VLAN_FRAME.getValue()) {
- builder.matchVlanId(VlanId.ANY);
- } else {
- builder.matchEthType((short) ethType);
- }
+ builder.matchEthType((short) ethType);
break;
case VLAN_VID:
VlanId vlanId = null;
@@ -703,4 +715,11 @@ public class FlowEntryBuilder {
}
return builder.build();
}
+
+ private DriverHandler getDriver(Dpid dpid) {
+ DeviceId deviceId = DeviceId.deviceId(Dpid.uri(dpid));
+ Driver driver = driverService.getDriver(deviceId);
+ DriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driver, deviceId));
+ return handler;
+ }
}
diff --git a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilder.java b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilder.java
index e050524a..7eca4920 100644
--- a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilder.java
+++ b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilder.java
@@ -15,16 +15,13 @@
*/
package org.onosproject.provider.of.flow.impl;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.Optional;
-
import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip4Prefix;
import org.onlab.packet.Ip6Address;
import org.onlab.packet.Ip6Prefix;
import org.onlab.packet.VlanId;
import org.onosproject.net.OchSignal;
+import org.onosproject.net.driver.DriverService;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.criteria.Criterion;
@@ -85,6 +82,10 @@ import org.projectfloodlight.openflow.types.VlanPcp;
import org.projectfloodlight.openflow.types.VlanVid;
import org.slf4j.Logger;
+import java.util.Optional;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
/**
* Builder for OpenFlow flow mods based on FlowRules.
*/
@@ -96,6 +97,7 @@ public abstract class FlowModBuilder {
private final FlowRule flowRule;
private final TrafficSelector selector;
protected final Long xid;
+ protected final Optional<DriverService> driverService;
/**
* Creates a new flow mod builder.
@@ -107,12 +109,13 @@ public abstract class FlowModBuilder {
*/
public static FlowModBuilder builder(FlowRule flowRule,
OFFactory factory,
- Optional<Long> xid) {
+ Optional<Long> xid,
+ Optional<DriverService> driverService) {
switch (factory.getVersion()) {
case OF_10:
- return new FlowModBuilderVer10(flowRule, factory, xid);
+ return new FlowModBuilderVer10(flowRule, factory, xid, driverService);
case OF_13:
- return new FlowModBuilderVer13(flowRule, factory, xid);
+ return new FlowModBuilderVer13(flowRule, factory, xid, driverService);
default:
throw new UnsupportedOperationException(
"No flow mod builder for protocol version " + factory.getVersion());
@@ -126,12 +129,13 @@ public abstract class FlowModBuilder {
* @param factory the OpenFlow factory to use to build the flow mod
* @param xid the transaction ID
*/
- protected FlowModBuilder(FlowRule flowRule, OFFactory factory, Optional<Long> xid) {
+ protected FlowModBuilder(FlowRule flowRule, OFFactory factory, Optional<Long> xid,
+ Optional<DriverService> driverService) {
this.factory = factory;
this.flowRule = flowRule;
this.selector = flowRule.selector();
this.xid = xid.orElse(0L);
-
+ this.driverService = driverService;
}
/**
diff --git a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer10.java b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer10.java
index f77819d5..c7898414 100644
--- a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer10.java
+++ b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer10.java
@@ -17,6 +17,7 @@ package org.onosproject.provider.of.flow.impl;
import org.onlab.packet.Ip4Address;
import org.onosproject.net.PortNumber;
+import org.onosproject.net.driver.DriverService;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.instructions.Instruction;
@@ -68,8 +69,9 @@ public class FlowModBuilderVer10 extends FlowModBuilder {
* @param xid the transaction ID
*/
protected FlowModBuilderVer10(FlowRule flowRule,
- OFFactory factory, Optional<Long> xid) {
- super(flowRule, factory, xid);
+ OFFactory factory, Optional<Long> xid,
+ Optional<DriverService> driverService) {
+ super(flowRule, factory, xid, driverService);
this.treatment = flowRule.treatment();
}
diff --git a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
index 64b4360a..a99aa817 100644
--- a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
+++ b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
@@ -18,10 +18,16 @@ package org.onosproject.provider.of.flow.impl;
import com.google.common.collect.Lists;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip6Address;
+import org.onosproject.net.DeviceId;
import org.onosproject.net.OchSignal;
import org.onosproject.net.PortNumber;
+import org.onosproject.net.driver.DefaultDriverData;
+import org.onosproject.net.driver.DefaultDriverHandler;
+import org.onosproject.net.driver.Driver;
+import org.onosproject.net.driver.DriverService;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.TrafficTreatment;
+import org.onosproject.net.flow.instructions.ExtensionInstruction;
import org.onosproject.net.flow.instructions.Instruction;
import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.net.flow.instructions.Instructions.GroupInstruction;
@@ -34,15 +40,16 @@ import org.onosproject.net.flow.instructions.L2ModificationInstruction;
import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction;
import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsBosInstruction;
import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction;
+import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModTunnelIdInstruction;
import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction;
import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction;
import org.onosproject.net.flow.instructions.L2ModificationInstruction.PushHeaderInstructions;
-import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModTunnelIdInstruction;
import org.onosproject.net.flow.instructions.L3ModificationInstruction;
import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction;
import org.onosproject.net.flow.instructions.L4ModificationInstruction;
import org.onosproject.net.flow.instructions.L4ModificationInstruction.ModTransportPortInstruction;
+import org.onosproject.openflow.controller.ExtensionInterpreter;
import org.projectfloodlight.openflow.protocol.OFFactory;
import org.projectfloodlight.openflow.protocol.OFFlowAdd;
import org.projectfloodlight.openflow.protocol.OFFlowDelete;
@@ -88,6 +95,7 @@ public class FlowModBuilderVer13 extends FlowModBuilder {
private static final int OFPCML_NO_BUFFER = 0xffff;
private final TrafficTreatment treatment;
+ private final DeviceId deviceId;
/**
* Constructor for a flow mod builder for OpenFlow 1.3.
@@ -96,10 +104,12 @@ public class FlowModBuilderVer13 extends FlowModBuilder {
* @param factory the OpenFlow factory to use to build the flow mod
* @param xid the transaction ID
*/
- protected FlowModBuilderVer13(FlowRule flowRule, OFFactory factory, Optional<Long> xid) {
- super(flowRule, factory, xid);
+ protected FlowModBuilderVer13(FlowRule flowRule, OFFactory factory, Optional<Long> xid,
+ Optional<DriverService> driverService) {
+ super(flowRule, factory, xid, driverService);
this.treatment = flowRule.treatment();
+ this.deviceId = flowRule.deviceId();
}
@Override
@@ -256,6 +266,10 @@ public class FlowModBuilderVer13 extends FlowModBuilder {
//FIXME: should not occur here.
tableFound = true;
break;
+ case EXTENSION:
+ actions.add(buildExtensionAction(((Instructions.ExtensionInstructionWrapper) i)
+ .extensionInstruction()));
+ break;
default:
log.warn("Instruction type {} not yet implemented.", i.type());
}
@@ -467,4 +481,20 @@ public class FlowModBuilderVer13 extends FlowModBuilder {
return null;
}
+ private OFAction buildExtensionAction(ExtensionInstruction i) {
+ if (!driverService.isPresent()) {
+ log.error("No driver service present");
+ return null;
+ }
+ Driver driver = driverService.get().getDriver(deviceId);
+ if (driver.hasBehaviour(ExtensionInterpreter.class)) {
+ DefaultDriverHandler handler =
+ new DefaultDriverHandler(new DefaultDriverData(driver, deviceId));
+ ExtensionInterpreter interpreter = handler.behaviour(ExtensionInterpreter.class);
+ return interpreter.mapInstruction(factory(), i);
+ }
+
+ return null;
+ }
+
}
diff --git a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/NewAdaptiveFlowStatsCollector.java b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/NewAdaptiveFlowStatsCollector.java
index 487cae96..d5186fa9 100644
--- a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/NewAdaptiveFlowStatsCollector.java
+++ b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/NewAdaptiveFlowStatsCollector.java
@@ -16,21 +16,10 @@
package org.onosproject.provider.of.flow.impl;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-
import org.onosproject.net.flow.DefaultTypedFlowEntry;
import org.onosproject.net.flow.FlowEntry;
import org.onosproject.net.flow.FlowId;
@@ -47,9 +36,19 @@ import org.projectfloodlight.openflow.types.OFPort;
import org.projectfloodlight.openflow.types.TableId;
import org.slf4j.Logger;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onlab.util.Tools.groupedThreads;
-import static org.onosproject.net.flow.TypedStoredFlowEntry.*;
+import static org.onosproject.net.flow.TypedStoredFlowEntry.FlowLiveType;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -232,7 +231,8 @@ public class NewAdaptiveFlowStatsCollector {
// send openflow flow stats request message with getting the specific flow entry(fe) to a given switch sw
private void ofFlowStatsRequestFlowSend(FlowEntry fe) {
// set find match
- Match match = FlowModBuilder.builder(fe, sw.factory(), Optional.empty()).buildMatch();
+ Match match = FlowModBuilder.builder(fe, sw.factory(), Optional.empty(),
+ Optional.empty()).buildMatch();
// set find tableId
TableId tableId = TableId.of(fe.tableId());
// set output port
diff --git a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
index 6374ca55..b37cb42c 100644
--- a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
+++ b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
@@ -21,7 +21,6 @@ import com.google.common.cache.RemovalCause;
import com.google.common.cache.RemovalNotification;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -32,6 +31,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.DeviceId;
+import org.onosproject.net.driver.DriverService;
import org.onosproject.net.flow.CompletedBatchOperation;
import org.onosproject.net.flow.DefaultTableStatisticsEntry;
import org.onosproject.net.flow.FlowEntry;
@@ -61,12 +61,12 @@ import org.projectfloodlight.openflow.protocol.OFErrorType;
import org.projectfloodlight.openflow.protocol.OFFlowMod;
import org.projectfloodlight.openflow.protocol.OFFlowRemoved;
import org.projectfloodlight.openflow.protocol.OFFlowStatsReply;
-import org.projectfloodlight.openflow.protocol.OFTableStatsReply;
-import org.projectfloodlight.openflow.protocol.OFTableStatsEntry;
import org.projectfloodlight.openflow.protocol.OFMessage;
import org.projectfloodlight.openflow.protocol.OFPortStatus;
import org.projectfloodlight.openflow.protocol.OFStatsReply;
import org.projectfloodlight.openflow.protocol.OFStatsType;
+import org.projectfloodlight.openflow.protocol.OFTableStatsEntry;
+import org.projectfloodlight.openflow.protocol.OFTableStatsReply;
import org.projectfloodlight.openflow.protocol.errormsg.OFBadRequestErrorMsg;
import org.projectfloodlight.openflow.protocol.errormsg.OFFlowModFailedErrorMsg;
import org.slf4j.Logger;
@@ -106,6 +106,9 @@ public class OpenFlowRuleProvider extends AbstractProvider
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ComponentConfigService cfgService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DriverService driverService;
+
private static final int DEFAULT_POLL_FREQUENCY = 5;
@Property(name = "flowPollFrequency", intValue = DEFAULT_POLL_FREQUENCY,
label = "Frequency (in seconds) for polling flow statistics")
@@ -269,7 +272,7 @@ public class OpenFlowRuleProvider extends AbstractProvider
return;
}
sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(),
- Optional.empty()).buildFlowAdd());
+ Optional.empty(), Optional.of(driverService)).buildFlowAdd());
if (adaptiveFlowSampling) {
// Add TypedFlowEntry to deviceFlowEntries in NewAdaptiveFlowStatsCollector
@@ -298,7 +301,7 @@ public class OpenFlowRuleProvider extends AbstractProvider
return;
}
sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(),
- Optional.empty()).buildFlowDel());
+ Optional.empty(), Optional.of(driverService)).buildFlowDel());
if (adaptiveFlowSampling) {
// Remove TypedFlowEntry to deviceFlowEntries in NewAdaptiveFlowStatsCollector
@@ -334,7 +337,8 @@ public class OpenFlowRuleProvider extends AbstractProvider
continue;
}
FlowModBuilder builder =
- FlowModBuilder.builder(fbe.target(), sw.factory(), Optional.of(batch.id()));
+ FlowModBuilder.builder(fbe.target(), sw.factory(),
+ Optional.of(batch.id()), Optional.of(driverService));
NewAdaptiveFlowStatsCollector collector = afsCollectors.get(dpid);
switch (fbe.operator()) {
case ADD:
@@ -423,7 +427,7 @@ public class OpenFlowRuleProvider extends AbstractProvider
case FLOW_REMOVED:
OFFlowRemoved removed = (OFFlowRemoved) msg;
- FlowEntry fr = new FlowEntryBuilder(dpid, removed).build();
+ FlowEntry fr = new FlowEntryBuilder(dpid, removed, driverService).build();
providerService.flowRemoved(fr);
if (adaptiveFlowSampling) {
@@ -474,7 +478,7 @@ public class OpenFlowRuleProvider extends AbstractProvider
InternalCacheEntry entry =
pendingBatches.getIfPresent(msg.getXid());
if (entry != null) {
- entry.appendFailure(new FlowEntryBuilder(dpid, fm).build());
+ entry.appendFailure(new FlowEntryBuilder(dpid, fm, driverService).build());
} else {
log.error("No matching batch for this error: {}", error);
}
@@ -501,7 +505,7 @@ public class OpenFlowRuleProvider extends AbstractProvider
DeviceId did = DeviceId.deviceId(Dpid.uri(dpid));
List<FlowEntry> flowEntries = replies.getEntries().stream()
- .map(entry -> new FlowEntryBuilder(dpid, entry).build())
+ .map(entry -> new FlowEntryBuilder(dpid, entry, driverService).build())
.collect(Collectors.toList());
if (adaptiveFlowSampling) {
diff --git a/framework/src/onos/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupBucketEntryBuilder.java b/framework/src/onos/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupBucketEntryBuilder.java
index b9de7c0f..d3a23782 100644
--- a/framework/src/onos/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupBucketEntryBuilder.java
+++ b/framework/src/onos/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupBucketEntryBuilder.java
@@ -115,6 +115,10 @@ public class GroupBucketEntryBuilder {
DefaultGroupBucket.createFailoverGroupBucket(treatment,
port, groupId);
break;
+ case ALL:
+ groupBucket =
+ DefaultGroupBucket.createAllGroupBucket(treatment);
+ break;
default:
log.error("Unsupported Group type : {}", type);
}
diff --git a/framework/src/onos/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java b/framework/src/onos/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java
index 8acf08ee..5783c842 100644
--- a/framework/src/onos/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java
+++ b/framework/src/onos/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java
@@ -252,7 +252,7 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv
private GroupDescription.Type getGroupType(OFGroupType type) {
switch (type) {
case ALL:
- return GroupDescription.Type.ALL;
+ return GroupDescription.Type.ALL;
case INDIRECT:
return GroupDescription.Type.INDIRECT;
case SELECT:
diff --git a/framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/OvsdbHostProvider.java b/framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/OvsdbHostProvider.java
index 0e3e1564..031fda78 100644
--- a/framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/OvsdbHostProvider.java
+++ b/framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/OvsdbHostProvider.java
@@ -111,7 +111,7 @@ public class OvsdbHostProvider extends AbstractProvider implements HostProvider
}
switch (event.type()) {
case PORT_ADDED:
- HostId hostId = HostId.hostId(subject.hwAddress(), null);
+ HostId hostId = HostId.hostId(subject.hwAddress(), VlanId.vlanId());
DeviceId deviceId = DeviceId.deviceId(uri(subject.dpid().value()));
PortNumber portNumber = PortNumber.portNumber(subject
.portNumber().value(), subject.portName().value());
@@ -127,7 +127,7 @@ public class OvsdbHostProvider extends AbstractProvider implements HostProvider
providerService.hostDetected(hostId, hostDescription);
break;
case PORT_REMOVED:
- HostId host = HostId.hostId(subject.hwAddress(), null);
+ HostId host = HostId.hostId(subject.hwAddress(), VlanId.vlanId());
providerService.hostVanished(host);
break;
default: