Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frr: Do not call addNeighbor on peer group neighbors #8157

Merged
merged 1 commit into from
Mar 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.batfish.representation.frr;

import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.groupingBy;
Expand Down Expand Up @@ -450,9 +451,8 @@ private static void convertBgpProcess(
Iterables.concat(ImmutableSet.of(bgpProcess.getDefaultVrf()), bgpProcess.getVrfs().values())
.forEach(
bgpVrf -> {
bgpVrf
.getNeighbors()
.values()
bgpVrf.getNeighbors().values().stream()
.filter(neighbor -> !(neighbor instanceof BgpPeerGroupNeighbor))
.forEach(neighbor -> addBgpNeighbor(c, vc, frr, bgpVrf, neighbor, w));
});
}
Expand Down Expand Up @@ -530,6 +530,9 @@ static void addBgpNeighbor(
BgpVrf bgpVrf,
BgpNeighbor neighbor,
Warnings w) {
checkArgument(
!(neighbor instanceof BgpPeerGroupNeighbor),
"addBgpNeighbor should not be called on BgpPeerGroupNeighbor");

org.batfish.datamodel.BgpProcess viBgpProcess =
c.getVrfs().get(bgpVrf.getVrfName()).getBgpProcess();
Expand Down Expand Up @@ -563,9 +566,7 @@ static void addBgpNeighbor(
} else if (neighbor instanceof BgpDynamicNeighbor) {
BgpDynamicNeighbor passiveNeighbor = (BgpDynamicNeighbor) neighbor;
addPassiveBgpNeighbor(c, vc, frr, passiveNeighbor, localAs, bgpVrf, viBgpProcess, w);
} else if (!(neighbor instanceof BgpPeerGroupNeighbor
|| neighbor instanceof BgpIpv6Neighbor
|| neighbor instanceof BgpDynamic6Neighbor)) {
} else if (!(neighbor instanceof BgpIpv6Neighbor || neighbor instanceof BgpDynamic6Neighbor)) {
throw new IllegalArgumentException(
"Unsupported BGP neighbor type: " + neighbor.getClass().getSimpleName());
}
Expand Down