mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-07 10:29:52 +00:00
selftest: netcons: refactor target creation
Extract the netconsole target creation from create_dynamic_target(), by moving it from create_dynamic_target() into a new helper function. This enables other tests to use the creation of netconsole targets with arbitrary parameters and no sleep. The new helper will be utilized by forthcoming torture-type selftests that require dynamic target management. Signed-off-by: Breno Leitao <leitao@debian.org> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20251107-netconsole_torture-v10-2-749227b55f63@debian.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
49c8d2c1f9
commit
39acc6a95e
@@ -113,31 +113,39 @@ function set_network() {
|
|||||||
configure_ip
|
configure_ip
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_dynamic_target() {
|
function _create_dynamic_target() {
|
||||||
local FORMAT=${1:-"extended"}
|
local FORMAT="${1:?FORMAT parameter required}"
|
||||||
|
local NCPATH="${2:?NCPATH parameter required}"
|
||||||
|
|
||||||
DSTMAC=$(ip netns exec "${NAMESPACE}" \
|
DSTMAC=$(ip netns exec "${NAMESPACE}" \
|
||||||
ip link show "${DSTIF}" | awk '/ether/ {print $2}')
|
ip link show "${DSTIF}" | awk '/ether/ {print $2}')
|
||||||
|
|
||||||
# Create a dynamic target
|
# Create a dynamic target
|
||||||
mkdir "${NETCONS_PATH}"
|
mkdir "${NCPATH}"
|
||||||
|
|
||||||
echo "${DSTIP}" > "${NETCONS_PATH}"/remote_ip
|
echo "${DSTIP}" > "${NCPATH}"/remote_ip
|
||||||
echo "${SRCIP}" > "${NETCONS_PATH}"/local_ip
|
echo "${SRCIP}" > "${NCPATH}"/local_ip
|
||||||
echo "${DSTMAC}" > "${NETCONS_PATH}"/remote_mac
|
echo "${DSTMAC}" > "${NCPATH}"/remote_mac
|
||||||
echo "${SRCIF}" > "${NETCONS_PATH}"/dev_name
|
echo "${SRCIF}" > "${NCPATH}"/dev_name
|
||||||
|
|
||||||
if [ "${FORMAT}" == "basic" ]
|
if [ "${FORMAT}" == "basic" ]
|
||||||
then
|
then
|
||||||
# Basic target does not support release
|
# Basic target does not support release
|
||||||
echo 0 > "${NETCONS_PATH}"/release
|
echo 0 > "${NCPATH}"/release
|
||||||
echo 0 > "${NETCONS_PATH}"/extended
|
echo 0 > "${NCPATH}"/extended
|
||||||
elif [ "${FORMAT}" == "extended" ]
|
elif [ "${FORMAT}" == "extended" ]
|
||||||
then
|
then
|
||||||
echo 1 > "${NETCONS_PATH}"/extended
|
echo 1 > "${NCPATH}"/extended
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo 1 > "${NETCONS_PATH}"/enabled
|
echo 1 > "${NCPATH}"/enabled
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_dynamic_target() {
|
||||||
|
local FORMAT=${1:-"extended"}
|
||||||
|
local NCPATH=${2:-"$NETCONS_PATH"}
|
||||||
|
_create_dynamic_target "${FORMAT}" "${NCPATH}"
|
||||||
|
|
||||||
# This will make sure that the kernel was able to
|
# This will make sure that the kernel was able to
|
||||||
# load the netconsole driver configuration. The console message
|
# load the netconsole driver configuration. The console message
|
||||||
|
|||||||
Reference in New Issue
Block a user