Skip to content

Conversation

@mkomon
Copy link
Contributor

@mkomon mkomon commented Sep 18, 2017

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.

@stacywsmith stacywsmith self-requested a review September 18, 2017 16:28
@stacywsmith stacywsmith self-assigned this Sep 18, 2017
@stacywsmith
Copy link
Contributor

@mkomon I like the idea of this module and will review the code today. On a related note...
Would you please consider submitting an additional pull request to add the routing_instance argument to junos_ping? That would also be helpful.

Copy link
Contributor

@stacywsmith stacywsmith left a 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.

# 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())
Copy link
Contributor

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.)

Copy link
Contributor Author

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.

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())
Copy link
Contributor

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,
Copy link
Contributor

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.

Copy link
Contributor Author

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.

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
Copy link
Contributor

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.

break
elif loss < 100:
# ping success, increase test_size
results["mtu"] = test_size
Copy link
Contributor

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.

Copy link
Contributor Author

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.

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
Copy link
Contributor

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.

@stacywsmith
Copy link
Contributor

@mkomon It looks like you've address all of my feedback except for changing the result key from mtu to inet_mtu. Let me know if you disagree or have an alternate suggestion.

@stacywsmith stacywsmith merged commit 724adc5 into Juniper:master Sep 18, 2017
@mkomon mkomon deleted the junos_pmtud branch September 18, 2017 21:35
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