@Test public void testGenerateBgpCommonPeerConfig_SetEbgpMultiHop() { Ip peerIp = Ip.parse("10.0.0.2"); BgpIpNeighbor neighbor = new BgpIpNeighbor("BgpNeighbor"); neighbor.setRemoteAs(10000L); neighbor.setRemoteAsType(RemoteAsType.INTERNAL); neighbor.setPeerIp(peerIp); neighbor.setEbgpMultihop(3L); org.batfish.datamodel.BgpProcess newProc = new org.batfish.datamodel.BgpProcess( Ip.parse("10.0.0.1"), ConfigurationFormat.CUMULUS_NCLU); Configuration viConfig = new NetworkFactory() .configurationBuilder() .setConfigurationFormat(ConfigurationFormat.CUMULUS_NCLU) .build(); CumulusNcluConfiguration ncluConfiguration = new CumulusNcluConfiguration(); BgpActivePeerConfig.Builder peerConfigBuilder = BgpActivePeerConfig.builder().setPeerAddress(peerIp); generateBgpCommonPeerConfig( viConfig, ncluConfiguration, neighbor, 10000L, new BgpVrf("Vrf"), newProc, peerConfigBuilder, new Warnings()); BgpActivePeerConfig peerConfig = newProc.getActiveNeighbors().get(peerIp.toPrefix()); assertTrue(peerConfig.getEbgpMultihop()); }
@VisibleForTesting static void generateBgpCommonPeerConfig( Configuration c, CumulusNodeConfiguration vsConfig, BgpNeighbor neighbor, @Nullable Long localAs, BgpVrf bgpVrf, org.batfish.datamodel.BgpProcess newProc, BgpPeerConfig.Builder<?, ?> peerConfigBuilder, Warnings w) { RoutingPolicy exportRoutingPolicy = computeBgpNeighborExportRoutingPolicy(c, neighbor, bgpVrf); @Nullable RoutingPolicy importRoutingPolicy = computeBgpNeighborImportRoutingPolicy(c, neighbor, bgpVrf); peerConfigBuilder .setBgpProcess(newProc) .setClusterId(inferClusterId(bgpVrf, newProc.getRouterId(), neighbor)) .setConfederation(bgpVrf.getConfederationId()) .setDescription(neighbor.getDescription()) .setGroup(neighbor.getPeerGroup()) .setLocalAs(localAs) .setRemoteAsns(computeRemoteAsns(neighbor, localAs)) .setEbgpMultihop(neighbor.getEbgpMultihop() != null) .setGeneratedRoutes( bgpDefaultOriginate(neighbor) ? ImmutableSet.of(GENERATED_DEFAULT_ROUTE) : null) .setIpv4UnicastAddressFamily( convertIpv4UnicastAddressFamily( neighbor.getIpv4UnicastAddressFamily(), bgpVrf.getDefaultIpv4Unicast(), exportRoutingPolicy, importRoutingPolicy)) .setEvpnAddressFamily( toEvpnAddressFamily( c, vsConfig, neighbor, localAs, bgpVrf, newProc, exportRoutingPolicy, w)) .build(); }
CumulusConversions { @VisibleForTesting static void generateBgpCommonPeerConfig( Configuration c, CumulusNodeConfiguration vsConfig, BgpNeighbor neighbor, @Nullable Long localAs, BgpVrf bgpVrf, org.batfish.datamodel.BgpProcess newProc, BgpPeerConfig.Builder<?, ?> peerConfigBuilder, Warnings w) { RoutingPolicy exportRoutingPolicy = computeBgpNeighborExportRoutingPolicy(c, neighbor, bgpVrf); @Nullable RoutingPolicy importRoutingPolicy = computeBgpNeighborImportRoutingPolicy(c, neighbor, bgpVrf); peerConfigBuilder .setBgpProcess(newProc) .setClusterId(inferClusterId(bgpVrf, newProc.getRouterId(), neighbor)) .setConfederation(bgpVrf.getConfederationId()) .setDescription(neighbor.getDescription()) .setGroup(neighbor.getPeerGroup()) .setLocalAs(localAs) .setRemoteAsns(computeRemoteAsns(neighbor, localAs)) .setEbgpMultihop(neighbor.getEbgpMultihop() != null) .setGeneratedRoutes( bgpDefaultOriginate(neighbor) ? ImmutableSet.of(GENERATED_DEFAULT_ROUTE) : null) .setIpv4UnicastAddressFamily( convertIpv4UnicastAddressFamily( neighbor.getIpv4UnicastAddressFamily(), bgpVrf.getDefaultIpv4Unicast(), exportRoutingPolicy, importRoutingPolicy)) .setEvpnAddressFamily( toEvpnAddressFamily( c, vsConfig, neighbor, localAs, bgpVrf, newProc, exportRoutingPolicy, w)) .build(); } }
CumulusConversions { @VisibleForTesting static void generateBgpCommonPeerConfig( Configuration c, CumulusNodeConfiguration vsConfig, BgpNeighbor neighbor, @Nullable Long localAs, BgpVrf bgpVrf, org.batfish.datamodel.BgpProcess newProc, BgpPeerConfig.Builder<?, ?> peerConfigBuilder, Warnings w) { RoutingPolicy exportRoutingPolicy = computeBgpNeighborExportRoutingPolicy(c, neighbor, bgpVrf); @Nullable RoutingPolicy importRoutingPolicy = computeBgpNeighborImportRoutingPolicy(c, neighbor, bgpVrf); peerConfigBuilder .setBgpProcess(newProc) .setClusterId(inferClusterId(bgpVrf, newProc.getRouterId(), neighbor)) .setConfederation(bgpVrf.getConfederationId()) .setDescription(neighbor.getDescription()) .setGroup(neighbor.getPeerGroup()) .setLocalAs(localAs) .setRemoteAsns(computeRemoteAsns(neighbor, localAs)) .setEbgpMultihop(neighbor.getEbgpMultihop() != null) .setGeneratedRoutes( bgpDefaultOriginate(neighbor) ? ImmutableSet.of(GENERATED_DEFAULT_ROUTE) : null) .setIpv4UnicastAddressFamily( convertIpv4UnicastAddressFamily( neighbor.getIpv4UnicastAddressFamily(), bgpVrf.getDefaultIpv4Unicast(), exportRoutingPolicy, importRoutingPolicy)) .setEvpnAddressFamily( toEvpnAddressFamily( c, vsConfig, neighbor, localAs, bgpVrf, newProc, exportRoutingPolicy, w)) .build(); }  }
CumulusConversions { @VisibleForTesting static void generateBgpCommonPeerConfig( Configuration c, CumulusNodeConfiguration vsConfig, BgpNeighbor neighbor, @Nullable Long localAs, BgpVrf bgpVrf, org.batfish.datamodel.BgpProcess newProc, BgpPeerConfig.Builder<?, ?> peerConfigBuilder, Warnings w) { RoutingPolicy exportRoutingPolicy = computeBgpNeighborExportRoutingPolicy(c, neighbor, bgpVrf); @Nullable RoutingPolicy importRoutingPolicy = computeBgpNeighborImportRoutingPolicy(c, neighbor, bgpVrf); peerConfigBuilder .setBgpProcess(newProc) .setClusterId(inferClusterId(bgpVrf, newProc.getRouterId(), neighbor)) .setConfederation(bgpVrf.getConfederationId()) .setDescription(neighbor.getDescription()) .setGroup(neighbor.getPeerGroup()) .setLocalAs(localAs) .setRemoteAsns(computeRemoteAsns(neighbor, localAs)) .setEbgpMultihop(neighbor.getEbgpMultihop() != null) .setGeneratedRoutes( bgpDefaultOriginate(neighbor) ? ImmutableSet.of(GENERATED_DEFAULT_ROUTE) : null) .setIpv4UnicastAddressFamily( convertIpv4UnicastAddressFamily( neighbor.getIpv4UnicastAddressFamily(), bgpVrf.getDefaultIpv4Unicast(), exportRoutingPolicy, importRoutingPolicy)) .setEvpnAddressFamily( toEvpnAddressFamily( c, vsConfig, neighbor, localAs, bgpVrf, newProc, exportRoutingPolicy, w)) .build(); }  static @Nonnull String computeBgpCommonExportPolicyName(String vrfName); @VisibleForTesting static @Nonnull String computeBgpPeerExportPolicyName(
      String vrfName, String peerInterface); static @Nonnull String computeBgpPeerImportPolicyName(String vrf, String peer); static String computeBgpGenerationPolicyName(boolean ipv4, String vrfName, String prefix); static String computeMatchSuppressedSummaryOnlyPolicyName(String vrfName); static String computeOspfExportPolicyName(String vrfName); }
