Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libnetwork/pasta: do not ignore ipv4 link local #2258

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions libnetwork/pasta/pasta_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,26 @@ func Setup(opts *SetupOptions) (*SetupResult, error) {
return err
}
for _, addr := range addrs {
// make sure to skip localhost and other special addresses
if ipnet, ok := addr.(*net.IPNet); ok && ipnet.IP.IsGlobalUnicast() {
result.IPAddresses = append(result.IPAddresses, ipnet.IP)
if !ipv4 && util.IsIPv4(ipnet.IP) {
// make sure to skip loopback and multicast addresses
if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() && !ipnet.IP.IsMulticast() {
Luap99 marked this conversation as resolved.
Show resolved Hide resolved
if util.IsIPv4(ipnet.IP) {
result.IPAddresses = append(result.IPAddresses, ipnet.IP)
ipv4 = true
}
if !ipv6 && util.IsIPv6(ipnet.IP) {
} else if !ipnet.IP.IsLinkLocalUnicast() {
// Else must be ipv6.
// We shouldn't resolve hosts.containers.internal to IPv6
// link-local addresses, for two reasons:
// 1. even if IPv6 is disabled in pasta (--ipv4-only), the
// kernel will configure an IPv6 link-local address in the
// container, but that doesn't mean that IPv6 connectivity
// is actually working
// 2. link-local addresses need to be suffixed by the zone
// (interface) to be of any use, but we can't do it here
//
// Thus, don't include IPv6 link-local addresses in
// IPAddresses: Podman uses them for /etc/hosts entries, and
// those need to be functional.
result.IPAddresses = append(result.IPAddresses, ipnet.IP)
ipv6 = true
}
}
Expand Down