Bug 1588336 - "domifaddr --source arp" can not show correct netmask
Summary: "domifaddr --source arp" can not show correct netmask
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.6
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: ---
Assignee: Michal Privoznik
QA Contact: chhu
Depends On:
TreeView+ depends on / blocked
Reported: 2018-06-07 06:01 UTC by yalzhang@redhat.com
Modified: 2018-10-30 09:56 UTC (History)
5 users (show)

Fixed In Version: libvirt-4.5.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2018-10-30 09:55:54 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2018:3113 None None None 2018-10-30 09:56:51 UTC

Description yalzhang@redhat.com 2018-06-07 06:01:32 UTC
Description of problem:
"domifaddr --source arp" can not show correct netmask

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Start a vm with interface as below:
<interface type='network'>
      <source network='default'/>
# virsh start rhel

2. check the vm's ip address, it shows the netmask as "/0" which is not correct
# virsh domifaddr rhel --source arp
 Name       MAC address          Protocol     Address
 vnet0      52:54:00:03:fa:7d    ipv4

Actual results:
"domifaddr --source arp" can not show the netmask as "/0", should be "/24"

Expected results:
should show the Address as ""

Additional info:
# virsh domifaddr rhel --source lease
 Name       MAC address          Protocol     Address
 vnet0      52:54:00:03:fa:7d      ipv4

Comment 2 Michal Privoznik 2018-06-08 14:51:30 UTC
Not sure if this is a bug. The documentation says '--source arp' parses ARP table. However, ARP does not have any sense of netmask. Just try 'cat /proc/net/arp'. So maybe we only need to document that not every method is capable of fetching all data.

Comment 3 Laine Stump 2018-06-08 17:33:57 UTC
I came here to say essentially what Michal just said above. There is one possibility for getting the info, but it could be a bit involed - from the arp table you can learn the interface where the MAC is reachable. If you then search through the IP addresses configured for that interface and find the one that "contains" the IP in the ARP entry within its network, you'll have the proper prefix/netmask. (Not saying we *should* go to all that trouble for a piece of information that will almost certainly never be used, but we *could*. Changing the documentation is much simpler, and probably of just as much value to the users).

Comment 4 Michal Privoznik 2018-06-12 11:35:09 UTC
Yeah, since I don't think ARP source is that valuable/accurate as the other two sources (leases file and agent) I don't think it's worth fixing any more than documentation.

Patch proposed upstream:


Comment 5 Michal Privoznik 2018-06-13 07:19:33 UTC
I've pushed the patch upstream:

commit d1605b5d99e847450a6cbbf752ae5dd76239b46f
Author:     Michal Privoznik <mprivozn@redhat.com>
AuthorDate: Tue Jun 12 13:13:06 2018 +0200
Commit:     Michal Privoznik <mprivozn@redhat.com>
CommitDate: Wed Jun 13 09:12:59 2018 +0200

    lib: Document limitation of virDomainInterfaceAddresses
    This API takes @source argument which tells it where to get
    domain IP addresses from. However, not all sources are capable of
    providing all the information we report, for instance ARP table
    has no notion of IP address prefixes. Document this limitation.
    Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
    Reviewed-by: Laine Stump <laine@laine.org>


Comment 7 chhu 2018-09-13 07:25:21 UTC
Verified on packages:

Test steps:
1. Install libvirt-debuginfo package

2. Check the libvirt source file: libvirt-domain.c line: 11805-11807 include the patch

# cd /usr/src/debug/libvirt-4.5.0/src/

libvirt-domain.c:11799: * If @source is VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP, the host
libvirt-domain.c:11806: * might be unset (e.g. VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP does not
qemu/qemu_driver.c:20680:    case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP:

Set the bug status to "VERIFIED"

Comment 9 errata-xmlrpc 2018-10-30 09:55:54 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.