Skip to content

Commit

Permalink
(maint) Merge up caf9270 to master
Browse files Browse the repository at this point in the history
Generated by CI

* commit 'caf92703f39c1bdb134a5c1ee1ff8a9b6d219f69':
  (FACT-1935) facter ipaddress6 without interface id
  • Loading branch information
puppetlabs-jenkins committed Aug 7, 2019
2 parents 542e36d + caf9270 commit 96a7409
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 17 additions & 0 deletions acceptance/tests/facts/networking_facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,21 @@
end
end
end

# Verify that IP Address v6 and network v6 is retrieved correctly and does not contain the interface identifier
agents.each do |agent|
if agent['platform'] =~ /windows/
step("verify that ipaddress6 is retrieved correctly") do
on(agent, facter("ipaddress6")) do |facter_result|
assert_match(/^[a-fA-F0-9:]+$/, facter_result.stdout.chomp)
end
end

step("verify that network6 is retrieved correctly") do
on(agent, facter("network6")) do |facter_result|
assert_match(/([a-fA-F0-9:]+)?:([a-fA-F0-9:]+)?$/, facter_result.stdout.chomp)
end
end
end
end
end
6 changes: 5 additions & 1 deletion lib/src/facts/windows/networking_resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ namespace facter { namespace facts { namespace windows {
bool ipv6 = it->Address.lpSockaddr->sa_family == AF_INET6;

binding b;
b.address = addr;

// IpAddress6 contains interface identifier, and should be removed when returning the ipaddress6
b.address = ipv6 ? addr.substr(0, addr.find('%')) : addr;

// Need to do lookup based on the structure length.
auto adapterAddr = reinterpret_cast<IP_ADAPTER_UNICAST_ADDRESS_LH&>(*it);
Expand All @@ -181,6 +183,8 @@ namespace facter { namespace facts { namespace windows {
auto masked = mask_ipv6_address(it->Address.lpSockaddr, mask);
b.netmask = winsock.address_to_string(mask);
b.network = winsock.address_to_string(masked);
// Network6 also contains the interface identifier, so it should be removed
b.network = b.network.substr(0, b.network.find('%'));
} else {
auto mask = create_ipv4_mask(adapterAddr.OnLinkPrefixLength);
auto masked = mask_ipv4_address(it->Address.lpSockaddr, mask);
Expand Down

0 comments on commit 96a7409

Please sign in to comment.