saltstack / saltstack/salt

saltstack network module fails with ecmp routes

Open
#58,377 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug severity-medium
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue

Salt network module not working when default route has several destinations.

Setup

Routing table looks like:

default proto bird metric 32 
	nexthop via 1.2.3.4 dev eth1 weight 1 
	nexthop via 2.3.4.5 dev eth2 weight 1 

and salt-call network.routes fails with:

[ERROR   ] An un-handled exception was caught by salt's global exception handler:
ValueError: u'nexthop' does not appear to be an IPv4 or IPv6 network
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
    salt_call()
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 431, in salt_call
    client.run()
  File "/usr/lib/python2.7/site-packages/salt/cli/call.py", line 57, in run
    caller.run()
  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 138, in run
    ret = self.call()
  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 237, in call
    ret['return'] = self.minion.executors[fname](self.opts, data, func, args, kwargs)
  File "/usr/lib/python2.7/site-packages/salt/executors/direct_call.py", line 12, in execute
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/modules/network.py", line 1686, in default_route
    _routes = routes()
  File "/usr/lib/python2.7/site-packages/salt/modules/network.py", line 1643, in routes
    routes_ = _ip_route_linux()
  File "/usr/lib/python2.7/site-packages/salt/modules/network.py", line 514, in _ip_route_linux
    address_mask = convert_cidr(comps[0])
  File "/usr/lib/python2.7/site-packages/salt/modules/network.py", line 1145, in convert_cidr
    cidr = calc_net(cidr)
  File "/usr/lib/python2.7/site-packages/salt/modules/network.py", line 1167, in calc_net
    return salt.utils.network.calc_net(ip_addr, netmask)
  File "/usr/lib/python2.7/site-packages/salt/utils/network.py", line 1087, in calc_net
    return six.text_type(ipaddress.ip_network(ipaddr, strict=False))
  File "/usr/lib/python2.7/site-packages/salt/ext/ipaddress.py", line 150, in ip_network
    address)
ValueError: u'nexthop' does not appear to be an IPv4 or IPv6 network
Versions Report
Salt Version:
           Salt: 2019.2.2
 
Dependency Versions:
           cffi: 1.6.0
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: 1.10.6
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: 0.26.3
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 0.8.1
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
   pycryptodome: 3.7.3
         pygit2: 0.26.4
         Python: 2.7.5 (default, Aug  7 2019, 00:51:29)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4
 
System Versions:
           dist: centos 7.7.1908 Core
         locale: UTF-8
        machine: x86_64
        release: 4.17.6-1.el7.elrepo.x86_64
         system: Linux
        version: CentOS Linux 7.7.1908 Core

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in salt/modules/network.py at _ip_route_linux, where the traceback shows the failure while parsing routes, then inspect convert_cidr and salt/utils/network.py. Reproduce salt-call network.routes with the reported ECMP routing table. Done means the command handles multiple nexthop entries without raising the reported ValueError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.