@Nullable public static RoutingPolicy findCommonRoutingPolicy(Configuration conf, Protocol proto) { if (proto.isOspf()) { String exp = conf.getDefaultVrf().getOspfProcess().getExportPolicy(); return conf.getRoutingPolicies().get(exp); } if (proto.isBgp()) { for (Map.Entry<String, RoutingPolicy> entry : conf.getRoutingPolicies().entrySet()) { String name = entry.getKey(); if (name.contains(BGP_COMMON_FILTER_LIST_NAME)) { return entry.getValue(); } } return null; } if (proto.isStatic()) { return null; } if (proto.isConnected()) { return null; } throw new BatfishException("TODO: findCommonRoutingPolicy for " + proto.name()); }
@Nullable public RoutingPolicy findExportRoutingPolicy(String router, Protocol proto, GraphEdge ge) { Configuration conf = _configurations.get(router); if (proto.isConnected()) { return null; } if (proto.isStatic()) { return null; } if (proto.isOspf()) { OspfProcess p = conf.getDefaultVrf().getOspfProcess(); if (p == null) { return null; } String exp = p.getExportPolicy(); return conf.getRoutingPolicies().get(exp); } if (proto.isBgp()) { BgpPeerConfig n = findBgpNeighbor(ge); // if no neighbor (e.g., loopback), or no export policy if (n == null || n.getExportPolicy() == null) { return null; } return conf.getRoutingPolicies().get(n.getExportPolicy()); } throw new BatfishException("TODO: findExportRoutingPolicy for " + proto.name()); }
public void computeRoutingPolicySources(Warnings w) { for (String rpName : _routingPolicies.keySet()) { computeRoutingPolicySources(rpName, w); } for (Vrf vrf : _vrfs.values()) { BgpProcess bgpProcess = vrf.getBgpProcess(); if (bgpProcess != null) { for (BgpPeerConfig neighbor : Iterables.concat( bgpProcess.getActiveNeighbors().values(), bgpProcess.getPassiveNeighbors().values())) { neighbor.setExportPolicySources(getRoutingPolicySources(neighbor.getExportPolicy())); neighbor.setImportPolicySources(getRoutingPolicySources(neighbor.getImportPolicy())); } } OspfProcess ospfProcess = vrf.getOspfProcess(); if (ospfProcess != null) { ospfProcess.setExportPolicySources(getRoutingPolicySources(ospfProcess.getExportPolicy())); } for (GeneratedRoute gr : vrf.getGeneratedRoutes()) { gr.setAttributePolicySources(getRoutingPolicySources(gr.getAttributePolicy())); gr.setGenerationPolicySources(getRoutingPolicySources(gr.getGenerationPolicy())); } } }
OspfProcess proc = vrf.getOspfProcess(); if (proc != null) { String exportPolicyName = proc.getExportPolicy(); if (exportPolicyName != null) { RoutingPolicy exportPolicy = c.getRoutingPolicies().get(exportPolicyName);
String exportPolicyName = _vrf.getOspfProcess().getExportPolicy(); if (exportPolicyName == null) { return; // nothing to export
OspfProcess.builder().setReferenceBandwidth(ospf.getReferenceBandwidth()).build(); abstractOspf.setAreas(ospf.getAreas()); abstractOspf.setExportPolicy(ospf.getExportPolicy()); abstractOspf.setRouterId(ospf.getRouterId());