From ba1982359b278b7a1e2a06161292fef55bcaf42c Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 5 Dec 2022 18:02:46 +0100 Subject: [PATCH] [v4.2.0-rhel] network create: support "-o parent=XXX" for ipvlan Just like macvlan the ipvlan driver accepts a specific parent interface. Fixes #16621 Cherry pick to address: https://bugzilla.redhat.com/show_bug.cgi?id=2181634 and https://bugzilla.redhat.com/show_bug.cgi?id=2181609 Signed-off-by: Paul Holzinger Signed-off-by: tomsweeneyredhat --- cmd/podman/networks/create.go | 2 +- test/e2e/network_test.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/cmd/podman/networks/create.go b/cmd/podman/networks/create.go index 8b0ebeb2b5..42c342df2c 100644 --- a/cmd/podman/networks/create.go +++ b/cmd/podman/networks/create.go @@ -125,7 +125,7 @@ func networkCreate(cmd *cobra.Command, args []string) error { logrus.Warn("The --macvlan option is deprecated, use `--driver macvlan --opt parent=` 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 diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go index b2f50ca55e..387dea71b1 100644 --- a/test/e2e/network_test.go +++ b/test/e2e/network_test.go @@ -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})