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

Add NextHop column to Routes answerer #7838

Merged
merged 2 commits into from
Dec 20, 2021

Conversation

arifogel
Copy link
Member

  • add Schema.NEXT_HOP
  • populate COL_NEXT_HOP using modern NextHop route attribute

- add `Schema.NEXT_HOP`
- populate `COL_NEXT_HOP` using modern `NextHop` route attribute
@batfish-bot
Copy link

This change is Reviewable

Copy link
Member Author

@arifogel arifogel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 12 files reviewed, 1 unresolved discussion

a discussion (no related file):
self-merge only


@codecov
Copy link

codecov bot commented Dec 20, 2021

Codecov Report

Merging #7838 (70a4a97) into master (e6dcde4) will decrease coverage by 0.00%.
The diff coverage is 96.15%.

@@             Coverage Diff              @@
##             master    #7838      +/-   ##
============================================
- Coverage     74.05%   74.04%   -0.01%     
- Complexity    42272    42279       +7     
============================================
  Files          3313     3314       +1     
  Lines        166526   166590      +64     
  Branches      19940    19945       +5     
============================================
+ Hits         123313   123346      +33     
- Misses        33677    33698      +21     
- Partials       9536     9546      +10     
Impacted Files Coverage Δ
.../batfish/question/routes/RouteRowSecondaryKey.java 76.47% <71.42%> (-0.46%) ⬇️
...ava/org/batfish/common/util/NextHopComparator.java 100.00% <100.00%> (ø)
...ain/java/org/batfish/datamodel/answers/Schema.java 95.60% <100.00%> (+0.09%) ⬆️
...src/main/java/org/batfish/datamodel/table/Row.java 85.55% <100.00%> (+0.16%) ⬆️
...va/org/batfish/question/routes/RoutesAnswerer.java 89.32% <100.00%> (+0.15%) ⬆️
...rg/batfish/question/routes/RoutesAnswererUtil.java 92.13% <100.00%> (+0.13%) ⬆️
.../datamodel/routing_policy/statement/Statement.java 72.72% <0.00%> (-9.10%) ⬇️
...src/main/java/org/batfish/coordinator/PoolMgr.java 55.95% <0.00%> (-4.77%) ⬇️
...ion/a10/A10VirtualServerConfigurationAnswerer.java 92.66% <0.00%> (-2.85%) ⬇️
.../org/batfish/question/routes/DiffRoutesOutput.java 60.97% <0.00%> (-2.44%) ⬇️
... and 7 more

Copy link
Member

