Search in sources :

Example 91 with TrafficSelector

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

the class OpenstackTroubleshootManager method setNorthSouthIcmpReplyRule.

/**
 * Installs/uninstalls a flow rule to match north-south ICMP reply packets,
 * direct all ICMP reply packets to the controller.
 *
 * @param port      instance port
 * @param gw        gateway node
 * @param install   installation flag
 */
private void setNorthSouthIcmpReplyRule(InstancePort port, OpenstackNode gw, boolean install) {
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPSrc(IpPrefix.valueOf(port.ipAddress(), PREFIX_LENGTH)).matchIPProtocol(IPv4.PROTOCOL_ICMP).matchIcmpType(ICMP.TYPE_ECHO_REPLY).matchTunnelId(getSegId(osNetworkService, port)).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setIpSrc(instancePortService.floatingIp(port.portId())).setEthSrc(port.macAddress()).setEthDst(DEFAULT_EXTERNAL_ROUTER_MAC).punt().build();
    osFlowRuleService.setRule(appId, gw.intgBridge(), selector, treatment, PRIORITY_ICMP_PROBE_RULE, GW_COMMON_TABLE, install);
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 92 with TrafficSelector

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

the class SimpleFabricForwarding method buildBrcIntents.

// Build Boadcast Intents for a L2 Network.
private Set<SinglePointToMultiPointIntent> buildBrcIntents(FabricNetwork fabricNetwork) {
    Set<Interface> interfaces = fabricNetwork.interfaces();
    if (interfaces.size() < 2 || !fabricNetwork.isForward() || !fabricNetwork.isBroadcast()) {
        return ImmutableSet.of();
    }
    Set<SinglePointToMultiPointIntent> brcIntents = Sets.newHashSet();
    ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
    // Generates broadcast Intents from any network interface to other
    // network interface from the L2 Network.
    interfaces.forEach(src -> {
        FilteredConnectPoint srcFcp = buildFilteredConnectedPoint(src);
        Set<FilteredConnectPoint> dstFcps = interfaces.stream().filter(iface -> !iface.equals(src)).map(this::buildFilteredConnectedPoint).collect(Collectors.toSet());
        Key key = buildKey(fabricNetwork.name(), "BCAST", srcFcp.connectPoint(), MacAddress.BROADCAST);
        TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(MacAddress.BROADCAST).build();
        SinglePointToMultiPointIntent.Builder intentBuilder = SinglePointToMultiPointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoint(srcFcp).filteredEgressPoints(dstFcps).constraints(buildConstraints(L2NETWORK_CONSTRAINTS, fabricNetwork.encapsulation())).priority(PRI_L2NETWORK_BROADCAST).resourceGroup(resourceGroup);
        brcIntents.add(intentBuilder.build());
    });
    return brcIntents;
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Interface(org.onosproject.net.intf.Interface) ResourceGroup(org.onosproject.net.ResourceGroup) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 93 with TrafficSelector

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

the class SimpleFabricForwarding method buildUniIntents.

// Builds unicast Intents for a L2 Network.
private Set<MultiPointToSinglePointIntent> buildUniIntents(FabricNetwork fabricNetwork, Set<Host> hosts) {
    Set<Interface> interfaces = fabricNetwork.interfaces();
    if (!fabricNetwork.isForward() || interfaces.size() < 2) {
        return ImmutableSet.of();
    }
    Set<MultiPointToSinglePointIntent> uniIntents = Sets.newHashSet();
    ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
    hosts.forEach(host -> {
        FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
        Set<FilteredConnectPoint> srcFcps = interfaces.stream().map(this::buildFilteredConnectedPoint).filter(fcp -> !fcp.equals(hostFcp)).collect(Collectors.toSet());
        Key key = buildKey(fabricNetwork.name(), "UNI", hostFcp.connectPoint(), host.mac());
        TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(host.mac()).build();
        MultiPointToSinglePointIntent.Builder intentBuilder = MultiPointToSinglePointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoints(srcFcps).filteredEgressPoint(hostFcp).constraints(buildConstraints(L2NETWORK_CONSTRAINTS, fabricNetwork.encapsulation())).priority(PRI_L2NETWORK_UNICAST).resourceGroup(resourceGroup);
        uniIntents.add(intentBuilder.build());
    });
    return uniIntents;
}
Also used : Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) CoreService(org.onosproject.core.CoreService) LoggerFactory(org.slf4j.LoggerFactory) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) HostService(org.onosproject.net.host.HostService) ConnectPoint(org.onosproject.net.ConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Component(org.osgi.service.component.annotations.Component) SimpleFabricListener(org.onosproject.simplefabric.api.SimpleFabricListener) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) IntentService(org.onosproject.net.intent.IntentService) SimpleFabricEvent(org.onosproject.simplefabric.api.SimpleFabricEvent) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) Intent(org.onosproject.net.intent.Intent) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Activate(org.osgi.service.component.annotations.Activate) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ResourceGroup(org.onosproject.net.ResourceGroup) PRI_L2NETWORK_BROADCAST(org.onosproject.simplefabric.api.Constants.PRI_L2NETWORK_BROADCAST) SimpleFabricService(org.onosproject.simplefabric.api.SimpleFabricService) PrintStream(java.io.PrintStream) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) Deactivate(org.osgi.service.component.annotations.Deactivate) Collection(java.util.Collection) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) FORWARDING_APP_ID(org.onosproject.simplefabric.api.Constants.FORWARDING_APP_ID) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Constraint(org.onosproject.net.intent.Constraint) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Objects(java.util.Objects) Key(org.onosproject.net.intent.Key) List(java.util.List) EncapsulationType(org.onosproject.net.EncapsulationType) PRI_L2NETWORK_UNICAST(org.onosproject.simplefabric.api.Constants.PRI_L2NETWORK_UNICAST) MacAddress(org.onlab.packet.MacAddress) Reference(org.osgi.service.component.annotations.Reference) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Interface(org.onosproject.net.intf.Interface) ResourceGroup(org.onosproject.net.ResourceGroup) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 94 with TrafficSelector

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

