summaryrefslogtreecommitdiff
path: root/pkg/domain/infra
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-09-16 17:17:08 -0400
committerGitHub <noreply@github.com>2021-09-16 17:17:08 -0400
commit6cf13c3dbf05a263c08c3f1b1a10cfed722e5929 (patch)
tree3f235e0cfcf8ffb9082855eb03d1828f71940047 /pkg/domain/infra
parent0acf540304b7d2f57357522e4fb47914b0b31a70 (diff)
parent5c7935057c34cbdb27be3a584d35bff3fcd81202 (diff)
downloadpodman-6cf13c3dbf05a263c08c3f1b1a10cfed722e5929.tar.gz
podman-6cf13c3dbf05a263c08c3f1b1a10cfed722e5929.tar.bz2
podman-6cf13c3dbf05a263c08c3f1b1a10cfed722e5929.zip
Merge pull request #11602 from Luap99/netname
Do not allow network modes to be used as network names
Diffstat (limited to 'pkg/domain/infra')
-rw-r--r--pkg/domain/infra/abi/network.go7
-rw-r--r--pkg/domain/infra/tunnel/network.go4
2 files changed, 7 insertions, 4 deletions
diff --git a/pkg/domain/infra/abi/network.go b/pkg/domain/infra/abi/network.go
index 45d2c6925..d792226a8 100644
--- a/pkg/domain/infra/abi/network.go
+++ b/pkg/domain/infra/abi/network.go
@@ -107,12 +107,15 @@ func (ic *ContainerEngine) NetworkRm(ctx context.Context, namesOrIds []string, o
return reports, nil
}
-func (ic *ContainerEngine) NetworkCreate(ctx context.Context, network types.Network) (*entities.NetworkCreateReport, error) {
+func (ic *ContainerEngine) NetworkCreate(ctx context.Context, network types.Network) (*types.Network, error) {
+ if util.StringInSlice(network.Name, []string{"none", "host", "bridge", "private", "slirp4netns", "container", "ns"}) {
+ return nil, errors.Errorf("cannot create network with name %q because it conflicts with a valid network mode", network.Name)
+ }
network, err := ic.Libpod.Network().NetworkCreate(network)
if err != nil {
return nil, err
}
- return &entities.NetworkCreateReport{Name: network.Name}, nil
+ return &network, nil
}
// NetworkDisconnect removes a container from a given network
diff --git a/pkg/domain/infra/tunnel/network.go b/pkg/domain/infra/tunnel/network.go
index 711c2e00c..6f227f565 100644
--- a/pkg/domain/infra/tunnel/network.go
+++ b/pkg/domain/infra/tunnel/network.go
@@ -62,12 +62,12 @@ func (ic *ContainerEngine) NetworkRm(ctx context.Context, namesOrIds []string, o
return reports, nil
}
-func (ic *ContainerEngine) NetworkCreate(ctx context.Context, net types.Network) (*entities.NetworkCreateReport, error) {
+func (ic *ContainerEngine) NetworkCreate(ctx context.Context, net types.Network) (*types.Network, error) {
net, err := network.Create(ic.ClientCtx, &net)
if err != nil {
return nil, err
}
- return &entities.NetworkCreateReport{Name: net.Name}, nil
+ return &net, nil
}
// NetworkDisconnect removes a container from a given network