Bug #1345
facter 1.5.0rc1 does not correctly handle BSD-style interface aliases
| Status: | Closed | Start date: | ||
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | library | |||
| Target version: | 1.5.0 | |||
| Keywords: | ipaddress netmask NetBSD BSD interfaces alias | Affected Facter version: | ||
| Branch: | ||||
| Votes: | 0 |
Description
Facter returns the last interface alias for an interface rather than the primary address, or better yet, all the addresses on that interface:
ipaddress_udav0 => 192.168.0.12 netmask_udav0 => 0xffffffff
On OpenBSD -current (but applies to previous versions and probably other BSD varients):
$ ifconfig udav0 udav0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:0a:79:64:b4:09
media: Ethernet autoselect (100baseTX full-duplex)
status: active
inet 192.168.0.10 netmask 0xffffff00 broadcast 192.168.0.255
inet6 fe80::20a:79ff:fe64:b409%udav0 prefixlen 64 scopeid 0x5
inet 192.168.0.11 netmask 0xffffffff broadcast 192.168.0.11
inet 192.168.0.12 netmask 0xffffffff broadcast 192.168.0.12
History
Updated by Ryan McBride almost 4 years ago
Oops, should have hit preview
$ ifconfig udav0 udav0: flags=8843mtu 1500 lladdr 00:0a:79:64:b4:09 media: Ethernet autoselect (100baseTX full-duplex) status: active inet 192.168.0.10 netmask 0xffffff00 broadcast 192.168.0.255 inet6 fe80::20a:79ff:fe64:b409%udav0 prefixlen 64 scopeid 0x5 inet 192.168.0.11 netmask 0xffffffff broadcast 192.168.0.11 inet 192.168.0.12 netmask 0xffffffff broadcast 192.168.0.12
Updated by Redmine Admin almost 4 years ago
Added a basic refacter – which does not fix the issue – but should allow someone to fix the underlying issue.
The commit has been pushed to master in commit:b574c6a7f8c596e98bfab7ca48e172eb38fe23fa.
Updated by Redmine Admin almost 4 years ago
- Status changed from 1 to Unreviewed
Updated by Ryan McBride almost 4 years ago
Although it was not explicitly mentioned in the original ticket, the incorrect netmask is also selected for the interface if aliases are present. This is problematic as aliases are generally set with a /32 netmask (0xffffffff / 255.255.255.255).
Updated by Mathieu Sauve-Frankel almost 4 years ago
- File ip_rb.diff added
The attached patch makes get_interface_value_bsd return the first ip_address and netmask found on an interface as opposed to the last, which is the problematic behaviour described in this ticket. The patch does not attempt to report multiple values.
diff --git a/lib/facter/util/ip.rb b/lib/facter/util/ip.rb
index fb13383..1a0c611 100644
--- a/lib/facter/util/ip.rb
+++ b/lib/facter/util/ip.rb
@@ -66,7 +66,7 @@ module Facter::IPAddress
def self.get_interface_value_bsd(interface, label)
- tmp1 = nil
+ tmp1 = []
int_hash = {}
output_int = %x{/sbin/ifconfig #{interface}}
@@ -85,12 +85,12 @@ module Facter::IPAddress
if interface != "lo" && interface != "lo0"
output_int.each { |s|
- tmp1 = $1 if s =~ regex
+ tmp1.push($1) if s =~ regex
}
end
if tmp1
- value = tmp1
+ value = tmp1.shift
end
end
Updated by James Turnbull almost 4 years ago
- Status changed from Unreviewed to Ready For Checkin
- Target version set to 1.5.0
- Keywords set to ipaddress netmask NetBSD BSD interfaces alias
- 3 changed from Unknown to Easy
- Patch changed from None to Code
Partial fix for #1345 pushed in commit:9581190fc6164ae9a4828088966fc711931ecad1 in branch master.
Updated by James Turnbull almost 4 years ago
- Status changed from Ready For Checkin to Closed