tools/testing/selftests/net/ovpn/common.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/ovpn/common.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/ovpn/common.sh
Extension
.sh
Size
8791 bytes
Lines
365
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2020-2025 OpenVPN, Inc.
#
#  Author:	Antonio Quartulli <antonio@openvpn.net>

OVPN_COMMON_DIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
source "$OVPN_COMMON_DIR/../../kselftest/ktap_helpers.sh"

OVPN_UDP_PEERS_FILE=${OVPN_UDP_PEERS_FILE:-udp_peers.txt}
OVPN_TCP_PEERS_FILE=${OVPN_TCP_PEERS_FILE:-tcp_peers.txt}
OVPN_CLI=${OVPN_CLI:-${OVPN_COMMON_DIR}/ovpn-cli}
OVPN_YNL=${OVPN_YNL:-${OVPN_COMMON_DIR}/../../../../net/ynl/pyynl/cli.py}
OVPN_ALG=${OVPN_ALG:-aes}
OVPN_PROTO=${OVPN_PROTO:-UDP}
OVPN_FLOAT=${OVPN_FLOAT:-0}
OVPN_SYMMETRIC_ID=${OVPN_SYMMETRIC_ID:-0}
OVPN_VERBOSE=${OVPN_VERBOSE:-0}

export OVPN_ID_OFFSET=$(( 9 * (OVPN_SYMMETRIC_ID == 0) ))

OVPN_JQ_FILTER='map(if type == "array" then .[] else . end) |
	map(select(.msg.peer | has("remote-ipv6") | not)) |
	map(del(.msg.ifindex)) | sort_by(.msg.peer.id)[]'
OVPN_LAN_IP="11.11.11.11"

declare -A OVPN_TMP_JSONS=()
declare -A OVPN_LISTENER_PIDS=()
OVPN_CURRENT_STAGE=""

ovpn_is_verbose() {
	[[ "${OVPN_VERBOSE}" == "1" ]]
}

ovpn_log() {
	ovpn_is_verbose || return 0
	printf '%s\n' "$*"
}

ovpn_print_cmd_output() {
	local output_file="$1"
	local line

	[[ -s "${output_file}" ]] || return 0

	while IFS= read -r line; do
		ovpn_log "${line}"
	done < "${output_file}"
}

ovpn_cmd_run() {
	local mode="$1"
	local label="$2"
	local output_file
	local rc
	local ret=0

	shift 2

	output_file=$(mktemp)
	if "$@" >"${output_file}" 2>&1; then
		rc=0
	else
		rc=$?
	fi

	case "${mode}" in
	ok)
		if [[ "${rc}" -ne 0 ]]; then
			cat "${output_file}"

Annotation

Implementation Notes