Skip to content

Commit

Permalink
Merge pull request #2258 from Luap99/pasta-link-local
Browse files Browse the repository at this point in the history
libnetwork/pasta: do not ignore ipv4 link local
  • Loading branch information
openshift-merge-bot[bot] authored Dec 4, 2024
2 parents 2d4a9a6 + 0b0b18e commit 9896e4d
Showing 1 changed file with 19 additions and 6 deletions.
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() {
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

1 comment on commit 9896e4d

@packit-as-a-service
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

podman-next COPR build failed. @containers/packit-build please check.

Please sign in to comment.