Skip to content

Commit

Permalink
[v4.2.0-rhel] network create: support "-o parent=XXX" for ipvlan
Browse files Browse the repository at this point in the history
Just like macvlan the ipvlan driver accepts a specific parent interface.

Fixes containers#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 <[email protected]>
Signed-off-by: tomsweeneyredhat <[email protected]>
  • Loading branch information
Luap99 authored and TomSweeneyRedHat committed Mar 24, 2023
1 parent 1a116d1 commit ba19823
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
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

0 comments on commit ba19823

Please sign in to comment.