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

Adding reachability check for IPsec tunnels #3931

Merged
merged 7 commits into from
May 24, 2019
Merged

Adding reachability check for IPsec tunnels #3931

merged 7 commits into from
May 24, 2019

Conversation

haverma
Copy link

@haverma haverma commented May 23, 2019

Now checking connectivity in the underlay network to properly verify the establishment of the IPsec based tunnels. This check is employed while we compute the fixed point IPsec topology in BDP engine.

More detailed intuition behind this change can be found here.

@batfish-bot
Copy link

This change is Reviewable

@haverma haverma requested a review from progwriter May 23, 2019 10:06
@codecov
Copy link

codecov bot commented May 23, 2019

Codecov Report

Merging #3931 into master will increase coverage by <.01%.
The diff coverage is 86.04%.

@@             Coverage Diff              @@
##             master    #3931      +/-   ##
============================================
+ Coverage     74.86%   74.86%   +<.01%     
- Complexity    24089    24106      +17     
============================================
  Files          2027     2027              
  Lines         96668    96755      +87     
  Branches      11509    11526      +17     
============================================
+ Hits          72367    72438      +71     
- Misses        19044    19053       +9     
- Partials       5257     5264       +7
Impacted Files Coverage Δ Complexity Δ
.../main/java/org/batfish/datamodel/IpsecSession.java 74.5% <ø> (ø) 8 <0> (ø) ⬇️
...g/batfish/dataplane/ibdp/IncrementalBdpEngine.java 90.32% <100%> (+0.07%) 85 <0> (ø) ⬇️
...c/main/java/org/batfish/common/util/IpsecUtil.java 85.53% <84.61%> (-0.31%) 72 <15> (+15)
.../src/main/java/org/batfish/datamodel/flow/Hop.java 53.33% <0%> (-6.67%) 5% <0%> (-1%)
...java/org/batfish/symbolic/state/EdgeStateExpr.java 80.95% <0%> (-4.77%) 10% <0%> (-1%)
...org/batfish/datamodel/flow/BidirectionalTrace.java 79.54% <0%> (-4.55%) 13% <0%> (-2%)
...rc/main/java/org/batfish/datamodel/flow/Trace.java 87.09% <0%> (-3.23%) 11% <0%> (-2%)
...ava/org/batfish/datamodel/bgp/Layer2VniConfig.java 85.71% <0%> (-2.86%) 15% <0%> (-1%)
...col/src/main/java/org/batfish/role/InferRoles.java 91.24% <0%> (-0.37%) 68% <0%> (-1%)
...tfish/representation/cisco/CiscoConfiguration.java 83.8% <0%> (-0.13%) 530% <0%> (-1%)
... and 5 more

Copy link
Contributor

@progwriter progwriter left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 4 files at r1.
Reviewable status: 3 of 4 files reviewed, 7 unresolved discussions (waiting on @haverma and @progwriter)


