Search in sources :

Example 36 with TrafficTreatment

use of org.onosproject.net.flow.TrafficTreatment in project onos by opennetworkinglab.

the class OFAgentVirtualGroupBucketEntryBuilder method build.

/**
 * Builds a GroupBuckets.
 *
 * @return GroupBuckets object, a list of GroupBuckets
 */
public GroupBuckets build() {
    List<GroupBucket> bucketList = Lists.newArrayList();
    for (OFBucket bucket : ofBuckets) {
        TrafficTreatment treatment = buildTreatment(bucket.getActions());
        // TODO: Use GroupBucketEntry
        GroupBucket groupBucket = null;
        switch(type) {
            case INDIRECT:
                groupBucket = DefaultGroupBucket.createIndirectGroupBucket(treatment);
                break;
            case SELECT:
                groupBucket = DefaultGroupBucket.createSelectGroupBucket(treatment, (short) bucket.getWeight());
                break;
            case FF:
                PortNumber port = PortNumber.portNumber(bucket.getWatchPort().getPortNumber());
                GroupId groupId = new GroupId(bucket.getWatchGroup().getGroupNumber());
                groupBucket = DefaultGroupBucket.createFailoverGroupBucket(treatment, port, groupId);
                break;
            case ALL:
                groupBucket = DefaultGroupBucket.createAllGroupBucket(treatment);
                break;
            default:
                log.error("Unsupported Group type : {}", type);
        }
        if (groupBucket != null) {
            bucketList.add(groupBucket);
        }
    }
    return new GroupBuckets(bucketList);
}
Also used : OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) PortNumber(org.onosproject.net.PortNumber) GroupBuckets(org.onosproject.net.group.GroupBuckets) GroupId(org.onosproject.core.GroupId)

Example 37 with TrafficTreatment

use of org.onosproject.net.flow.TrafficTreatment in project onos by opennetworkinglab.

the class OFAgentVirtualGroupBucketEntryBuilder method buildTreatment.

private TrafficTreatment buildTreatment(List<OFAction> actions) {
    DriverHandler driverHandler = getDriver(dpid);
    TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
    // If this is a drop rule
    if (actions.isEmpty()) {
        builder.drop();
        return builder.build();
    }
    return FlowEntryBuilder.configureTreatmentBuilder(actions, builder, driverHandler, DeviceId.deviceId(Dpid.uri(dpid))).build();
}
Also used : DriverHandler(org.onosproject.net.driver.DriverHandler) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment)

Example 38 with TrafficTreatment

use of org.onosproject.net.flow.TrafficTreatment in project onos by opennetworkinglab.

the class ControlPlaneRedirectManagerTest method setUpInterfaceConfiguration.

/**
 * Setting up flowobjective expectations for basic forwarding and ospf.
 */
private void setUpInterfaceConfiguration(Interface intf, boolean install) {
    DeviceId deviceId = controlPlaneConnectPoint.deviceId();
    PortNumber controlPlanePort = controlPlaneConnectPoint.port();
    for (InterfaceIpAddress ip : intf.ipAddressesList()) {
        int cpNextId, intfNextId;
        cpNextId = modifyNextObjective(deviceId, controlPlanePort, VlanId.vlanId(ControlPlaneRedirectManager.ASSIGNED_VLAN), true, install);
        intfNextId = modifyNextObjective(deviceId, intf.connectPoint().port(), VlanId.vlanId(ControlPlaneRedirectManager.ASSIGNED_VLAN), true, install);
        // IP to router
        TrafficSelector toSelector = buildIPDstSelector(ip.ipAddress().toIpPrefix(), intf.connectPoint().port(), null, intf.mac(), intf.vlan());
        flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, null, cpNextId, install, ACL_PRIORITY));
        expectLastCall().once();
        // IP from router
        TrafficSelector fromSelector = buildIPSrcSelector(ip.ipAddress().toIpPrefix(), controlPlanePort, intf.mac(), null, intf.vlan());
        flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, null, intfNextId, install, ACL_PRIORITY));
        expectLastCall().once();
        TrafficTreatment puntTreatment = DefaultTrafficTreatment.builder().punt().build();
        if (ip.ipAddress().isIp4()) {
            // ARP to router
            toSelector = buildArpSelector(intf.connectPoint().port(), intf.vlan(), null, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // ARP from router
            fromSelector = buildArpSelector(controlPlanePort, intf.vlan(), ip.ipAddress().getIp4Address(), intf.mac());
            flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, puntTreatment, intfNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
        } else {
            // NDP solicitation to router
            // Global unicast address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, ip.ipAddress().toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP solicitation to router
            // Link local address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP solicitation to router
            // solicitated global unicast address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getSolicitNodeAddress(ip.ipAddress().toOctets())).toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP solicitation to router
            // solicitated link local address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getSolicitNodeAddress(getLinkLocalAddress(intf.mac().toBytes()))).toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP solicitation from router
            // Global unicast address
            fromSelector = buildNdpSelector(controlPlanePort, intf.vlan(), ip.ipAddress().toIpPrefix(), null, NEIGHBOR_SOLICITATION, intf.mac());
            flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, puntTreatment, intfNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP solicitation from router
            // Link local address
            fromSelector = buildNdpSelector(controlPlanePort, intf.vlan(), Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), null, NEIGHBOR_SOLICITATION, intf.mac());
            flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, puntTreatment, intfNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP advertisement to router
            // Global unicast address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, ip.ipAddress().toIpPrefix(), NEIGHBOR_ADVERTISEMENT, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP advertisement to router
            // Link local address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), NEIGHBOR_ADVERTISEMENT, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP advertisement from the router
            // Global unicast address
            fromSelector = buildNdpSelector(controlPlanePort, intf.vlan(), ip.ipAddress().toIpPrefix(), null, NEIGHBOR_ADVERTISEMENT, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, puntTreatment, intfNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP advertisement from router
            // Link local address
            fromSelector = buildNdpSelector(controlPlanePort, intf.vlan(), Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), null, NEIGHBOR_ADVERTISEMENT, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, puntTreatment, intfNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
        }
    }
    // setting expectations for ospf forwarding.
    TrafficSelector toSelector = DefaultTrafficSelector.builder().matchInPort(intf.connectPoint().port()).matchEthType(EthType.EtherType.IPV4.ethType().toShort()).matchVlanId(intf.vlan()).matchIPProtocol((byte) OSPF_IP_PROTO).build();
    modifyNextObjective(deviceId, controlPlanePort, VlanId.vlanId((short) 4094), true, install);
    flowObjectiveService.forward(controlPlaneConnectPoint.deviceId(), buildForwardingObjective(toSelector, null, 1, install, 40001));
    expectLastCall().once();
}
Also used : DeviceId(org.onosproject.net.DeviceId) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) PortNumber(org.onosproject.net.PortNumber) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 39 with TrafficTreatment