CumulusConversions { @VisibleForTesting static void generateBgpCommonPeerConfig( Configuration c, CumulusNodeConfiguration vsConfig, BgpNeighbor neighbor, @Nullable Long localAs, BgpVrf bgpVrf, org.batfish.datamodel.BgpProcess newProc, BgpPeerConfig.Builder<?, ?> peerConfigBuilder, Warnings w) { RoutingPolicy exportRoutingPolicy = computeBgpNeighborExportRoutingPolicy(c, neighbor, bgpVrf); @Nullable RoutingPolicy importRoutingPolicy = computeBgpNeighborImportRoutingPolicy(c, neighbor, bgpVrf); peerConfigBuilder .setBgpProcess(newProc) .setClusterId(inferClusterId(bgpVrf, newProc.getRouterId(), neighbor)) .setConfederation(bgpVrf.getConfederationId()) .setDescription(neighbor.getDescription()) .setGroup(neighbor.getPeerGroup()) .setLocalAs(localAs) .setRemoteAsns(computeRemoteAsns(neighbor, localAs)) .setEbgpMultihop(neighbor.getEbgpMultihop() != null) .setGeneratedRoutes( bgpDefaultOriginate(neighbor) ? ImmutableSet.of(GENERATED_DEFAULT_ROUTE) : null) .setIpv4UnicastAddressFamily( convertIpv4UnicastAddressFamily( neighbor.getIpv4UnicastAddressFamily(), bgpVrf.getDefaultIpv4Unicast(), exportRoutingPolicy, importRoutingPolicy)) .setEvpnAddressFamily( toEvpnAddressFamily( c, vsConfig, neighbor, localAs, bgpVrf, newProc, exportRoutingPolicy, w)) .build(); }  static @Nonnull String computeBgpCommonExportPolicyName(String vrfName); @VisibleForTesting static @Nonnull String computeBgpPeerExportPolicyName(
      String vrfName, String peerInterface); static @Nonnull String computeBgpPeerImportPolicyName(String vrf, String peer); static String computeBgpGenerationPolicyName(boolean ipv4, String vrfName, String prefix); static String computeMatchSuppressedSummaryOnlyPolicyName(String vrfName); static String computeOspfExportPolicyName(String vrfName); static final int DEFAULT_STATIC_ROUTE_ADMINISTRATIVE_DISTANCE; static final int DEFAULT_STATIC_ROUTE_METRIC; static final Ip CLAG_LINK_LOCAL_IP; static final long DEFAULT_MAX_MED; static final double SPEED_CONVERSION_FACTOR; static final double DEFAULT_LOOPBACK_BANDWIDTH; static final double DEFAULT_PORT_BANDWIDTH; }