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

RoutesQuestion: Add more match criteria #7714

Merged
merged 7 commits into from
Nov 20, 2021
Merged

RoutesQuestion: Add more match criteria #7714

merged 7 commits into from
Nov 20, 2021

Conversation

ratulm
Copy link
Member

@ratulm ratulm commented Nov 19, 2021

For the main RIB only.

@batfish-bot
Copy link

This change is Reviewable

Copy link
Contributor

@anothermattbrown anothermattbrown left a comment

Choose a reason for hiding this comment

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

Reviewed 11 of 12 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @ratulm)


projects/question/src/main/java/org/batfish/question/routes/RoutesAnswererUtil.java, line 176 at r2 (raw file):

mainRib

Is any of this specific to the main RIB? Can we rename to rib?


projects/question/src/main/java/org/batfish/question/routes/RoutesAnswererUtil.java, line 202 at r2 (raw file):

      case LONGEST_PREFIX_MATCH: // handled separately
      default:
        throw new IllegalArgumentException("Illegal PrefixMatchType " + prefixMatchType);

To make our lives easier if/when we add more match types, I would distinguish between illegal (LPM) and unimplemented new match types.


projects/question/src/main/java/org/batfish/question/routes/RoutesQuestion.java, line 60 at r2 (raw file):

all prefixes equal or longer than the input network; can return multiple prefixes

only matches prefixes contained by the input network?


projects/question/src/main/java/org/batfish/question/routes/RoutesQuestion.java, line 62 at r2 (raw file):

all prefixes equal or shorter than the input network; can return multiple prefixes 

only matches prefixes that contain the input network?


projects/question/src/main/java/org/batfish/question/routes/RoutesQuestion.java, line 68 at r2 (raw file):

only for main RIB

why doesn't this work for other RIBs?


projects/question/src/test/java/org/batfish/question/routes/RoutesAnswererUtilTest.java, line 945 at r2 (raw file):

testPrefixMatches() 

please add test cases for longer/shorter prefixes without containment

Copy link
Member Author

@ratulm ratulm 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, 3 unresolved discussions (waiting on @anothermattbrown)


projects/question/src/main/java/org/batfish/question/routes/RoutesAnswererUtil.java, line 176 at r2 (raw file):

Previously, anothermattbrown (Matt Brown) wrote…
mainRib

Is any of this specific to the main RIB? Can we rename to rib?

This code is not specific. So, renamed. But it will be called only on the main RIB.


projects/question/src/main/java/org/batfish/question/routes/RoutesQuestion.java, line 60 at r2 (raw file):

Previously, anothermattbrown (Matt Brown) wrote…
all prefixes equal or longer than the input network; can return multiple prefixes

only matches prefixes contained by the input network?

Done.


projects/question/src/main/java/org/batfish/question/routes/RoutesQuestion.java, line 62 at r2 (raw file):

Previously, anothermattbrown (Matt Brown) wrote…
all prefixes equal or shorter than the input network; can return multiple prefixes 

only matches prefixes that contain the input network?

Done.


projects/question/src/main/java/org/batfish/question/routes/RoutesQuestion.java, line 68 at r2 (raw file):

Previously, anothermattbrown (Matt Brown) wrote…
only for main RIB

why doesn't this work for other RIBs?

FWICT, protocol RIBs do not appear to be stored as RIB but as set of routes. So, LPM on that is extra work.

Copy link
Contributor

@anothermattbrown anothermattbrown 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 6 files at r3.
Reviewable status: 9 of 13 files reviewed, 2 unresolved discussions (waiting on @anothermattbrown and @ratulm)


projects/question/src/main/java/org/batfish/question/routes/RoutesQuestion.java, line 68 at r2 (raw file):

Previously, ratulm wrote…

FWICT, protocol RIBs do not appear to be stored as RIB but as set of routes. So, LPM on that is extra work.

it should be easy/efficient enough to create a PrefixTrieMultiMap containing the matching routes and then call longestPrefixMatch(Ip address, int maxPrefixLength).

Copy link
Contributor

@anothermattbrown anothermattbrown left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 6 files at r3.
Reviewable status: 10 of 13 files reviewed, 1 unresolved discussion (waiting on @anothermattbrown and @ratulm)


projects/question/src/main/java/org/batfish/question/routes/RoutesQuestion.java, line 68 at r2 (raw file):

Previously, anothermattbrown (Matt Brown) wrote…

it should be easy/efficient enough to create a PrefixTrieMultiMap containing the matching routes and then call longestPrefixMatch(Ip address, int maxPrefixLength).

or just do it directly -- find the max length of matching networks, then do exact match. doesn't seem like that much extra work

Copy link
Member Author

@ratulm ratulm 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: 10 of 13 files reviewed, 1 unresolved discussion (waiting on @anothermattbrown)


projects/question/src/main/java/org/batfish/question/routes/RoutesQuestion.java, line 68 at r2 (raw file):

Previously, anothermattbrown (Matt Brown) wrote…

or just do it directly -- find the max length of matching networks, then do exact match. doesn't seem like that much extra work

sure, on it.

Copy link
Contributor

@anothermattbrown anothermattbrown 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 6 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @anothermattbrown)

@codecov
Copy link

codecov bot commented Nov 19, 2021

Codecov Report

Merging #7714 (38bf63b) into master (26c226e) will increase coverage by 0.01%.
The diff coverage is 87.05%.

@@             Coverage Diff              @@
##             master    #7714      +/-   ##
============================================
+ Coverage     73.81%   73.82%   +0.01%     
- Complexity    41814    41873      +59     
============================================
  Files          3282     3290       +8     
  Lines        164631   164798     +167     
  Branches      19782    19793      +11     
============================================
+ Hits         121515   121661     +146     
- Misses        33623    33636      +13     
- Partials       9493     9501       +8     
Impacted Files Coverage Δ
...va/org/batfish/question/routes/RoutesAnswerer.java 89.00% <60.00%> (+1.50%) ⬆️
...rg/batfish/question/routes/RoutesAnswererUtil.java 91.91% <91.66%> (+0.53%) ⬆️
...va/org/batfish/question/routes/RoutesQuestion.java 100.00% <100.00%> (ø)
.../datamodel/routing_policy/statement/Statement.java 72.72% <0.00%> (-9.10%) ⬇️
...fish/bddreachability/BDDLoopDetectionAnalysis.java 80.23% <0.00%> (-2.33%) ⬇️
...ava/org/batfish/datamodel/bgp/Layer2VniConfig.java 80.00% <0.00%> (-2.00%) ⬇️
...ain/java/org/batfish/storage/FileBasedStorage.java 85.45% <0.00%> (-0.86%) ⬇️
...java/org/batfish/dataplane/ibdp/VirtualRouter.java 89.16% <0.00%> (-0.29%) ⬇️
...sh/vendor/a10/representation/A10Configuration.java 95.48% <0.00%> (-0.19%) ⬇️
...sh/vendor/a10/representation/A10StructureType.java 100.00% <0.00%> (ø)
... and 10 more

Copy link
Contributor

@anothermattbrown anothermattbrown left a comment

Choose a reason for hiding this comment

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

Reviewed 10 of 10 files at r5, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @ratulm)


projects/question/src/main/java/org/batfish/question/routes/RoutesAnswererUtil.java, line 687 at r3 (raw file):

BgpRouteStatus.

why remove qualification here but not elsewhere?


projects/question/src/main/java/org/batfish/question/routes/RoutesAnswererUtil.java, line 305 at r5 (raw file):

   * <p>It the prefix match type is LONGEST_PREFIX_MATCH, the returned prefix is decided based on
   * LPM on the best routes table.

this is based on the invariant that the backup table won't contain any longer prefixes (because they would not be backing anything up)? would be helpful to document that.


projects/question/src/main/java/org/batfish/question/routes/RoutesAnswererUtil.java, line 334 at r5 (raw file):

PrefixMatchType.EXACT

why hard-code exact here?


projects/question/src/test/java/org/batfish/question/routes/RoutesAnswererUtilTest.java, line 1159 at r5 (raw file):

EXACT

this block says it's testing LPM


projects/question/src/test/java/org/batfish/question/routes/RoutesAnswererUtilTest.java, line 1194 at r5 (raw file):

multi-prefix matcher

for LONGER_PREFIXES, we should test that equal prefixes are included and shorter prefixes are excluded (and similarly for shorter).

Copy link
Member Author

@ratulm ratulm 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, 5 unresolved discussions (waiting on @anothermattbrown)


projects/question/src/main/java/org/batfish/question/routes/RoutesAnswererUtil.java, line 687 at r3 (raw file):

Previously, anothermattbrown (Matt Brown) wrote…
BgpRouteStatus.

why remove qualification here but not elsewhere?

IDE ...


projects/question/src/main/java/org/batfish/question/routes/RoutesAnswererUtil.java, line 305 at r5 (raw file):

Previously, anothermattbrown (Matt Brown) wrote…
   * <p>It the prefix match type is LONGEST_PREFIX_MATCH, the returned prefix is decided based on
   * LPM on the best routes table.

this is based on the invariant that the backup table won't contain any longer prefixes (because they would not be backing anything up)? would be helpful to document that.

Done.


projects/question/src/main/java/org/batfish/question/routes/RoutesAnswererUtil.java, line 334 at r5 (raw file):

Previously, anothermattbrown (Matt Brown) wrote…
PrefixMatchType.EXACT

why hard-code exact here?

ooooh. BUG!


projects/question/src/test/java/org/batfish/question/routes/RoutesAnswererUtilTest.java, line 1159 at r5 (raw file):

Previously, anothermattbrown (Matt Brown) wrote…
EXACT

this block says it's testing LPM

Done.


projects/question/src/test/java/org/batfish/question/routes/RoutesAnswererUtilTest.java, line 1194 at r5 (raw file):

Previously, anothermattbrown (Matt Brown) wrote…
multi-prefix matcher

for LONGER_PREFIXES, we should test that equal prefixes are included and shorter prefixes are excluded (and similarly for shorter).

That testing is there in testPrefixMatches. The function being tested here delegates to prefixMatches. You see value in doing it here too?

Copy link
Contributor

@anothermattbrown anothermattbrown 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 r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ratulm)


projects/question/src/main/java/org/batfish/question/routes/RoutesAnswererUtil.java, line 324 at r6 (raw file):

   * A consequence of these semantics is that if the user asks only for backup routes (via
   * routeStatus), nothing may be reported in cases where the LPM-based matching on the best table
   * leads to prefix P1 but P1 is not present in the backup table.

This seems like a weird UX, though I'm not sure what the use case of LPM matching over only backup routes would be...


projects/question/src/test/java/org/batfish/question/routes/RoutesAnswererUtilTest.java, line 1194 at r5 (raw file):

Previously, ratulm wrote…

That testing is there in testPrefixMatches. The function being tested here delegates to prefixMatches. You see value in doing it here too?

nope that sounds right

Copy link
Member Author

@ratulm ratulm 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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ratulm)


projects/question/src/main/java/org/batfish/question/routes/RoutesAnswererUtil.java, line 324 at r6 (raw file):

Previously, anothermattbrown (Matt Brown) wrote…
   * A consequence of these semantics is that if the user asks only for backup routes (via
   * routeStatus), nothing may be reported in cases where the LPM-based matching on the best table
   * leads to prefix P1 but P1 is not present in the backup table.

This seems like a weird UX, though I'm not sure what the use case of LPM matching over only backup routes would be...

FWIW, a similar issue is happening with protocol filters: do LPM first, and then filter. This semantics is consistent with what is happening there.

We can revisit if it seems counter-intuitive to users. Need to lookup what routers do as well.

Copy link
Member Author

@ratulm ratulm left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ratulm)

@ratulm ratulm merged commit c9458b1 into master Nov 20, 2021
@ratulm ratulm deleted the routes-match-type branch November 20, 2021 04:21
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

3 participants