Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
The network.routes execution module does not handle blackhole routes when netstat is not installed.
If netstat is not installed, then the module uses ip, which does not display backhole route the same way, and ends up with a traceback:
# salt-call network.routes
[ERROR ] An un-handled exception was caught by salt's global exception handler:
ValueError: 'blackhole' does not appear to be an IPv4 or IPv6 network
Traceback (most recent call last):
File "/bin/salt-call", line 11, in <module>
load_entry_point('salt==3002.6', 'console_scripts', 'salt-call')()
File "/usr/lib/python3.6/site-packages/salt/scripts.py", line 449, in salt_call
client.run()
File "/usr/lib/python3.6/site-packages/salt/cli/call.py", line 58, in run
caller.run()
File "/usr/lib/python3.6/site-packages/salt/cli/caller.py", line 112, in run
ret = self.call()
File "/usr/lib/python3.6/site-packages/salt/cli/caller.py", line 220, in call
self.opts, data, func, args, kwargs
File "/usr/lib/python3.6/site-packages/salt/executors/direct_call.py", line 12, in execute
return func(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/modules/network.py", line 1769, in routes
routes_ = _ip_route_linux()
File "/usr/lib/python3.6/site-packages/salt/modules/network.py", line 554, in _ip_route_linux
address_mask = convert_cidr(comps[0])
File "/usr/lib/python3.6/site-packages/salt/modules/network.py", line 1237, in convert_cidr
cidr = calc_net(cidr)
File "/usr/lib/python3.6/site-packages/salt/modules/network.py", line 1260, in calc_net
return __utils__["network.calc_net"](ip_addr, netmask)
File "/usr/lib/python3.6/site-packages/salt/utils/network.py", line 1109, in calc_net
return str(ipaddress.ip_network(ipaddr, strict=False))
File "/usr/lib64/python3.6/ipaddress.py", line 84, in ip_network
address)
Setup
No netstat binary present
A blackhole route set
$ ip r
[...]
blackhole 10.233.162.0/26 proto bird
[...]
Steps to Reproduce the behavior
Ensure that net-tools package is not present, then setup a backhole route and run the following command:
salt-call network.routes
Expected behavior
The module returns a list of all routes on the host.
Versions Report
$ salt-call --versions-report
Salt Version:
Salt: 3002.6
Dependency Versions:
cffi: 1.9.1
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 2.11.1
libgit2: Not Installed
M2Crypto: 0.35.2
Mako: Not Installed
msgpack: 0.6.2
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: 2.14
pycrypto: Not Installed
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.6.8 (default, Nov 16 2020, 16:55:22)
python-gnupg: Not Installed
PyYAML: 3.13
PyZMQ: 17.0.0
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.1.4
System Versions:
dist: centos 7 Core
locale: UTF-8
machine: x86_64
release: 3.10.0-1127.el7.x86_64
system: Linux
version: CentOS Linux 7 Core
Description
The
network.routes
execution module does not handle blackhole routes whennetstat
is not installed. Ifnetstat
is not installed, then the module usesip
, which does not display backhole route the same way, and ends up with a traceback:Setup
netstat
binary presentSteps to Reproduce the behavior Ensure that
net-tools
package is not present, then setup a backhole route and run the following command:Expected behavior The module returns a list of all routes on the host.
Versions Report