diff --git a/prisma_config/do.py b/prisma_config/do.py index 1da889b..ce3730e 100755 --- a/prisma_config/do.py +++ b/prisma_config/do.py @@ -5567,11 +5567,41 @@ def get_parent_child_dict(config_interfaces, id2n=None): bypasspair_wan_name = id2n.get(bypasspair_wan, bypasspair_wan) bypasspair_lan_name = id2n.get(bypasspair_lan, bypasspair_lan) - if bypasspair_wan_name in used_parent_name_list or bypasspair_lan_name in used_parent_name_list: - # used multiple times. - throw_error("Bypass pair {0} is using a port that is a parent of another interface:" - "".format(config_interfaces_name), - config_interfaces_value) + # Check if ports are already used, but allow if they're used by another bypass pair + # (since one will be removed - default bypass pairs are removed if user specifies config) + wan_conflict = bypasspair_wan_name in used_parent_name_list + lan_conflict = bypasspair_lan_name in used_parent_name_list + + if wan_conflict or lan_conflict: + # Check if the conflict is with another bypass pair (which will be removed) + # or with a non-bypasspair interface (which is a real conflict) + conflict_is_bypasspair = False + if wan_conflict: + existing_children = parent_if_map.get(bypasspair_wan_name, []) + if existing_children: + # Check if the existing child is a bypass pair + for child_name in existing_children: + child_config = config_interfaces.get(child_name, {}) + if child_config.get('type') == 'bypasspair': + conflict_is_bypasspair = True + break + + if not conflict_is_bypasspair and lan_conflict: + existing_children = parent_if_map.get(bypasspair_lan_name, []) + if existing_children: + for child_name in existing_children: + child_config = config_interfaces.get(child_name, {}) + if child_config.get('type') == 'bypasspair': + conflict_is_bypasspair = True + break + + if not conflict_is_bypasspair: + # used multiple times by non-bypasspair interface - real conflict + throw_error("Bypass pair {0} is using a port that is a parent of another interface:" + "".format(config_interfaces_name), + config_interfaces_value) + # If conflict_is_bypasspair is True, allow it - the other bypass pair will be removed + # We still add the ports to the list to prevent further conflicts # no duplicates, update parent map (bypasspairs many parent, one child). parent_if_map[bypasspair_wan_name] = [config_interfaces_name]