Skip to content

Commit

Permalink
Frr: Do not call addNeighbor on peer group neighbors (#8157)
Browse files Browse the repository at this point in the history
  • Loading branch information
ratulm committed Mar 18, 2022
1 parent 285857c commit 6c2db35
Showing 1 changed file with 7 additions and 6 deletions.
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

0 comments on commit 6c2db35

Please sign in to comment.