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

_ebgpv4Rib and _bgpv4Rib of BgpRoutingProcess process two equal-cost EBGP routes differently when multipathIbgp enabled but multipathEbgp disabled #8990

Open
heroinedd opened this issue Apr 14, 2024 · 1 comment

Comments

@heroinedd
Copy link

Hi, I notice a possible bug of Batfish. That is, when a BgpProcess is multipathIbgp enabled but multipathEbgp disabled (implying multipath enabled, since multipath = multipathIbgp || multipathEbgp), given two equal-cost EBGP routes LEARNED from neighbors, the corresponding BgpRoutingProcess's _ebgpv4Rib will insert only one of them into its RibTree since it is multipath disabled, while its _bgpv4Rib will insert both of the routes into its RibTree since it is multipath enabled.

You can use the following code to find the inconsistency:

    // set up
    NetworkFactory nf = new NetworkFactory();
    Configuration c =
        nf.configurationBuilder()
            .setConfigurationFormat(ConfigurationFormat.CISCO_IOS)
            .setHostname("c1")
            .build();
    Vrf vrf = nf.vrfBuilder().setOwner(c).setName(DEFAULT_VRF_NAME).build();
    BgpProcess bgpProcess = BgpProcess.testBgpProcess(Ip.ZERO);
    bgpProcess.setMultipathIbgp(true);
    bgpProcess.setMultipathEbgp(false);
    vrf.setBgpProcess(bgpProcess);
    Rib mainRib = new Rib();
    mainRib.mergeRouteGetDelta(
        new AnnotatedRoute<>(
            StaticRoute.testBuilder().setNetwork(Prefix.parse("70.0.0.0/24")).build(),
            DEFAULT_VRF_NAME));
    mainRib.mergeRouteGetDelta(
        new AnnotatedRoute<>(
            StaticRoute.testBuilder().setNetwork(Prefix.parse("60.0.0.0/24")).build(),
            DEFAULT_VRF_NAME));

    BgpRoutingProcess routingProcess =
        new BgpRoutingProcess(
            bgpProcess, c, DEFAULT_VRF_NAME, mainRib, BgpTopology.EMPTY, new PrefixTracer());

    // init two equal-cost EBGP routes learned from neighbors
    Prefix pfx = Prefix.parse("10.0.1.0/24");
    Bgpv4Route r1 =
        Bgpv4Route.testBuilder()
            .setNetwork(pfx)
            .setNextHopIp(Ip.parse("70.0.0.1"))
            .setOriginMechanism(OriginMechanism.LEARNED)
            .setReceivedFrom(ReceivedFromIp.of(Ip.parse("70.0.0.1")))
            .build();
    Bgpv4Route r2 =
        Bgpv4Route.testBuilder()
            .setNetwork(pfx)
            .setNextHopIp(Ip.parse("60.0.0.1"))
            .setOriginMechanism(OriginMechanism.LEARNED)
            .setReceivedFrom(ReceivedFromIp.of(Ip.parse("60.0.0.1")))
            .build();

    // insert r1 into _bgpv4Rib and _ebgpv4Rib, the test will success
    routingProcess._bgpv4Rib.mergeRouteGetDelta(r1);
    routingProcess._ebgpv4Rib.mergeRouteGetDelta(r1);
    assertEquals(routingProcess._bgpv4Rib.getRoutes(pfx), routingProcess._ebgpv4Rib.getRoutes(pfx));

    // insert r2 into _bgpv4Rib and _ebgpv4Rib, the test will fail
    routingProcess._bgpv4Rib.mergeRouteGetDelta(r2);
    routingProcess._ebgpv4Rib.mergeRouteGetDelta(r2);
    assertEquals(routingProcess._bgpv4Rib.getRoutes(pfx), routingProcess._ebgpv4Rib.getRoutes(pfx));
@dhalperi
Copy link
Member

dhalperi commented Apr 15, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants