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

juniper conversion for 'from condition' #6749

Merged
merged 9 commits into from
Mar 22, 2021

Conversation

arifogel
Copy link
Member

  • add route policy primitives for getting main rib routes
  • add route policy primitives for checking presence of another route in
    the main rib matching some condition
  • implement conversion for juniper 'from condition' based on new route
    policy primitives

- add route policy primitives for getting main rib routes
- add route policy primitives for checking presence of another route in
the main rib matching some condition
- implement conversion for juniper 'from condition' based on new route
policy primitives
@batfish-bot
Copy link

This change is Reviewable

@codecov
Copy link

codecov bot commented Mar 18, 2021

Codecov Report

Merging #6749 (f186455) into master (90f3c44) will increase coverage by 0.13%.
The diff coverage is 93.10%.

@@             Coverage Diff              @@
##             master    #6749      +/-   ##
============================================
+ Coverage     69.51%   69.65%   +0.13%     
- Complexity    35916    36081     +165     
============================================
  Files          3011     3020       +9     
  Lines        153079   153262     +183     
  Branches      18402    18428      +26     
============================================
+ Hits         106420   106751     +331     
+ Misses        38065    37900     -165     
- Partials       8594     8611      +17     
Impacted Files Coverage Δ Complexity Δ
...atfish/datamodel/routing_policy/RoutingPolicy.java 93.40% <83.33%> (-0.92%) 31.00 <3.00> (+1.00) ⬇️
.../org/batfish/dataplane/ibdp/BgpRoutingProcess.java 84.92% <83.33%> (+0.01%) 151.00 <0.00> (ø)
.../routing_policy/expr/RibIntersectsPrefixSpace.java 86.95% <86.95%> (ø) 12.00 <12.00> (?)
...java/org/batfish/datamodel/PrefixTrieMultiMap.java 85.95% <91.66%> (+0.41%) 55.00 <1.00> (+1.00)
...del/bgp/community/CommunityStructuresVerifier.java 96.70% <100.00%> (+0.05%) 13.00 <0.00> (ø)
.../batfish/datamodel/routing_policy/Environment.java 87.64% <100.00%> (+0.28%) 42.00 <1.00> (+1.00)
...tamodel/routing_policy/expr/ExplicitPrefixSet.java 61.53% <100.00%> (+9.53%) 8.00 <1.00> (+2.00)
...batfish/datamodel/routing_policy/expr/MainRib.java 100.00% <100.00%> (ø) 6.00 <6.00> (?)
...tfish/datamodel/visitors/PrefixSpaceEvaluator.java 100.00% <100.00%> (ø) 4.00 <4.00> (?)
...org/batfish/dataplane/ibdp/OspfRoutingProcess.java 92.87% <100.00%> (ø) 188.00 <0.00> (ø)
... and 58 more

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 24 of 26 files at r1, 2 of 2 files at r2.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @anothermattbrown and @arifogel)


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/routing_policy/expr/HasMatchingRoute.java, line 46 at r2 (raw file):

    Collection<AbstractRoute> routeCandidates =
        _routesExpr.accept(RoutesExprEvaluator.instance(), environment);

This feels really heavyweight - build a collection of all the routes in the main RIB as a precursor to any work, when the most typical (only known?) is "is this prefix present". Is there a better way?

- provide RibExpr instead of RoutesExpr, which is evaluated by data plane code
- instead of testing each rib route, check for for intersection of Rib and PrefixSpace
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: 3 of 36 files reviewed, 1 unresolved discussion (waiting on @anothermattbrown and @dhalperi)


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/routing_policy/expr/HasMatchingRoute.java, line 46 at r2 (raw file):

Previously, dhalperi (Dan Halperin) wrote…
    Collection<AbstractRoute> routeCandidates =
        _routesExpr.accept(RoutesExprEvaluator.instance(), environment);

This feels really heavyweight - build a collection of all the routes in the main RIB as a precursor to any work, when the most typical (only known?) is "is this prefix present". Is there a better way?

Now GenericRib has function to check intersection with a PrefixSpace, which should be much more efficient.

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 37 files at r3.
Reviewable status: 5 of 36 files reviewed, 1 unresolved discussion (waiting on @dhalperi)

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.

Reviewable status: 5 of 36 files reviewed, 1 unresolved discussion (waiting on @dhalperi)


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/PrefixTrieMultiMap.java, line 254 at r3 (raw file):

return true.

probably worth documenting here that this this node has any elements means _prefix is a key.

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.

:lgtm:

Reviewed 35 of 37 files at r3.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @arifogel)


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/GenericRibReadOnly.java, line 56 at r3 (raw file):

 to routes in this rib

Is it worth clarifying what we mean by this? Active routes, installed routes, forwarding routes, routing routes, etc?


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/route/nh/NextHop.java, line 19 at r3 (raw file):

4 

revert?


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/routing_policy/RoutingPolicy.java, line 243 at r3 (raw file):

