From nobody Fri Oct 3 05:25:15 2025 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 758DD1A9F90; Thu, 4 Sep 2025 18:00:57 +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=1757008859; cv=none; b=rUaGzYdH6FPswkI+blUu2orVgNqwyGIq1W7XH65qyKfd+z/COMUhN4GMoZW24U0gzXgwc+fwTAVCBk1n5Ik91sO5hT6xvPprhe3mGmUq747PSiJAe5t6cchK+jARekUE4Z9urhmBUOuqMEv8qkYL93giqMIpIT/X8UCcFUveKRQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757008859; c=relaxed/simple; bh=EWRGVYbzjKHznInjRONuXtYIkysZPWgAaf+XG+yvXcU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MnxMflV/tHQTmL4xnxpSqS8Z65ToErzYUDS3sVFlXZ8aW09uwygzkgKRNn1m8dsjZ9IY98UgUTVyBNAn6WJ8YpWQbGJ7q29Nq/vnwl2Czll/rOVpYmZjHiOWjfKCnirShcwXHW8SWxuCIjnKddRAglJBGOSRCwdsLpLXDOOohAc= 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-b00a9989633so235392266b.0; Thu, 04 Sep 2025 11:00:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757008856; x=1757613656; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=459waJuUGWapraaUHEaPCUC2CtqoaRCHyhregbFJ7zg=; b=FXMEqIRx8H6Xrue9S/EAr6h/ShVidK8W5YLmnoGAhI9y5JQgIPsoEWYKAQUFgolbJx GTChb2gsT3LrOIoJvMwm3F3DH9tMMCzPlzpwlM/NrXG5dk6WIDfDajD5iBjgvoCcPwPU UIYg8x9v4IRjqjNX+fPC68zgzjVp4c8M93TNywybihy2yAf3i3sZbWrhn2d/7Qq/ghZU SapmNc/4aYWQCad3Y7Ex76vDG9AD2LSFTmSQvB5IWXGfik7q2tIHpOt1ozwORMnBLs84 rzDYdU6lLsJ/2XYBtF1C8mHWTjOshdsjUSJLnNnbcgfAYDO33qfrfAeyN3WGaZAidlAy ejNg== X-Forwarded-Encrypted: i=1; AJvYcCUD41aIpVEKGE2ygqaj7Oy6IH6qOGsCQLp0Tzx4+aip3aspEvPT2Xbfjr1h4vbQ99N7/QgVUTFE@vger.kernel.org, AJvYcCV4zZS2tgHnfVJcpc8q0fSv7dQWVJeTv2EGlQoDvCo8yeKY3Fun/zpn1UH15IUKGlulZq9HlH0xOY5oyR2d3PI=@vger.kernel.org X-Gm-Message-State: AOJu0Yz4D6YMMVAJ5qOdI6c9PhF8O3Ias3Ei8suVON2dm9f83fPuwozu jxdPmW2P/KyhP+o3tRBDlXOLIhcsm1EMNLnAVfzI1bD1ubD/wP5xjeA0 X-Gm-Gg: ASbGnctxd5IfZvuDJ4xJ9xR+r2Mh4Nn9i9JF4DrsxH+s9qFF6hJmVDug0uI/gv2lqmt RLCkFS5MYcD+qHfSPmaST4xrMn082vhE4feuWOJHIE41mjcXhI6ZaiBPpVqUstTBwZkIAPHjdGH Z2H6PVCe4rA6h3eN/sppbmUzAaB2DxZg/O6ZesQEE8KiEZkEo4IhOuiPHDDJMYC/YUax3Fo7VB1 i9hNWjFVt7B1rul1A/iaryXY3AQbBMCvUNZYbpURbiZR3n3pSUquGivJIROp/9r8DdObEFB6f+R c+Ew7ZK4R5h497CI/nzJAm2NAV1mJ2Owtn7JhHDFbQC7ujqphoicFVOL60sYRke7EPKYeenpybf Uvka3mnUdHX99BxhnoXYozOVTVtvDkw8Kpw== X-Google-Smtp-Source: AGHT+IFG96x9+hmd3HCFTPQlZzkUtuhxREt1yTfU/jsOZTgQ9ijbuZZE98ghypqaQRZPSkxLsYVs3A== X-Received: by 2002:a17:907:7e93:b0:afd:d62f:aa4a with SMTP id a640c23a62f3a-b04930b436dmr59750666b.9.1757008855551; Thu, 04 Sep 2025 11:00:55 -0700 (PDT) Received: from localhost ([2a03:2880:30ff:9::]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b04110b94cbsm1257139366b.93.2025.09.04.11.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Sep 2025 11:00:55 -0700 (PDT) From: Breno Leitao Date: Thu, 04 Sep 2025 11:00:40 -0700 Subject: [PATCH net-next v2 1/2] selftest: netcons: refactor target creation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250904-netconsole_torture-v2-1-5775ed5dc366@debian.org> References: <20250904-netconsole_torture-v2-0-5775ed5dc366@debian.org> In-Reply-To: <20250904-netconsole_torture-v2-0-5775ed5dc366@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, asantostc@gmail.com, efault@gmx.de, calvin@wbinvd.org, kernel-team@meta.com, Breno Leitao X-Mailer: b4 0.15-dev-dd21f X-Developer-Signature: v=1; a=openpgp-sha256; l=2432; i=leitao@debian.org; h=from:subject:message-id; bh=EWRGVYbzjKHznInjRONuXtYIkysZPWgAaf+XG+yvXcU=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBoudPUZZqljD5URdD+uIenEMe7tUQWpVub81qWW DGlxoreVk+JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaLnT1AAKCRA1o5Of/Hh3 bZ71D/9zLH23nfh2FekoBhwVMbTnRuGnLQPAi+Ne6hv1vPzX2aVQtvYmmc0wGGgtrCWL8K10VC/ uC8kFOwLEnuefjzyCnPRq7yjLn50hjRceEJOA855Z9m3+Ssu2PefE1A47UqJvhe/UxYblu5vLn2 BRWRSVzZeA7bTrcMSIGshNLahcDp4Q9UOakCVZcrGbMJl/+Ff5JqBzWEXVzOhJY9T+/TvNDyh5h IgaHhaA8A+859kkdvRxMFUL/UlNs1hm67b8cTLg3SCr6fdAm5UYCaX15E3qlu0ZF30S/3SmNG0K WhIjhURrZDoU0v+r5CcrmYiec6qsez5zCZ2WMZR458i9UjsVE2g53E9xbS42B/GTQC3+DS5hDK0 0WIEx4Yi47qMsg2NqwPoj4/v3lAru1xdRq+bMbvHI/TRyjAZmH4V+UHWaLFsK6tWua8fQmes9io 1OHbrQ/9YOfvvxNLHRbjZZFWabhqYM9dcr0tx5Teq2RwYuys82TIQUVT06ejcCnWDUvlb0188AH MVbayfcfSLX5aZ0sUUSFOxGeeg662G3gijjArdcRovzVJuen0F58QEoLrgAKsJ0apI2d4Bynwh3 3RrBMgxmoMhWgSsmRfN4p8umZwpOt9F6vKFCpjcLn61Dh7MQvhNmoXOSFd/H/sL/gWMIuY5BKE7 Rh5pyVAZRFq+YAA== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D 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 --- .../selftests/drivers/net/lib/sh/lib_netcons.sh | 30 ++++++++++++++----= ---- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh b/to= ols/testing/selftests/drivers/net/lib/sh/lib_netcons.sh index 8e1085e896472..9b5ef8074440c 100644 --- a/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh +++ b/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh @@ -113,31 +113,39 @@ function set_network() { configure_ip } =20 -function create_dynamic_target() { - local FORMAT=3D${1:-"extended"} +function _create_dynamic_target() { + local FORMAT=3D"${1:?FORMAT parameter required}" + local NCPATH=3D"${2:?NCPATH parameter required}" =20 DSTMAC=3D$(ip netns exec "${NAMESPACE}" \ ip link show "${DSTIF}" | awk '/ether/ {print $2}') =20 # Create a dynamic target - mkdir "${NETCONS_PATH}" + mkdir "${NCPATH}" =20 - echo "${DSTIP}" > "${NETCONS_PATH}"/remote_ip - echo "${SRCIP}" > "${NETCONS_PATH}"/local_ip - echo "${DSTMAC}" > "${NETCONS_PATH}"/remote_mac - echo "${SRCIF}" > "${NETCONS_PATH}"/dev_name + echo "${DSTIP}" > "${NCPATH}"/remote_ip + echo "${SRCIP}" > "${NCPATH}"/local_ip + echo "${DSTMAC}" > "${NCPATH}"/remote_mac + echo "${SRCIF}" > "${NCPATH}"/dev_name =20 if [ "${FORMAT}" =3D=3D "basic" ] then # Basic target does not support release - echo 0 > "${NETCONS_PATH}"/release - echo 0 > "${NETCONS_PATH}"/extended + echo 0 > "${NCPATH}"/release + echo 0 > "${NCPATH}"/extended elif [ "${FORMAT}" =3D=3D "extended" ] then - echo 1 > "${NETCONS_PATH}"/extended + echo 1 > "${NCPATH}"/extended fi =20 - echo 1 > "${NETCONS_PATH}"/enabled + echo 1 > "${NCPATH}"/enabled + +} + +function create_dynamic_target() { + local FORMAT=3D${1:-"extended"} + local NCPATH=3D${2:-"$NETCONS_PATH"} + _create_dynamic_target "${FORMAT}" "${NCPATH}" =20 # This will make sure that the kernel was able to # load the netconsole driver configuration. The console message --=20 2.47.3 From nobody Fri Oct 3 05:25:15 2025 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.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 0A83B34166F; Thu, 4 Sep 2025 18:00:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757008860; cv=none; b=qybEcCRjQx86HswRR7ot5Ffsgmv9UM6fn2X7ntXAmgMUC22tfgRZHNGPYrmtkycCQK0PiucAO8K7UoS3bsB40Cwjn2l38cFFQ5cHXhUGt6dWuZ1OMOJQRiO4LCU5x6FNIzB+fHG9phfrqIY0Gyw2MqEB8nU2OUZj/4joFw51nrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757008860; c=relaxed/simple; bh=Rj/aqwJo1eDbOH1a9/u0mZvk6QA6zymZcXs+2NbyVlw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M7pRiuEtFklabBAVgLLvUMOVBJYW3I0O6EI6DxoERrKdED7Pf63oUW4Yrn6mnk3xNahmNqJypHQhOhHQ4qkVCpKWA/wcp/QkedjNlobwo1W/t5WB5B//4V/WdhOhOvDJpEPU951AjO68rOOLrfHupFoFgc7h68lFtOKvXyTuYTY= 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.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-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-6188b6f7f15so1854277a12.2; Thu, 04 Sep 2025 11:00:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757008857; x=1757613657; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P8TcQd40DwftcY+OnUbKSA5yId8h3+mNgJMC7BEIRO4=; b=eoV5xEyKc2LKj6d1kwoT+/PszprHB5cLbqf1tTsqL/LwlPikY78pNmpME7Skgh0kZt CnsS+0xlTuKSf4VkGqdukuJbqjO1Qj0VnmbqqQSkN+JoODQTVrLX42rpZx9CPAIRwtZU onnaY2AAtvYamFf7xSy7zfqQg25wGnnOUMckS68Cf8Rznysgyw56eHgxLFFZbNt4GLBQ hutIyvtAmbVOWiAvCCUcKUSVQt3bGA7dsnqscNye4ic80djHJZugowTWTMl1O2CJHCMH SjveSE4FpfCamsBmLnuRQt/AjxfjD2vOKFOluOxAAVHWHgv7y4Sd/X9Dgug9QkSLvD9Y EJdg== X-Forwarded-Encrypted: i=1; AJvYcCUQsA7qZhD7Q0UFEmyyxD+5cishYQal5p0TzyB9vNhOkV7SA0xpisEvVZZf5tLuEWf+9BzXZ2V+8cjifCH57I4=@vger.kernel.org, AJvYcCXSVI+OFF2yKPRWgTG+tkI0nhpiEYqjsk+8vNsh6dnMM7yXw4o16qRnPGDPEoJtqXu+9/uR5V/R@vger.kernel.org X-Gm-Message-State: AOJu0Yzh0tYPEMkhDJP/5u7Bw1LiJLpAs945vQE/vTJllfLS1Mhft+3C EYqBdMZ20nEPdJ7nijs3w6GT8NqzhAn1itPnm5Q/oJw0kx+93qzUArcs X-Gm-Gg: ASbGncs0Fqwq8KMMYGO9NDfINRLSaAhFPptrzqxJIrA5hcLWB5oHbZFTmFU9ea4r5uk zNDCUD/QNx/Xji6eY0YYL9SrrzIJXqtPr9ap9G+fhINMymXXGr2MOp7D8p1T49XSexygaLdJ/dL ChKOA9RnGuJMO+T9IYS4ue9HlzWG9jJwkhR+bS5Uy+iAU0IgoZBgt6mYpOQTO1dG+IUpoiO3ZIc 6RGbiN2RFZ2xdrS+fAJU8AvO6WwUbJJ3OeRvjjsnk+m6zCgjWf9eUs1wiVOOIX2I31mMIM72Yb/ mMSZV9tuFQTabuZhEGDBGj8LqBptgBtg0BOjQPCApjU8wKCH5YPQqjOwojv+I6BjEZTePtRB8Lk k4D7dLImGIA== X-Google-Smtp-Source: AGHT+IGevcgoHTZIQ292kIzWTrPkKUWbWymSXeh3zV9OYq806RT7xD1Ty3dCoqV0TTU/yKG1Xkqrig== X-Received: by 2002:a05:6402:4382:b0:61a:9385:c795 with SMTP id 4fb4d7f45d1cf-61d26eb51f8mr18283230a12.38.1757008857070; Thu, 04 Sep 2025 11:00:57 -0700 (PDT) Received: from localhost ([2a03:2880:30ff::]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-620e3289db2sm336619a12.4.2025.09.04.11.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Sep 2025 11:00:56 -0700 (PDT) From: Breno Leitao Date: Thu, 04 Sep 2025 11:00:41 -0700 Subject: [PATCH net-next v2 2/2] selftest: netcons: create a torture test Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250904-netconsole_torture-v2-2-5775ed5dc366@debian.org> References: <20250904-netconsole_torture-v2-0-5775ed5dc366@debian.org> In-Reply-To: <20250904-netconsole_torture-v2-0-5775ed5dc366@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, asantostc@gmail.com, efault@gmx.de, calvin@wbinvd.org, kernel-team@meta.com, Breno Leitao X-Mailer: b4 0.15-dev-dd21f X-Developer-Signature: v=1; a=openpgp-sha256; l=5156; i=leitao@debian.org; h=from:subject:message-id; bh=Rj/aqwJo1eDbOH1a9/u0mZvk6QA6zymZcXs+2NbyVlw=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBoudPUDrDLTIJL+kC+/eGhpFfugCgwWmtScz0VP 34vn+t1FCyJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaLnT1AAKCRA1o5Of/Hh3 bebuD/9MStT2lufaDTldmt2sNGc2M2MNBes+dTYSaMN7WKcwz1LOGc/qrHwkZvekPgrtpSuNZIm NNR79RQcNOT6UTFis1Ndv4J7ER5Oiw5qB8j545sZiN2CQdD5kwCaa1qM8dvr7n6nXw7HPK79Txi 82qMNiZ3M4f/vHntZFco4kKMXhCYm8VzGIEo2fExqFKoiGHcU864cod1frLPWufVyJBODWSd8ov bt2Co8GtKwYFFX2CAuNH6NCBvGCL4Mi8FZ6g1CrIPOs3ZG+0PfGzVR0+nzmchUrUR/+gSMNOaXe k1FRG7GFRcDpFzBmPX0dDDJ7oUyPv5oPvzpAHLuLAlw8D2Lmg1TixBv0pS0xA91GMfh7cIHzzJe RPdsbh6iKLt4GfLerDLIysahvC3L9heOHIKee4VdOr2WSh/t6f1DMJNEmiEEw9vpXjJeU2Vlw90 KsA8ZP3cuJuJryDeeWqqy5qLsRWKEVp6LKMaHp9lKi1G+kWNt0gyi2jAMJTXDH/Kak5U7Vb3+Nk fgpnodIIbs7szBLzLb2tBbwCOkKFqeWrwmu5uHHzLDF3Eu1EO1+M4RMNNQQc2J7t0LlfAHrZhzW Ugsr3H0XE9ruonOygV+Zq6MpMc0939T2T9+OqROomRpR93TV4U+O2tQicNLYGbxoBnTMWibOUU2 bYhd1hYad4qhRGQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Create a netconsole test that puts a lot of pressure on the netconsole list manipulation. Do it by creating dynamic targets and deleting targets while messages are being sent. Also put interface down while the messages are being sent, as creating parallel targets. The code launches three background jobs on distinct schedules: * Toggle netcons target every 30 iterations * create and delete random_target every 50 iterations * toggle iface every 70 iterations This creates multiple concurrency sources that interact with netconsole states. This is good practice to simulate stress, and exercise netpoll and netconsole locks. This test already found an issue as reported in [1] Link: https://lore.kernel.org/all/20250901-netpoll_memleak-v1-1-34a181977df= c@debian.org/ [1] Signed-off-by: Breno Leitao Reviewed-by: Andre Carvalho --- tools/testing/selftests/drivers/net/Makefile | 1 + .../selftests/drivers/net/netcons_torture.sh | 127 +++++++++++++++++= ++++ 2 files changed, 128 insertions(+) diff --git a/tools/testing/selftests/drivers/net/Makefile b/tools/testing/s= elftests/drivers/net/Makefile index 984ece05f7f92..2b253b1ff4f38 100644 --- a/tools/testing/selftests/drivers/net/Makefile +++ b/tools/testing/selftests/drivers/net/Makefile @@ -17,6 +17,7 @@ TEST_PROGS :=3D \ netcons_fragmented_msg.sh \ netcons_overflow.sh \ netcons_sysdata.sh \ + netcons_torture.sh \ netpoll_basic.py \ ping.py \ queues.py \ diff --git a/tools/testing/selftests/drivers/net/netcons_torture.sh b/tools= /testing/selftests/drivers/net/netcons_torture.sh new file mode 100755 index 0000000000000..ed95cdac7f47a --- /dev/null +++ b/tools/testing/selftests/drivers/net/netcons_torture.sh @@ -0,0 +1,127 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-2.0 + +# Repeatedly send kernel messages, toggles netconsole targets on and off, +# creates and deletes targets in parallel, and toggles the source interfac= e to +# simulate stress conditions. +# +# This test aims verify the robustness of netconsole under dynamic +# configurations and concurrent operations. +# +# The major goal is to run this test with LOCKDEP, Kmemleak and KASAN to m= ake +# sure no issues is reported. +# +# Author: Breno Leitao + +set -euo pipefail + +SCRIPTDIR=3D$(dirname "$(readlink -e "${BASH_SOURCE[0]}")") + +source "${SCRIPTDIR}"/lib/sh/lib_netcons.sh + +# Number of times the main loop run +ITERATIONS=3D${1:-1000} + +# Only test extended format +FORMAT=3D"extended" +# And ipv6 only +IP_VERSION=3D"ipv6" + +# Create, enable and delete some targets. +create_and_delete_random_target() { + COUNT=3D2 + RND_PREFIX=3D$(mktemp -u netcons_rnd_XXXX_) + + if [ -d "${NETCONS_CONFIGFS}/${RND_PREFIX}${COUNT}" ] || \ + [ -d "${NETCONS_CONFIGFS}/${RND_PREFIX}0" ]; then + echo "Function didn't finish yet, skipping it." >&2 + return + fi + + # enable COUNT targets + for i in $(seq ${COUNT}) + do + RND_TARGET=3D"${RND_PREFIX}"${i} + RND_TARGET_PATH=3D"${NETCONS_CONFIGFS}"/"${RND_TARGET}" + + # Basic population so the target can come up + _create_dynamic_target "${FORMAT}" "${RND_TARGET_PATH}" + done + + echo "netconsole selftest: ${COUNT} additional target was created" > /dev= /kmsg + # disable them all + for i in $(seq ${COUNT}) + do + RND_TARGET=3D"${RND_PREFIX}"${i} + RND_TARGET_PATH=3D"${NETCONS_CONFIGFS}"/"${RND_TARGET}" + echo 0 > "${RND_TARGET_PATH}"/enabled + rmdir "${RND_TARGET_PATH}" + done +} + +# Disable and enable the target mid-air, while messages +# are being transmitted. +toggle_netcons_target() { + for i in $(seq 2) + do + if [ ! -d "${NETCONS_PATH}" ] + then + break + fi + echo 0 > "${NETCONS_PATH}"/enabled 2> /dev/null || true + # Try to enable a bit harder, given it might fail to enable + # Write to `enabled` might fail depending on the lock, which is + # highly contentious here + for _ in $(seq 5) + do + echo 1 > "${NETCONS_PATH}"/enabled 2> /dev/null || true + done + done +} + +toggle_iface(){ + ip link set "${SRCIF}" down + ip link set "${SRCIF}" up +} + +# Start here + +modprobe netdevsim 2> /dev/null || true +modprobe netconsole 2> /dev/null || true + +# Check for basic system dependency and exit if not found +check_for_dependencies +# Set current loglevel to KERN_INFO(6), and default to KERN_NOTICE(5) +echo "6 5" > /proc/sys/kernel/printk +# Remove the namespace, interfaces and netconsole target on exit +trap cleanup EXIT +# Create one namespace and two interfaces +set_network "${IP_VERSION}" +# Create a dynamic target for netconsole +create_dynamic_target "${FORMAT}" + +for i in $(seq "$ITERATIONS") +do + for _ in $(seq 10) + do + echo "${MSG}: ${TARGET} ${i}" > /dev/kmsg + done + wait + + if (( i % 30 =3D=3D 0 )); then + toggle_netcons_target & + fi + + if (( i % 50 =3D=3D 0 )); then + # create some targets, enable them, send msg and disable + # all in a parallel thread + create_and_delete_random_target & + fi + + if (( i % 70 =3D=3D 0 )); then + toggle_iface & + fi +done +wait + +exit "${ksft_pass}" --=20 2.47.3