the class PeerConnectivityManager method buildIntents.

/**
 * Builds the required intents between a BGP speaker and an external router.
 *
 * @param portOne the BGP speaker connect point
 * @param vlanOne the BGP speaker VLAN
 * @param ipOne the BGP speaker IP address
 * @param portTwo the external BGP peer connect point
 * @param vlanTwo the external BGP peer VLAN
 * @param ipTwo the external BGP peer IP address
 * @param encap the encapsulation type
 * @return the intents to install
 */
private Collection<PointToPointIntent> buildIntents(ConnectPoint portOne, VlanId vlanOne, IpAddress ipOne, ConnectPoint portTwo, VlanId vlanTwo, IpAddress ipTwo, EncapsulationType encap) {
    List<PointToPointIntent> intents = new ArrayList<>();
    TrafficTreatment.Builder treatmentToPeer = DefaultTrafficTreatment.builder();
    TrafficTreatment.Builder treatmentToSpeaker = DefaultTrafficTreatment.builder();
    PointToPointIntent.Builder intentBuilder;
    TrafficSelector selector;
    Key key;
    byte tcpProtocol;
    byte icmpProtocol;
    if (ipOne.isIp4()) {
        tcpProtocol = IPv4.PROTOCOL_TCP;
        icmpProtocol = IPv4.PROTOCOL_ICMP;
    } else {
        tcpProtocol = IPv6.PROTOCOL_TCP;
        icmpProtocol = IPv6.PROTOCOL_ICMP6;
    }
    // Add VLAN treatment for traffic going from BGP speaker to BGP peer
    treatmentToPeer = applyVlanTreatment(vlanOne, vlanTwo, treatmentToPeer);
    // Path from BGP speaker to BGP peer matching destination TCP port 179
    selector = buildSelector(tcpProtocol, vlanOne, ipOne, ipTwo, null, BGP_PORT);
    key = buildKey(ipOne, ipTwo, SUFFIX_DST);
    intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).selector(selector).treatment(treatmentToPeer.build()).priority(PRIORITY_OFFSET);
    encap(intentBuilder, encap);
    intents.add(intentBuilder.build());
    // Path from BGP speaker to BGP peer matching source TCP port 179
    selector = buildSelector(tcpProtocol, vlanOne, ipOne, ipTwo, BGP_PORT, null);
    key = buildKey(ipOne, ipTwo, SUFFIX_SRC);
    intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).selector(selector).treatment(treatmentToPeer.build()).priority(PRIORITY_OFFSET);
    encap(intentBuilder, encap);
    intents.add(intentBuilder.build());
    // ICMP path from BGP speaker to BGP peer
    selector = buildSelector(icmpProtocol, vlanOne, ipOne, ipTwo, null, null);
    key = buildKey(ipOne, ipTwo, SUFFIX_ICMP);
    intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).selector(selector).treatment(treatmentToPeer.build()).priority(PRIORITY_OFFSET);
    encap(intentBuilder, encap);
    intents.add(intentBuilder.build());
    // Add VLAN treatment for traffic going from BGP peer to BGP speaker
    treatmentToSpeaker = applyVlanTreatment(vlanTwo, vlanOne, treatmentToSpeaker);
    // Path from BGP peer to BGP speaker matching destination TCP port 179
    selector = buildSelector(tcpProtocol, vlanTwo, ipTwo, ipOne, null, BGP_PORT);
    key = buildKey(ipTwo, ipOne, SUFFIX_DST);
    intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).selector(selector).treatment(treatmentToSpeaker.build()).priority(PRIORITY_OFFSET);
    encap(intentBuilder, encap);
    intents.add(intentBuilder.build());
    // Path from BGP peer to BGP speaker matching source TCP port 179
    selector = buildSelector(tcpProtocol, vlanTwo, ipTwo, ipOne, BGP_PORT, null);
    key = buildKey(ipTwo, ipOne, SUFFIX_SRC);
    intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).selector(selector).treatment(treatmentToSpeaker.build()).priority(PRIORITY_OFFSET);
    encap(intentBuilder, encap);
    intents.add(intentBuilder.build());
    // ICMP path from BGP peer to BGP speaker
    selector = buildSelector(icmpProtocol, vlanTwo, ipTwo, ipOne, null, null);
    key = buildKey(ipTwo, ipOne, SUFFIX_ICMP);
    intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).selector(selector).treatment(treatmentToSpeaker.build()).priority(PRIORITY_OFFSET);
    encap(intentBuilder, encap);
    intents.add(intentBuilder.build());
    return intents;
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ArrayList(java.util.ArrayList) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 95 with TrafficSelector

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

the class FilteredConnectPointSerializer method read.

@Override
public FilteredConnectPoint read(Kryo kryo, Input input, Class<FilteredConnectPoint> type) {
    ConnectPoint connectPoint = (ConnectPoint) kryo.readClassAndObject(input);
    TrafficSelector trafficSelector = (TrafficSelector) kryo.readClassAndObject(input);
    return new FilteredConnectPoint(connectPoint, trafficSelector);
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Aggregations

TrafficSelector (org.onosproject.net.flow.TrafficSelector)396 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)354 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)249 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)235 FlowRule (org.onosproject.net.flow.FlowRule)94 Test (org.junit.Test)85 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)84 PiAction (org.onosproject.net.pi.runtime.PiAction)54 ConnectPoint (org.onosproject.net.ConnectPoint)51 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)48 DeviceId (org.onosproject.net.DeviceId)43 PortNumber (org.onosproject.net.PortNumber)43 List (java.util.List)42 NextObjective (org.onosproject.net.flowobjective.NextObjective)41 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)39 PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)38 Instruction (org.onosproject.net.flow.instructions.Instruction)37 Criterion (org.onosproject.net.flow.criteria.Criterion)36 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)36 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)35