summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile12
-rw-r--r--completions/Readme.md2
-rw-r--r--docs/source/markdown/podman-network-create.1.md9
-rw-r--r--go.mod2
-rw-r--r--go.sum6
-rw-r--r--libpod/network/create.go18
-rw-r--r--libpod/network/netconflist.go6
-rw-r--r--libpod/network/network.go12
-rw-r--r--test/e2e/common_test.go10
-rw-r--r--test/e2e/network_test.go41
-rw-r--r--vendor/modules.txt2
11 files changed, 101 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index dfa36e3ef..a5e126176 100644
--- a/Makefile
+++ b/Makefile
@@ -639,6 +639,18 @@ install.libseccomp.sudo:
cd ../../seccomp/libseccomp && git checkout --detach $(LIBSECCOMP_COMMIT) && ./autogen.sh && ./configure --prefix=/usr && make all && make install
+.PHONY: completions
+completions: podman podman-remote
+ # key = shell, value = completion filename
+ declare -A outfiles=([bash]=%s [zsh]=_%s [fish]=%s.fish);\
+ for shell in $${!outfiles[*]}; do \
+ for remote in "" "-remote"; do \
+ podman="podman$$remote"; \
+ outfile=$$(printf "completions/$$shell/$${outfiles[$$shell]}" $$podman); \
+ ./bin/$$podman completion $$shell >| $$outfile; \
+ done;\
+ done
+
.PHONY: validate.completions
validate.completions: SHELL:=/usr/bin/env bash # Set shell to bash for this target
validate.completions:
diff --git a/completions/Readme.md b/completions/Readme.md
index 5c9d16f3c..132a38bbf 100644
--- a/completions/Readme.md
+++ b/completions/Readme.md
@@ -2,6 +2,6 @@
Podman offers shell completion scripts for bash, zsh and fish. The completion scripts are available for both `podman` and `podman-remote`.
-The shell completion scripts are generated by `make completion`, do not edit these files directly. To install them you can run `sudo make install.completions`.
+The shell completion scripts are generated by `make completions`; do not edit these files directly. To install them you can run `sudo make install.completions`.
For information about these scripts see [`man podman-completion`](../docs/source/markdown/podman-completion.1.md)
diff --git a/docs/source/markdown/podman-network-create.1.md b/docs/source/markdown/podman-network-create.1.md
index 2fafd1e31..86b15162a 100644
--- a/docs/source/markdown/podman-network-create.1.md
+++ b/docs/source/markdown/podman-network-create.1.md
@@ -7,8 +7,9 @@ podman\-network-create - Create a Podman CNI network
**podman network create** [*options*] name
## DESCRIPTION
-Create a CNI-network configuration for use with Podman. By default, Podman creates a bridge connection. A
-*Macvlan* connection can be created with the *macvlan* option. In the case of *Macvlan* connections, the
+Create a CNI-network configuration for use with Podman. By default, Podman creates a bridge connection.
+A *Macvlan* connection can be created with the *-d macvlan* option. A parent device for macvlan can
+be designated with the *-o parent=<device>* option. In the case of *Macvlan* connections, the
CNI *dhcp* plugin needs to be activated or the container image must have a DHCP client to interact
with the host network's DHCP server.
@@ -55,6 +56,8 @@ Set metadata for a network (e.g., --label mykey=value).
#### **--macvlan**
+*This option is being deprecated*
+
Create a *Macvlan* based connection rather than a classic bridge. You must pass an interface name from the host for the
Macvlan connection.
@@ -101,7 +104,7 @@ Create a network that uses a *192.168.55.0/24** subnet and has an IP address ran
Create a Macvlan based network using the host interface eth0
```
-# podman network create --macvlan eth0 newnet
+# podman network create -d macvlan -o parent=eth0 newnet
/etc/cni/net.d/newnet.conflist
```
diff --git a/go.mod b/go.mod
index cd60fb6ec..f52bf687d 100644
--- a/go.mod
+++ b/go.mod
@@ -49,7 +49,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.0
- github.com/rootless-containers/rootlesskit v0.12.0
+ github.com/rootless-containers/rootlesskit v0.13.0
github.com/sirupsen/logrus v1.7.0
github.com/spf13/cobra v1.1.1
github.com/spf13/pflag v1.0.5
diff --git a/go.sum b/go.sum
index 064295f31..1e52459ea 100644
--- a/go.sum
+++ b/go.sum
@@ -263,8 +263,6 @@ github.com/google/shlex v0.0.0-20181106134648-c34317bd91bf/go.mod h1:RpwtwJQFrIE
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/google/uuid v1.1.5 h1:kxhtnfFVi+rYdOALN0B3k9UT86zVJKfBimRaciULW4I=
-github.com/google/uuid v1.1.5/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
@@ -513,8 +511,8 @@ github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDa
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
-github.com/rootless-containers/rootlesskit v0.12.0 h1:nEVacjGda4wBYnPLWsmZSeA+mFwajGorCuA4VHmu2OE=
-github.com/rootless-containers/rootlesskit v0.12.0/go.mod h1:swXXhX7XMmJQvgqYlaezs6M6vkHN851uPXRStsFr8ug=
+github.com/rootless-containers/rootlesskit v0.13.0 h1:41nnfB7yFxtHSeQHYupSvVxAJWh/hjmn03w6UjH7nv8=
+github.com/rootless-containers/rootlesskit v0.13.0/go.mod h1:DwE/9ASct8sj7bueOXqKiwcdzyZ+yV6qhTAtJUO7988=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
diff --git a/libpod/network/create.go b/libpod/network/create.go
index a8f985af9..88310a79c 100644
--- a/libpod/network/create.go
+++ b/libpod/network/create.go
@@ -29,7 +29,7 @@ func Create(name string, options entities.NetworkCreateOptions, runtimeConfig *c
return nil, err
}
defer l.releaseCNILock()
- if len(options.MacVLAN) > 0 {
+ if len(options.MacVLAN) > 0 || options.Driver == MacVLANNetworkDriver {
fileName, err = createMacVLAN(name, options, runtimeConfig)
} else {
fileName, err = createBridge(name, options, runtimeConfig)
@@ -256,9 +256,17 @@ func createMacVLAN(name string, options entities.NetworkCreateOptions, runtimeCo
return "", err
}
- // Make sure the host-device exists
- if !util.StringInSlice(options.MacVLAN, liveNetNames) {
- return "", errors.Errorf("failed to find network interface %q", options.MacVLAN)
+ // The parent can be defined with --macvlan or as an option (-o parent:device)
+ parentNetworkDevice := options.MacVLAN
+ if len(parentNetworkDevice) < 1 {
+ if parent, ok := options.Options["parent"]; ok {
+ parentNetworkDevice = parent
+ }
+ }
+
+ // Make sure the host-device exists if provided
+ if len(parentNetworkDevice) > 0 && !util.StringInSlice(parentNetworkDevice, liveNetNames) {
+ return "", errors.Errorf("failed to find network interface %q", parentNetworkDevice)
}
if len(name) > 0 {
netNames, err := GetNetworkNamesFromFileSystem(runtimeConfig)
@@ -275,7 +283,7 @@ func createMacVLAN(name string, options entities.NetworkCreateOptions, runtimeCo
}
}
ncList := NewNcList(name, version.Current(), options.Labels)
- macvlan := NewMacVLANPlugin(options.MacVLAN)
+ macvlan := NewMacVLANPlugin(parentNetworkDevice)
plugins = append(plugins, macvlan)
ncList["plugins"] = plugins
b, err := json.MarshalIndent(ncList, "", " ")
diff --git a/libpod/network/netconflist.go b/libpod/network/netconflist.go
index 165a9067b..ca6a4a70b 100644
--- a/libpod/network/netconflist.go
+++ b/libpod/network/netconflist.go
@@ -177,9 +177,13 @@ func NewMacVLANPlugin(device string) MacVLANConfig {
m := MacVLANConfig{
PluginType: "macvlan",
- Master: device,
IPAM: i,
}
+ // CNI is supposed to use the default route if a
+ // parent device is not provided
+ if len(device) > 0 {
+ m.Master = device
+ }
return m
}
diff --git a/libpod/network/network.go b/libpod/network/network.go
index 0fb878b18..0ff14c1f7 100644
--- a/libpod/network/network.go
+++ b/libpod/network/network.go
@@ -17,11 +17,17 @@ import (
"github.com/sirupsen/logrus"
)
-// DefaultNetworkDriver is the default network type used
-var DefaultNetworkDriver = "bridge"
+var (
+ // BridgeNetworkDriver defines the bridge cni driver
+ BridgeNetworkDriver = "bridge"
+ // DefaultNetworkDriver is the default network type used
+ DefaultNetworkDriver = BridgeNetworkDriver
+ // MacVLANNetworkDriver defines the macvlan cni driver
+ MacVLANNetworkDriver = "macvlan"
+)
// SupportedNetworkDrivers describes the list of supported drivers
-var SupportedNetworkDrivers = []string{DefaultNetworkDriver}
+var SupportedNetworkDrivers = []string{BridgeNetworkDriver, MacVLANNetworkDriver}
// isSupportedDriver checks if the user provided driver is supported
func isSupportedDriver(driver string) error {
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go
index 781bbb6d2..ffa6f1329 100644
--- a/test/e2e/common_test.go
+++ b/test/e2e/common_test.go
@@ -1,6 +1,7 @@
package integration
import (
+ "bytes"
"fmt"
"io/ioutil"
"math/rand"
@@ -794,3 +795,12 @@ func (p *PodmanTestIntegration) removeCNINetwork(name string) {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(BeNumerically("<=", 1))
}
+
+func (p *PodmanSessionIntegration) jq(jqCommand string) (string, error) {
+ var out bytes.Buffer
+ cmd := exec.Command("jq", jqCommand)
+ cmd.Stdin = strings.NewReader(p.OutputToString())
+ cmd.Stdout = &out
+ err := cmd.Run()
+ return strings.TrimRight(out.String(), "\n"), err
+}
diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go
index 2f5290c76..124ee7e29 100644
--- a/test/e2e/network_test.go
+++ b/test/e2e/network_test.go
@@ -457,6 +457,47 @@ var _ = Describe("Podman network", func() {
Expect(nc.ExitCode()).To(Equal(0))
})
+ It("podman network create/remove macvlan as driver (-d) no device name", func() {
+ net := "macvlan" + stringid.GenerateNonCryptoID()
+ nc := podmanTest.Podman([]string{"network", "create", "-d", "macvlan", net})
+ nc.WaitWithDefaultTimeout()
+ defer podmanTest.removeCNINetwork(net)
+ Expect(nc.ExitCode()).To(Equal(0))
+
+ inspect := podmanTest.Podman([]string{"network", "inspect", net})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.ExitCode()).To(BeZero())
+
+ out, err := inspect.jq(".[0].plugins[0].master")
+ Expect(err).To(BeNil())
+ Expect(out).To(Equal("\"\""))
+
+ nc = podmanTest.Podman([]string{"network", "rm", net})
+ nc.WaitWithDefaultTimeout()
+ Expect(nc.ExitCode()).To(Equal(0))
+ })
+
+ It("podman network create/remove macvlan as driver (-d) with device name", func() {
+ net := "macvlan" + stringid.GenerateNonCryptoID()
+ nc := podmanTest.Podman([]string{"network", "create", "-d", "macvlan", "-o", "parent=lo", net})
+ nc.WaitWithDefaultTimeout()
+ defer podmanTest.removeCNINetwork(net)
+ Expect(nc.ExitCode()).To(Equal(0))
+
+ inspect := podmanTest.Podman([]string{"network", "inspect", net})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.ExitCode()).To(BeZero())
+ fmt.Println(inspect.OutputToString())
+
+ out, err := inspect.jq(".[0].plugins[0].master")
+ Expect(err).To(BeNil())
+ Expect(out).To(Equal("\"lo\""))
+
+ nc = podmanTest.Podman([]string{"network", "rm", net})
+ nc.WaitWithDefaultTimeout()
+ Expect(nc.ExitCode()).To(Equal(0))
+ })
+
It("podman network exists", func() {
net := "net" + stringid.GenerateNonCryptoID()
session := podmanTest.Podman([]string{"network", "create", net})
diff --git a/vendor/modules.txt b/vendor/modules.txt
index b55515db1..b90178637 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -503,7 +503,7 @@ github.com/prometheus/common/model
# github.com/prometheus/procfs v0.0.3
github.com/prometheus/procfs
github.com/prometheus/procfs/internal/fs
-# github.com/rootless-containers/rootlesskit v0.12.0
+# github.com/rootless-containers/rootlesskit v0.13.0
github.com/rootless-containers/rootlesskit/pkg/msgutil
github.com/rootless-containers/rootlesskit/pkg/port
github.com/rootless-containers/rootlesskit/pkg/port/builtin