-
Notifications
You must be signed in to change notification settings - Fork 229
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
Conversation
- 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
Codecov Report
@@ 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 |
There was a problem hiding this 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
There was a problem hiding this 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.
There was a problem hiding this 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)
There was a problem hiding this 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this 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
forintersection!empty
and also hascontainsPrefix
which is maybe even simpler?
simplified
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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}
"
There was a problem hiding this 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
There was a problem hiding this 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)
There was a problem hiding this 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:complete! all files reviewed, all discussions resolved
There was a problem hiding this 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:complete! all files reviewed, all discussions resolved
the main rib matching some condition
policy primitives