Resolves: rhbz#1937155

Signed-off-by: Hangbin Liu <haliu@redhat.com>
This commit is contained in:
Hangbin Liu 2021-05-24 18:24:37 +08:00
parent 13babea34f
commit cdc16e689a
2 changed files with 72 additions and 1 deletions

View File

@ -0,0 +1,67 @@
From f961dbffb5ca769c2a87a6f1e2548e63d2a0a169 Mon Sep 17 00:00:00 2001
From: Hangbin Liu <haliu@redhat.com>
Date: Mon, 24 May 2021 12:58:02 +0800
Subject: [PATCH 2/2] team2bond: fix min_ports format and add lacp_key
Should set to str when add min_ports to bond config.
Also add missed lacp_key config.
Signed-off-by: Hangbin Liu <haliu@redhat.com>
---
utils/team2bond | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/utils/team2bond b/utils/team2bond
index 6ac9d52..265bc79 100755
--- a/utils/team2bond
+++ b/utils/team2bond
@@ -66,7 +66,7 @@ def convert_runner_opts(runner_opts):
if 'sys_prio' in runner_opts:
bond_opts += ",ad_actor_sys_prio=" + str(runner_opts['sys_prio'])
if 'min_ports' in runner_opts:
- bond_opts += ",min_links=" + runner_opts['min_ports']
+ bond_opts += ",min_links=" + str(runner_opts['min_ports'])
if 'agg_select_policy' in runner_opts:
if runner_opts['agg_select_policy'] == 'bandwidth':
bond_opts += ",ad_select=bandwidth"
@@ -214,6 +214,7 @@ def convert_opts(bond_name, team_opts, exec_cmd):
def setup_ports(bond_name, team_opts, exec_cmd):
primary = {'name': "", 'prio': -2**63, 'sticky': False}
bond_ports = []
+ lacp_key = 0
prio = 0
if 'ports' in team_opts:
@@ -228,6 +229,15 @@ def setup_ports(bond_name, team_opts, exec_cmd):
if 'lacp_prio' in team_opts['ports'][iface]:
print("# Warn: Option lacp_prio: %d on interface %s is not supported by bonding" %
(team_opts['ports'][iface]['lacp_prio'], iface))
+ if 'lacp_key' in team_opts['ports'][iface]:
+ if lacp_key == 0:
+ lacp_key = team_opts['ports'][iface]['lacp_key']
+ if lacp_key < 0 or lacp_key > 1023:
+ lacp_key = 0
+ print("# Warn: Option lacp_key: Invalid value %d for port %s" % (lacp_key, iface))
+ else:
+ print("# Warn: Option lacp_key: already has one key %d, ignore the new one %d" %
+ (lacp_key, team_opts['ports'][iface]['lacp_key']))
if 'prio' in team_opts['ports'][iface]:
prio = int(team_opts['ports'][iface]['prio'])
if prio > primary['prio'] and primary['sticky'] is False:
@@ -256,6 +266,13 @@ def setup_ports(bond_name, team_opts, exec_cmd):
else:
print('nmcli con add type %s ifname %s master %s' % (if_type, port, bond_name))
+ if lacp_key != 0:
+ if exec_cmd:
+ subprocess.run(['nmcli', 'con', 'mod', 'bond-' + bond_name,
+ '+bond.options', "ad_user_port_key=" + str(lacp_key)])
+ else:
+ print('nmcli con mod bond-' + bond_name \
+ + ' +bond.options "ad_user_port_key=' + str(lacp_key) + '"')
if primary['name']:
if exec_cmd:
subprocess.run(['nmcli', 'con', 'mod', 'bond-' + bond_name,
--
2.26.3

View File

@ -1,12 +1,13 @@
Name: libteam
Version: 1.31
Release: 5%{?dist}
Release: 6%{?dist}
Summary: Library for controlling team network device
License: LGPLv2+
URL: http://www.libteam.org
Source: http://www.libteam.org/files/libteam-%{version}.tar.gz
Patch1: 0001-team-add-a-tool-for-team-to-bonding-config-migration.patch
Patch2: 0002-team2bond-fix-min_ports-format-and-add-lacp_key.patch
BuildRequires: gcc
BuildRequires: jansson-devel
@ -133,6 +134,9 @@ install -p -m 755 utils/bond2team $RPM_BUILD_ROOT%{_bindir}/bond2team
%{_sysconfdir}/sysconfig/network-scripts/ifdown-TeamPort
%changelog
* Mon May 24 2021 Hangbin Liu <haliu@redhat.com> - 1.31-6
- team2bond: fix min_ports format and add lacp_key [1937155]
* Wed May 12 2021 Hangbin Liu <haliu@redhat.com> - 1.31-5
- team: add a tool for team to bonding config migration [1937155]