1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3#
4# Helper functions
5
6wait_local_port_listen()
7{
8	local listener_ns="${1}"
9	local port="${2}"
10	local protocol="${3}"
11	local port_hex
12	local i
13
14	port_hex="$(printf "%04X" "${port}")"
15	for i in $(seq 10); do
16		if ip netns exec "${listener_ns}" cat /proc/net/"${protocol}"* | \
17		   grep -q "${port_hex}"; then
18			break
19		fi
20		sleep 0.1
21	done
22}
23