-
Couldn't load subscription status.
- Fork 167
add junos_pmtud module #263
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
Conversation
|
@mkomon I like the idea of this module and will review the code today. On a related note... |
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.
See specific comments. Suggest that this be updated to either restrict to IPv4 only or add additional code to support other address families correctly.
library/junos_pmtud
Outdated
| # Check if ICMP passes | ||
| ping_params['size'] = str(64) | ||
| rpc_reply = dev.rpc.ping(**ping_params) | ||
| loss = int(rpc_reply.find('probe-results-summary').findtext("packet-loss").strip()) |
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.
This line will throw an exception if the expected XML elements are not present. This could be avoided with something like:
loss = int(rpc_reply.findtext('probe-results-summary/packet-loss', default='100').strip())
(Yes, we need to make similar changes in the junos_ping module in the long run.)
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.
Thanks for the hint! Fixed.
library/junos_pmtud
Outdated
| step = step / 2 if step >= 2 else 0 | ||
| ping_params['size'] = str(test_size) | ||
| rpc_reply = dev.rpc.ping(**ping_params) | ||
| loss = int(rpc_reply.find('probe-results-summary').findtext("packet-loss").strip()) |
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.
See comment on line 219.
| ping_params = dict( | ||
| host=m_args['dest_ip'], | ||
| count='3', | ||
| do_not_fragment=True, |
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.
As it currently stands, a user could enter an IPv6 address for dest-ip (or a hostname which resolves to an IPv6 address) and the module will return a value that is 20 bytes less than the actual IPv6 MTU because it assumes IPv4 sized header.
For now, we can force IPv4 only and avoid an incorrect answer by adding inet=True to ping_params
In the long run, additional arguments and code could be added for other non-IPv4 address families.
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.
Admittedly, I had only IPv4 in mind when writing this. At the moment I don't have environment with IPv6 running on JUNOS so I agree to limit the module to IPv4 now.
library/junos_pmtud
Outdated
| loss = int(rpc_reply.find('probe-results-summary').findtext("packet-loss").strip()) | ||
| if loss < 100 and test_size == int(m_args['max_size']): | ||
| # ping success with max test_size, save and break | ||
| results["mtu"] = test_size |
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.
See comment on line 187.
library/junos_pmtud
Outdated
| break | ||
| elif loss < 100: | ||
| # ping success, increase test_size | ||
| results["mtu"] = test_size |
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.
See comment on line 187.
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.
At first I didn't get this one. Sure, inet_mtu makes sense, I've pushed a new commit.
library/junos_pmtud
Outdated
| if not results["mtu"]: | ||
| module.fail_json(msg='MTU too low, increase max_range.', **results) | ||
| else: | ||
| results["mtu"] += 28 # adjust for IP and ICMP headers |
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.
See comment on line 187.
|
@mkomon It looks like you've address all of my feedback except for changing the result key from |
Add junos_pmtud module to perform path MTU discovery on Junos devices.
Finds path MTU to destination IP, with defaults it finds MTU in range 989-1500 B in exactly 9 steps (always log2(max_range) steps). Tolerates any packet loss lower than 100 pct.