use of org.onosproject.net.flow.TrafficTreatment in project onos by opennetworkinglab.

the class FibInstaller method updateMcastFilteringObjective.

/**
 * Installs or removes multicast filtering objectives relating to an interface.
 *
 * @param routerIntf interface to update objectives for
 * @param install true to install the objectives, false to remove them
 */
private void updateMcastFilteringObjective(InterfaceProvisionRequest routerIntf, boolean install) {
    Interface intf = routerIntf.intf();
    VlanId assignedVlan = (egressVlan().equals(VlanId.NONE)) ? VlanId.vlanId(ASSIGNED_VLAN) : egressVlan();
    FilteringObjective.Builder fob = DefaultFilteringObjective.builder();
    // first add filter for the interface
    fob.withKey(Criteria.matchInPort(intf.connectPoint().port())).addCondition(Criteria.matchEthDstMasked(MacAddress.IPV4_MULTICAST, MacAddress.IPV4_MULTICAST_MASK)).addCondition(Criteria.matchVlanId(ingressVlan()));
    fob.withPriority(PRIORITY_OFFSET);
    TrafficTreatment tt = DefaultTrafficTreatment.builder().pushVlan().setVlanId(assignedVlan).build();
    fob.withMeta(tt);
    fob.permit().fromApp(fibAppId);
    sendFilteringObjective(install, fob, intf);
}
Also used : DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Interface(org.onosproject.net.intf.Interface) VlanId(org.onlab.packet.VlanId)

Example 40 with TrafficTreatment

use of org.onosproject.net.flow.TrafficTreatment in project onos by opennetworkinglab.

the class FibInstaller method updateFilteringObjective.

/**
 * Installs or removes unicast filtering objectives relating to an interface.
 *
 * @param routerIntf interface to update objectives for
 * @param install true to install the objectives, false to remove them
 */
private void updateFilteringObjective(InterfaceProvisionRequest routerIntf, boolean install) {
    Interface intf = routerIntf.intf();
    VlanId assignedVlan = (egressVlan().equals(VlanId.NONE)) ? VlanId.vlanId(ASSIGNED_VLAN) : egressVlan();
    FilteringObjective.Builder fob = DefaultFilteringObjective.builder();
    // first add filter for the interface
    fob.withKey(Criteria.matchInPort(intf.connectPoint().port())).addCondition(Criteria.matchEthDst(intf.mac())).addCondition(Criteria.matchVlanId(intf.vlan()));
    fob.withPriority(PRIORITY_OFFSET);
    if (intf.vlan() == VlanId.NONE) {
        TrafficTreatment tt = DefaultTrafficTreatment.builder().pushVlan().setVlanId(assignedVlan).build();
        fob.withMeta(tt);
    }
    fob.permit().fromApp(fibAppId);
    sendFilteringObjective(install, fob, intf);
    // then add the same mac/vlan filters for control-plane connect point
    fob.withKey(Criteria.matchInPort(routerIntf.controlPlaneConnectPoint().port()));
    sendFilteringObjective(install, fob, intf);
}
Also used : DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Interface(org.onosproject.net.intf.Interface) VlanId(org.onlab.packet.VlanId)

Aggregations

TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)395 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)369 TrafficSelector (org.onosproject.net.flow.TrafficSelector)257 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)236 FlowRule (org.onosproject.net.flow.FlowRule)93 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)86 PiAction (org.onosproject.net.pi.runtime.PiAction)79 Test (org.junit.Test)78 PortNumber (org.onosproject.net.PortNumber)70 PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)56 Instruction (org.onosproject.net.flow.instructions.Instruction)52 DeviceId (org.onosproject.net.DeviceId)46 NextObjective (org.onosproject.net.flowobjective.NextObjective)45 ConnectPoint (org.onosproject.net.ConnectPoint)44 List (java.util.List)43 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)43 Ethernet (org.onlab.packet.Ethernet)40 Criterion (org.onosproject.net.flow.criteria.Criterion)39 GroupBucket (org.onosproject.net.group.GroupBucket)39 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)37