Committed by
Gerrit Code Review
Support for matching on MPLS BOS indicator bit
Change-Id: I9f8c3f499beff7c70b4c829c2846c71007932d94
Showing
7 changed files
with
128 additions
and
15 deletions
| ... | @@ -294,6 +294,11 @@ public final class DefaultTrafficSelector implements TrafficSelector { | ... | @@ -294,6 +294,11 @@ public final class DefaultTrafficSelector implements TrafficSelector { |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | @Override | 296 | @Override |
| 297 | + public Builder matchMplsBos(boolean mplsBos) { | ||
| 298 | + return add(Criteria.matchMplsLabel(mplsBos)); | ||
| 299 | + } | ||
| 300 | + | ||
| 301 | + @Override | ||
| 297 | public TrafficSelector.Builder matchTunnelId(long tunnelId) { | 302 | public TrafficSelector.Builder matchTunnelId(long tunnelId) { |
| 298 | return add(Criteria.matchTunnelId(tunnelId)); | 303 | return add(Criteria.matchTunnelId(tunnelId)); |
| 299 | } | 304 | } | ... | ... |
| ... | @@ -18,6 +18,7 @@ package org.onosproject.net.flow; | ... | @@ -18,6 +18,7 @@ package org.onosproject.net.flow; |
| 18 | import java.util.Set; | 18 | import java.util.Set; |
| 19 | 19 | ||
| 20 | import org.onosproject.net.PortNumber; | 20 | import org.onosproject.net.PortNumber; |
| 21 | +import org.onosproject.net.flow.DefaultTrafficSelector.Builder; | ||
| 21 | import org.onosproject.net.flow.criteria.Criterion; | 22 | import org.onosproject.net.flow.criteria.Criterion; |
| 22 | import org.onlab.packet.IpPrefix; | 23 | import org.onlab.packet.IpPrefix; |
| 23 | import org.onlab.packet.Ip6Address; | 24 | import org.onlab.packet.Ip6Address; |
| ... | @@ -301,6 +302,14 @@ public interface TrafficSelector { | ... | @@ -301,6 +302,14 @@ public interface TrafficSelector { |
| 301 | Builder matchMplsLabel(MplsLabel mplsLabel); | 302 | Builder matchMplsLabel(MplsLabel mplsLabel); |
| 302 | 303 | ||
| 303 | /** | 304 | /** |
| 305 | + * Matches on a MPLS Bottom-of-Stack indicator bit. | ||
| 306 | + * | ||
| 307 | + * @param mplsBos boolean value indicating BOS=1 (true) or BOS=0 (false). | ||
| 308 | + * @return a selection builder | ||
| 309 | + */ | ||
| 310 | + Builder matchMplsBos(boolean mplsBos); | ||
| 311 | + | ||
| 312 | + /** | ||
| 304 | * Matches a tunnel id. | 313 | * Matches a tunnel id. |
| 305 | * | 314 | * |
| 306 | * @param tunnelId a tunnel id | 315 | * @param tunnelId a tunnel id | ... | ... |
| ... | @@ -356,6 +356,16 @@ public final class Criteria { | ... | @@ -356,6 +356,16 @@ public final class Criteria { |
| 356 | } | 356 | } |
| 357 | 357 | ||
| 358 | /** | 358 | /** |
| 359 | + * Creates a match on MPLS Bottom-of-Stack indicator bit. | ||
| 360 | + * | ||
| 361 | + * @param mplsBos boolean value indicating true (BOS=1) or false (BOS=0) | ||
| 362 | + * @return match criterion | ||
| 363 | + */ | ||
| 364 | + public static Criterion matchMplsLabel(boolean mplsBos) { | ||
| 365 | + return new MplsBosCriterion(mplsBos); | ||
| 366 | + } | ||
| 367 | + | ||
| 368 | + /** | ||
| 359 | * Creates a match on Tunnel ID. | 369 | * Creates a match on Tunnel ID. |
| 360 | * | 370 | * |
| 361 | * @param tunnelId Tunnel ID (64 bits) | 371 | * @param tunnelId Tunnel ID (64 bits) | ... | ... |
| 1 | +package org.onosproject.net.flow.criteria; | ||
| 2 | + | ||
| 3 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
| 4 | +import java.util.Objects; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * Implementation of MPLS BOS criterion (1 bit). | ||
| 8 | + */ | ||
| 9 | +public class MplsBosCriterion implements Criterion { | ||
| 10 | + private boolean mplsBos; | ||
| 11 | + | ||
| 12 | + MplsBosCriterion(boolean mplsBos) { | ||
| 13 | + this.mplsBos = mplsBos; | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + @Override | ||
| 17 | + public Type type() { | ||
| 18 | + return Type.MPLS_BOS; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public boolean mplsBos() { | ||
| 22 | + return mplsBos; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + @Override | ||
| 26 | + public String toString() { | ||
| 27 | + return toStringHelper(type().toString()) | ||
| 28 | + .add("bos", mplsBos).toString(); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + @Override | ||
| 32 | + public int hashCode() { | ||
| 33 | + return Objects.hash(type().ordinal(), mplsBos); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + @Override | ||
| 37 | + public boolean equals(Object obj) { | ||
| 38 | + if (this == obj) { | ||
| 39 | + return true; | ||
| 40 | + } | ||
| 41 | + if (obj instanceof MplsBosCriterion) { | ||
| 42 | + MplsBosCriterion that = (MplsBosCriterion) obj; | ||
| 43 | + return Objects.equals(mplsBos, that.mplsBos()) && | ||
| 44 | + Objects.equals(this.type(), that.type()); | ||
| 45 | + } | ||
| 46 | + return false; | ||
| 47 | + } | ||
| 48 | +} |
| ... | @@ -31,6 +31,7 @@ import java.util.stream.Collectors; | ... | @@ -31,6 +31,7 @@ import java.util.stream.Collectors; |
| 31 | 31 | ||
| 32 | import org.onlab.osgi.ServiceDirectory; | 32 | import org.onlab.osgi.ServiceDirectory; |
| 33 | import org.onlab.packet.Ethernet; | 33 | import org.onlab.packet.Ethernet; |
| 34 | +import org.onlab.packet.MplsLabel; | ||
| 34 | import org.onlab.packet.VlanId; | 35 | import org.onlab.packet.VlanId; |
| 35 | import org.onlab.util.KryoNamespace; | 36 | import org.onlab.util.KryoNamespace; |
| 36 | import org.onosproject.core.ApplicationId; | 37 | import org.onosproject.core.ApplicationId; |
| ... | @@ -618,6 +619,36 @@ public class OFDPA1Pipeline extends AbstractHandlerBehaviour implements Pipeline | ... | @@ -618,6 +619,36 @@ public class OFDPA1Pipeline extends AbstractHandlerBehaviour implements Pipeline |
| 618 | //processBridgingTable(); | 619 | //processBridgingTable(); |
| 619 | //processAclTable(); | 620 | //processAclTable(); |
| 620 | //processGroupTable(); | 621 | //processGroupTable(); |
| 622 | + //processMplsTable(); | ||
| 623 | + } | ||
| 624 | + | ||
| 625 | + protected void processMplsTable() { | ||
| 626 | + FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); | ||
| 627 | + TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | ||
| 628 | + selector.matchEthType(Ethernet.MPLS_UNICAST); | ||
| 629 | + selector.matchMplsLabel(MplsLabel.mplsLabel(0xff)); | ||
| 630 | + selector.matchMplsBos(true); | ||
| 631 | + TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); | ||
| 632 | + treatment.popMpls(Ethernet.TYPE_IPV4); | ||
| 633 | + treatment.transition(ACL_TABLE); | ||
| 634 | + FlowRule test = DefaultFlowRule.builder().forDevice(deviceId) | ||
| 635 | + .withSelector(selector.build()).withTreatment(treatment.build()) | ||
| 636 | + .withPriority(LOWEST_PRIORITY).fromApp(driverId).makePermanent() | ||
| 637 | + .forTable(25).build(); | ||
| 638 | + ops = ops.add(test); | ||
| 639 | + | ||
| 640 | + flowRuleService.apply(ops.build(new FlowRuleOperationsContext() { | ||
| 641 | + @Override | ||
| 642 | + public void onSuccess(FlowRuleOperations ops) { | ||
| 643 | + log.info("Initialized mpls table"); | ||
| 644 | + } | ||
| 645 | + | ||
| 646 | + @Override | ||
| 647 | + public void onError(FlowRuleOperations ops) { | ||
| 648 | + log.info("Failed to initialize mpls table"); | ||
| 649 | + } | ||
| 650 | + })); | ||
| 651 | + | ||
| 621 | } | 652 | } |
| 622 | 653 | ||
| 623 | protected void processPortTable() { | 654 | protected void processPortTable() { | ... | ... |
| ... | @@ -15,7 +15,14 @@ | ... | @@ -15,7 +15,14 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.provider.of.flow.impl; | 16 | package org.onosproject.provider.of.flow.impl; |
| 17 | 17 | ||
| 18 | -import com.google.common.collect.Lists; | 18 | +import static org.onosproject.net.flow.criteria.Criteria.matchLambda; |
| 19 | +import static org.onosproject.net.flow.criteria.Criteria.matchOchSignalType; | ||
| 20 | +import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupChannelSpacing; | ||
| 21 | +import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupGridType; | ||
| 22 | +import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupOchSignalType; | ||
| 23 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 24 | + | ||
| 25 | +import java.util.List; | ||
| 19 | 26 | ||
| 20 | import org.onlab.packet.Ip4Address; | 27 | import org.onlab.packet.Ip4Address; |
| 21 | import org.onlab.packet.Ip4Prefix; | 28 | import org.onlab.packet.Ip4Prefix; |
| ... | @@ -78,14 +85,7 @@ import org.projectfloodlight.openflow.types.U8; | ... | @@ -78,14 +85,7 @@ import org.projectfloodlight.openflow.types.U8; |
| 78 | import org.projectfloodlight.openflow.types.VlanPcp; | 85 | import org.projectfloodlight.openflow.types.VlanPcp; |
| 79 | import org.slf4j.Logger; | 86 | import org.slf4j.Logger; |
| 80 | 87 | ||
| 81 | -import java.util.List; | 88 | +import com.google.common.collect.Lists; |
| 82 | - | ||
| 83 | -import static org.onosproject.net.flow.criteria.Criteria.matchLambda; | ||
| 84 | -import static org.onosproject.net.flow.criteria.Criteria.matchOchSignalType; | ||
| 85 | -import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupChannelSpacing; | ||
| 86 | -import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupGridType; | ||
| 87 | -import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupOchSignalType; | ||
| 88 | -import static org.slf4j.LoggerFactory.getLogger; | ||
| 89 | 89 | ||
| 90 | public class FlowEntryBuilder { | 90 | public class FlowEntryBuilder { |
| 91 | private final Logger log = getLogger(getClass()); | 91 | private final Logger log = getLogger(getClass()); |
| ... | @@ -598,6 +598,9 @@ public class FlowEntryBuilder { | ... | @@ -598,6 +598,9 @@ public class FlowEntryBuilder { |
| 598 | builder.matchMplsLabel(MplsLabel.mplsLabel((int) match.get(MatchField.MPLS_LABEL) | 598 | builder.matchMplsLabel(MplsLabel.mplsLabel((int) match.get(MatchField.MPLS_LABEL) |
| 599 | .getValue())); | 599 | .getValue())); |
| 600 | break; | 600 | break; |
| 601 | + case MPLS_BOS: | ||
| 602 | + builder.matchMplsBos(match.get(MatchField.MPLS_BOS).getValue()); | ||
| 603 | + break; | ||
| 601 | case SCTP_SRC: | 604 | case SCTP_SRC: |
| 602 | builder.matchSctpSrc((short) match.get(MatchField.SCTP_SRC).getPort()); | 605 | builder.matchSctpSrc((short) match.get(MatchField.SCTP_SRC).getPort()); |
| 603 | break; | 606 | break; | ... | ... |
| ... | @@ -15,6 +15,10 @@ | ... | @@ -15,6 +15,10 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.provider.of.flow.impl; | 16 | package org.onosproject.provider.of.flow.impl; |
| 17 | 17 | ||
| 18 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 19 | + | ||
| 20 | +import java.util.Optional; | ||
| 21 | + | ||
| 18 | import org.onlab.packet.Ip4Address; | 22 | import org.onlab.packet.Ip4Address; |
| 19 | import org.onlab.packet.Ip4Prefix; | 23 | import org.onlab.packet.Ip4Prefix; |
| 20 | import org.onlab.packet.Ip6Address; | 24 | import org.onlab.packet.Ip6Address; |
| ... | @@ -23,6 +27,7 @@ import org.onlab.packet.VlanId; | ... | @@ -23,6 +27,7 @@ import org.onlab.packet.VlanId; |
| 23 | import org.onosproject.net.OchSignal; | 27 | import org.onosproject.net.OchSignal; |
| 24 | import org.onosproject.net.flow.FlowRule; | 28 | import org.onosproject.net.flow.FlowRule; |
| 25 | import org.onosproject.net.flow.TrafficSelector; | 29 | import org.onosproject.net.flow.TrafficSelector; |
| 30 | +import org.onosproject.net.flow.criteria.Criterion; | ||
| 26 | import org.onosproject.net.flow.criteria.EthCriterion; | 31 | import org.onosproject.net.flow.criteria.EthCriterion; |
| 27 | import org.onosproject.net.flow.criteria.EthTypeCriterion; | 32 | import org.onosproject.net.flow.criteria.EthTypeCriterion; |
| 28 | import org.onosproject.net.flow.criteria.IPCriterion; | 33 | import org.onosproject.net.flow.criteria.IPCriterion; |
| ... | @@ -38,6 +43,7 @@ import org.onosproject.net.flow.criteria.IcmpTypeCriterion; | ... | @@ -38,6 +43,7 @@ import org.onosproject.net.flow.criteria.IcmpTypeCriterion; |
| 38 | import org.onosproject.net.flow.criteria.Icmpv6CodeCriterion; | 43 | import org.onosproject.net.flow.criteria.Icmpv6CodeCriterion; |
| 39 | import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion; | 44 | import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion; |
| 40 | import org.onosproject.net.flow.criteria.MetadataCriterion; | 45 | import org.onosproject.net.flow.criteria.MetadataCriterion; |
| 46 | +import org.onosproject.net.flow.criteria.MplsBosCriterion; | ||
| 41 | import org.onosproject.net.flow.criteria.MplsCriterion; | 47 | import org.onosproject.net.flow.criteria.MplsCriterion; |
| 42 | import org.onosproject.net.flow.criteria.OchSignalCriterion; | 48 | import org.onosproject.net.flow.criteria.OchSignalCriterion; |
| 43 | import org.onosproject.net.flow.criteria.OchSignalTypeCriterion; | 49 | import org.onosproject.net.flow.criteria.OchSignalTypeCriterion; |
| ... | @@ -48,7 +54,6 @@ import org.onosproject.net.flow.criteria.TunnelIdCriterion; | ... | @@ -48,7 +54,6 @@ import org.onosproject.net.flow.criteria.TunnelIdCriterion; |
| 48 | import org.onosproject.net.flow.criteria.UdpPortCriterion; | 54 | import org.onosproject.net.flow.criteria.UdpPortCriterion; |
| 49 | import org.onosproject.net.flow.criteria.VlanIdCriterion; | 55 | import org.onosproject.net.flow.criteria.VlanIdCriterion; |
| 50 | import org.onosproject.net.flow.criteria.VlanPcpCriterion; | 56 | import org.onosproject.net.flow.criteria.VlanPcpCriterion; |
| 51 | -import org.onosproject.net.flow.criteria.Criterion; | ||
| 52 | import org.projectfloodlight.openflow.protocol.OFFactory; | 57 | import org.projectfloodlight.openflow.protocol.OFFactory; |
| 53 | import org.projectfloodlight.openflow.protocol.OFFlowAdd; | 58 | import org.projectfloodlight.openflow.protocol.OFFlowAdd; |
| 54 | import org.projectfloodlight.openflow.protocol.OFFlowDelete; | 59 | import org.projectfloodlight.openflow.protocol.OFFlowDelete; |
| ... | @@ -67,6 +72,7 @@ import org.projectfloodlight.openflow.types.IpEcn; | ... | @@ -67,6 +72,7 @@ import org.projectfloodlight.openflow.types.IpEcn; |
| 67 | import org.projectfloodlight.openflow.types.IpProtocol; | 72 | import org.projectfloodlight.openflow.types.IpProtocol; |
| 68 | import org.projectfloodlight.openflow.types.MacAddress; | 73 | import org.projectfloodlight.openflow.types.MacAddress; |
| 69 | import org.projectfloodlight.openflow.types.Masked; | 74 | import org.projectfloodlight.openflow.types.Masked; |
| 75 | +import org.projectfloodlight.openflow.types.OFBooleanValue; | ||
| 70 | import org.projectfloodlight.openflow.types.OFMetadata; | 76 | import org.projectfloodlight.openflow.types.OFMetadata; |
| 71 | import org.projectfloodlight.openflow.types.OFPort; | 77 | import org.projectfloodlight.openflow.types.OFPort; |
| 72 | import org.projectfloodlight.openflow.types.OFVlanVidMatch; | 78 | import org.projectfloodlight.openflow.types.OFVlanVidMatch; |
| ... | @@ -79,10 +85,6 @@ import org.projectfloodlight.openflow.types.VlanPcp; | ... | @@ -79,10 +85,6 @@ import org.projectfloodlight.openflow.types.VlanPcp; |
| 79 | import org.projectfloodlight.openflow.types.VlanVid; | 85 | import org.projectfloodlight.openflow.types.VlanVid; |
| 80 | import org.slf4j.Logger; | 86 | import org.slf4j.Logger; |
| 81 | 87 | ||
| 82 | -import java.util.Optional; | ||
| 83 | - | ||
| 84 | -import static org.slf4j.LoggerFactory.getLogger; | ||
| 85 | - | ||
| 86 | /** | 88 | /** |
| 87 | * Builder for OpenFlow flow mods based on FlowRules. | 89 | * Builder for OpenFlow flow mods based on FlowRules. |
| 88 | */ | 90 | */ |
| ... | @@ -401,12 +403,17 @@ public abstract class FlowModBuilder { | ... | @@ -401,12 +403,17 @@ public abstract class FlowModBuilder { |
| 401 | mBuilder.setExact(MatchField.TUNNEL_ID, | 403 | mBuilder.setExact(MatchField.TUNNEL_ID, |
| 402 | U64.of(tunnelId.tunnelId())); | 404 | U64.of(tunnelId.tunnelId())); |
| 403 | break; | 405 | break; |
| 406 | + case MPLS_BOS: | ||
| 407 | + MplsBosCriterion mplsBos = (MplsBosCriterion) c; | ||
| 408 | + mBuilder.setExact(MatchField.MPLS_BOS, | ||
| 409 | + mplsBos.mplsBos() ? OFBooleanValue.TRUE | ||
| 410 | + : OFBooleanValue.FALSE); | ||
| 411 | + break; | ||
| 404 | case ARP_OP: | 412 | case ARP_OP: |
| 405 | case ARP_SHA: | 413 | case ARP_SHA: |
| 406 | case ARP_SPA: | 414 | case ARP_SPA: |
| 407 | case ARP_THA: | 415 | case ARP_THA: |
| 408 | case ARP_TPA: | 416 | case ARP_TPA: |
| 409 | - case MPLS_BOS: | ||
| 410 | case MPLS_TC: | 417 | case MPLS_TC: |
| 411 | case PBB_ISID: | 418 | case PBB_ISID: |
| 412 | default: | 419 | default: | ... | ... |
-
Please register or login to post a comment