Search in sources :

Example 6 with FabricRoute

use of org.onosproject.simplefabric.api.FabricRoute in project onos by opennetworkinglab.

the class SimpleFabricRouting method ipPacketReactiveProcessor.

/**
 * Routes packet reactively.
 */
private void ipPacketReactiveProcessor(PacketContext context, Ethernet ethPkt, ConnectPoint srcCp, IpAddress srcIp, IpAddress dstIp, byte ipProto) {
    /* check reactive handling and forward packet */
    log.trace("ip packet: srcCp={} srcIp={} dstIp={} ipProto={}", srcCp, srcIp, dstIp, ipProto);
    EncapsulationType encap = EncapsulationType.NONE;
    // prefix and nextHop for local Subnet
    IpPrefix srcPrefix = srcIp.toIpPrefix();
    IpPrefix dstPrefix = dstIp.toIpPrefix();
    IpAddress srcNextHop = srcIp;
    IpAddress dstNextHop = dstIp;
    MacAddress treatmentSrcMac = ethPkt.getDestinationMAC();
    int borderRoutePrefixLength = 0;
    boolean updateMac = simpleFabric.isVirtualGatewayMac(ethPkt.getDestinationMAC());
    // check subnet local or route
    FabricSubnet srcSubnet = simpleFabric.fabricSubnet(srcIp);
    if (srcSubnet == null) {
        FabricRoute route = simpleFabric.fabricRoute(srcIp);
        if (route == null) {
            log.warn("unknown srcIp; drop: srcCp={} srcIp={} dstIp={} ipProto={}", srcCp, srcIp, dstIp, ipProto);
            return;
        }
        srcPrefix = route.prefix();
        srcNextHop = route.nextHop();
        borderRoutePrefixLength = route.prefix().prefixLength();
    }
    FabricSubnet dstSubnet = simpleFabric.fabricSubnet(dstIp);
    if (dstSubnet == null) {
        FabricRoute route = simpleFabric.fabricRoute(dstIp);
        if (route == null) {
            log.warn("unknown dstIp; drop: srcCp={} srcIp={} dstIp={} ipProto={}", srcCp, srcIp, dstIp, ipProto);
            return;
        }
        dstPrefix = route.prefix();
        dstNextHop = route.nextHop();
        borderRoutePrefixLength = route.prefix().prefixLength();
    }
    if (dstSubnet != null) {
        // destination is local subnet ip
        if (ALLOW_ETH_ADDRESS_SELECTOR && dstSubnet.equals(srcSubnet)) {
            // NOTE: if ALLOW_ETH_ADDRESS_SELECTOR=false; isForward is always false
            FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(dstSubnet.networkName());
            treatmentSrcMac = ethPkt.getSourceMAC();
            if (fabricNetwork != null && fabricNetwork.isForward()) {
                // NOTE: no reactive route action but do forward packet for L2Forward do not handle packet
                // update mac only if dstMac is virtualGatewayMac, else assume valid mac already for the l2 network
                log.info("LOCAL FORWARD ONLY: " + "srcCp={} srcIp={} dstIp={} srcMac={} dstMac={} vlanId={} ipProto={} updateMac={}", context.inPacket().receivedFrom(), srcIp, dstIp, ethPkt.getSourceMAC(), ethPkt.getDestinationMAC(), ethPkt.getVlanID(), ipProto, updateMac);
                forwardPacketToDstIp(context, dstIp, treatmentSrcMac, updateMac);
                return;
            }
        }
        encap = dstSubnet.encapsulation();
        if (encap == EncapsulationType.NONE && srcSubnet != null) {
            encap = srcSubnet.encapsulation();
        }
    } else {
        // destination is external network
        if (srcSubnet == null) {
            // both are externel network
            log.warn("INVALID PACKET: srcIp and dstIp are both NON-LOCAL: " + "srcCP={} srcIp={} dstIp={} srcMac={} dstMac={} vlanId={} ipProto={} updateMac={}", context.inPacket().receivedFrom(), srcIp, dstIp, ethPkt.getSourceMAC(), ethPkt.getDestinationMAC(), ethPkt.getVlanID(), ipProto, updateMac);
            return;
        }
        encap = srcSubnet.encapsulation();
    }
    log.info("REGI AND FORWARD: " + "srcCP={} srcIp={} dstIp={} srcMac={} dstMac={} vlanId={} ipProto={} updateMac={}", context.inPacket().receivedFrom(), srcIp, dstIp, ethPkt.getSourceMAC(), ethPkt.getDestinationMAC(), ethPkt.getVlanID(), ipProto, updateMac);
    setUpConnectivity(srcCp, ipProto, srcPrefix, dstPrefix, dstNextHop, treatmentSrcMac, encap, updateMac, dstSubnet != null, borderRoutePrefixLength);
    forwardPacketToDstIp(context, dstNextHop, treatmentSrcMac, updateMac);
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) EncapsulationType(org.onosproject.net.EncapsulationType) FabricSubnet(org.onosproject.simplefabric.api.FabricSubnet) IpAddress(org.onlab.packet.IpAddress) MacAddress(org.onlab.packet.MacAddress) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) HashedPathSelectionConstraint(org.onosproject.net.intent.constraint.HashedPathSelectionConstraint) ConnectPoint(org.onosproject.net.ConnectPoint) Constraint(org.onosproject.net.intent.Constraint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FabricRoute(org.onosproject.simplefabric.api.FabricRoute)

Example 7 with FabricRoute

use of org.onosproject.simplefabric.api.FabricRoute in project onos by opennetworkinglab.

the class SimpleFabricRouting method monitorBorderPeers.

// monitor border peers for routeService lookup to be effective
private void monitorBorderPeers() {
    for (FabricRoute route : simpleFabric.fabricRoutes()) {
        hostService.startMonitoringIp(route.nextHop());
        simpleFabric.requestMac(route.nextHop());
    }
}
Also used : FabricRoute(org.onosproject.simplefabric.api.FabricRoute)

Aggregations

FabricRoute (org.onosproject.simplefabric.api.FabricRoute)7 FabricNetwork (org.onosproject.simplefabric.api.FabricNetwork)4 FabricSubnet (org.onosproject.simplefabric.api.FabricSubnet)4 IpAddress (org.onlab.packet.IpAddress)3 MacAddress (org.onlab.packet.MacAddress)3 HashSet (java.util.HashSet)2 IpPrefix (org.onlab.packet.IpPrefix)2 ConnectPoint (org.onosproject.net.ConnectPoint)2 EncapsulationType (org.onosproject.net.EncapsulationType)2 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)2 Host (org.onosproject.net.Host)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ImmutableList (com.google.common.collect.ImmutableList)1 DefaultByteArrayNodeFactory (com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory)1 ConcurrentInvertedRadixTree (com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree)1 PrintStream (java.io.PrintStream)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1