libnetwork/netavark: accept metric option for mac/ipvlan

This option is also supported by netavark for macvlan and ipvlan
networks.

Fixes #2051

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2024-06-25 11:32:01 +02:00
parent bafd436977
commit 80e2634dee
2 changed files with 18 additions and 0 deletions

View File

@ -326,6 +326,11 @@ func createIpvlanOrMacvlan(network *types.Network) error {
return fmt.Errorf("unknown ipvlan mode %q", value)
}
}
case types.MetricOption:
_, err := strconv.ParseUint(value, 10, 32)
if err != nil {
return err
}
case types.MTUOption:
_, err := internalutil.ParseMTU(value)
if err != nil {

View File

@ -1750,6 +1750,19 @@ var _ = Describe("Config", func() {
Expect(err.Error()).To(Equal("route gateway nil"))
})
It("create macvlan config with metric option", func() {
network := types.Network{
Driver: "macvlan",
Options: map[string]string{
"metric": "99",
},
}
network1, err := libpodNet.NetworkCreate(network, nil)
Expect(err).ToNot(HaveOccurred())
Expect(network1.Options).To(HaveLen(1))
Expect(network1.Options["metric"]).To(Equal("99"))
})
It("create bridge config with no_default_route", func() {
network := types.Network{
Driver: "bridge",