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

astraceroute: stopping when target is reached, finer control on number of packets sent, and other smaller changes #210

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

uno20001
Copy link
Contributor

I would like to apologize in advance for the size of this commit. The changes should have been implemented in multiple commits. This was a serious oversight on my part. I also interpreted the 80 character line length limit quite liberally in some places.

The necessary changes have been implemented in order for astraceroute to stop when a response arrives from the target. Furthermore the MAN page has been updated.

Change log:

  • IPv4 and IPv6 BPF filter have been updated to accept the necessary packets (which enable the program to stop when the target responds)
  • check_ipv4() and check_ipv6() have been more or less rewritten to make stopping possible
  • finer control is given to the user on the number of packets sent; a new option: -s, --num-packets have been added to specify the number of packets sent in one probe
  • most of the panic() messages have been updated to print errno and the actual error message from the system call
  • PF_* constants have been replaced by AF_* constants where I deemed the change appropriate
  • the MAN page and help() have been modified to reflect the changes, and extended with extra information for some options
  • default configuration values are now preprocessor constant

I have tested the changes on multiple machines, with both IPv4 and IPv6, and the program seems to function correctly, however, it is very much possible that bugs have been introduced into the codebase.

This PR should fix issue #204.

The commits have not been squashed and signed off yet, and will not be until the fate of this PR is decided.

@tklauser
Copy link
Member

Thanks for the PR.

I would like to apologize in advance for the size of this commit. The changes should have been implemented in multiple commits. This was a serious oversight on my part. I also interpreted the 80 character line length limit quite liberally in some places.

Yes, the commit is definitely too large for me to review and touches many (partially unrelated) things which makes it even harder. Please try to split it up into several smaller commits which do just one thing at a time. As for the 80 character line limit, feel free to interpret it liberally. I have done so in the past as well :)

Maybe start with the cleanup changes and then the actual fix for issue #204.

Change log:

  • IPv4 and IPv6 BPF filter have been updated to accept the necessary packets (which enable the program to stop when the target responds)

  • check_ipv4() and check_ipv6() have been more or less rewritten to make stopping possible

  • finer control is given to the user on the number of packets sent; a new option: -s, --num-packets have been added to specify the number of packets sent in one probe

  • most of the panic() messages have been updated to print errno and the actual error message from the system call

  • PF_* constants have been replaced by AF_* constants where I deemed the change appropriate

  • the MAN page and help() have been modified to reflect the changes, and extended with extra information for some options

  • default configuration values are now preprocessor constant

I think each of these should be more or less one commit with the commit message describing what was changed and why.

I have tested the changes on multiple machines, with both IPv4 and IPv6, and the program seems to function correctly, however, it is very much possible that bugs have been introduced into the code base.

This PR should fix issue #204.

The commits have not been squashed and signed off yet, and will not be until the fate of this PR is decided.

Your work on this is definitely appreciated, but as said above, in the current state it's not reviewable for me in a decent amount of time.

@uno20001
Copy link
Contributor Author

I have broken up the changes into multiple commits. (It was done the crudest way possible with git, but I am no guru, and it works.) Hopefully now the changes are manageable and can be sufficiently reviewed.

@tklauser
Copy link
Member

Please rebase your branch on top of current master (i.e. drop the old changes and the "back to current version ..." commit) so it only has the individual changes instead of the big change + revert + individual changes.

@uno20001
Copy link
Contributor Author

I really hope I did exactly that, and nothing more, nothing less.

@tklauser
Copy link
Member

Thanks, now it looks better. I'll have a look in detail in the next few days.

@tklauser
Copy link
Member

Thanks for the update. I didn't yet have time to review this PR thoroughly but noticed some possible improvements regarding the commit format.

Please read through the SubmittingPatches file and follow its instructions regarding the commit format and messages, namely:

  • for each change provide a a meaningful commit message, which:
    . explains the problem the change tries to solve, iow, what is wrong with
    the current code without the change.
    . justifies the way the change solves the problem, iow, why the result with
    the change is better.
  • add a Signed-off-by line to each commit
  • prefix the commit message subject with the the changed component followed by, e.g. astraceroute: update packet filters

