Search in sources :

Example 11 with FabricNetwork

use of org.onosproject.simplefabric.api.FabricNetwork 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)

Aggregations

FabricNetwork (org.onosproject.simplefabric.api.FabricNetwork)11 MacAddress (org.onlab.packet.MacAddress)7 FabricSubnet (org.onosproject.simplefabric.api.FabricSubnet)6 Host (org.onosproject.net.Host)5 Interface (org.onosproject.net.intf.Interface)5 FabricRoute (org.onosproject.simplefabric.api.FabricRoute)5 IpAddress (org.onlab.packet.IpAddress)4 EncapsulationType (org.onosproject.net.EncapsulationType)4 HashSet (java.util.HashSet)3 Set (java.util.Set)3 IpPrefix (org.onlab.packet.IpPrefix)3 ApplicationId (org.onosproject.core.ApplicationId)3 ConnectPoint (org.onosproject.net.ConnectPoint)3 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)3 Constraint (org.onosproject.net.intent.Constraint)3 Key (org.onosproject.net.intent.Key)3 MultiPointToSinglePointIntent (org.onosproject.net.intent.MultiPointToSinglePointIntent)3 EncapsulationConstraint (org.onosproject.net.intent.constraint.EncapsulationConstraint)3 PartialFailureConstraint (org.onosproject.net.intent.constraint.PartialFailureConstraint)3 SimpleFabricEvent (org.onosproject.simplefabric.api.SimpleFabricEvent)3