projects/batfish/src/main/java/org/batfish/dataplane/ibdp/IncrementalBdpEngine.java, line 140 at r1 (raw file):

                  initialTopologyContext.getIpsecTopology(),
                  configurations,
                  new TracerouteEngineImpl(

time to factor out the engine into a variable? why are we re-creating it three times here?


projects/batfish/src/test/java/org/batfish/dataplane/ibdp/FixedPointTopologyTest.java, line 407 at r1 (raw file):

            .build();
    IncrementalBdpEngine engine =
        new IncrementalBdpEngine(

Using org.batfish.main.BatfishTestUtils#getBatfish and do batfish.computeDataplane() seems much easier and in line with other tests. (applies elsewhere in the file)


projects/batfish-common-protocol/src/main/java/org/batfish/common/util/IpsecUtil.java, line 546 at r1 (raw file):

      }

      Optional<IpsecSession> ipsecSession = ipsecTopology.getGraph().edgeValue(peerIdU, peerIdV);

I personally like to do the .orElse(null) at the end, that way your var type is not optional, you don't get to get() a bunch of times below, and you can still do if equal to null, continue.


projects/batfish-common-protocol/src/main/java/org/batfish/common/util/IpsecUtil.java, line 555 at r1 (raw file):

      }

      if (ipsecSession.get().isCloud()

Comment why we're doing this -- it's a workaround until we're confident ISP modeling will let us do traceroutes properly.


projects/batfish-common-protocol/src/main/java/org/batfish/common/util/IpsecUtil.java, line 576 at r1 (raw file):

   * IPsec encrypted data
   */
  private static boolean reachableIpsecEdge(

We should think for a better name. edges aren't reachable by themselves. nor does this return an edge (as the name would imply). perhaps isIpsecPeerReachable?


projects/batfish-common-protocol/src/main/java/org/batfish/common/util/IpsecUtil.java, line 644 at r1 (raw file):

    List<Trace> traces =
        tracerouteEngine
            .computeTraces(ImmutableSet.of(flowForIpsecNegotiation), false)

should we use bidir traceroute here?


projects/batfish-common-protocol/src/main/java/org/batfish/common/util/IpsecUtil.java, line 649 at r1 (raw file):

        .noneMatch(
            trace -> {
              List<Hop> hops = trace.getHops();

factor into a small static function: boolean isSuccessfulTraceroute(trace, hostname)

Copy link
Contributor

@progwriter progwriter 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 4 files at r1.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @haverma)

Copy link
Author

@haverma haverma 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: 2 of 4 files reviewed, 2 unresolved discussions (waiting on @progwriter)


projects/batfish/src/main/java/org/batfish/dataplane/ibdp/IncrementalBdpEngine.java, line 140 at r1 (raw file):

Previously, progwriter (Victor Heorhiadi) wrote…

time to factor out the engine into a variable? why are we re-creating it three times here?

makes sense, done. newBgpTopology is using the newLayer3Topology so done only for VXLAN and IPsec.


projects/batfish/src/test/java/org/batfish/dataplane/ibdp/FixedPointTopologyTest.java, line 407 at r1 (raw file):

Previously, progwriter (Victor Heorhiadi) wrote…

Using org.batfish.main.BatfishTestUtils#getBatfish and do batfish.computeDataplane() seems much easier and in line with other tests. (applies elsewhere in the file)

If I use batfish.computeDataplane() then I would need to instantiate every required property of IPsec in the two configurations, so that the IPsec topology can be inferred. But if I call IncrementalBdpEngine.computeDataplane(), I can directly pass the (bare minimum) IPsec topology in the TopologyContext, thus making the setup network a little less verbose.
I copied the pattern used in FixedPointTopologyTest.testFixedPointVxlanTopology()


projects/batfish-common-protocol/src/main/java/org/batfish/common/util/IpsecUtil.java, line 546 at r1 (raw file):

Previously, progwriter (Victor Heorhiadi) wrote…

I personally like to do the .orElse(null) at the end, that way your var type is not optional, you don't get to get() a bunch of times below, and you can still do if equal to null, continue.

done


projects/batfish-common-protocol/src/main/java/org/batfish/common/util/IpsecUtil.java, line 555 at r1 (raw file):

Previously, progwriter (Victor Heorhiadi) wrote…

Comment why we're doing this -- it's a workaround until we're confident ISP modeling will let us do traceroutes properly.

done


projects/batfish-common-protocol/src/main/java/org/batfish/common/util/IpsecUtil.java, line 576 at r1 (raw file):

Previously, progwriter (Victor Heorhiadi) wrote…

We should think for a better name. edges aren't reachable by themselves. nor does this return an edge (as the name would imply). perhaps isIpsecPeerReachable?

makes sense, changed as suggested


projects/batfish-common-protocol/src/main/java/org/batfish/common/util/IpsecUtil.java, line 644 at r1 (raw file):

Previously, progwriter (Victor Heorhiadi) wrote…

should we use bidir traceroute here?

From my understanding I thought that bidirectional traceroute cannot be done for UDP (or non TCP) flow. I got this idea from VxlanTopologyUtils.reachableEdge() (and also by looking at its PR)
If it is incorrect, I can surely change it to bidirectional traceroute.


projects/batfish-common-protocol/src/main/java/org/batfish/common/util/IpsecUtil.java, line 649 at r1 (raw file):

Previously, progwriter (Victor Heorhiadi) wrote…

factor into a small static function: boolean isSuccessfulTraceroute(trace, hostname)

done, using a static function isSuccessfulTraceroute( Flow flow, String destinationNode, TracerouteEngine tracerouteEngine)

Copy link
Contributor

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

Copy link
Author

@haverma haverma 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 4 files reviewed, all discussions resolved (waiting on @progwriter)


projects/batfish-common-protocol/src/main/java/org/batfish/common/util/IpsecUtil.java, line 644 at r1 (raw file):

Previously, haverma (Harsh Verma) wrote…

From my understanding I thought that bidirectional traceroute cannot be done for UDP (or non TCP) flow. I got this idea from VxlanTopologyUtils.reachableEdge() (and also by looking at its PR)
If it is incorrect, I can surely change it to bidirectional traceroute.

Using bi-directional traceroute now

Copy link
Contributor

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


projects/batfish/src/test/java/org/batfish/dataplane/ibdp/FixedPointTopologyTest.java, line 407 at r1 (raw file):

Previously, haverma (Harsh Verma) wrote…

If I use batfish.computeDataplane() then I would need to instantiate every required property of IPsec in the two configurations, so that the IPsec topology can be inferred. But if I call IncrementalBdpEngine.computeDataplane(), I can directly pass the (bare minimum) IPsec topology in the TopologyContext, thus making the setup network a little less verbose.
I copied the pattern used in FixedPointTopologyTest.testFixedPointVxlanTopology()

I see. We need better test utils API for dataplane tests then. But that, of course, is not a blocker.

@haverma haverma merged commit dfa1cc3 into master May 24, 2019
@haverma haverma deleted the ipsec-reach branch May 24, 2019 16:50
agember pushed a commit to colgate-cs-research/batfish that referenced this pull request May 28, 2019
* adding and setting cloud flag in IPsec session

* using bidirectional traceroute
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