napalm-automation / napalm-ios

Apache License 2.0
31 stars 40 forks source link

Some IOS devices don't support ttl and timeout traceroute arguments #101

Closed XioNoX closed 6 years ago

XioNoX commented 7 years ago

Description of Issue/Question

napalm-ios version

(Paste verbatim output from pip freeze | grep napalm-ios between quotes below)

napalm-ios==0.5.0

IOS version

(Paste verbatim output from show version between quotes below)

Cisco IOS Software, IOS-XE Software, Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 03.06.04.E RELEASE SOFTWARE (fc2)

Steps to Reproduce the Issue

On at least this version of IOS, traceroute doesn't support the ttl and timeout arguments:

#traceroute ?                    
  WORD       Trace route to destination address or hostname
  appletalk  AppleTalk Trace
  clns       ISO CLNS Trace
  ip         IP Trace
  ipv6       IPv6 Trace
  ipx        IPX Trace
  mac        Trace Layer2 path between 2 endpoints
  oldvines   Vines Trace (Cisco)
  vines      Vines Trace (Banyan)
  vrf        Select VPN routing instance
  <cr>

But napalm sets defaults at: TRACEROUTE_TTL = 255 and TRACEROUTE_TIMEOUT = 2 in constants.py. So even if the user doesn't set any ttl or timeout, it will add them to the command, resulting in an issue:

>> device.traceroute(destination='8.8.8.8')
Command ran on the device
traceroute 8.8.8.8 ttl 0 255 timeout 2
Which is not supported:
#traceroute 8.8.8.8 ttl 0 255 timeout 2
                                      ^
% Invalid input detected at '^' marker.
(note that the marker point at the "ttl" term)
mirceaulinic commented 7 years ago

In that case I think we should default them to None and send them to the device only when the user requests. I am not a fan of this behaviour either and I think that's enough reason to change it - could you please open a PR to change this in the napalm-base: https://github.com/napalm-automation/napalm-base/blob/develop/napalm_base/base.py#L1177 defaulting all of them to None and we'll synchronise on all devices. Same for ping.

XioNoX commented 7 years ago

The specific issue with traceroute is on https://github.com/napalm-automation/napalm-ios/blob/develop/napalm_ios/ios.py#L1604 If we set to None, then it doesn't know what to use to calculate max_loops. If there is a documented way of calculating a default max_loops, I can add it though.

I didn't run into that issue with ping.

mirceaulinic commented 7 years ago

What's the default maximal TTL & timeout value on IOS?

ktbyers commented 7 years ago

In the above the "% Invalid input" corresponds to the timeout, not the TTL (i.e. it looks like it accepted the TTL).

You need to add an IP to the traceroute to see the options in that context (in the context sensitive help):

pynet-rtr1#traceroute ?
  WORD       Trace route to destination address or hostname
  appletalk  AppleTalk Trace
  clns       ISO CLNS Trace
  ethernet   Ethernet Traceroute
  ip         IP Trace
  ipv6       IPv6 Trace
  ipx        IPX Trace
  <cr>

pynet-rtr1#traceroute 8.8.8.8 ?
  numeric  display numeric address
  port     specify port number
  probe    specify number of probes per hop
  source   specify source address or name
  timeout  specify time out
  ttl      specify minimum and maximum ttl
  <cr>

pynet-rtr1#traceroute 8.8.8.8 ttl ?
  <0-255>  minimum ttl

pynet-rtr1#traceroute 8.8.8.8 ttl 0 255 ?
  numeric  display numeric address
  port     specify port number
  probe    specify number of probes per hop
  source   specify source address or name
  timeout  specify time out
  <cr>

pynet-rtr1#traceroute 8.8.8.8 ttl 0 255 ti
pynet-rtr1#traceroute 8.8.8.8 ttl 0 255 timeout ?
  <1-3600>  time out in seconds

pynet-rtr1#traceroute 8.8.8.8 ttl 0 255 timeout 2
XioNoX commented 7 years ago

In the first comment, the marker originally points at the ttl field, but github formating makes it appear afterwards. Adding an IP doesn't show more auto-completion

#traceroute 8.8.8.8 ?
  <cr>

2#traceroute 8.8.8.8 ttl ?
% Unrecognized command
ktbyers commented 7 years ago

Ooops, my bad...missed your earlier comment on this.

XioNoX commented 7 years ago

What's the default maximal TTL & timeout value on IOS?

TTL seems to be around 254 or 255 depending on the different doc I found online.

A max_loops,of 2700 (default with the current constants) works fine for me, but no idea if it would be the case for everyone.

mirceaulinic commented 6 years ago

This has been moved to https://github.com/napalm-automation/napalm/issues/450