Committed by
Gerrit Code Review
ONOS-1882: fix wrong MPLS label assignment
Change-Id: I469765722b7e2b45551c52427422fbe920bbbb54
Showing
1 changed file
with
15 additions
and
11 deletions
... | @@ -22,6 +22,7 @@ import org.apache.felix.scr.annotations.Component; | ... | @@ -22,6 +22,7 @@ import org.apache.felix.scr.annotations.Component; |
22 | import org.apache.felix.scr.annotations.Deactivate; | 22 | import org.apache.felix.scr.annotations.Deactivate; |
23 | import org.apache.felix.scr.annotations.Reference; | 23 | import org.apache.felix.scr.annotations.Reference; |
24 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 24 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
25 | +import org.onlab.packet.EthType; | ||
25 | import org.onlab.packet.Ethernet; | 26 | import org.onlab.packet.Ethernet; |
26 | import org.onlab.packet.VlanId; | 27 | import org.onlab.packet.VlanId; |
27 | import org.onosproject.core.ApplicationId; | 28 | import org.onosproject.core.ApplicationId; |
... | @@ -217,7 +218,7 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { | ... | @@ -217,7 +218,7 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { |
217 | 218 | ||
218 | // Set the new label only if the label on the packet is | 219 | // Set the new label only if the label on the packet is |
219 | // different | 220 | // different |
220 | - if (prevLabel.equals(outLabel)) { | 221 | + if (!prevLabel.equals(outLabel)) { |
221 | treat.setMpls(outLabel.label()); | 222 | treat.setMpls(outLabel.label()); |
222 | } | 223 | } |
223 | 224 | ||
... | @@ -257,16 +258,7 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { | ... | @@ -257,16 +258,7 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { |
257 | if (intent.egressLabel().isPresent()) { | 258 | if (intent.egressLabel().isPresent()) { |
258 | treat.setMpls(intent.egressLabel().get()); | 259 | treat.setMpls(intent.egressLabel().get()); |
259 | } else { | 260 | } else { |
260 | - // if the ingress ethertype is defined, the egress traffic | 261 | + treat.popMpls(outputEthType(intent.selector())); |
261 | - // will be use that value, otherwise the IPv4 ethertype is used. | ||
262 | - Criterion c = intent.selector().getCriterion(Criterion.Type.ETH_TYPE); | ||
263 | - if (c != null && c instanceof EthTypeCriterion) { | ||
264 | - EthTypeCriterion ethertype = (EthTypeCriterion) c; | ||
265 | - treat.popMpls(ethertype.ethType().toShort()); | ||
266 | - } else { | ||
267 | - treat.popMpls(Ethernet.TYPE_IPV4); | ||
268 | - } | ||
269 | - | ||
270 | } | 262 | } |
271 | treat.setOutput(link.src().port()); | 263 | treat.setOutput(link.src().port()); |
272 | return createFlowRule(intent, link.src().deviceId(), | 264 | return createFlowRule(intent, link.src().deviceId(), |
... | @@ -284,4 +276,16 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { | ... | @@ -284,4 +276,16 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { |
284 | .makePermanent() | 276 | .makePermanent() |
285 | .build(); | 277 | .build(); |
286 | } | 278 | } |
279 | + | ||
280 | + // if the ingress ethertype is defined, the egress traffic | ||
281 | + // will be use that value, otherwise the IPv4 ethertype is used. | ||
282 | + private EthType outputEthType(TrafficSelector selector) { | ||
283 | + Criterion c = selector.getCriterion(Criterion.Type.ETH_TYPE); | ||
284 | + if (c != null && c instanceof EthTypeCriterion) { | ||
285 | + EthTypeCriterion ethertype = (EthTypeCriterion) c; | ||
286 | + return ethertype.ethType(); | ||
287 | + } else { | ||
288 | + return EthType.EtherType.IPV4.ethType(); | ||
289 | + } | ||
290 | + } | ||
287 | } | 291 | } | ... | ... |
-
Please register or login to post a comment