Please take a look at the git history for a reference of how we expect commit messages to look in general.

@uno20001 uno20001 force-pushed the master branch 2 times, most recently from f302d50 to 1ccd31d Compare June 28, 2019 12:57
@uno20001
Copy link
Contributor Author

Hopefully now everything is more or less what it should be. I tried to keep the commit messages concise and short, that is why I did not try to justify all my decisions in them. I hope that is not a problem. The commits have been signed off.

@uno20001
Copy link
Contributor Author

uno20001 commented Aug 8, 2019

Just pinging to see if there are news about the fate of this PR.

@uno20001
Copy link
Contributor Author

uno20001 commented Oct 1, 2019

Could you please inform me about the progress of handling this PR?
@tklauser

Copy link
Member

@tklauser tklauser left a comment

Choose a reason for hiding this comment

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

Some small review comments inline, still didn't get to review all of this. I also cherry-picked the first commit of this PR as 500e708, please drop your change accordingly and rebase on top of current master.

Also, please make sure you set the author name (pseudonym is fine) on each of your commits.

astraceroute.8 Show resolved Hide resolved
@@ -303,7 +303,7 @@ static void __noreturn help(void)
" -6|--ipv6 Use IPv6-only requests\n"
" -n|--numeric Do not do reverse DNS lookup for hops (default)\n"
" -u|--update Update GeoIP databases\n"
" -L|--latitude Show do_geo_lookup and longitude\n"
" -L|--latitude Show latitude and longitude\n"
Copy link
Member

Choose a reason for hiding this comment

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

Please squash this with the commit (in your branch) that introduced the typo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

astraceroute.c Outdated
Comment on lines 82 to 110
void (*handler)(uint8_t *packet, size_t len, int do_dns_resolution,
int do_geo_lookup);
Copy link
Member

Choose a reason for hiding this comment

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

Change do_dns_resolution and do_geo_lookup to bool type while at it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@uno20001
Copy link
Contributor Author

uno20001 commented Oct 8, 2019

EDIT: I just realized that there is a Reopen and comment button...

My not having a clue about how Git functions really shows here. I tried to rebase onto netsniff-ng:master, Git showed conflicts, and I promptly ignored them doing git rebase --continue. Then I force-pushed to uno20001:master. I hoped that everything would turn out fine, alas, it did not. I noticed (thanks to the automatic testing) that Git inserted some lines (probably to show where rebase failed?). Then, for some reason, I thought it would be a good idea to soft reset my local copy and force-push to uno20001:master and the commit my changes later. Unfortunately the moment I finished force-pushing, GitHub closed the pull request because the branches were the same at that moment. It also did not help that since then I have committed and pushed the changes to uno20001:master. I really hope that this can be solved easily. I do not want to open a new pull request as I think it should be possible to reopen this one somehow.

@uno20001 uno20001 reopened this Oct 8, 2019
@uno20001
Copy link
Contributor Author

@tklauser any updates?

@tklauser
Copy link
Member

@tklauser any updates?

Sorry @uno20001, this somehow fell between the cracks. I've cherry-picked the first two clean-up commits and will try to get to review the rest of this PR as soon as possible. Thanks.

@uno20001
Copy link
Contributor Author

uno20001 commented Jun 14, 2022

I thought I will finally rework this PR into a reasonable form for its three year anniversary. But I have encountered some things that I find a bit confusing.

I would like to modify the main loop to better fit to what is described in the man page:

-q <num>, --num-probes <num>
              Specifies the number of queries to be done on a particular hop. The default is 2  query
              requests.

-x <sec>, --timeout <sec>
              Tells  astraceroute  the  probe response timeout in seconds, in other words the maximum
              time astraceroute must wait for an ICMP response from the current hop. The default is 3
              seconds.

That is, restructure the code so that __probe_remote() does exactly ctx::queries probes (per protocol), and each probe waits until an acceptable reply is received or the timeout elapses, whichever comes first. And the printed time is the median of the successful probes.

@tklauser what do you think?

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.

2 participants