Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v4.2.0-rhel] network create: support "-o parent=XXX" for ipvlan #17920

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/podman/networks/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func networkCreate(cmd *cobra.Command, args []string) error {
logrus.Warn("The --macvlan option is deprecated, use `--driver macvlan --opt parent=<device>` instead")
network.Driver = types.MacVLANNetworkDriver
network.NetworkInterface = networkCreateOptions.MacVLAN
} else if networkCreateOptions.Driver == types.MacVLANNetworkDriver {
} else if networkCreateOptions.Driver == types.MacVLANNetworkDriver || networkCreateOptions.Driver == types.IPVLANNetworkDriver {
// new -d macvlan --opt parent=... syntax
if parent, ok := network.Options["parent"]; ok {
network.NetworkInterface = parent
Expand Down
29 changes: 29 additions & 0 deletions test/e2e/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,35 @@ var _ = Describe("Podman network", func() {
Expect(nc).Should(Exit(0))
})

It("podman network create/remove ipvlan as driver (-d) with device name", func() {
// Netavark currently does not support ipvlan
SkipIfNetavark(podmanTest)
net := "ipvlan" + stringid.GenerateRandomID()
nc := podmanTest.Podman([]string{"network", "create", "-d", "ipvlan", "-o", "parent=lo", net})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(net)
Expect(nc).Should(Exit(0))

inspect := podmanTest.Podman([]string{"network", "inspect", net})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))

var results []types.Network
err := json.Unmarshal([]byte(inspect.OutputToString()), &results)
Expect(err).ToNot(HaveOccurred())
Expect(results).To(HaveLen(1))
result := results[0]

Expect(result).To(HaveField("Driver", "ipvlan"))
Expect(result).To(HaveField("NetworkInterface", "lo"))
Expect(result.IPAMOptions).To(HaveKeyWithValue("driver", "dhcp"))
Expect(result.Subnets).To(HaveLen(0))

nc = podmanTest.Podman([]string{"network", "rm", net})
nc.WaitWithDefaultTimeout()
Expect(nc).Should(Exit(0))
})

It("podman network exists", func() {
net := "net" + stringid.GenerateRandomID()
session := podmanTest.Podman([]string{"network", "create", net})
Expand Down