libteam/0013-utils-team2bond-add-ns...

99 lines
4.5 KiB
Diff

From 519f8529ac0bc5b19199ec8a2e83a06e88c078b0 Mon Sep 17 00:00:00 2001
From: Hangbin Liu <haliu@redhat.com>
Date: Fri, 24 Mar 2023 11:33:17 +0800
Subject: [PATCH 13/15] utils/team2bond: add ns_ip6_target support
Rename variable arp_target to target_hosts as we will store both IPv4
and IPv6 address.
Signed-off-by: Hangbin Liu <haliu@redhat.com>
---
utils/team2bond | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/utils/team2bond b/utils/team2bond
index ef4210d..f337906 100755
--- a/utils/team2bond
+++ b/utils/team2bond
@@ -111,9 +111,9 @@ def convert_runner_opts(runner_opts):
return bond_opts
-# arp_target is used to store multi targets
-# exist_opts is used to check if there are duplicated arp_intervals
-def convert_link_watch(link_watch_opts, arp_target, exist_opts):
+# target_hosts is used to store multi targets
+# exist_opts is used to check if there are duplicated options
+def convert_link_watch(link_watch_opts, target_hosts, exist_opts):
bond_opts=""
if 'name' not in link_watch_opts:
print("Error: no link_watch.name in team config file!")
@@ -139,20 +139,20 @@ def convert_link_watch(link_watch_opts, arp_target, exist_opts):
print("# Warn: duplicated downdelay detected, bonding supports only one.")
else:
bond_opts += ",downdelay=" + str(link_watch_opts['delay_down'])
- elif link_watch_opts['name'] == 'arp_ping':
+ elif link_watch_opts['name'] == 'arp_ping' or link_watch_opts['name'] == 'nsna_ping':
if exist_opts.find("miimon") >= 0:
print("# Warn: detecte arp_interval(arp_ping) setting, but miimon(ethtool) already set, will ignore.")
return bond_opts
+ if 'target_host' in link_watch_opts and link_watch_opts['target_host'] not in target_hosts:
+ target_hosts.append(link_watch_opts['target_host'])
+
if 'interval' in link_watch_opts:
if exist_opts.find('arp_interval') >= 0:
print("# Warn: duplicated arp_interval detected, bonding supports only one.")
else:
bond_opts += ",arp_interval=" + str(link_watch_opts['interval'])
- if 'target_host' in link_watch_opts:
- arp_target.append(link_watch_opts['target_host'])
-
if 'missed_max' in link_watch_opts:
if exist_opts.find('arp_missed_max') >= 0:
print("# Warn: duplicated arp_missed_max detected, bonding supports only one.")
@@ -217,22 +217,32 @@ def convert_opts(bond_name, team_opts, exec_cmd):
print("# Warn: option mcast_rejoin.interval: %d is not supported by bonding" % team_opts['mcast_rejoin']['count'])
# The link_watch maybe a dict or list
- arp_target = list()
+ target_hosts = list()
if 'link_watch' in team_opts:
if isinstance(team_opts['link_watch'], list):
for link_watch_opts in team_opts['link_watch']:
- bond_opts += convert_link_watch(link_watch_opts, arp_target, bond_opts)
+ bond_opts += convert_link_watch(link_watch_opts, target_hosts, bond_opts)
elif isinstance(team_opts['link_watch'], dict):
- bond_opts += convert_link_watch(team_opts['link_watch'], arp_target, bond_opts)
+ bond_opts += convert_link_watch(team_opts['link_watch'], target_hosts, bond_opts)
# Check link watch in team ports, we asume it's a dict only?
if 'ports' in team_opts:
for iface in team_opts['ports']:
if ('link_watch' in team_opts['ports'][iface] and
isinstance(team_opts['ports'][iface]['link_watch'], dict)):
- bond_opts += convert_link_watch(team_opts['ports'][iface]['link_watch'], arp_target, bond_opts)
-
- if arp_target:
- bond_opts += ",arp_ip_target=" + " ".join(arp_target)
+ bond_opts += convert_link_watch(team_opts['ports'][iface]['link_watch'], target_hosts, bond_opts)
+
+ if target_hosts:
+ arp_targets = list()
+ ns_targets = list()
+ for target in target_hosts:
+ if target.find(':') == -1:
+ arp_targets.append(target)
+ else:
+ ns_targets.append(target)
+ if arp_targets:
+ bond_opts += ",arp_ip_target=" + " ".join(arp_targets)
+ if ns_targets:
+ bond_opts += ",ns_ip6_target=" + " ".join(ns_targets)
if bond_opts.find("miimon") == -1 and bond_opts.find("_target") == -1:
print("Warn: No link_watch in team config file, use miimon=100 by default")
--
2.38.1