saltstack / saltstack/salt

[BUG] Work module network.arp with multiple ip addresses with single mac-address

Open
#60,794 1 comment 0 reactions 1 assignee View on GitHub

@xeacott is already working on this.

Since Aug 26, 2021.

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

Description

Description
We have servers where single mac-address has many IP addresses (for example remote server has IP aliases on single interface):

arp -an | grep "40:c3:2d:a0:71:81"
? (1.1.1.1) at "40:c3:2d:a0:71:81" [ether] on eth0
? (2.2.2.2) at "40:c3:2d:a0:71:81" [ether] on eth0
? (3.3.3.3) at "40:c3:2d:a0:71:81"1 [ether] on eth0

Module network.arp run command arp -an, then create dictionary, where key - mac-address, value - ip address.

/usr/lib/python3/dist-packages/salt/modules/network.py
    out = __salt__['cmd.run']('arp -an')
    for line in out.splitlines():
        comps = line.split()
        if len(comps) < 4:
            continue
        if __grains__['kernel'] == 'SunOS':
            if ':' not in comps[-1]:
                continue
            ret[comps[-1]] = comps[1]
...
        else:
            ret[comps[3]] = comps[1].strip('(').strip(')')

I think, create dict with key mac-address not very correct, because when multiple ip addresses with single mac-address show in command arp -an, we receive only one record in dictionary (other records will be overwritten).
Also, if docker install on host, arp table have many records like this:

arp -an | grep "incomplete"
? (172.17.22.33) at <incomplete> on docker0
? (172.17.142.134) at <incomplete> on docker0
? (172.17.60.215) at <incomplete> on docker0
? (172.17.164.102) at <incomplete> on docker0

Why it is trouble: for example I want receive mac address my default gateway ( I know it ip address), but in arp table mac address default gateway has multiple ip addresses => in summary dictionary I can receive default gw mac address with other ip in key.
salt-minion - Debian GNU/Linux 9.12 (stretch)
salt master - 2019.2.5+ds-1

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.