[ONOS-5097]adding group table entry failed
Change-Id: I17fc9f156e1f10800caba2cbc180dac45e97a675
diff --git a/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelectorType.java b/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelectorType.java
index dad75cb..94de7d9 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelectorType.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelectorType.java
@@ -40,7 +40,9 @@
NICIRA_MATCH_NSH_CH4(5),
NICIRA_MATCH_ENCAP_ETH_TYPE(6),
OFDPA_MATCH_VLAN_VID(16),
- BMV2_MATCH_PARAMS(128);
+ BMV2_MATCH_PARAMS(128),
+
+ UNRESOLVED_TYPE(200);
private ExtensionSelectorType type;
diff --git a/core/api/src/main/java/org/onosproject/net/flow/criteria/UnresolvedExtensionSelector.java b/core/api/src/main/java/org/onosproject/net/flow/criteria/UnresolvedExtensionSelector.java
new file mode 100644
index 0000000..e5bc0c4
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/flow/criteria/UnresolvedExtensionSelector.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.flow.criteria;
+
+import org.onosproject.net.flow.AbstractExtension;
+import java.util.Arrays;
+import java.util.Objects;
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+
+/**
+ * Unresolved extension selector.
+ */
+public class UnresolvedExtensionSelector extends AbstractExtension implements ExtensionSelector {
+
+ private byte[] bytes;
+ private ExtensionSelectorType unresolvedSelectorType;
+
+ /**
+ * Creates a new unresolved extension selector with given data in byte form.
+ *
+ * @param type unresolved extension data type
+ */
+ public UnresolvedExtensionSelector(byte[] arraybyte, ExtensionSelectorType type) {
+ this.bytes = arraybyte;
+ this.unresolvedSelectorType = type;
+ }
+
+ @Override
+ public byte[] serialize() {
+ return bytes;
+ }
+
+ @Override
+ public void deserialize(byte[] data) {
+ bytes = data;
+ }
+
+ @Override
+ public ExtensionSelectorType type() {
+ return ExtensionSelectorType.ExtensionSelectorTypes.UNRESOLVED_TYPE.type();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(bytes);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof UnresolvedExtensionSelector) {
+ UnresolvedExtensionSelector that = (UnresolvedExtensionSelector) obj;
+ return Arrays.equals(bytes, that.bytes);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(type().toString())
+ .add("bytes", bytes)
+ .add("unresolvedSelectorType", unresolvedSelectorType)
+ .toString();
+ }
+}
+
diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java
index a8df465..f036638 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java
@@ -62,7 +62,9 @@
NICIRA_ENCAP_ETH_DST(122),
NICIRA_ENCAP_ETH_TYPE(123),
BMV2_ACTION(128),
- OPLINK_ATTENUATION(130);
+ OPLINK_ATTENUATION(130),
+
+ UNRESOLVED_TYPE(200);
private ExtensionTreatmentType type;
diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/UnresolvedExtensionTreatment.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/UnresolvedExtensionTreatment.java
new file mode 100644
index 0000000..bf8c18b
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/UnresolvedExtensionTreatment.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.flow.instructions;
+
+import com.google.common.base.MoreObjects;
+import org.onosproject.net.flow.AbstractExtension;
+import java.util.Arrays;
+import java.util.Objects;
+
+/**
+ * Unresolved extension treatment.
+ */
+public class UnresolvedExtensionTreatment extends AbstractExtension implements ExtensionTreatment {
+
+ private byte[] bytes;
+ private ExtensionTreatmentType unresolvedTreatmentType;
+
+ /**
+ * Creates a new unresolved extension treatment with given data in byte form.
+ *
+ * @param type unresolved extension data type
+ */
+ public UnresolvedExtensionTreatment(byte[] arraybyte, ExtensionTreatmentType type) {
+ this.bytes = arraybyte;
+ this.unresolvedTreatmentType = type;
+ }
+
+ @Override
+ public ExtensionTreatmentType type() {
+ return ExtensionTreatmentType.ExtensionTreatmentTypes.UNRESOLVED_TYPE.type();
+ }
+
+ @Override
+ public void deserialize(byte[] data) {
+ bytes = data;
+ }
+
+ @Override
+ public byte[] serialize() {
+ return bytes;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(bytes);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof UnresolvedExtensionTreatment) {
+ UnresolvedExtensionTreatment that = (UnresolvedExtensionTreatment) obj;
+ return Arrays.equals(bytes, that.bytes);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("bytes", bytes)
+ .add("unresolvedTreatmentType", unresolvedTreatmentType)
+ .toString();
+ }
+}
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionCriterionSerializer.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionCriterionSerializer.java
index c9e51b5..8e5eb90 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionCriterionSerializer.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionCriterionSerializer.java
@@ -21,6 +21,7 @@
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import org.onlab.osgi.DefaultServiceDirectory;
+import org.onlab.util.ItemNotFoundException;
import org.onosproject.net.DeviceId;
import org.onosproject.net.behaviour.ExtensionSelectorResolver;
import org.onosproject.net.driver.DefaultDriverData;
@@ -31,6 +32,7 @@
import org.onosproject.net.flow.criteria.ExtensionCriterion;
import org.onosproject.net.flow.criteria.ExtensionSelector;
import org.onosproject.net.flow.criteria.ExtensionSelectorType;
+import org.onosproject.net.flow.criteria.UnresolvedExtensionSelector;
/**
* Serializer for extension criteria.
@@ -56,16 +58,20 @@
Class<ExtensionCriterion> type) {
ExtensionSelectorType exType = (ExtensionSelectorType) kryo.readClassAndObject(input);
DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);
-
DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
- DriverHandler handler = new DefaultDriverHandler(
- new DefaultDriverData(driverService.getDriver(deviceId), deviceId));
-
- ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class);
- ExtensionSelector selector = resolver.getExtensionSelector(exType);
-
byte[] bytes = (byte[]) kryo.readClassAndObject(input);
- selector.deserialize(bytes);
+ ExtensionSelector selector;
+
+ try {
+ DriverHandler handler = new DefaultDriverHandler(
+ new DefaultDriverData(driverService.getDriver(deviceId), deviceId));
+ ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class);
+ selector = resolver.getExtensionSelector(exType);
+ selector.deserialize(bytes);
+ } catch (ItemNotFoundException | IllegalArgumentException e) {
+ selector = new UnresolvedExtensionSelector(bytes, exType);
+ }
+
return Criteria.extension(selector, deviceId);
}
}
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionInstructionSerializer.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionInstructionSerializer.java
index ef55977..daf6910 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionInstructionSerializer.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionInstructionSerializer.java
@@ -21,6 +21,7 @@
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import org.onlab.osgi.DefaultServiceDirectory;
+import org.onlab.util.ItemNotFoundException;
import org.onosproject.net.DeviceId;
import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
import org.onosproject.net.driver.DefaultDriverData;
@@ -30,6 +31,7 @@
import org.onosproject.net.flow.instructions.ExtensionTreatment;
import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
import org.onosproject.net.flow.instructions.Instructions;
+import org.onosproject.net.flow.instructions.UnresolvedExtensionTreatment;
/**
* Serializer for extension instructions.
@@ -56,17 +58,19 @@
Class<Instructions.ExtensionInstructionWrapper> type) {
ExtensionTreatmentType exType = (ExtensionTreatmentType) kryo.readClassAndObject(input);
DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);
-
DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
- DriverHandler handler = new DefaultDriverHandler(
- new DefaultDriverData(driverService.getDriver(deviceId), deviceId));
-
- ExtensionTreatmentResolver resolver = handler.behaviour(ExtensionTreatmentResolver.class);
- ExtensionTreatment instruction = resolver.getExtensionInstruction(exType);
-
byte[] bytes = (byte[]) kryo.readClassAndObject(input);
+ ExtensionTreatment instruction;
- instruction.deserialize(bytes);
+ try {
+ DriverHandler handler = new DefaultDriverHandler(
+ new DefaultDriverData(driverService.getDriver(deviceId), deviceId));
+ ExtensionTreatmentResolver resolver = handler.behaviour(ExtensionTreatmentResolver.class);
+ instruction = resolver.getExtensionInstruction(exType);
+ instruction.deserialize(bytes);
+ } catch (ItemNotFoundException | IllegalArgumentException e) {
+ instruction = new UnresolvedExtensionTreatment(bytes, exType);
+ }
return Instructions.extension(instruction, deviceId);
}