saltstack / saltstack/salt

[BUG] salt.modules.debian_ip does not handle ipv6addr(s)

Open
#62,549 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug debian Execution-Module needs-triage
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description

When passed ipv6addr or ipv6addrs as an option, the debian_ip module ignore them.

Setup

Using upstream salt 3004.2 on debian stable (bullseye)

  • on-prem machine
  • VM (kvm through openstack)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD

Steps to Reproduce the behavior

Using a state which is almost identical to this one, provided in the documentation for salt.states.network:

eth8:
  network.managed:
    - type: eth
    - noifupdown: True

    # IPv4
    - proto: static
    - ipaddr: 192.168.4.9
    - netmask: 255.255.255.0
    - gateway: 192.168.4.1
    - enable_ipv6: True

    # IPv6
    - ipv6proto: static
    - ipv6addr: 2001:db8:dead:c0::3
    - ipv6netmask: 64
    - ipv6gateway: 2001:db8:dead:c0::1
    # override shared; makes those options v4-only
    - ipv6ttl: 15

Result:

----------
          ID: lo:0
    Function: network.managed
      Result: False
     Comment: Invalid option -- Interface: lo:0, Option: 'ipaddr' '192.168.4.9', Expected: [IPv6 address]
     Started: 10:12:06.182859
    Duration: 0.841 ms
     Changes:

Expected behavior
The interface is configured.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3004.2
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: 4.0.5
     gitpython: 3.1.14
        Jinja2: 2.11.3
       libgit2: 1.1.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.0
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: 3.9.7
        pygit2: 1.4.0
        Python: 3.9.2 (default, Feb 28 2021, 17:03:44)
  python-gnupg: Not Installed
        PyYAML: 5.3.1
         PyZMQ: 20.0.0
         smmap: 4.0.0
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: debian 11 bullseye
        locale: utf-8
       machine: x86_64
       release: 5.10.0-17-cloud-amd64
        system: Linux
       version: Debian GNU/Linux 11 bullseye

Additional context

I believe this issue to be caused by the following code:

https://github.com/saltstack/salt/blob/e5b8bac19963696566d1f1bfbd07af41b4c1d734/salt/modules/debian_ip.py#L1311-L1314

Where ipv6addr becomes addr which maps to nothing and is silently ignored. The code later falls back on ipaddr which contains an ipv4, causing an error.

It is possible to work around this bug by naming the option ipv6ipaddr in the state, at the cost of potentially breaking compatibility with other operating systems.

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/debian_ip.py at the linked code around lines 1311-1314 and reproduce the issue with the network.managed state shown in the report. Trace how ipv6addr and ipv6addrs are mapped, then verify that the interface is configured using the documented IPv6 options without requiring the ipv6ipaddr workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.