@sfraint sfraint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 12 of 12 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @arifogel and @dhalperi)


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/table/Row.java, line 322 at r1 (raw file):

  }

  public @Nullable NextHop getNextHop(String column) {

why Nullable? should there always be some nexthop?

Code quote:

  public @Nullable NextHop getNextHop(String column) {
    return (NextHop) get(column, Schema.NEXT_HOP);
  }

projects/batfish-common-protocol/src/test/java/org/batfish/common/util/NextHopComparatorTest.java, line 20 at r1 (raw file):

  @Test
  public void testCompareClass() {

nit, for this test, would be slightly more readable / easier to maintain if the different NextHop objects were stored in variables instead of repeated for each test

NextHopInterface nhIface = NextHopInterface.of("foo");
...

projects/question/src/main/java/org/batfish/question/routes/RoutesAnswerer.java, line 253 at r1 (raw file):

  private static final Comparator<Row> BGP_COMPARATOR =
      Comparator.<Row, String>comparing(row -> row.getNode(COL_NODE).getName())
          .thenComparing(row -> row.getString(COL_VRF_NAME))

is this comparator needed anymore?

Code quote:

  private static final Comparator<Row> BGP_COMPARATOR =
      Comparator.<Row, String>comparing(row -> row.getNode(COL_NODE).getName())
          .thenComparing(row -> row.getString(COL_VRF_NAME))
          .thenComparing(row -> row.getPrefix(COL_NETWORK))
          .thenComparing(row -> row.getNextHop(COL_NEXT_HOP), NextHopComparator.instance());

projects/question/src/main/java/org/batfish/question/routes/RoutesAnswerer.java, line 360 at r1 (raw file):

                    COL_NEXT_HOP,
                    Schema.NEXT_HOP,
                    "Route's Next Hop IP",

this column is not IP

Code quote:

                    "Route's Next Hop IP",

Copy link
Member Author

@arifogel arifogel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @dhalperi and @sfraint)


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/table/Row.java, line 322 at r1 (raw file):

Previously, sfraint (Spencer Fraint) wrote…

why Nullable? should there always be some nexthop?

Should be null for some route diffs IIRC.


projects/batfish-common-protocol/src/test/java/org/batfish/common/util/NextHopComparatorTest.java, line 20 at r1 (raw file):

Previously, sfraint (Spencer Fraint) wrote…

nit, for this test, would be slightly more readable / easier to maintain if the different NextHop objects were stored in variables instead of repeated for each test

NextHopInterface nhIface = NextHopInterface.of("foo");
...

done


projects/question/src/main/java/org/batfish/question/routes/RoutesAnswerer.java, line 253 at r1 (raw file):

Previously, sfraint (Spencer Fraint) wrote…

is this comparator needed anymore?

Why wouldn't it be? It has two usages in answer:

    switch (question.getRib()) {
      case BGP:
        rows.addAll(
            getBgpRibRoutes(
                dp.getBgpRoutes(),
                dp.getBgpBackupRoutes(),
                matchingVrfsByNode,
                network,
                protocolSpec,
                expandedBgpRouteStatuses,
                question.getPrefixMatchType()));
        rows.sort(BGP_COMPARATOR);
        break;
      case EVPN:
        rows.addAll(
            getEvpnRoutes(
                dp.getEvpnRoutes(),
                dp.getEvpnBackupRoutes(),
                matchingVrfsByNode,
                network,
                protocolSpec,
                ImmutableSet.of(BEST, BACKUP),
                question.getPrefixMatchType()));
        rows.sort(BGP_COMPARATOR);
        break;

projects/question/src/main/java/org/batfish/question/routes/RoutesAnswerer.java, line 360 at r1 (raw file):

Previously, sfraint (Spencer Fraint) wrote…

this column is not IP

fixed

Copy link
Member

@sfraint sfraint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @arifogel and @dhalperi)


projects/question/src/main/java/org/batfish/question/routes/RoutesAnswerer.java, line 253 at r1 (raw file):

Previously, arifogel (Ari Fogel) wrote…

Why wouldn't it be? It has two usages in answer:

    switch (question.getRib()) {
      case BGP:
        rows.addAll(
            getBgpRibRoutes(
                dp.getBgpRoutes(),
                dp.getBgpBackupRoutes(),
                matchingVrfsByNode,
                network,
                protocolSpec,
                expandedBgpRouteStatuses,
                question.getPrefixMatchType()));
        rows.sort(BGP_COMPARATOR);
        break;
      case EVPN:
        rows.addAll(
            getEvpnRoutes(
                dp.getEvpnRoutes(),
                dp.getEvpnBackupRoutes(),
                matchingVrfsByNode,
                network,
                protocolSpec,
                ImmutableSet.of(BEST, BACKUP),
                question.getPrefixMatchType()));
        rows.sort(BGP_COMPARATOR);
        break;

Sorry, I meant: is this comparator identical to the MAIN_RIB_COMPARATOR now that nexthop column comparison is consolidated? if so, do we need to keep two separate, identical comparator instances or can we migrate all usage onto the main rib one?

Copy link
Member Author

@arifogel arifogel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dhalperi and @sfraint)


projects/question/src/main/java/org/batfish/question/routes/RoutesAnswerer.java, line 253 at r1 (raw file):

Previously, sfraint (Spencer Fraint) wrote…

Sorry, I meant: is this comparator identical to the MAIN_RIB_COMPARATOR now that nexthop column comparison is consolidated? if so, do we need to keep two separate, identical comparator instances or can we migrate all usage onto the main rib one?

Ah gotcha. It's possible we may want to sort by some BGP-rib-specific columns in the future. I'd prefer to investigate and address in a separate PR, since I consider that to be out of scope for this PR.

Copy link
Member

@dhalperi dhalperi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dhalperi and @sfraint)

@arifogel arifogel merged commit 5db4e3e into batfish:master Dec 20, 2021
@arifogel arifogel deleted the ari-routes-next-hop-column branch December 20, 2021 22:02
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

Successfully merging this pull request may close these issues.

None yet

4 participants