Skip to content

Commit 9cb7ef2

Browse files
authored
Merge pull request #2540 from smortex/fix-ipv6-unique-local-unicast-address-filtering
(FACT-3172) Fix IPv6 unique-local unicast address filtering
2 parents 70328b0 + 40cdf79 commit 9cb7ef2

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

lib/facter/util/resolvers/networking/networking.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def find_valid_binding(bindings)
6666

6767
IPV4_LINK_LOCAL_ADDR = IPAddr.new('169.254.0.0/16').freeze # RFC5735
6868
IPV6_LINK_LOCAL_ADDR = IPAddr.new('fe80::/10').freeze # RFC4291
69+
IPV6_UNIQUE_LOCAL_ADDR = IPAddr.new('fc00::/7').freeze # RFC4193
6970

7071
def ignored_ip_address(addr)
7172
return true if addr.empty?
@@ -75,7 +76,8 @@ def ignored_ip_address(addr)
7576

7677
[
7778
IPV4_LINK_LOCAL_ADDR,
78-
IPV6_LINK_LOCAL_ADDR
79+
IPV6_LINK_LOCAL_ADDR,
80+
IPV6_UNIQUE_LOCAL_ADDR
7981
].each do |range|
8082
return true if range.include?(ip)
8183
end

spec/facter/util/resolvers/networking/networking_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,36 @@
263263
end
264264
end
265265

266+
context 'when there is a unique local ip address' do
267+
let(:networking_facts) do
268+
{
269+
interfaces:
270+
{ 'lo0' =>
271+
{ mtu: 16_384,
272+
bindings6:
273+
[{ address: '::1',
274+
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
275+
network: '::1' },
276+
{ address: 'fdfc:f496:4c6f:0:b0e3:7bff:fe3a:6baf',
277+
netmask: 'ffff:ffff:ffff:ffff::',
278+
network: 'fdfc:f496:4c6f:0::' }] } }
279+
}
280+
end
281+
282+
it 'expands the correct binding' do
283+
expected = {
284+
ip6: '::1',
285+
netmask6: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
286+
network6: '::1',
287+
scope6: 'host'
288+
}
289+
290+
networking_helper.expand_main_bindings(networking_facts)
291+
292+
expect(networking_facts[:interfaces]['lo0']).to include(expected)
293+
end
294+
end
295+
266296
context 'when there is a global ip address' do
267297
let(:networking_facts) do
268298
{

0 commit comments

Comments
 (0)