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

allowing dst (node or IP) as a traceroute parameter #805

Merged
merged 8 commits into from
Dec 28, 2017

Conversation

ratulm
Copy link
Member

@ratulm ratulm commented Dec 27, 2017

Partial fix to #622.

Change dstIp parameter to dst which can be an IP or a hostname. If the latter, we use the "canonical IP" for the host.


This change is Reviewable

@dhalperi
Copy link
Member

Reviewed 10 of 10 files at r1.
Review status: all files reviewed at latest revision, 4 unresolved discussions.


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

  /** Returns the lowest IP across all interfaces for now. We'll improve it later. */
  @JsonIgnore

Add @Nullable


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

    } else {
      return null;
    }

Use the java8 built-in support for minimum over a stream.

  /** Returns the lowest IP across all interfaces for now. We'll improve it later. */
  @JsonIgnore
  @Nullable
  public Ip getCanonicalIp() {
    return getVrfs()
        .values()
        .stream()
        .flatMap(v -> v.getInterfaces().values().stream())
        .flatMap(i -> i.getAllPrefixes().stream())
        .map(Prefix::getAddress)
        .min(Ip::compareTo)
        .orElse(null);
  }

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

  }

  public static Ip createIpOrNull(String addr) {

Would prefer to keep this logic inline where you have it now rather than in the Ip class itself. Does not seem very general.


projects/question/src/main/java/org/batfish/question/TracerouteQuestionPlugin.java, line 600 at r1 (raw file):

    }

    @Override

Why delete this @Override?


Comments from Reviewable

@ratulm
Copy link
Member Author

ratulm commented Dec 28, 2017

Review status: all files reviewed at latest revision, 4 unresolved discussions.


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

Previously, dhalperi (Dan Halperin) wrote…

Add @Nullable

Done.


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

Previously, dhalperi (Dan Halperin) wrote…

Use the java8 built-in support for minimum over a stream.

  /** Returns the lowest IP across all interfaces for now. We'll improve it later. */
  @JsonIgnore
  @Nullable
  public Ip getCanonicalIp() {
    return getVrfs()
        .values()
        .stream()
        .flatMap(v -> v.getInterfaces().values().stream())
        .flatMap(i -> i.getAllPrefixes().stream())
        .map(Prefix::getAddress)
        .min(Ip::compareTo)
        .orElse(null);
  }

Done.


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

Previously, dhalperi (Dan Halperin) wrote…

Would prefer to keep this logic inline where you have it now rather than in the Ip class itself. Does not seem very general.

done. had to change the visibility of a function in Ip.java.


projects/question/src/main/java/org/batfish/question/TracerouteQuestionPlugin.java, line 600 at r1 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

Why delete this @Override?

accident. done.


Comments from Reviewable

@dhalperi
Copy link
Member

Reviewed 4 of 4 files at r2.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/Ip.java, line 37 at r2 (raw file):

  public static final Ip ZERO = new Ip(0L);

  public static long ipStrToLong(String addr) {

Why do this vs just using the new Ip(String) constructor?, which calls ipStrToLong internally?


projects/question/src/main/java/org/batfish/question/TracerouteQuestionPlugin.java, line 307 at r2 (raw file):

      if (_dst != null) {
        try {
          Ip dstIp = new Ip(Ip.ipStrToLong(_dst));

I think this is the same as the existing new Ip(String) constructor without the visibility change.


Comments from Reviewable

@ratulm
Copy link
Member Author

ratulm commented Dec 28, 2017

Review status: 9 of 11 files reviewed at latest revision, 2 unresolved discussions.


projects/batfish-common-protocol/src/main/java/org/batfish/datamodel/Ip.java, line 37 at r2 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

Why do this vs just using the new Ip(String) constructor?, which calls ipStrToLong internally?

argh. i am stupid.


projects/question/src/main/java/org/batfish/question/TracerouteQuestionPlugin.java, line 307 at r2 (raw file):

argh. i am stupid.


Comments from Reviewable

@dhalperi
Copy link
Member

Reviewed 1 of 2 files at r3.
Review status: 10 of 11 files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@dhalperi
Copy link
Member

:lgtm:


Reviewed 1 of 2 files at r3.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@ratulm ratulm merged commit 524a4d9 into master Dec 28, 2017
@ratulm ratulm deleted the nodename-traceroute branch December 28, 2017 01:36
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

2 participants