Skip to content

Commit

Permalink
Add bond hash policy
Browse files Browse the repository at this point in the history
  • Loading branch information
shibaPuppy committed Apr 25, 2023
1 parent 89eb70c commit 417dff1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
6 changes: 6 additions & 0 deletions api/v1beta1/metal3datatemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ type NetworkDataLinkBond struct {
// balance-rr, active-backup, balance-xor, broadcast, balance-tlb, balance-alb, 802.3ad
BondMode string `json:"bondMode"`

// +kubebuilder:validation:Enum="layer2";"layer3+4";"layer2+3"
// Selects the transmit hash policy used for port selection in balance-xor and 802.3ad modes
// +optional
BondHashPolicy string `json:"bond_xmit_hash_policy"`

// Id is the ID of the interface (used for naming)
Id string `json:"id"` //nolint:revive,stylecheck

Expand All @@ -238,6 +243,7 @@ type NetworkDataLinkBond struct {
MACAddress *NetworkLinkEthernetMac `json:"macAddress"`

// BondLinks is the list of links that are part of the bond.
// +optional
BondLinks []string `json:"bondLinks"`
}

Expand Down
13 changes: 7 additions & 6 deletions baremetal/metal3data_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,12 +762,13 @@ func renderNetworkLinks(networkLinks infrav1.NetworkDataLink, bmh *bmov1alpha1.B
return nil, err
}
data = append(data, map[string]interface{}{
"type": "bond",
"id": link.Id,
"mtu": link.MTU,
"ethernet_mac_address": macAddress,
"bond_mode": link.BondMode,
"bond_links": link.BondLinks,
"type": "bond",
"id": link.Id,
"mtu": link.MTU,
"ethernet_mac_address": macAddress,
"bond_mode": link.BondMode,
"bond_xmit_hash_policy": link.BondHashPolicy,
"bond_links": link.BondLinks,
})
}

Expand Down
20 changes: 11 additions & 9 deletions baremetal/metal3data_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1752,9 +1752,10 @@ var _ = Describe("Metal3Data manager", func() {
links: infrav1.NetworkDataLink{
Bonds: []infrav1.NetworkDataLinkBond{
{
BondMode: "802.3ad",
Id: "bond0",
MTU: 1500,
BondMode: "802.3ad",
BondHashPolicy: "layer3+4",
Id: "bond0",
MTU: 1500,
MACAddress: &infrav1.NetworkLinkEthernetMac{
String: pointer.String("XX:XX:XX:XX:XX:XX"),
},
Expand All @@ -1764,12 +1765,13 @@ var _ = Describe("Metal3Data manager", func() {
},
expectedOutput: []interface{}{
map[string]interface{}{
"type": "bond",
"id": "bond0",
"mtu": 1500,
"ethernet_mac_address": "XX:XX:XX:XX:XX:XX",
"bond_mode": "802.3ad",
"bond_links": []string{"eth0"},
"type": "bond",
"id": "bond0",
"mtu": 1500,
"ethernet_mac_address": "XX:XX:XX:XX:XX:XX",
"bond_mode": "802.3ad",
"bond_xmit_hash_policy": "layer3+4",
"bond_links": []string{"eth0"},
},
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,14 @@ spec:
description: NetworkDataLinkBond represents a bond link
object.
properties:
bond_xmit_hash_policy:
description: Selects the transmit hash policy used for
port selection in balance-xor and 802.3ad modes
enum:
- layer2
- layer3+4
- layer2+3
type: string
bondLinks:
description: BondLinks is the list of links that are
part of the bond.
Expand Down Expand Up @@ -1189,7 +1197,6 @@ spec:
maximum: 9000
type: integer
required:
- bondLinks
- bondMode
- id
- macAddress
Expand Down

0 comments on commit 417dff1

Please sign in to comment.