Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

networkmanager: fix primary bond option #21533

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions pkg/networkmanager/bond.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ const bond_monitoring_choices =
{ choice: 'arp', title: _("ARP") }
];

const modes_with_primary = [
'active-backup',
'balance-tlb',
'balance-alb'
];

export const BondDialog = ({ connection, dev, settings }) => {
const Dialogs = useDialogs();
const idPrefix = "network-bond-settings";
Expand All @@ -77,9 +83,12 @@ export const BondDialog = ({ connection, dev, settings }) => {
const [memberChoices, setMemberChoices] = useState(memberChoicesInit);
const [mode, setMode] = useState(options.mode);
const [monitoringTargets, setMonitoringTargets] = useState(options.arp_ip_target);
const [primary, setPrimary] = useState(undefined);
const [primary, setPrimary] = useState(options.primary);

const onSubmit = (ev) => {
const options = settings.bond.options;
delete options['primary'];

const createSettingsObj = () => ({
...settings,
connection: {
Expand All @@ -94,7 +103,7 @@ export const BondDialog = ({ connection, dev, settings }) => {
...settings.bond,
interface_name: iface,
options: {
...settings.bond.options,
...options,
mode,
...(linkMonitoring == 'mii' && {
miimon: linkMonitoringInterval,
Expand All @@ -105,7 +114,7 @@ export const BondDialog = ({ connection, dev, settings }) => {
arp_interval: linkMonitoringInterval,
arp_ip_target: monitoringTargets,
}),
...(mode == "active-backup" && { primary })
...(modes_with_primary.includes(mode) && primary && { primary })
}
}
});
Expand Down Expand Up @@ -174,11 +183,11 @@ export const BondDialog = ({ connection, dev, settings }) => {
{bond_mode_choices.map(choice => <FormSelectOption value={choice.choice} label={choice.title} key={choice.choice} />)}
</FormSelect>
</FormGroup>
{mode == "active-backup" && <FormGroup fieldId={idPrefix + "-primary-select"} label={_("Primary")}>
{modes_with_primary.includes(mode) && <FormGroup fieldId={idPrefix + "-primary-select"} label={_("Primary")}>
<FormSelect id={idPrefix + "-primary-select"} onChange={(_, val) => setPrimary(val)}
value={primary}>
<>
<FormSelectOption key='-' value={null} label='-' />
<FormSelectOption key='-' value='' label='-' />
{Object.keys(memberChoices)
.filter(iface => memberChoices[iface])
.map(iface => <FormSelectOption key={iface} label={iface} value={iface} />)}
Expand Down
Loading