mirror of
https://github.com/containers/podman.git
synced 2025-12-02 11:08:36 +08:00
update c/{buildah,common,image,storage} to latest main
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
2
vendor/github.com/containers/common/libnetwork/cni/cni_conversion.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/cni/cni_conversion.go
generated
vendored
@@ -9,6 +9,7 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -18,7 +19,6 @@ import (
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
"github.com/containers/common/libnetwork/util"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/exp/slices"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
||||
2
vendor/github.com/containers/common/libnetwork/cni/config.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/cni/config.go
generated
vendored
@@ -7,11 +7,11 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"slices"
|
||||
|
||||
internalutil "github.com/containers/common/libnetwork/internal/util"
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
func (n *cniNetwork) NetworkUpdate(_ string, _ types.NetworkUpdateOptions) error {
|
||||
|
||||
2
vendor/github.com/containers/common/libnetwork/etchosts/hosts.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/etchosts/hosts.go
generated
vendored
@@ -6,10 +6,10 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/common/pkg/config"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
2
vendor/github.com/containers/common/libnetwork/internal/util/bridge.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/internal/util/bridge.go
generated
vendored
@@ -3,11 +3,11 @@ package util
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"slices"
|
||||
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
"github.com/containers/common/libnetwork/util"
|
||||
"github.com/containers/common/pkg/config"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
func CreateBridge(n NetUtil, network *types.Network, usedNetworks []*net.IPNet, subnetPools []config.SubnetPool) error {
|
||||
|
||||
2
vendor/github.com/containers/common/libnetwork/internal/util/util.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/internal/util/util.go
generated
vendored
@@ -4,11 +4,11 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"slices"
|
||||
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
"github.com/containers/common/pkg/config"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
// GetBridgeInterfaceNames returns all bridge interface names
|
||||
|
||||
2
vendor/github.com/containers/common/libnetwork/netavark/config.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/netavark/config.go
generated
vendored
@@ -10,13 +10,13 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
internalutil "github.com/containers/common/libnetwork/internal/util"
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
"github.com/containers/storage/pkg/stringid"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
func sliceRemoveDuplicates(strList []string) []string {
|
||||
|
||||
2
vendor/github.com/containers/common/libnetwork/netavark/run.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/netavark/run.go
generated
vendored
@@ -5,13 +5,13 @@ package netavark
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/common/libnetwork/internal/util"
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
type netavarkOptions struct {
|
||||
|
||||
191
vendor/github.com/containers/common/libnetwork/pasta/pasta_linux.go
generated
vendored
191
vendor/github.com/containers/common/libnetwork/pasta/pasta_linux.go
generated
vendored
@@ -15,6 +15,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os/exec"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/containernetworking/plugins/pkg/ns"
|
||||
@@ -54,100 +55,16 @@ func Setup(opts *SetupOptions) error {
|
||||
// Note that there is no need for any special cleanup logic, the pasta
|
||||
// process will automatically exit when the netns path is deleted.
|
||||
func Setup2(opts *SetupOptions) (*SetupResult, error) {
|
||||
NoTCPInitPorts := true
|
||||
NoUDPInitPorts := true
|
||||
NoTCPNamespacePorts := true
|
||||
NoUDPNamespacePorts := true
|
||||
NoMapGW := true
|
||||
|
||||
path, err := opts.Config.FindHelperBinary(BinaryName, true)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not find pasta, the network namespace can't be configured: %w", err)
|
||||
}
|
||||
|
||||
cmdArgs := []string{}
|
||||
cmdArgs = append(cmdArgs, "--config-net")
|
||||
|
||||
for _, i := range opts.Ports {
|
||||
protocols := strings.Split(i.Protocol, ",")
|
||||
for _, protocol := range protocols {
|
||||
var addr string
|
||||
|
||||
if i.HostIP != "" {
|
||||
addr = i.HostIP + "/"
|
||||
}
|
||||
|
||||
switch protocol {
|
||||
case "tcp":
|
||||
cmdArgs = append(cmdArgs, "-t")
|
||||
case "udp":
|
||||
cmdArgs = append(cmdArgs, "-u")
|
||||
default:
|
||||
return nil, fmt.Errorf("can't forward protocol: %s", protocol)
|
||||
}
|
||||
|
||||
arg := fmt.Sprintf("%s%d-%d:%d-%d", addr,
|
||||
i.HostPort,
|
||||
i.HostPort+i.Range-1,
|
||||
i.ContainerPort,
|
||||
i.ContainerPort+i.Range-1)
|
||||
cmdArgs = append(cmdArgs, arg)
|
||||
}
|
||||
cmdArgs, dnsForwardIPs, err := createPastaArgs(opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// first append options set in the config
|
||||
cmdArgs = append(cmdArgs, opts.Config.Network.PastaOptions.Get()...)
|
||||
// then append the ones that were set on the cli
|
||||
cmdArgs = append(cmdArgs, opts.ExtraOptions...)
|
||||
|
||||
var dnsForwardIPs []string
|
||||
for i, opt := range cmdArgs {
|
||||
switch opt {
|
||||
case "-t", "--tcp-ports":
|
||||
NoTCPInitPorts = false
|
||||
case "-u", "--udp-ports":
|
||||
NoUDPInitPorts = false
|
||||
case "-T", "--tcp-ns":
|
||||
NoTCPNamespacePorts = false
|
||||
case "-U", "--udp-ns":
|
||||
NoUDPNamespacePorts = false
|
||||
case "--map-gw":
|
||||
NoMapGW = false
|
||||
// not an actual pasta(1) option
|
||||
cmdArgs = append(cmdArgs[:i], cmdArgs[i+1:]...)
|
||||
case dnsForwardOpt:
|
||||
// if there is no arg after it pasta will likely error out anyway due invalid cli args
|
||||
if len(cmdArgs) > i+1 {
|
||||
dnsForwardIPs = append(dnsForwardIPs, cmdArgs[i+1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(dnsForwardIPs) == 0 {
|
||||
// the user did not request custom --dns-forward so add our own.
|
||||
cmdArgs = append(cmdArgs, dnsForwardOpt, dnsForwardIpv4)
|
||||
dnsForwardIPs = append(dnsForwardIPs, dnsForwardIpv4)
|
||||
}
|
||||
|
||||
if NoTCPInitPorts {
|
||||
cmdArgs = append(cmdArgs, "-t", "none")
|
||||
}
|
||||
if NoUDPInitPorts {
|
||||
cmdArgs = append(cmdArgs, "-u", "none")
|
||||
}
|
||||
if NoTCPNamespacePorts {
|
||||
cmdArgs = append(cmdArgs, "-T", "none")
|
||||
}
|
||||
if NoUDPNamespacePorts {
|
||||
cmdArgs = append(cmdArgs, "-U", "none")
|
||||
}
|
||||
if NoMapGW {
|
||||
cmdArgs = append(cmdArgs, "--no-map-gw")
|
||||
}
|
||||
|
||||
// always pass --quiet to silence the info output from pasta
|
||||
cmdArgs = append(cmdArgs, "--quiet", "--netns", opts.Netns)
|
||||
|
||||
logrus.Debugf("pasta arguments: %s", strings.Join(cmdArgs, " "))
|
||||
|
||||
// pasta forks once ready, and quits once we delete the target namespace
|
||||
@@ -205,3 +122,103 @@ func Setup2(opts *SetupOptions) (*SetupResult, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// createPastaArgs creates the pasta arguments, it returns the args to be passed to pasta(1) and as second arg the dns forward ips used.
|
||||
func createPastaArgs(opts *SetupOptions) ([]string, []string, error) {
|
||||
noTCPInitPorts := true
|
||||
noUDPInitPorts := true
|
||||
noTCPNamespacePorts := true
|
||||
noUDPNamespacePorts := true
|
||||
noMapGW := true
|
||||
|
||||
cmdArgs := []string{"--config-net"}
|
||||
// first append options set in the config
|
||||
cmdArgs = append(cmdArgs, opts.Config.Network.PastaOptions.Get()...)
|
||||
// then append the ones that were set on the cli
|
||||
cmdArgs = append(cmdArgs, opts.ExtraOptions...)
|
||||
|
||||
cmdArgs = slices.DeleteFunc(cmdArgs, func(s string) bool {
|
||||
// --map-gw is not a real pasta(1) option so we must remove it
|
||||
// and not add --no-map-gw below
|
||||
if s == "--map-gw" {
|
||||
noMapGW = false
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
var dnsForwardIPs []string
|
||||
for i, opt := range cmdArgs {
|
||||
switch opt {
|
||||
case "-t", "--tcp-ports":
|
||||
noTCPInitPorts = false
|
||||
case "-u", "--udp-ports":
|
||||
noUDPInitPorts = false
|
||||
case "-T", "--tcp-ns":
|
||||
noTCPNamespacePorts = false
|
||||
case "-U", "--udp-ns":
|
||||
noUDPNamespacePorts = false
|
||||
case dnsForwardOpt:
|
||||
// if there is no arg after it pasta will likely error out anyway due invalid cli args
|
||||
if len(cmdArgs) > i+1 {
|
||||
dnsForwardIPs = append(dnsForwardIPs, cmdArgs[i+1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, i := range opts.Ports {
|
||||
protocols := strings.Split(i.Protocol, ",")
|
||||
for _, protocol := range protocols {
|
||||
var addr string
|
||||
|
||||
if i.HostIP != "" {
|
||||
addr = i.HostIP + "/"
|
||||
}
|
||||
|
||||
switch protocol {
|
||||
case "tcp":
|
||||
noTCPInitPorts = false
|
||||
cmdArgs = append(cmdArgs, "-t")
|
||||
case "udp":
|
||||
noUDPInitPorts = false
|
||||
cmdArgs = append(cmdArgs, "-u")
|
||||
default:
|
||||
return nil, nil, fmt.Errorf("can't forward protocol: %s", protocol)
|
||||
}
|
||||
|
||||
arg := fmt.Sprintf("%s%d-%d:%d-%d", addr,
|
||||
i.HostPort,
|
||||
i.HostPort+i.Range-1,
|
||||
i.ContainerPort,
|
||||
i.ContainerPort+i.Range-1)
|
||||
cmdArgs = append(cmdArgs, arg)
|
||||
}
|
||||
}
|
||||
|
||||
if len(dnsForwardIPs) == 0 {
|
||||
// the user did not request custom --dns-forward so add our own.
|
||||
cmdArgs = append(cmdArgs, dnsForwardOpt, dnsForwardIpv4)
|
||||
dnsForwardIPs = append(dnsForwardIPs, dnsForwardIpv4)
|
||||
}
|
||||
|
||||
if noTCPInitPorts {
|
||||
cmdArgs = append(cmdArgs, "-t", "none")
|
||||
}
|
||||
if noUDPInitPorts {
|
||||
cmdArgs = append(cmdArgs, "-u", "none")
|
||||
}
|
||||
if noTCPNamespacePorts {
|
||||
cmdArgs = append(cmdArgs, "-T", "none")
|
||||
}
|
||||
if noUDPNamespacePorts {
|
||||
cmdArgs = append(cmdArgs, "-U", "none")
|
||||
}
|
||||
if noMapGW {
|
||||
cmdArgs = append(cmdArgs, "--no-map-gw")
|
||||
}
|
||||
|
||||
// always pass --quiet to silence the info output from pasta
|
||||
cmdArgs = append(cmdArgs, "--quiet", "--netns", opts.Netns)
|
||||
|
||||
return cmdArgs, dnsForwardIPs, nil
|
||||
}
|
||||
|
||||
2
vendor/github.com/containers/common/libnetwork/resolvconf/resolv.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/resolvconf/resolv.go
generated
vendored
@@ -5,12 +5,12 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/storage/pkg/fileutils"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
2
vendor/github.com/containers/common/libnetwork/util/filters.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/util/filters.go
generated
vendored
@@ -2,12 +2,12 @@ package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
"github.com/containers/common/pkg/filters"
|
||||
"github.com/containers/common/pkg/util"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
func GenerateNetworkFilters(f map[string][]string) ([]types.FilterFunc, error) {
|
||||
|
||||
Reference in New Issue
Block a user