use of org.batfish.datamodel.OspfAreaSummary in project batfish by batfish.
the class VirtualRouter method computeInterAreaSummaries.
boolean computeInterAreaSummaries() {
OspfProcess proc = _vrf.getOspfProcess();
boolean changed = false;
// Ensure we have a running OSPF process on the VRF, otherwise bail.
if (proc == null) {
return false;
}
// Admin cost for the given protocol
int admin = RoutingProtocol.OSPF_IA.getSummaryAdministrativeCost(_c.getConfigurationFormat());
// Determine whether to use min metric by default, based on RFC1583 compatibility setting.
// Routers (at least Cisco and Juniper) default to min metric unless using RFC2328 with
// RFC1583 compatibility explicitly disabled, in which case they default to max.
boolean useMin = MoreObjects.firstNonNull(proc.getRfc1583Compatible(), true);
// Compute summaries for each area
for (Entry<Long, OspfArea> e : proc.getAreas().entrySet()) {
long areaNum = e.getKey();
OspfArea area = e.getValue();
for (Entry<Prefix, OspfAreaSummary> e2 : area.getSummaries().entrySet()) {
Prefix prefix = e2.getKey();
OspfAreaSummary summary = e2.getValue();
// Only advertised summaries can contribute
if (!summary.getAdvertised()) {
continue;
}
Long metric = summary.getMetric();
if (summary.getMetric() == null) {
// No metric was configured; compute it from any possible contributing routes.
for (OspfIntraAreaRoute contributingRoute : _ospfIntraAreaRib.getRoutes()) {
metric = computeUpdatedOspfSummaryMetric(contributingRoute, prefix, metric, areaNum, useMin);
}
for (OspfInterAreaRoute contributingRoute : _ospfInterAreaRib.getRoutes()) {
metric = computeUpdatedOspfSummaryMetric(contributingRoute, prefix, metric, areaNum, useMin);
}
}
// No routes contributed to the summary, nothing to construct
if (metric == null) {
continue;
}
// Non-null metric means we generate a new summary and put it in the RIB
OspfInterAreaRoute summaryRoute = new OspfInterAreaRoute(prefix, Ip.ZERO, admin, metric, areaNum);
if (_ospfInterAreaStagingRib.mergeRoute(summaryRoute)) {
changed = true;
}
}
}
return changed;
}
Aggregations