Search in sources :

Example 1 with Ofdpa3MatchOvid

use of org.onosproject.driver.extensions.Ofdpa3MatchOvid in project onos by opennetworkinglab.

the class Ofdpa3Pipeline method processPwFilter.

/**
 * Method to process the pw related filtering objectives.
 *
 * @param portCriterion the in port match
 * @param innerVlanIdCriterion the inner vlan match
 * @param outerVlanIdCriterion the outer vlan match
 * @param tunnelId the tunnel id
 * @param applicationId the application id
 * @param egressVlan the vlan to modify, was passed in metadata
 * @return a list of flow rules to install
 */
private List<FlowRule> processPwFilter(PortCriterion portCriterion, VlanIdCriterion innerVlanIdCriterion, VlanIdCriterion outerVlanIdCriterion, long tunnelId, ApplicationId applicationId, VlanId egressVlan) {
    FlowRule vlan1FlowRule;
    int mplsLogicalPort = ((int) portCriterion.port().toLong());
    // We have to match on the inner vlan and outer vlan at the same time.
    // Ofdpa supports this through the OVID meta-data type.
    ImmutableList<FlowRule> toReturn;
    // pseudowire configured with double tagged vlans
    if (!(innerVlanIdCriterion.vlanId().equals(VlanId.NONE)) && !(outerVlanIdCriterion.vlanId().equals(VlanId.NONE))) {
        log.info("Installing filter objective for double tagged CE for tunnel {}", tunnelId);
        TrafficSelector.Builder vlan1Selector = DefaultTrafficSelector.builder().matchInPort(portCriterion.port()).matchVlanId(innerVlanIdCriterion.vlanId()).extension(new Ofdpa3MatchOvid(outerVlanIdCriterion.vlanId()), deviceId);
        // TODO understand for the future how to manage the vlan rewrite.
        TrafficTreatment.Builder vlan1Treatment = DefaultTrafficTreatment.builder().pushVlan().setVlanId(egressVlan).extension(new Ofdpa3SetMplsType(VPWS), deviceId).extension(new Ofdpa3SetMplsL2Port(mplsLogicalPort), deviceId).setTunnelId(tunnelId).transition(MPLS_L2_PORT_FLOW_TABLE);
        vlan1FlowRule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(vlan1Selector.build()).withTreatment(vlan1Treatment.build()).withPriority(DEFAULT_PRIORITY).fromApp(applicationId).makePermanent().forTable(VLAN_1_TABLE).build();
        // Finally we create the flow rule for the vlan table.
        FlowRule vlanFlowRule;
        // We have to match on the outer vlan.
        TrafficSelector.Builder vlanSelector = DefaultTrafficSelector.builder().matchInPort(portCriterion.port()).matchVlanId(outerVlanIdCriterion.vlanId());
        // TODO understand for the future how to manage the vlan rewrite.
        TrafficTreatment.Builder vlanTreatment = DefaultTrafficTreatment.builder().popVlan().extension(new Ofdpa3SetOvid(outerVlanIdCriterion.vlanId()), deviceId).transition(VLAN_1_TABLE);
        vlanFlowRule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(vlanSelector.build()).withTreatment(vlanTreatment.build()).withPriority(DEFAULT_PRIORITY).fromApp(applicationId).makePermanent().forTable(VLAN_TABLE).build();
        return ImmutableList.of(vlan1FlowRule, vlanFlowRule);
    } else if (!(innerVlanIdCriterion.vlanId().equals(VlanId.NONE)) && (outerVlanIdCriterion.vlanId().equals(VlanId.NONE))) {
        log.info("Installing filter objective for single tagged CE for tunnel {}", tunnelId);
        TrafficSelector.Builder singleVlanSelector = DefaultTrafficSelector.builder().matchInPort(portCriterion.port()).matchVlanId(innerVlanIdCriterion.vlanId());
        TrafficTreatment.Builder singleVlanTreatment = DefaultTrafficTreatment.builder().extension(new Ofdpa3SetMplsType(VPWS), deviceId).extension(new Ofdpa3SetMplsL2Port(mplsLogicalPort), deviceId).setTunnelId(tunnelId).transition(MPLS_L2_PORT_FLOW_TABLE);
        vlan1FlowRule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(singleVlanSelector.build()).withTreatment(singleVlanTreatment.build()).withPriority(DEFAULT_PRIORITY).fromApp(applicationId).makePermanent().forTable(VLAN_TABLE).build();
        return ImmutableList.of(vlan1FlowRule);
    } else if ((innerVlanIdCriterion.vlanId().equals(VlanId.NONE)) && (outerVlanIdCriterion.vlanId().equals(VlanId.NONE))) {
        TrafficSelector.Builder singleVlanSelector = DefaultTrafficSelector.builder().matchInPort(portCriterion.port()).matchVlanId(innerVlanIdCriterion.vlanId());
        TrafficTreatment.Builder singleVlanTreatment = DefaultTrafficTreatment.builder().extension(new Ofdpa3SetMplsType(VPWS), deviceId).extension(new Ofdpa3SetMplsL2Port(mplsLogicalPort), deviceId).setTunnelId(tunnelId).transition(MPLS_L2_PORT_FLOW_TABLE);
        vlan1FlowRule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(singleVlanSelector.build()).withTreatment(singleVlanTreatment.build()).withPriority(DEFAULT_PRIORITY).fromApp(applicationId).makePermanent().forTable(VLAN_TABLE).build();
        return ImmutableList.of(vlan1FlowRule);
    } else {
        // failure...
        return Collections.emptyList();
    }
}
Also used : Ofdpa3SetMplsL2Port(org.onosproject.driver.extensions.Ofdpa3SetMplsL2Port) Ofdpa3SetOvid(org.onosproject.driver.extensions.Ofdpa3SetOvid) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Ofdpa3SetMplsType(org.onosproject.driver.extensions.Ofdpa3SetMplsType) Ofdpa3MatchOvid(org.onosproject.driver.extensions.Ofdpa3MatchOvid)