public boolean processBgpRoute(

kill this one? When we have a ton of them, it just leads to us using the wrong one over and over again.


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/routing_policy/expr/RibIntersectsPrefixSpace.java, line 50 at r3 (raw file):

Cannot check RIB routes outside of data plane generation

Maybe something that's mildly more user-facing (just less specific to Batfish internals), such as "Cannot check RIB routes; main RIB state is not available at this time"

Also would be robust to code where we call the wrong process function and forget to build environment correctly.


projects/batfish-common-protocol/src/test/java/org/batfish/datamodel/MockRib.java, line 83 at r3 (raw file):

Quoted 7 lines of code…
    return !new PrefixSpace(
            _routes.stream()
                .map(AnnotatedRoute::getNetwork)
                .map(PrefixRange::fromPrefix)
                .collect(ImmutableList.toImmutableList()))
        .intersection(prefixSpace)
        .isEmpty();

optional: can this not be moved inside the stream / no collection needed?

Also: PrefixSpace has overlaps for intersection!empty and also has containsPrefix which is maybe even simpler?

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: 30 of 39 files reviewed, 3 unresolved discussions (waiting on @anothermattbrown and @dhalperi)


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/GenericRibReadOnly.java, line 56 at r3 (raw file):

Previously, dhalperi (Dan Halperin) wrote…
 to routes in this rib

Is it worth clarifying what we mean by this? Active routes, installed routes, forwarding routes, routing routes, etc?

It means any routes in this rib. Is there a need to clarify when there is no restriction?


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/PrefixTrieMultiMap.java, line 254 at r3 (raw file):

Previously, anothermattbrown (Matt Brown) wrote…
return true.

probably worth documenting here that this this node has any elements means _prefix is a key.

done


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/route/nh/NextHop.java, line 19 at r3 (raw file):

Previously, dhalperi (Dan Halperin) wrote…
4 

revert?

done


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/routing_policy/RoutingPolicy.java, line 243 at r3 (raw file):

Previously, dhalperi (Dan Halperin) wrote…
public boolean processBgpRoute(

kill this one? When we have a ton of them, it just leads to us using the wrong one over and over again.

ok. i feel like more cleanup is warranted, but stopping at removing this one for now.


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/routing_policy/expr/RibIntersectsPrefixSpace.java, line 50 at r3 (raw file):

Previously, dhalperi (Dan Halperin) wrote…
Cannot check RIB routes outside of data plane generation

Maybe something that's mildly more user-facing (just less specific to Batfish internals), such as "Cannot check RIB routes; main RIB state is not available at this time"

Also would be robust to code where we call the wrong process function and forget to build environment correctly.

changed


projects/batfish-common-protocol/src/test/java/org/batfish/datamodel/MockRib.java, line 83 at r3 (raw file):

Previously, dhalperi (Dan Halperin) wrote…
    return !new PrefixSpace(
            _routes.stream()
                .map(AnnotatedRoute::getNetwork)
                .map(PrefixRange::fromPrefix)
                .collect(ImmutableList.toImmutableList()))
        .intersection(prefixSpace)
        .isEmpty();

optional: can this not be moved inside the stream / no collection needed?

Also: PrefixSpace has overlaps for intersection!empty and also has containsPrefix which is maybe even simpler?

simplified

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 10 of 10 files at r4.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @arifogel)


projects/batfish/src/main/java/org/batfish/dataplane/ibdp/BgpRoutingProcess.java, line 821 at r4 (raw file):

          acceptIncoming =
              importPolicy.processBgpRoute(
                  remoteRoute, transformedIncomingRouteBuilder, sessionProperties, IN, null);

So now I'm confused which parts of the pipeline need the evaluator. Isn't importing routes from peers the main one?


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/GenericRibReadOnly.java, line 56 at r3 (raw file):

Previously, arifogel (Ari Fogel) wrote…

It means any routes in this rib. Is there a need to clarify when there is no restriction?

I guess it depends on what "in" means? The RIB has transitive pointers to backup routes, non-forwarding routes, (maybe?) non-routing routes, etc.

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 @arifogel and @dhalperi)


projects/batfish/src/main/java/org/batfish/dataplane/ibdp/BgpRoutingProcess.java, line 821 at r4 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

So now I'm confused which parts of the pipeline need the evaluator. Isn't importing routes from peers the main one?

On XR, any part of the pipeline can use the evaluator. Seems the most common is generating default routes for various protocols.

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 @arifogel and @dhalperi)


projects/batfish/src/main/java/org/batfish/dataplane/ibdp/BgpRoutingProcess.java, line 821 at r4 (raw file):

Previously, arifogel (Ari Fogel) wrote…

On XR, any part of the pipeline can use the evaluator. Seems the most common is generating default routes for various protocols.

..but on Juniper, I think it's really any part that uses a policy.

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.

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


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/GenericRibReadOnly.java, line 56 at r3 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

I guess it depends on what "in" means? The RIB has transitive pointers to backup routes, non-forwarding routes, (maybe?) non-routing routes, etc.

Offline discussion; "in the rib" means "returned by {@link #getRoutes}"

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: 38 of 39 files reviewed, 2 unresolved discussions (waiting on @dhalperi)


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/GenericRibReadOnly.java, line 56 at r3 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

Offline discussion; "in the rib" means "returned by {@link #getRoutes}"

updated

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 1 of 1 files at r5.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dhalperi)

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 1 of 1 files at r6.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

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.

Reviewed 1 of 1 files at r7.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@arifogel arifogel merged commit 91537bc into batfish:master Mar 22, 2021
@arifogel arifogel deleted the ari-has-matching-route branch March 22, 2021 20:42
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