Committed by
Gerrit Code Review
[ONOS-5097]adding group table entry failed
Change-Id: I17fc9f156e1f10800caba2cbc180dac45e97a675
Showing
6 changed files
with
194 additions
and
17 deletions
... | @@ -40,7 +40,9 @@ public class ExtensionSelectorType { | ... | @@ -40,7 +40,9 @@ public class ExtensionSelectorType { |
40 | NICIRA_MATCH_NSH_CH4(5), | 40 | NICIRA_MATCH_NSH_CH4(5), |
41 | NICIRA_MATCH_ENCAP_ETH_TYPE(6), | 41 | NICIRA_MATCH_ENCAP_ETH_TYPE(6), |
42 | OFDPA_MATCH_VLAN_VID(16), | 42 | OFDPA_MATCH_VLAN_VID(16), |
43 | - BMV2_MATCH_PARAMS(128); | 43 | + BMV2_MATCH_PARAMS(128), |
44 | + | ||
45 | + UNRESOLVED_TYPE(200); | ||
44 | 46 | ||
45 | private ExtensionSelectorType type; | 47 | private ExtensionSelectorType type; |
46 | 48 | ... | ... |
core/api/src/main/java/org/onosproject/net/flow/criteria/UnresolvedExtensionSelector.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import org.onosproject.net.flow.AbstractExtension; | ||
19 | +import java.util.Arrays; | ||
20 | +import java.util.Objects; | ||
21 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
22 | + | ||
23 | + | ||
24 | +/** | ||
25 | + * Unresolved extension selector. | ||
26 | + */ | ||
27 | +public class UnresolvedExtensionSelector extends AbstractExtension implements ExtensionSelector { | ||
28 | + | ||
29 | + private byte[] bytes; | ||
30 | + private ExtensionSelectorType unresolvedSelectorType; | ||
31 | + | ||
32 | + /** | ||
33 | + * Creates a new unresolved extension selector with given data in byte form. | ||
34 | + * | ||
35 | + * @param type unresolved extension data type | ||
36 | + */ | ||
37 | + public UnresolvedExtensionSelector(byte[] arraybyte, ExtensionSelectorType type) { | ||
38 | + this.bytes = arraybyte; | ||
39 | + this.unresolvedSelectorType = type; | ||
40 | + } | ||
41 | + | ||
42 | + @Override | ||
43 | + public byte[] serialize() { | ||
44 | + return bytes; | ||
45 | + } | ||
46 | + | ||
47 | + @Override | ||
48 | + public void deserialize(byte[] data) { | ||
49 | + bytes = data; | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public ExtensionSelectorType type() { | ||
54 | + return ExtensionSelectorType.ExtensionSelectorTypes.UNRESOLVED_TYPE.type(); | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public int hashCode() { | ||
59 | + return Objects.hash(bytes); | ||
60 | + } | ||
61 | + | ||
62 | + @Override | ||
63 | + public boolean equals(Object obj) { | ||
64 | + if (this == obj) { | ||
65 | + return true; | ||
66 | + } | ||
67 | + if (obj instanceof UnresolvedExtensionSelector) { | ||
68 | + UnresolvedExtensionSelector that = (UnresolvedExtensionSelector) obj; | ||
69 | + return Arrays.equals(bytes, that.bytes); | ||
70 | + } | ||
71 | + return false; | ||
72 | + } | ||
73 | + | ||
74 | + @Override | ||
75 | + public String toString() { | ||
76 | + return toStringHelper(type().toString()) | ||
77 | + .add("bytes", bytes) | ||
78 | + .add("unresolvedSelectorType", unresolvedSelectorType) | ||
79 | + .toString(); | ||
80 | + } | ||
81 | +} | ||
82 | + |
... | @@ -62,7 +62,9 @@ public final class ExtensionTreatmentType { | ... | @@ -62,7 +62,9 @@ public final class ExtensionTreatmentType { |
62 | NICIRA_ENCAP_ETH_DST(122), | 62 | NICIRA_ENCAP_ETH_DST(122), |
63 | NICIRA_ENCAP_ETH_TYPE(123), | 63 | NICIRA_ENCAP_ETH_TYPE(123), |
64 | BMV2_ACTION(128), | 64 | BMV2_ACTION(128), |
65 | - OPLINK_ATTENUATION(130); | 65 | + OPLINK_ATTENUATION(130), |
66 | + | ||
67 | + UNRESOLVED_TYPE(200); | ||
66 | 68 | ||
67 | private ExtensionTreatmentType type; | 69 | private ExtensionTreatmentType type; |
68 | 70 | ... | ... |
core/api/src/main/java/org/onosproject/net/flow/instructions/UnresolvedExtensionTreatment.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2015-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.net.flow.instructions; | ||
18 | + | ||
19 | +import com.google.common.base.MoreObjects; | ||
20 | +import org.onosproject.net.flow.AbstractExtension; | ||
21 | +import java.util.Arrays; | ||
22 | +import java.util.Objects; | ||
23 | + | ||
24 | +/** | ||
25 | + * Unresolved extension treatment. | ||
26 | + */ | ||
27 | +public class UnresolvedExtensionTreatment extends AbstractExtension implements ExtensionTreatment { | ||
28 | + | ||
29 | + private byte[] bytes; | ||
30 | + private ExtensionTreatmentType unresolvedTreatmentType; | ||
31 | + | ||
32 | + /** | ||
33 | + * Creates a new unresolved extension treatment with given data in byte form. | ||
34 | + * | ||
35 | + * @param type unresolved extension data type | ||
36 | + */ | ||
37 | + public UnresolvedExtensionTreatment(byte[] arraybyte, ExtensionTreatmentType type) { | ||
38 | + this.bytes = arraybyte; | ||
39 | + this.unresolvedTreatmentType = type; | ||
40 | + } | ||
41 | + | ||
42 | + @Override | ||
43 | + public ExtensionTreatmentType type() { | ||
44 | + return ExtensionTreatmentType.ExtensionTreatmentTypes.UNRESOLVED_TYPE.type(); | ||
45 | + } | ||
46 | + | ||
47 | + @Override | ||
48 | + public void deserialize(byte[] data) { | ||
49 | + bytes = data; | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public byte[] serialize() { | ||
54 | + return bytes; | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public int hashCode() { | ||
59 | + return Objects.hash(bytes); | ||
60 | + } | ||
61 | + | ||
62 | + @Override | ||
63 | + public boolean equals(Object obj) { | ||
64 | + if (this == obj) { | ||
65 | + return true; | ||
66 | + } | ||
67 | + if (obj instanceof UnresolvedExtensionTreatment) { | ||
68 | + UnresolvedExtensionTreatment that = (UnresolvedExtensionTreatment) obj; | ||
69 | + return Arrays.equals(bytes, that.bytes); | ||
70 | + } | ||
71 | + return false; | ||
72 | + } | ||
73 | + | ||
74 | + @Override | ||
75 | + public String toString() { | ||
76 | + return MoreObjects.toStringHelper(getClass()) | ||
77 | + .add("bytes", bytes) | ||
78 | + .add("unresolvedTreatmentType", unresolvedTreatmentType) | ||
79 | + .toString(); | ||
80 | + } | ||
81 | +} |
... | @@ -21,6 +21,7 @@ import com.esotericsoftware.kryo.Serializer; | ... | @@ -21,6 +21,7 @@ import com.esotericsoftware.kryo.Serializer; |
21 | import com.esotericsoftware.kryo.io.Input; | 21 | import com.esotericsoftware.kryo.io.Input; |
22 | import com.esotericsoftware.kryo.io.Output; | 22 | import com.esotericsoftware.kryo.io.Output; |
23 | import org.onlab.osgi.DefaultServiceDirectory; | 23 | import org.onlab.osgi.DefaultServiceDirectory; |
24 | +import org.onlab.util.ItemNotFoundException; | ||
24 | import org.onosproject.net.DeviceId; | 25 | import org.onosproject.net.DeviceId; |
25 | import org.onosproject.net.behaviour.ExtensionSelectorResolver; | 26 | import org.onosproject.net.behaviour.ExtensionSelectorResolver; |
26 | import org.onosproject.net.driver.DefaultDriverData; | 27 | import org.onosproject.net.driver.DefaultDriverData; |
... | @@ -31,6 +32,7 @@ import org.onosproject.net.flow.criteria.Criteria; | ... | @@ -31,6 +32,7 @@ import org.onosproject.net.flow.criteria.Criteria; |
31 | import org.onosproject.net.flow.criteria.ExtensionCriterion; | 32 | import org.onosproject.net.flow.criteria.ExtensionCriterion; |
32 | import org.onosproject.net.flow.criteria.ExtensionSelector; | 33 | import org.onosproject.net.flow.criteria.ExtensionSelector; |
33 | import org.onosproject.net.flow.criteria.ExtensionSelectorType; | 34 | import org.onosproject.net.flow.criteria.ExtensionSelectorType; |
35 | +import org.onosproject.net.flow.criteria.UnresolvedExtensionSelector; | ||
34 | 36 | ||
35 | /** | 37 | /** |
36 | * Serializer for extension criteria. | 38 | * Serializer for extension criteria. |
... | @@ -56,16 +58,20 @@ public class ExtensionCriterionSerializer extends Serializer<ExtensionCriterion> | ... | @@ -56,16 +58,20 @@ public class ExtensionCriterionSerializer extends Serializer<ExtensionCriterion> |
56 | Class<ExtensionCriterion> type) { | 58 | Class<ExtensionCriterion> type) { |
57 | ExtensionSelectorType exType = (ExtensionSelectorType) kryo.readClassAndObject(input); | 59 | ExtensionSelectorType exType = (ExtensionSelectorType) kryo.readClassAndObject(input); |
58 | DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input); | 60 | DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input); |
59 | - | ||
60 | DriverService driverService = DefaultServiceDirectory.getService(DriverService.class); | 61 | DriverService driverService = DefaultServiceDirectory.getService(DriverService.class); |
61 | - DriverHandler handler = new DefaultDriverHandler( | 62 | + byte[] bytes = (byte[]) kryo.readClassAndObject(input); |
62 | - new DefaultDriverData(driverService.getDriver(deviceId), deviceId)); | 63 | + ExtensionSelector selector; |
63 | 64 | ||
64 | - ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class); | 65 | + try { |
65 | - ExtensionSelector selector = resolver.getExtensionSelector(exType); | 66 | + DriverHandler handler = new DefaultDriverHandler( |
67 | + new DefaultDriverData(driverService.getDriver(deviceId), deviceId)); | ||
68 | + ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class); | ||
69 | + selector = resolver.getExtensionSelector(exType); | ||
70 | + selector.deserialize(bytes); | ||
71 | + } catch (ItemNotFoundException | IllegalArgumentException e) { | ||
72 | + selector = new UnresolvedExtensionSelector(bytes, exType); | ||
73 | + } | ||
66 | 74 | ||
67 | - byte[] bytes = (byte[]) kryo.readClassAndObject(input); | ||
68 | - selector.deserialize(bytes); | ||
69 | return Criteria.extension(selector, deviceId); | 75 | return Criteria.extension(selector, deviceId); |
70 | } | 76 | } |
71 | } | 77 | } | ... | ... |
... | @@ -21,6 +21,7 @@ import com.esotericsoftware.kryo.Serializer; | ... | @@ -21,6 +21,7 @@ import com.esotericsoftware.kryo.Serializer; |
21 | import com.esotericsoftware.kryo.io.Input; | 21 | import com.esotericsoftware.kryo.io.Input; |
22 | import com.esotericsoftware.kryo.io.Output; | 22 | import com.esotericsoftware.kryo.io.Output; |
23 | import org.onlab.osgi.DefaultServiceDirectory; | 23 | import org.onlab.osgi.DefaultServiceDirectory; |
24 | +import org.onlab.util.ItemNotFoundException; | ||
24 | import org.onosproject.net.DeviceId; | 25 | import org.onosproject.net.DeviceId; |
25 | import org.onosproject.net.behaviour.ExtensionTreatmentResolver; | 26 | import org.onosproject.net.behaviour.ExtensionTreatmentResolver; |
26 | import org.onosproject.net.driver.DefaultDriverData; | 27 | import org.onosproject.net.driver.DefaultDriverData; |
... | @@ -30,6 +31,7 @@ import org.onosproject.net.driver.DriverService; | ... | @@ -30,6 +31,7 @@ import org.onosproject.net.driver.DriverService; |
30 | import org.onosproject.net.flow.instructions.ExtensionTreatment; | 31 | import org.onosproject.net.flow.instructions.ExtensionTreatment; |
31 | import org.onosproject.net.flow.instructions.ExtensionTreatmentType; | 32 | import org.onosproject.net.flow.instructions.ExtensionTreatmentType; |
32 | import org.onosproject.net.flow.instructions.Instructions; | 33 | import org.onosproject.net.flow.instructions.Instructions; |
34 | +import org.onosproject.net.flow.instructions.UnresolvedExtensionTreatment; | ||
33 | 35 | ||
34 | /** | 36 | /** |
35 | * Serializer for extension instructions. | 37 | * Serializer for extension instructions. |
... | @@ -56,17 +58,19 @@ public class ExtensionInstructionSerializer extends | ... | @@ -56,17 +58,19 @@ public class ExtensionInstructionSerializer extends |
56 | Class<Instructions.ExtensionInstructionWrapper> type) { | 58 | Class<Instructions.ExtensionInstructionWrapper> type) { |
57 | ExtensionTreatmentType exType = (ExtensionTreatmentType) kryo.readClassAndObject(input); | 59 | ExtensionTreatmentType exType = (ExtensionTreatmentType) kryo.readClassAndObject(input); |
58 | DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input); | 60 | DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input); |
59 | - | ||
60 | DriverService driverService = DefaultServiceDirectory.getService(DriverService.class); | 61 | DriverService driverService = DefaultServiceDirectory.getService(DriverService.class); |
61 | - DriverHandler handler = new DefaultDriverHandler( | ||
62 | - new DefaultDriverData(driverService.getDriver(deviceId), deviceId)); | ||
63 | - | ||
64 | - ExtensionTreatmentResolver resolver = handler.behaviour(ExtensionTreatmentResolver.class); | ||
65 | - ExtensionTreatment instruction = resolver.getExtensionInstruction(exType); | ||
66 | - | ||
67 | byte[] bytes = (byte[]) kryo.readClassAndObject(input); | 62 | byte[] bytes = (byte[]) kryo.readClassAndObject(input); |
63 | + ExtensionTreatment instruction; | ||
68 | 64 | ||
69 | - instruction.deserialize(bytes); | 65 | + try { |
66 | + DriverHandler handler = new DefaultDriverHandler( | ||
67 | + new DefaultDriverData(driverService.getDriver(deviceId), deviceId)); | ||
68 | + ExtensionTreatmentResolver resolver = handler.behaviour(ExtensionTreatmentResolver.class); | ||
69 | + instruction = resolver.getExtensionInstruction(exType); | ||
70 | + instruction.deserialize(bytes); | ||
71 | + } catch (ItemNotFoundException | IllegalArgumentException e) { | ||
72 | + instruction = new UnresolvedExtensionTreatment(bytes, exType); | ||
73 | + } | ||
70 | 74 | ||
71 | return Instructions.extension(instruction, deviceId); | 75 | return Instructions.extension(instruction, deviceId); |
72 | } | 76 | } | ... | ... |
-
Please register or login to post a comment