Example 2 with Ofdpa3MatchOvid

use of org.onosproject.driver.extensions.Ofdpa3MatchOvid in project onos by opennetworkinglab.

the class Ofdpa3Pipeline method processDoubleVlanIdFilter.

/**
 * Internal implementation of processDoubleVlanIdFilter.
 *
 * @param portCriterion       port on device for which this filter is programmed
 * @param innerVidCriterion   inner vlan
 * @param outerVidCriterion   outer vlan
 * @param popVlan             true if outer vlan header needs to be removed
 * @param applicationId       for application programming this filter
 * @return flow rules for port-vlan filters
 */
private List<FlowRule> processDoubleVlanIdFilter(PortCriterion portCriterion, VlanIdCriterion innerVidCriterion, VlanIdCriterion outerVidCriterion, boolean popVlan, ApplicationId applicationId) {
    TrafficSelector.Builder outerSelector = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder outerTreatment = DefaultTrafficTreatment.builder();
    TrafficSelector.Builder innerSelector = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder innerTreatment = DefaultTrafficTreatment.builder();
    VlanId outerVlanId = outerVidCriterion.vlanId();
    VlanId innerVlanId = innerVidCriterion.vlanId();
    PortNumber portNumber = portCriterion.port();
    // Check arguments
    if (PortNumber.ALL.equals(portNumber) || outerVlanId.equals(VlanId.NONE) || innerVlanId.equals(VlanId.NONE)) {
        log.warn("Incomplete Filtering Objective. " + "VLAN Table cannot be programmed for {}", deviceId);
        return ImmutableList.of();
    } else {
        outerSelector.matchInPort(portNumber);
        innerSelector.matchInPort(portNumber);
        outerTreatment.transition(VLAN_1_TABLE);
        innerTreatment.transition(TMAC_TABLE);
        if (requireVlanExtensions()) {
            OfdpaMatchVlanVid ofdpaOuterMatchVlanVid = new OfdpaMatchVlanVid(outerVlanId);
            outerSelector.extension(ofdpaOuterMatchVlanVid, deviceId);
            OfdpaMatchVlanVid ofdpaInnerMatchVlanVid = new OfdpaMatchVlanVid(innerVlanId);
            innerSelector.extension(ofdpaInnerMatchVlanVid, deviceId);
        } else {
            outerSelector.matchVlanId(outerVlanId);
            innerSelector.matchVlanId(innerVlanId);
        }
        innerSelector.extension(new Ofdpa3MatchOvid(outerVlanId), deviceId);
        outerTreatment.extension(new Ofdpa3SetOvid(outerVlanId), deviceId);
        if (popVlan) {
            outerTreatment.popVlan();
        }
    }
    FlowRule outerRule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(outerSelector.build()).withTreatment(outerTreatment.build()).withPriority(DEFAULT_PRIORITY).fromApp(applicationId).makePermanent().forTable(VLAN_TABLE).build();
    FlowRule innerRule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(innerSelector.build()).withTreatment(innerTreatment.build()).withPriority(DEFAULT_PRIORITY).fromApp(applicationId).makePermanent().forTable(VLAN_1_TABLE).build();
    return ImmutableList.of(outerRule, innerRule);
}
Also used : Ofdpa3SetOvid(org.onosproject.driver.extensions.Ofdpa3SetOvid) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PortNumber(org.onosproject.net.PortNumber) VlanId(org.onlab.packet.VlanId) OfdpaMatchVlanVid(org.onosproject.driver.extensions.OfdpaMatchVlanVid) Ofdpa3MatchOvid(org.onosproject.driver.extensions.Ofdpa3MatchOvid)

Aggregations

Ofdpa3MatchOvid (org.onosproject.driver.extensions.Ofdpa3MatchOvid)2 Ofdpa3SetOvid (org.onosproject.driver.extensions.Ofdpa3SetOvid)2 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)2 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)2 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)2 FlowRule (org.onosproject.net.flow.FlowRule)2 TrafficSelector (org.onosproject.net.flow.TrafficSelector)2 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)2 VlanId (org.onlab.packet.VlanId)1 Ofdpa3SetMplsL2Port (org.onosproject.driver.extensions.Ofdpa3SetMplsL2Port)1 Ofdpa3SetMplsType (org.onosproject.driver.extensions.Ofdpa3SetMplsType)1 OfdpaMatchVlanVid (org.onosproject.driver.extensions.OfdpaMatchVlanVid)1 PortNumber (org.onosproject.net.PortNumber)1