Skip to content

Commit

Permalink
Merge pull request #1475 from Luap99/v0.51
Browse files Browse the repository at this point in the history
[v0.51] netavark: add bclim option for macvlan
  • Loading branch information
openshift-merge-robot authored May 26, 2023
2 parents 172f4d0 + 90a06bf commit 34ee7df
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
5 changes: 5 additions & 0 deletions libnetwork/netavark/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ func createMacvlan(network *types.Network) error {
if err != nil {
return err
}
case types.BclimOption:
_, err := strconv.ParseInt(value, 10, 32)
if err != nil {
return fmt.Errorf("failed to parse %q option: %w", key, err)
}
default:
return fmt.Errorf("unsupported macvlan network option %s", key)
}
Expand Down
45 changes: 45 additions & 0 deletions libnetwork/netavark/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,51 @@ var _ = Describe("Config", func() {
Expect(network1.IPAMOptions).To(HaveKeyWithValue("driver", "host-local"))
})

It("create macvlan config with bclim", func() {
subnet := "10.1.0.0/24"
n, _ := types.ParseCIDR(subnet)
network := types.Network{
Driver: "macvlan",
Subnets: []types.Subnet{
{Subnet: n},
},
Options: map[string]string{
types.BclimOption: "-1",
},
}
network1, err := libpodNet.NetworkCreate(network, nil)
Expect(err).ToNot(HaveOccurred())
Expect(network1.Name).ToNot(BeEmpty())
Expect(network1.Options).To(HaveKeyWithValue("bclim", "-1"))

network = types.Network{
Driver: "macvlan",
Subnets: []types.Subnet{
{Subnet: n},
},
Options: map[string]string{
types.BclimOption: "1000",
},
}
network1, err = libpodNet.NetworkCreate(network, nil)
Expect(err).ToNot(HaveOccurred())
Expect(network1.Name).ToNot(BeEmpty())
Expect(network1.Options).To(HaveKeyWithValue("bclim", "1000"))

network = types.Network{
Driver: "macvlan",
Subnets: []types.Subnet{
{Subnet: n},
},
Options: map[string]string{
types.BclimOption: "abc",
},
}
_, err = libpodNet.NetworkCreate(network, nil)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal("failed to parse \"bclim\" option: strconv.ParseInt: parsing \"abc\": invalid syntax"))
})

It("create macvlan config with mode", func() {
subnet := "10.1.0.0/24"
n, _ := types.ParseCIDR(subnet)
Expand Down
1 change: 1 addition & 0 deletions libnetwork/types/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const (
ModeOption = "mode"
IsolateOption = "isolate"
MetricOption = "metric"
BclimOption = "bclim"
)

type NetworkBackend string
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package version

// Version is the version of the build.
const Version = "0.51.3-dev"
const Version = "0.51.4-dev"

0 comments on commit 34ee7df

Please sign in to comment.