Skip to content

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

Description

@unix196

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

Metadata

Metadata

Assignees

Labels

bugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions