Search in sources :

Example 6 with OspfIntraAreaRoute

use of org.batfish.datamodel.OspfIntraAreaRoute in project batfish by batfish.

the class VirtualRouter method propagateOspfInternalRoutesFromNeighbor.

/**
 * Propagate OSPF Internal routes from a single neighbor.
 *
 * @param proc The receiving OSPF process
 * @param neighbor the neighbor
 * @param connectingInterface interface on which we are connected to the neighbor
 * @param neighborInterface interface that the neighbor uses to connect to us
 * @param adminCost route administrative distance
 * @return true if new routes have been added to our staging RIB
 */
boolean propagateOspfInternalRoutesFromNeighbor(OspfProcess proc, Node neighbor, Interface connectingInterface, Interface neighborInterface, int adminCost) {
    OspfArea area = connectingInterface.getOspfArea();
    OspfArea neighborArea = neighborInterface.getOspfArea();
    // Ensure that the link (i.e., both interfaces) has OSPF enabled and OSPF areas are set
    if (!connectingInterface.getOspfEnabled() || connectingInterface.getOspfPassive() || !neighborInterface.getOspfEnabled() || neighborInterface.getOspfPassive() || area == null || neighborArea == null || !area.getName().equals(neighborArea.getName())) {
        return false;
    }
    /*
     * An OSPF neighbor relationship exists on this edge. So we examine all intra- and inter-area
     * routes belonging to the neighbor to see what should be propagated to this router. We add the
     * incremental cost associated with our settings and the connecting interface, and use the
     * neighborInterface's address as the next hop ip.
     */
    int connectingInterfaceCost = connectingInterface.getOspfCost();
    long incrementalCost = proc.getMaxMetricTransitLinks() != null ? proc.getMaxMetricTransitLinks() : connectingInterfaceCost;
    Long areaNum = area.getName();
    VirtualRouter neighborVirtualRouter = neighbor._virtualRouters.get(neighborInterface.getVrfName());
    boolean changed = false;
    for (OspfIntraAreaRoute neighborRoute : neighborVirtualRouter._ospfIntraAreaRib.getRoutes()) {
        changed |= propagateOspfIntraAreaRoute(neighborRoute, incrementalCost, neighborInterface, adminCost, areaNum);
        changed |= propagateOspfInterAreaRouteFromIntraAreaRoute(neighbor, neighborRoute, incrementalCost, neighborInterface, adminCost, areaNum);
    }
    for (OspfInterAreaRoute neighborRoute : neighborVirtualRouter._ospfInterAreaRib.getRoutes()) {
        changed |= propagateOspfInterAreaRouteFromInterAreaRoute(neighbor, neighborRoute, incrementalCost, neighborInterface, adminCost, areaNum);
    }
    return changed;
}
Also used : OspfArea(org.batfish.datamodel.OspfArea) OspfIntraAreaRoute(org.batfish.datamodel.OspfIntraAreaRoute) OspfInterAreaRoute(org.batfish.datamodel.OspfInterAreaRoute)

Aggregations

OspfIntraAreaRoute (org.batfish.datamodel.OspfIntraAreaRoute)6 Prefix (org.batfish.datamodel.Prefix)4 OspfInterAreaRoute (org.batfish.datamodel.OspfInterAreaRoute)3 Interface (org.batfish.datamodel.Interface)2 Ip (org.batfish.datamodel.Ip)2 OspfArea (org.batfish.datamodel.OspfArea)2 OspfProcess (org.batfish.datamodel.OspfProcess)2 Test (org.junit.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)1 Arrays (java.util.Arrays)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 SortedSet (java.util.SortedSet)1 Collectors (java.util.stream.Collectors)1