From patchwork Tue Oct 29 09:00:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13854523 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68C35204025; Tue, 29 Oct 2024 09:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730192566; cv=none; b=EGXKmOQfRfGETAa+TtTEUlzTqZfHamE47/5v+wos/53XpaSGhl6JsRcj6LRIP3GnDSCnJLAnZfRhe7Ie+Eq7hTfTvcNWzX7Gkv/ggLgGohIP4BVXTL6Op4mOG4NrXF7oiYCMhN9TqggLKcewYLDduwuFxvGIT7Zgy0/qz58wmFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730192566; c=relaxed/simple; bh=cZmCWXnEMFuEvbiRjQJjkisQxM2pI7bde0PEaidilag=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n2l9fSqcMBoUtB98L/EvU8XrX/23pge0FiD2/JSuKRiMIVLV6ulPhOl45N/w+AERuI0lQZ2ZMHW2Uekf4l7CQfHqWggLntG/fVQ1o/rDdKEevaRHzXqv+cMxnuipeTXje2Z6MUJuViv0149Tp9dZ5hAoUda2N/2qxTEra+KlLZc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-5c94c4ad9d8so6523616a12.2; Tue, 29 Oct 2024 02:02:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730192563; x=1730797363; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s+qogARyrPHsNa4LKKggrQIs6Ul7expLA2YsGcgM5ac=; b=i2NgtLw1QJXaCaRGk8M53UFPyA17HnQWGt1apCLbELNn4uxkSISPF45Q/0v0JHrsnf /Pt8EmSXv+JV5B+NaPowLfUgwZaaYl6j2phRMUDJhI1hrwe3d0Mu8YEQENrwiWGwWW4o MoOtKkFCCnlKYfjuzPgFuwFTe3V0QH9sS0VEIFxUpR0X+/lTKdKczyQuibtydp7TiHLV 3kHJPHHyOlFf4W+DEUJTG+Lak8dAswlTCKJZCh3u7ashMeVBGsq3VQy3cYDrz/gfaYVU uCKHBXD7dqNHIQDHTEDdGoaN55NQIUAjhXHqz1qmIvXPnTc8Laomq6csfGd9mrDZEpVJ D/+A== X-Forwarded-Encrypted: i=1; AJvYcCUxVIQNxV9Zw8JZeVxk8sap4n+1hagC6IcS+eXfw+9yAiigd5Js6KMmPPGeelAP9ctHZHR0dGvx@vger.kernel.org, AJvYcCVw9BemAY4O+mw+A/NOVGLCfLVlqcExVJJSOBC5vqrCDRX2ep7A0ApMqDAHAwW5kPt/HcdxdebKApIy0P4=@vger.kernel.org, AJvYcCXTUx+ngA+czBCh/9fnn0aRap/ptmH/yfFvPx0rz7ZYsAKrX4UJ3cNUW86Q67CjceM+m0Ocps76XQ819u01DfcP@vger.kernel.org X-Gm-Message-State: AOJu0YyzWkxGkBvXetQ2mRdBXs1d57cgpUYOC4m1a6/noOiPBh2nutyN xC/g1FfbbRgp3YPcnKSgBYr72kF5bmjpmcFaWtQb1YT4Nnv9QsHW X-Google-Smtp-Source: AGHT+IERrA80HJeonAD2Mz4knSrWKBx5dAcJsAWmKh5+iYjrJGCmt3Qtfpd4lCqJly6frlH3YmRckA== X-Received: by 2002:a05:6402:4413:b0:5cb:b66f:908 with SMTP id 4fb4d7f45d1cf-5cbbf886472mr7590824a12.7.1730192562448; Tue, 29 Oct 2024 02:02:42 -0700 (PDT) Received: from localhost (fwdproxy-lla-006.fbsv.net. [2a03:2880:30ff:6::face:b00c]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb63197bdsm3751228a12.70.2024.10.29.02.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 02:02:41 -0700 (PDT) From: Breno Leitao To: kuba@kernel.org, horms@kernel.org, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, matttbe@kernel.org, Andrew Lunn , Shuah Khan Cc: thepacketgeek@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, davej@codemonkey.org.uk, vlad.wing@gmail.com, max@kutsevol.com, kernel-team@meta.com, aehkn@xenhub.one, Petr Machata , linux-kselftest@vger.kernel.org (open list:KERNEL SELFTEST FRAMEWORK) Subject: [PATCH net-next v2 1/2] net: netconsole: selftests: Change the IP subnet Date: Tue, 29 Oct 2024 02:00:28 -0700 Message-ID: <20241029090030.1793551-2-leitao@debian.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241029090030.1793551-1-leitao@debian.org> References: <20241029090030.1793551-1-leitao@debian.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Use a less populated IP range to run the tests, as suggested by Petr in Link: https://lore.kernel.org/netdev/87ikvukv3s.fsf@nvidia.com/. Suggested-by: Petr Machata Signed-off-by: Breno Leitao --- tools/testing/selftests/drivers/net/netcons_basic.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/drivers/net/netcons_basic.sh b/tools/testing/selftests/drivers/net/netcons_basic.sh index 06021b2059b7..8d28e5189e91 100755 --- a/tools/testing/selftests/drivers/net/netcons_basic.sh +++ b/tools/testing/selftests/drivers/net/netcons_basic.sh @@ -20,9 +20,9 @@ SCRIPTDIR=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")") # Simple script to test dynamic targets in netconsole SRCIF="" # to be populated later -SRCIP=192.168.1.1 +SRCIP=192.0.2.1 DSTIF="" # to be populated later -DSTIP=192.168.1.2 +DSTIP=192.0.2.2 PORT="6666" MSG="netconsole selftest" From patchwork Tue Oct 29 09:00:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13854524 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A99212040A1; Tue, 29 Oct 2024 09:02:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730192569; cv=none; b=X/hJErnByqUNsV1wgJuNt4Z9lYLlC1fvzJgbuaUSV//JiexINqW8hoZzU1SUHtYsWHQqfU+9Gq1/4xYKi0VmuiiPkT7mpw1OquX+8DBUUinyIdkMJ12G5G9o/483DtoeLPqkkXFv9cNdzyZjblhbcxAYHNtydhPpwlo6Jh55uMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730192569; c=relaxed/simple; bh=Ub3JOupuqWjUk3HULuyE8gnjOQk5DyjDLzJSHSx0fE8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nz2Ed70vkLNsiWl2IKnfLdtrtBngP2b84SKjQnaggJdSDBFiXhnBJQ2mD6X9w5XuSFvgTtQKNwiUAnb/RqzMPDdiz7WT52qEUa0SUrhfw7m1CkM2UNOwwiKG5neVQiGuec79/MNZBNfc1f0vWFbJDpEJkcJ/Fe0U2z41scTzkzI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a9a2209bd7fso784124066b.2; Tue, 29 Oct 2024 02:02:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730192565; x=1730797365; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h8KmgzHmXCIHO7IwqRFHxFBLUuOqlLnQ0ZWza/gvri4=; b=XrHoWHRepwIFbqYjJf021Qc33f86n3rTgXiDtYJP43jD2kRiueJSCofnrmNv+ZHdrh YRCs6BANZ0T5GPSoahcTVcj9dRqUYxPAYGC9dmgwbaevV4/fbANCxtfXKDjK0Sjn/HRm fRuac4Q2vROxDaLSxGVKoTvNvRGp1/p6e1Wx8pz6O6rgHant599xcmkZbqRx8PjIoxZX HkwqDGnnvQzESZcjPodYHILd+vJlWpmN/0vSgsEmdX2P3ubQ+BFxbpQMx95c7rzQimdM rvWOz3vJrG3r2YXvGHEwLw+Ost6qO/YHl4bvTnETfhF8BXrYGy/7gp8yggm9tiQ/JVWz +VLw== X-Forwarded-Encrypted: i=1; AJvYcCVHonJoIKPjFW649jSGdeyR+XFSVUvb6tab9ORqBV001LKZ1glPPKMdHe+PhAcePjTLSIxO4UTL@vger.kernel.org, AJvYcCVdWqusD0SI1Sn70fpPrViQIL0zokv5aO7zL+u/UwhZSAOmITM6ePzu0GxNzBQKc89I00nfq9DgsK2GOuU=@vger.kernel.org, AJvYcCWeDYbuYmik3mYiImeQS3C6+NtfkRrnNmvH/8z6+a3RYjT+chAg/lkozeV8xj0T1lst+CbfiGimxeBxzNn5UyKS@vger.kernel.org X-Gm-Message-State: AOJu0Yx8SujbfGdg3OaLQtH17YlVh190lhMr+HbCfySyf2tqWYbF+K1w ihjDcPWS4ms4kCtkZ+caU/uWVW6dTPylVpDBOW8xFAH6jpsvE/32 X-Google-Smtp-Source: AGHT+IHBj130d7ta9XxkPZVQVBWQz+DEK1lCUO/wu21ZFXfZAhcZjnTyshCgfiAGmW3QyD2WW4+iOA== X-Received: by 2002:a17:907:7f0e:b0:a9a:9df:5580 with SMTP id a640c23a62f3a-a9de5ce6778mr1049167266b.19.1730192564557; Tue, 29 Oct 2024 02:02:44 -0700 (PDT) Received: from localhost (fwdproxy-lla-007.fbsv.net. [2a03:2880:30ff:7::face:b00c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f029537sm451502966b.52.2024.10.29.02.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 02:02:43 -0700 (PDT) From: Breno Leitao To: kuba@kernel.org, horms@kernel.org, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, matttbe@kernel.org, Andrew Lunn , Shuah Khan Cc: thepacketgeek@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, davej@codemonkey.org.uk, vlad.wing@gmail.com, max@kutsevol.com, kernel-team@meta.com, aehkn@xenhub.one, linux-kselftest@vger.kernel.org (open list:KERNEL SELFTEST FRAMEWORK) Subject: [PATCH net-next v2 2/2] net: netconsole: selftests: Add userdata validation Date: Tue, 29 Oct 2024 02:00:29 -0700 Message-ID: <20241029090030.1793551-3-leitao@debian.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241029090030.1793551-1-leitao@debian.org> References: <20241029090030.1793551-1-leitao@debian.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Extend netcons_basic selftest to verify the userdata functionality by: 1. Creating a test key in the userdata configfs directory 2. Writing a known value to the key 3. Validating the key-value pair appears in the captured network output This ensures the userdata feature is properly tested during selftests. Signed-off-by: Breno Leitao --- .../selftests/drivers/net/netcons_basic.sh | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/testing/selftests/drivers/net/netcons_basic.sh b/tools/testing/selftests/drivers/net/netcons_basic.sh index 8d28e5189e91..182eb1a97e59 100755 --- a/tools/testing/selftests/drivers/net/netcons_basic.sh +++ b/tools/testing/selftests/drivers/net/netcons_basic.sh @@ -26,10 +26,13 @@ DSTIP=192.0.2.2 PORT="6666" MSG="netconsole selftest" +USERDATA_KEY="key" +USERDATA_VALUE="value" TARGET=$(mktemp -u netcons_XXXXX) DEFAULT_PRINTK_VALUES=$(cat /proc/sys/kernel/printk) NETCONS_CONFIGFS="/sys/kernel/config/netconsole" NETCONS_PATH="${NETCONS_CONFIGFS}"/"${TARGET}" +KEY_PATH="${NETCONS_PATH}/userdata/${USERDATA_KEY}" # NAMESPACE will be populated by setup_ns with a random value NAMESPACE="" @@ -122,6 +125,8 @@ function cleanup() { # delete netconsole dynamic reconfiguration echo 0 > "${NETCONS_PATH}"/enabled + # Remove key + rmdir "${KEY_PATH}" # Remove the configfs entry rmdir "${NETCONS_PATH}" @@ -136,6 +141,18 @@ function cleanup() { echo "${DEFAULT_PRINTK_VALUES}" > /proc/sys/kernel/printk } +function set_user_data() { + if [[ ! -d "${NETCONS_PATH}""/userdata" ]] + then + echo "Userdata path not available in ${NETCONS_PATH}/userdata" + exit "${ksft_skip}" + fi + + mkdir -p "${KEY_PATH}" + VALUE_PATH="${KEY_PATH}""/value" + echo "${USERDATA_VALUE}" > "${VALUE_PATH}" +} + function listen_port_and_save_to() { local OUTPUT=${1} # Just wait for 2 seconds @@ -146,6 +163,10 @@ function listen_port_and_save_to() { function validate_result() { local TMPFILENAME="$1" + # TMPFILENAME will contain something like: + # 6.11.1-0_fbk0_rc13_509_g30d75cea12f7,13,1822,115075213798,-;netconsole selftest: netcons_gtJHM + # key=value + # Check if the file exists if [ ! -f "$TMPFILENAME" ]; then echo "FAIL: File was not generated." >&2 @@ -158,6 +179,12 @@ function validate_result() { exit "${ksft_fail}" fi + if ! grep -q "${USERDATA_KEY}=${USERDATA_VALUE}" "${TMPFILENAME}"; then + echo "FAIL: ${USERDATA_KEY}=${USERDATA_VALUE} not found in ${TMPFILENAME}" >&2 + cat "${TMPFILENAME}" >&2 + exit "${ksft_fail}" + fi + # Delete the file once it is validated, otherwise keep it # for debugging purposes rm "${TMPFILENAME}" @@ -220,6 +247,8 @@ trap cleanup EXIT set_network # Create a dynamic target for netconsole create_dynamic_target +# Set userdata "key" with the "value" value +set_user_data # Listed for netconsole port inside the namespace and destination interface listen_port_and_save_to "${OUTPUT_FILE}" & # Wait for socat to start and listen to the port.