Bug 1261432

Summary: net-dhcp-leases should return error when parse invalid mac
Product: Red Hat Enterprise Linux 7 Reporter: Shanzhi Yu <shyu>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.2CC: dyuan, jsuchane, jtomko, mzhan, rbalakri, yalzhang
Target Milestone: rcKeywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.3.1-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:23:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Shanzhi Yu 2015-09-09 10:20:58 UTC
Description of problem:

net-dhcp-leases should return error when parse invalid mac 

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

libvirt-1.2.17-8.el7.x86_64
How reproducible:
100%

Steps to Reproduce:
1.

# virsh net-dhcp-leases default 
 Expiry Time          MAC address        Protocol  IP address                Hostname        Client ID or DUID
-------------------------------------------------------------------------------------------------------------------
 2015-09-09 19:07:34  52:54:00:18:95:1f  ipv4      192.168.122.147/24        -               -
 2015-09-09 19:07:41  52:54:00:40:2b:42  ipv4      192.168.122.217/24        test            -

2.
# virsh net-dhcp-leases default  --mac invalid 
 Expiry Time          MAC address        Protocol  IP address                Hostname        Client ID or DUID
-------------------------------------------------------------------------------------------------------------------


3.

Actual results:

as in step 2 

Expected results:

return error when pass invalid mac address to option "--mac"

Additional info:

Comment 1 Jaroslav Suchanek 2015-11-26 12:53:11 UTC

*** This bug has been marked as a duplicate of bug 1281707 ***

Comment 2 Ján Tomko 2015-12-03 10:04:34 UTC
Upstream patch:
https://www.redhat.com/archives/libvir-list/2015-December/msg00095.html

Comment 3 Ján Tomko 2015-12-03 12:55:32 UTC
Fixed upstream by:
commit 1e6d87bdfc801d2c006a17054bd19273430dce14
Author:     Ján Tomko <jtomko>
CommitDate: 2015-12-03 10:15:22 +0100

    bridge: check for invalid MAC in networkGetDHCPLeases
    
    Instead of comparing garbage strings against real MAC addresses,
    introduce an error mesage for unparsable ones:
    
    $ virsh net-dhcp-leases default  --mac t12
    error: Failed to get leases info for default
    error: invalid MAC address: t12
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1261432

git describe: v1.3.0-rc1-3-g1e6d87b

Comment 5 yalzhang@redhat.com 2016-02-23 09:07:10 UTC
verified on libvirt-1.3.1-1.el7.x86_64, the result is as expected.

[root@work tmp]# virsh net-dhcp-leases default
 Expiry Time          MAC address        Protocol  IP address                Hostname        Client ID or DUID
-------------------------------------------------------------------------------------------------------------------
 2016-02-23 17:55:31  52:54:00:1b:6f:e5  ipv4      192.168.122.159/24        -               -
 2016-02-23 17:32:43  52:54:00:ed:89:bc  ipv4      192.168.122.176/24        yalan-PC        01:52:54:00:ed:89:bc

[root@work tmp]# virsh net-dhcp-leases default  --mac invalid 
error: Failed to get leases info for default
error: invalid MAC address: invalid

Comment 6 yalzhang@redhat.com 2016-02-26 10:31:31 UTC
Tried more invalid mac address, the result is as expected. 
The mac should be dotted hexadecimal and 16 characters in all.

[root@work tmp]# virsh net-dhcp-leases default '52:54:00:ed:89:fg'
error: Failed to get leases info for default
error: invalid MAC address: 52:54:00:ed:89:fg

[root@work tmp]# virsh net-dhcp-leases default --mac " 52:54:00:ed:89:bc" 
error: Failed to get leases info for default
error: invalid MAC address: 52:54:00:ed:89:bc

[root@work tmp]# virsh net-dhcp-leases default --mac 52-54-00-ed-89-bc
error: Failed to get leases info for default
error: invalid MAC address: 52-54-00-ed-89-bc

[root@work tmp]# virsh net-dhcp-leases default --mac 52:54:00:ed:89
error: Failed to get leases info for default
error: invalid MAC address: 52:54:00:ed:89

check a valid mac:
[root@work tmp]# virsh net-dhcp-leases default --mac "52:54:00:ed:89:bc"
Expiry Time MAC address Protocol IP address Hostname Client ID or DUID
-------------------------------------------------------------------------------------------------------------------
2016-02-23 18:29:59 52:54:00:ed:89:bc ipv4 192.168.122.176/24 yalan-PC 01:52:54:00:ed:89:bc

Comment 9 errata-xmlrpc 2016-11-03 18:23:50 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.

https://rhn.redhat.com/errata/RHSA-2016-2577.html