summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpod/network/create.go26
-rw-r--r--test/e2e/network_create_test.go7
2 files changed, 26 insertions, 7 deletions
diff --git a/libpod/network/create.go b/libpod/network/create.go
index e9ab93262..094fbe349 100644
--- a/libpod/network/create.go
+++ b/libpod/network/create.go
@@ -173,14 +173,26 @@ func createBridge(name string, options entities.NetworkCreateOptions, runtimeCon
ipMasq = false
}
- mtu, err := parseMTU(options.Options["mtu"])
- if err != nil {
- return "", err
- }
+ var mtu int
+ var vlan int
+ for k, v := range options.Options {
+ var err error
+ switch k {
+ case "mtu":
+ mtu, err = parseMTU(v)
+ if err != nil {
+ return "", err
+ }
- vlan, err := parseVlan(options.Options["vlan"])
- if err != nil {
- return "", err
+ case "vlan":
+ vlan, err = parseVlan(v)
+ if err != nil {
+ return "", err
+ }
+
+ default:
+ return "", errors.Errorf("unsupported option %s", k)
+ }
}
// obtain host bridge name
diff --git a/test/e2e/network_create_test.go b/test/e2e/network_create_test.go
index 1afd7cec4..21b3074fc 100644
--- a/test/e2e/network_create_test.go
+++ b/test/e2e/network_create_test.go
@@ -355,4 +355,11 @@ var _ = Describe("Podman network create", func() {
Expect(nc.OutputToString()).To(ContainSubstring(`"vlan": 9`))
})
+ It("podman network create with invalid option", func() {
+ net := "invalid-test"
+ nc := podmanTest.Podman([]string{"network", "create", "--opt", "foo=bar", net})
+ nc.WaitWithDefaultTimeout()
+ Expect(nc).To(ExitWithError())
+ })
+
})