find_ip_via_arp() results in unpredictable, and in some cases, incorrect IP addresses

Bug #1310844 reported by Dustin Kirkland 
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
High
Dustin Kirkland 
maas (Ubuntu)
Triaged
High
Unassigned
Trusty
Triaged
High
Unassigned

Bug Description

MAAS was changed recently to have the AMT power template require MAC addresses rather than IP addresses, in that there is a race condition, when AMT is expecting DHCP to provide an address, and the MAAS DHCP server may not be running yet.

The solution was to create a function, find_ip_via_arp() in src/provisioningserver/utils/__init__.py that resolves MAC addresses to IP addresses.

Unfortunately, the output of this function is somewhat unpredictable, particularly in a MAC address resolves to multiple IP addresses.

That's easily reproducible, if you set AMT to use a static IP address, while the OS running on the system draws its own DHCP address from MAAS. In this case, there are actually multiple MAC addresses with the same IP address.

To at least provide consistent results by this function, I strongly recommend that this code sorts the results, so that the lowest IP address is returned. While not perfect, it's at least predictable, and we can work with that.

=== modified file 'src/provisioningserver/utils/__init__.py'
--- src/provisioningserver/utils/__init__.py 2014-03-28 15:23:38 +0000
+++ src/provisioningserver/utils/__init__.py 2014-04-14 22:14:09 +0000
@@ -819,7 +819,7 @@

     output = call_capture_and_check(['arp', '-n']).split('\n')

- for line in output:
+ for line in sorted(output):
         columns = line.split()
         if len(columns) == 5 and columns[2] == mac:
             return columns[0]

Tags: patch

Related branches

Revision history for this message
Dustin Kirkland  (kirkland) wrote :
Changed in maas (Ubuntu):
importance: Undecided → High
Changed in maas:
importance: Undecided → High
status: New → Triaged
Changed in maas (Ubuntu):
status: New → Triaged
milestone: none → trusty-updates
Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Proposing this for trusty-updates. This one-line fix solves a big problem I'm having using AMT systems with MAAS in trusty right now.

tags: added: patch
Revision history for this message
Julian Edwards (julian-edwards) wrote : Re: [Bug 1310844] Re: find_ip_via_arp() results in unpredictable, and in some cases, incorrect IP addresses

> That's easily reproducible, if you set AMT to use a static IP address,
> while the OS running on the system draws its own DHCP address from MAAS.
> In this case, there are actually multiple MAC addresses with the same IP
> address.

Don't you mean a single MAC with multiple IPs? The other way around would be
absurd and break your network.

Changed in maas:
status: Triaged → Fix Committed
Changed in maas:
milestone: none → 1.6.0
assignee: nobody → Dustin Kirkland  (kirkland)
Changed in maas:
status: Fix Committed → Fix Released
Mathew Hodson (mhodson)
Changed in maas (Ubuntu):
milestone: trusty-updates → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.