From patchwork Thu May 13 21:03:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Korsgaard X-Patchwork-Id: 1478205 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=PZ9DX/AC; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fh40P3VGMz9sWM for ; Fri, 14 May 2021 07:04:21 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 1D2E083C64; Thu, 13 May 2021 21:04:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8CpiF1V6-Pha; Thu, 13 May 2021 21:04:18 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 5676081801; Thu, 13 May 2021 21:04:17 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 2F4B91C118B for ; Thu, 13 May 2021 21:04:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1B4104015C for ; Thu, 13 May 2021 21:04:02 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HWHIWFg2IuKX for ; Thu, 13 May 2021 21:04:01 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by smtp2.osuosl.org (Postfix) with ESMTPS id CE1EA400B8 for ; Thu, 13 May 2021 21:04:00 +0000 (UTC) Received: by mail-ej1-x631.google.com with SMTP id m12so41798721eja.2 for ; Thu, 13 May 2021 14:04:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WxRXmrpHgCpyiZ+fawR9qjg043wbBDJ50pDAdHmDCH4=; b=PZ9DX/AC9xnnx9B1pZ+xjCWyLqfbBN4oLrgRN0gde3RP2YI78sefnsdjwR9i/qi+d0 ApzFh+0gHsTEAPhyXZv9w/xcRciRKoeB2dKgYC1zj+OXu3MooKHwXu+NEUdNxFlWbu5W LNorMCp/utaR70n72dYyDjxXX4EM4nfs2FsAHrGt5er+YtLGxO93bNM5CaRabzkH8URr 55T42xrPjK8wXuPCfgGpXn12+btzU1+jT69blaaysr9OLWsZDPQDWRSBgsOIwaMPhqIY icXceMDb/1xoTs2ImxUZ4EpyEzVhLsCtwtRmfzU/OpwheDFm1pJ2YJOnjnU9dWh8Oufz ptjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=WxRXmrpHgCpyiZ+fawR9qjg043wbBDJ50pDAdHmDCH4=; b=FFkYN9f/rMCHVnYzbr1WwvlO62n4CUhjrauxXU4Wp9LZhM6X0QttK5ZrE+R64LpGM1 ZenIF1DSkJfErgFDT6Ka7IJctj8sfnpONAxIM9Ve4OdG7/9AP8QGb2h5ZZAS8ODpP4t4 KHV5K9udtyaFSwK0KTtmC7dSWBQYKPK4HtL++xN5R9HbMVKnWJV+IgwUJXq8JaL4Fsvu M9PKxz3Kyi+P4xTEulzqMSULw/suqICdMzWpDPuK96CO55469YjM1kZ5D59jRCDIIlDt QlQY/O8rMTvo2gg3TvxzDdkfEOcywoKCBkS4hX0KVx70YkZdPst5e7Njg7SqDYgT/cfS zgzw== X-Gm-Message-State: AOAM530P/wKOw9n7AnZSSWuOchNQNSb2LKOIYtXm9qDUEkckZeP/TfaJ MO6x6OjI1MSM0+eb2htPLNEZWk1uSmHdiQ== X-Google-Smtp-Source: ABdhPJxGkkPHVaUayN/U91Qteo4G5v5Mv9ophiVKNj5Gj0HZjwE8DmJW28f53pWdSOxQ00SGjr7uSQ== X-Received: by 2002:a17:906:2bd0:: with SMTP id n16mr45482865ejg.110.1620939838837; Thu, 13 May 2021 14:03:58 -0700 (PDT) Received: from dell.be.48ers.dk (d51A5BC31.access.telenet.be. [81.165.188.49]) by smtp.gmail.com with ESMTPSA id k12sm3005734edo.50.2021.05.13.14.03.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 May 2021 14:03:57 -0700 (PDT) Received: from peko by dell.be.48ers.dk with local (Exim 4.92) (envelope-from ) id 1lhIUu-0002xc-DA; Thu, 13 May 2021 23:03:56 +0200 From: Peter Korsgaard To: buildroot@buildroot.org Date: Thu, 13 May 2021 23:03:51 +0200 Message-Id: <20210513210353.11335-1-peter@korsgaard.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Buildroot] [PATCH 1/3] package/docker-engine: fix port forwarding for hosts without IPv6 X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" docker-engine 20.10.6 broke container port forwarding for hosts without IPv6 support: docker: Error response from daemon: driver failed programming external connectivity on endpoint naughty_moore (038e9ed4b5ea77e1c52462d6d04ad001fbad9beb185a6511aadc217c8a271608): Error starting userland proxy: listen tcp6 [::]:80: socket: address family not supported by protocol. Add a libnetwork patch from an upstream pull request to fix this, after adjusting the patch to apply to docker-engine (which has libnetwork vendored under vendor/github.com/docker/libnetwork): - https://github.com/moby/libnetwork/pull/2635, - https://github.com/moby/moby/pull/42322 Signed-off-by: Peter Korsgaard --- ...-port-forwarding-with-ipv6.disable-1.patch | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 package/docker-engine/0001-fix-port-forwarding-with-ipv6.disable-1.patch diff --git a/package/docker-engine/0001-fix-port-forwarding-with-ipv6.disable-1.patch b/package/docker-engine/0001-fix-port-forwarding-with-ipv6.disable-1.patch new file mode 100644 index 0000000000..c5161ef0db --- /dev/null +++ b/package/docker-engine/0001-fix-port-forwarding-with-ipv6.disable-1.patch @@ -0,0 +1,74 @@ +From 7b9c2905883df5171fda10a364a81b8c6176c8e2 Mon Sep 17 00:00:00 2001 +From: Akihiro Suda +Date: Mon, 26 Apr 2021 15:28:40 +0900 +Subject: [PATCH] fix port forwarding with ipv6.disable=1 + +Make `docker run -p 80:80` functional again on environments with kernel boot parameter `ipv6.disable=1`. + +Fix moby/moby issue 42288 + +Signed-off-by: Akihiro Suda +[Upstream: https://github.com/moby/libnetwork/pull/2635, + https://github.com/moby/moby/pull/42322] +[Rework path/drop test for docker-engine] +Signed-off-by: Peter Korsgaard +--- + vendor/github.com/docker/libnetwork/drivers/bridge/port_mapping.go | 31 +++++++++++++++++++++++++++++++ + 1 file changed, 35 insertions(+), 0 deletion(-) + +diff --git a/vendor/github.com/docker/libnetwork/drivers/bridge/port_mapping.go b/vendor/github.com/docker/libnetwork/drivers/bridge/port_mapping.go +index 946130ec..17bf36f9 100644 +--- a/vendor/github.com/docker/libnetwork/drivers/bridge/port_mapping.go ++++ b/vendor/github.com/docker/libnetwork/drivers/bridge/port_mapping.go +@@ -5,6 +5,7 @@ import ( + "errors" + "fmt" + "net" ++ "sync" + + "github.com/docker/libnetwork/types" + "github.com/ishidawataru/sctp" +@@ -50,6 +51,13 @@ func (n *bridgeNetwork) allocatePortsInternal(bindings []types.PortBinding, cont + bs = append(bs, bIPv4) + } + ++ // skip adding implicit v6 addr, when the kernel was booted with `ipv6.disable=1` ++ // https://github.com/moby/moby/issues/42288 ++ isV6Binding := c.HostIP != nil && c.HostIP.To4() == nil ++ if !isV6Binding && !IsV6Listenable() { ++ continue ++ } ++ + // Allocate IPv6 Port mappings + // If the container has no IPv6 address, allow proxying host IPv6 traffic to it + // by setting up the binding with the IPv4 interface if the userland proxy is enabled +@@ -211,3 +219,26 @@ func (n *bridgeNetwork) releasePort(bnd types.PortBinding) error { + + return portmapper.Unmap(host) + } ++ ++var ( ++ v6ListenableCached bool ++ v6ListenableOnce sync.Once ++) ++ ++// IsV6Listenable returns true when `[::1]:0` is listenable. ++// IsV6Listenable returns false mostly when the kernel was booted with `ipv6.disable=1` option. ++func IsV6Listenable() bool { ++ v6ListenableOnce.Do(func() { ++ ln, err := net.Listen("tcp6", "[::1]:0") ++ if err != nil { ++ // When the kernel was booted with `ipv6.disable=1`, ++ // we get err "listen tcp6 [::1]:0: socket: address family not supported by protocol" ++ // https://github.com/moby/moby/issues/42288 ++ logrus.Debugf("port_mapping: v6Listenable=false (%v)", err) ++ } else { ++ v6ListenableCached = true ++ ln.Close() ++ } ++ }) ++ return v6ListenableCached ++} +-- +2.20.1 +