From nobody Sun May 24 18:44:41 2026 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (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 CA35939769E for ; Sun, 24 May 2026 16:12:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639146; cv=none; b=WNTKbb/fU2dZXdr8s7/Afyt2zNVjwaGH4OwRgAtVXIVpC5aZn0C7jVUmnLCJiy3SgUkc5jZbv84yl9gOEx9EwOhSpn9X7jb7oDbocX68Aqk514yfAPJAjjLckHtXcdqNGZ1PPXBqVSK+/LfUKL3GCn6awSqxM12ewhikMJpUpjA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639146; c=relaxed/simple; bh=T9qIxgaheOEm+rMyCgkNcm0rzEL5ECu5Zl3Ffl94m/w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rzaeJyRPWhr0DMJB23TNDY2G5BxG7DPlNaenGqwUsascveLF6Kp2QnUni2qS8+i08XDKveBAUKZJ9R1Mj717V2d/qFO2f5ORqPreGSuKRJr2yTKJTZ89B6yM3A+pCkbkE+aVTBwWmOLI5KmtJlhODzsAS2/RhpYe+MHRjY5YFxA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-7df05fc49e5so9187809a34.3 for ; Sun, 24 May 2026 09:12:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779639144; x=1780243944; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=movPS/nWqhcug4Zf5cEU9tpTwZ6Ry4Oer6dKVmnqmVw=; b=D6czZg9ho8krDZnDxvEIV9Ac6UYZ11OMACU214/963VqS1KSUOkvEm6E85Jwc4lXI9 ei9qXZ3GRckHRIejSZtxUifFsNfp6VkYDJPj3yLJx+jfvbxI5pbMJM/C/L3qhXXR3Tjb LG+cA4C9d6ZirWLBjikpm52QhhqGrbKEdCyIZ0A3zEEORCILm9UM/CZTwX7f5QGXEJ9F Hm8Tgtv2qqYqJnV8MtoO0cGxFKDXKlIPEG55faNgT47sdoN4BqON/zG34lAPLRo1QYV5 b8X2Ki1Xzq389bqoM67rQoh5bYdZxlVC9bALaCba5rv11ZedDPxa+fVLpV6hT7QkgnN4 llgQ== X-Forwarded-Encrypted: i=1; AFNElJ9k1d1tBo5o1D8c9fLOZZUnCqSlTM5ZDA3YkLzzC0XIOZUQGirdzeeSoOCDxMypO4RVRx/m+Oa7PG/iHEQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwiawBSc6VtpstdZ0kf0F7BCXMpwe7NBqb32erKhSoNBqtvFXBH 0zscd2zKkfpOCf3BKLuooYZ3KNMieLJEqxlnZlV+uajOPNq9GwOJPFDx X-Gm-Gg: Acq92OEznznsBro6Jvm71i0RVFAR3sgYvJovQ72leB1aIClaW6Dd1DzW5xb9AA9PSWW k/KvI6aoXKSY+69oyHCl56uvELjFMl7bxkBv1LooudSl924CipBVHYeJvb2gp/JuDXJVikligs1 ZjD/Z2VfK2ObHsJIrO9eNDThXakj3MyjRgDRvdlgpd2tm+Rx+NPAplzBH0ssJ9x6bqUcnKAVBaW RDlVBMbIPQET4NReTTnZ1xXbW21fLjnrgONQunJGxoLcohHIFMSEqup9B4o//Ke6Ep2vGZmOGeZ pp0AXpi44r08vTvqyLbY2TAafKfHq6Eo8jvUlb7GTTnjxfVTAsqej5QwIL0Au2tHDqA7+sKGIll EgK7jRF/kj/Ei0xVYkvHkr6uxTF5Aen+Q6/fmn+30OslGqXTHTw8UhmwvvcKqMRM9/bNJIGvP2J /oi19IVPIImvRr X-Received: by 2002:a05:6830:3789:b0:7d7:d524:bc88 with SMTP id 46e09a7af769-7e5fed4ba10mr8019625a34.10.1779639143752; Sun, 24 May 2026 09:12:23 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:1::]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7e60666ae5fsm5566542a34.24.2026.05.24.09.12.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2026 09:12:23 -0700 (PDT) From: Breno Leitao Date: Sun, 24 May 2026 09:12:17 -0700 Subject: [PATCH 1/9] netpoll: export refill_skbs(), refill_skbs_work_handler(), skb_pool_flush() 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: <20260524-netconsole_move_more-v1-1-909d1ab398b4@debian.org> References: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> In-Reply-To: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, gustavold@gmail.com, asantostc@gmail.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=2949; i=leitao@debian.org; h=from:subject:message-id; bh=T9qIxgaheOEm+rMyCgkNcm0rzEL5ECu5Zl3Ffl94m/w=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqEyNlhqHigKt/B4HA1tPvLMeXNVsZ5gVhxBN+9 Ybr7Zmaw3CJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCahMjZQAKCRA1o5Of/Hh3 bVWZEACRAQ1Mga9O7ihpelGl2ZqjGLT6b9tCB2RtvtZ+1WcwPMMAF2i+z93SQr7aCJu4JukJC8X ha8cJAm/zQ1sM4m5wGsQR0686akwAynFbEbQLXkNzs3QDHMoZxiTTuA3ZYBemOPFpjG/040tkQ0 fXmJ+sDvcQPYEry5vp15bGwBJqG5ezkyx7PauFnm02FScy/9ytU3HnfGtmA6VGuGECH09V/y3Nb rYXjhtWz0CLMTjiWJzPWweQGkQLzg3Ft10GHUkhFKp7QfMYZEstAnipATnpC9zBHEDtL0HwEfh1 r3nDkkrJi6ueaU1l6ZOaNqxFoFISyit8xyl7alVh2CXhPuBahM/5NUznNOXdSg75pbfaCkrj+8+ fKaKglGBOrbm9XnWbvFzaI8EIP+Ox0pb4IUkacM/Luy69qYwNega80FciWabzDkgpNoTBrQkb2O VldQstss2VmkVmTkVcUADdXijeYk5rUaFP2jIyTNxmMaODKNduIrHYRfbYmFxuaW3hXI6dfPXfL E2OhcC43FLo9zdRfhOwaO9p8HBGdxO8xbu9YHP1qQ8vGIhCGwe8NZiPGU0DjLnXstrfMmhsVaxP Z6G6+tP8nUB2ZEsOb43VDKWt7nEEsDFSsWYQxa8jm6lDMy3rLCU6wqOJvnTcsWbQgng0xDTkA4l mGq4dPvo17+8u/w== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D These three helpers manage the per-netpoll fallback skb pool. They are file-static today because all of their callers live in net/core/netpoll.c. Subsequent patches relocate the pool's owner from struct netpoll to the only consumer that actually uses it (netconsole), and that work needs netconsole to drive the helpers directly while the function bodies still live here. Drop static, add prototypes in , and EXPORT_SYMBOL_GPL() each. No behaviour change. The exports are transitional. Each helper is moved into drivers/net/netconsole.c later in this series, and at that point its EXPORT_SYMBOL_GPL() and prototype are dropped. By the end of the series no symbol introduced here remains exported. Signed-off-by: Breno Leitao --- include/linux/netpoll.h | 3 +++ net/core/netpoll.c | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index e4b8f1f91e54..9fa4deed0bff 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h @@ -74,6 +74,9 @@ void netpoll_cleanup(struct netpoll *np); void do_netpoll_cleanup(struct netpoll *np); netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb); void netpoll_zap_completion_queue(void); +void refill_skbs(struct netpoll *np); +void refill_skbs_work_handler(struct work_struct *work); +void skb_pool_flush(struct netpoll *np); =20 #ifdef CONFIG_NETPOLL static inline void *netpoll_poll_lock(struct napi_struct *napi) diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 33ab3d827a42..84cbfa85028a 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -220,7 +220,7 @@ void netpoll_poll_enable(struct net_device *dev) up(&ni->dev_lock); } =20 -static void refill_skbs(struct netpoll *np) +void refill_skbs(struct netpoll *np) { struct sk_buff_head *skb_pool; struct sk_buff *skb; @@ -235,6 +235,7 @@ static void refill_skbs(struct netpoll *np) skb_queue_tail(skb_pool, skb); } } +EXPORT_SYMBOL_GPL(refill_skbs); =20 void netpoll_zap_completion_queue(void) { @@ -356,7 +357,7 @@ netdev_tx_t netpoll_send_skb(struct netpoll *np, struct= sk_buff *skb) } EXPORT_SYMBOL(netpoll_send_skb); =20 -static void skb_pool_flush(struct netpoll *np) +void skb_pool_flush(struct netpoll *np) { struct sk_buff_head *skb_pool; =20 @@ -364,14 +365,16 @@ static void skb_pool_flush(struct netpoll *np) skb_pool =3D &np->skb_pool; skb_queue_purge_reason(skb_pool, SKB_CONSUMED); } +EXPORT_SYMBOL_GPL(skb_pool_flush); =20 -static void refill_skbs_work_handler(struct work_struct *work) +void refill_skbs_work_handler(struct work_struct *work) { struct netpoll *np =3D container_of(work, struct netpoll, refill_wq); =20 refill_skbs(np); } +EXPORT_SYMBOL_GPL(refill_skbs_work_handler); =20 int __netpoll_setup(struct netpoll *np, struct net_device *ndev) { --=20 2.54.0 From nobody Sun May 24 18:44:41 2026 Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (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 3366E3A7D6F for ; Sun, 24 May 2026 16:12:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639148; cv=none; b=oGnmjBWYNE6BZstpysOqMEeHy4zdvSnn/Hu0+KJDndkjfZwWdFGWk6fgtMrVC2q6eH1ntVxCTLea6F95DEUmKl9AE9Tw2uBJfZcUnwE0iovW1rU269cJukypV9nnfQokMCFExud3Tr5tf3Pz3j73wxa6p4oEFR6KFJpuIJDDNwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639148; c=relaxed/simple; bh=5/m2fXEcKTwq4VE2M3CiECuFwRYgiwJCNHqcIKe3YtI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fSGoSXhUrGmIBBggj02nqumHax4n8ek1TOAcYEum/skPnHlgsJ5WX9Qy+SQ2GMIa3+ta63DWJezcDi1D3QuqnwULLlKE1wnreOKvyyaOGQquQnuDYZASwngCC+WVB9cc45kU2p+u+h0m+RYTxS8jQwiFrgCA8G5QhUAjNesylkk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.167.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-484cf882ce5so6475206b6e.1 for ; Sun, 24 May 2026 09:12:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779639145; x=1780243945; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=a2y50PnAa7g4k/kKUP511R8FfNJbjHYAN7KunxmODts=; b=O6mHzy7XmLQOzGeCwMoDVTLzQfsz6Yjg/AhVnleJEvMWNykFWwk4HOUk+TYsBKyHfl LzAvGXcyLXIz0STVgPnEzZ7ZqXOkE8MRc201drtuAlS6UNuRgqG0697Zf1IAQa537Ji2 SGrVkDctkD63HnsTb0Ni2ZK7DYgnO0wapoYuPJ0V30pUGZjwdjoaMxH1uaSHf8w7ZPdc 9o5FfcJW2+NUQD6Uq+Mjd+HoycQxYic9qdIrDkAPRBFOCiaAcgo3l1gaHxyeIwPvuyBh zX0OqsYcSO+Ga+NM6m8n3s2aDfqTpdaKXtoyzh9aQ4XC+cgJnpQTVdzyoQtOCPhUysNt HMeA== X-Forwarded-Encrypted: i=1; AFNElJ+A7dE5uXk6iw9LBPefHH77IyIrL3t5Box7QPjEUBRZp39qCTXP4iMGMt1T6zlqScjuofDXmtU4ZwA/Ji4=@vger.kernel.org X-Gm-Message-State: AOJu0YyXBn8pjHFP1BNPQ4t1LTS50I9Kkb7H9Ih2JvOgqCSUKViIZcKf uPaU/iS8715lp3E6xNfwT2fx4sBICs9b8Ke6ynrBvrOSeKlK08BGEH73 X-Gm-Gg: Acq92OHTWIywqrlOZfUo24w+8u1SMDJqsZa6z92J1BicrjodV6N8Tys1Lyj23zsbZuz 1MdL9x87hfKqD/3wEeVUrFGZFQgV9lWck1h7Yfv41NI75eSrkuWI35LxXemndjYAYm9udGRYL3p j6rc1f7AsII8hVSv2LGLDVGACAt2NLl7/Xgc5qsJ480H20fUiRpPqzhb7nwu3TaKaYds3ZVly+H D9tbmXvWslzPXmVnz6LBrE/TG5Jszy7cI9aCDfJoiD5HHwWfab7xeWll87suz7ktsoo6R93mDZ3 NeHnvXWV2LZ9vo2RbadTTUR/XncLA45LYHe3U/s0iPqF0fMTpj2AOXyd7sj1q4vGRnsLcpucalv FFizbaL85nA/VBYMlSBO/w2PoXApdOvaXVXfDUw3lQ/GVDDQ1yuH3mCSdLrVjMisa+x6WW3FB6f 2QfJhU124eKpoHew== X-Received: by 2002:a05:6808:c1ae:b0:479:d16e:9619 with SMTP id 5614622812f47-4854a27111emr6939423b6e.43.1779639144986; Sun, 24 May 2026 09:12:24 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:49::]) by smtp.gmail.com with ESMTPSA id 5614622812f47-48554041ccasm3466118b6e.0.2026.05.24.09.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2026 09:12:24 -0700 (PDT) From: Breno Leitao Date: Sun, 24 May 2026 09:12:18 -0700 Subject: [PATCH 2/9] netconsole: take over skb pool lifecycle from netpoll 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: <20260524-netconsole_move_more-v1-2-909d1ab398b4@debian.org> References: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> In-Reply-To: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, gustavold@gmail.com, asantostc@gmail.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=7752; i=leitao@debian.org; h=from:subject:message-id; bh=5/m2fXEcKTwq4VE2M3CiECuFwRYgiwJCNHqcIKe3YtI=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqEyNl49Q26LAEvxIZTEXRoIXWm3bJsHNlyyewR L0NbFgoc0eJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCahMjZQAKCRA1o5Of/Hh3 bRG2D/946bEbT2U/pu14FaNnejmEZ3OBAIEv7PLH7oMhI8B7JQNPvA+LSRiWZupSYcOwaLg3/L+ 1+OocNFout0KUstLIZZgDJA+CxHVSh2iVTosTpbxmvCIp/+EDfPbgRoHm/FNSybOXatp+mU/vLT EJSkvP+SCEseosxWtevl+0X/qg+SlbWdQ5qLp1lfxMiUgQkjlx3rh8hXOBOjHZq7qRePicOFAPw xBzFfgRVUP+pphDVL0QTAwNJ8Zer4WZ81HJpMUaCHxEEw5qSIN3emPw6ChO4gcg8dEIDqu3i+5g YrPCH1FoxPsFRZ6xVd14+RWAvty83720j3H+QFcfsr2bc7qiezmCejAd0Fy6QozTvhY/LpuNO9o okrkJFJvOb2pwoGq/beGJWwYCVxMecsPFkYkk+qU2UwFNbACYBsnKCIRr309A5K/x+O5YY0GvWI bE2OrR293iEmvCn2AiSce+QtrQPstnhqno5VWeKvk5dL4sZgG8IJqGG7Qpjmzwc7hPsJ729YH0b 6snQq8UDkq/Z6hxyPWu4XRPwaQlJ6JNPqThwYeeVbeQCQnwU6j7bx5XAoH6tn47h9u4zMdTQ8uK RQDkgM3//8wNfUtMQGDimdrp7VCa0GDOa8S2xq2trVoPF2DpTlcm7OIUCiZF5fXv6rhhe00zhVV Q8UJfz+T37scK5g== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D The fallback skb pool fronted by find_skb() is netconsole's only client: every other netpoll consumer (bonding, team, vlan, bridge, macvlan, dsa) goes through __netpoll_setup() / netpoll_send_skb() without ever touching np->skb_pool. Today __netpoll_setup() and __netpoll_cleanup() create and destroy the pool for everyone, paying ~48 KB of pre-allocated skbs per netpoll instance that almost nobody uses. Move the responsibility to netconsole. Add netconsole-side netconsole_skb_pool_{init,flush}() wrappers that call the (now exported) refill_skbs(), refill_skbs_work_handler() and skb_pool_flush() helpers, and wire them at the same three netpoll setup paths (resume_target, enabled_store, alloc_param_target) and matching teardowns (netconsole_process_cleanups_core, drop_netconsole_target, free_param_target). Init runs *before* netpoll_setup(), and the failure path flushes before returning. netpoll_setup() makes nt->np.dev visible to target_list walkers (notably netconsole_netdev_event); if a NETDEV_UNREGISTER / NETDEV_RELEASE / NETDEV_JOIN raced and moved the target to target_cleanup_list before init had run, netconsole_process_cleanups_core() would call netconsole_skb_pool_flush() on an uninitialised refill_wq / skb_pool, splatting WARN_ON(!work->func) in flush_work() and acquiring an uninitialised spinlock in skb_queue_purge_reason(). Doing init first preserves the pre-series invariant that the pool is valid whenever nt->np.dev is observable. Drop the corresponding init/flush from __netpoll_setup(), __netpoll_cleanup() and the netpoll_setup() error path; the now empty 'flush' label is also removed. The fields and helpers stay in struct netpoll for now; subsequent patches relocate the helper functions and then the fields themselves. For non-netconsole consumers, np->skb_pool / np->refill_wq are never initialised, never refilled and never flushed by netpoll itself, but they are also never read by anyone, so the change is a no-op for them. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 51 ++++++++++++++++++++++++++++++++++++++++++++= ++-- net/core/netpoll.c | 12 +----------- 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index d804d44af87c..b84de3ba44c3 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -283,11 +283,35 @@ static bool bound_by_mac(struct netconsole_target *nt) return is_valid_ether_addr(nt->np.dev_mac); } =20 +/* Initialise the per-target skb pool that find_skb() falls back to and + * seed it. Pair with netconsole_skb_pool_flush() at the matching + * netpoll teardown. + */ +static void netconsole_skb_pool_init(struct netconsole_target *nt) +{ + skb_queue_head_init(&nt->np.skb_pool); + INIT_WORK(&nt->np.refill_wq, refill_skbs_work_handler); + refill_skbs(&nt->np); +} + +static void netconsole_skb_pool_flush(struct netconsole_target *nt) +{ + skb_pool_flush(&nt->np); +} + /* Attempts to resume logging to a deactivated target. */ static void resume_target(struct netconsole_target *nt) { + /* Initialise the skb pool before netpoll_setup() makes nt->np.dev + * visible to target_list walkers (e.g. netconsole_netdev_event), + * which otherwise may move the target to the cleanup list and + * call netconsole_skb_pool_flush() on uninitialised state. + */ + netconsole_skb_pool_init(nt); + if (netpoll_setup(&nt->np)) { /* netpoll fails setup once, do not try again. */ + netconsole_skb_pool_flush(nt); nt->state =3D STATE_DISABLED; return; } @@ -389,6 +413,7 @@ static void netconsole_process_cleanups_core(void) list_for_each_entry_safe(nt, tmp, &target_cleanup_list, list) { /* all entries in the cleanup_list needs to be disabled */ WARN_ON_ONCE(nt->state =3D=3D STATE_ENABLED); + netconsole_skb_pool_flush(nt); do_netpoll_cleanup(&nt->np); if (bound_by_mac(nt)) memset(&nt->np.dev_name, 0, IFNAMSIZ); @@ -732,9 +757,19 @@ static ssize_t enabled_store(struct config_item *item, */ netconsole_print_banner(&nt->np); =20 + /* Initialise the skb pool before netpoll_setup() so the pool + * is valid as soon as nt->np.dev becomes visible to + * target_list walkers (netconsole_netdev_event), which would + * otherwise call netconsole_skb_pool_flush() on uninitialised + * state. + */ + netconsole_skb_pool_init(nt); + ret =3D netpoll_setup(&nt->np); - if (ret) + if (ret) { + netconsole_skb_pool_flush(nt); goto out_unlock; + } =20 nt->state =3D STATE_ENABLED; pr_info("network logging started\n"); @@ -1474,8 +1509,10 @@ static void drop_netconsole_target(struct config_gro= up *group, * The target may have never been enabled, or was manually disabled * before being removed so netpoll may have already been cleaned up. */ - if (nt->state =3D=3D STATE_ENABLED) + if (nt->state =3D=3D STATE_ENABLED) { + netconsole_skb_pool_flush(nt); netpoll_cleanup(&nt->np); + } =20 config_item_put(&nt->group.cg_item); } @@ -2257,10 +2294,18 @@ static struct netconsole_target *alloc_param_target= (char *target_config, if (err) goto fail; =20 + /* Initialise the skb pool before netpoll_setup() so the pool is + * valid as soon as nt->np.dev becomes visible. The target is not + * yet on target_list, so a netdev event cannot reach it here, but + * mirror the configfs path for symmetry. + */ + netconsole_skb_pool_init(nt); + err =3D netpoll_setup(&nt->np); if (err) { pr_err("Not enabling netconsole for %s%d. Netpoll setup failed\n", NETCONSOLE_PARAM_TARGET_PREFIX, cmdline_count); + netconsole_skb_pool_flush(nt); if (!IS_ENABLED(CONFIG_NETCONSOLE_DYNAMIC)) /* only fail if dynamic reconfiguration is set, * otherwise, keep the target in the list, but disabled. @@ -2282,6 +2327,8 @@ static struct netconsole_target *alloc_param_target(c= har *target_config, static void free_param_target(struct netconsole_target *nt) { cancel_work_sync(&nt->resume_wq); + if (nt->state =3D=3D STATE_ENABLED) + netconsole_skb_pool_flush(nt); netpoll_cleanup(&nt->np); #ifdef CONFIG_NETCONSOLE_DYNAMIC kfree(nt->userdata); diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 84cbfa85028a..a4d176ff9376 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -382,9 +382,6 @@ int __netpoll_setup(struct netpoll *np, struct net_devi= ce *ndev) const struct net_device_ops *ops; int err; =20 - skb_queue_head_init(&np->skb_pool); - INIT_WORK(&np->refill_wq, refill_skbs_work_handler); - if (ndev->priv_flags & IFF_DISABLE_NETPOLL) { np_err(np, "%s doesn't support polling, aborting\n", ndev->name); @@ -419,9 +416,6 @@ int __netpoll_setup(struct netpoll *np, struct net_devi= ce *ndev) np->dev =3D ndev; strscpy(np->dev_name, ndev->name, IFNAMSIZ); =20 - /* fill up the skb queue */ - refill_skbs(np); - /* last thing to do is link it to the net device structure */ rcu_assign_pointer(ndev->npinfo, npinfo); =20 @@ -611,7 +605,7 @@ int netpoll_setup(struct netpoll *np) =20 err =3D __netpoll_setup(np, ndev); if (err) - goto flush; + goto put; rtnl_unlock(); =20 /* Make sure all NAPI polls which started before dev->npinfo @@ -622,8 +616,6 @@ int netpoll_setup(struct netpoll *np) =20 return 0; =20 -flush: - skb_pool_flush(np); put: DEBUG_NET_WARN_ON_ONCE(np->dev); if (ip_overwritten) @@ -674,8 +666,6 @@ static void __netpoll_cleanup(struct netpoll *np) RCU_INIT_POINTER(np->dev->npinfo, NULL); call_rcu(&npinfo->rcu, rcu_cleanup_netpoll_info); } - - skb_pool_flush(np); } =20 void __netpoll_free(struct netpoll *np) --=20 2.54.0 From nobody Sun May 24 18:44:41 2026 Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) (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 67B0B3A8721 for ; Sun, 24 May 2026 16:12:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639149; cv=none; b=d64cwB5FeFpRrdpWFDrTA8c4GmEk4Sx4py4w3zu/071MQOOU8t7PayNroi0Q9WoLm9EHSTi/1BvOCLOEwPTQoYRVhaznlY1wIZBp41BPWvYeGmAfYH4eRbn5qL2jbaL53pf+HC7xRW7nv9oTrLiLFptI8SkD96G3Y4MAt2VAAX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639149; c=relaxed/simple; bh=GNE2yLcVmAnaMs7p03niEqNRSstWxlcBl/ztKs03sM0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pLIHxC9XqU2ACJBaphIu+xJbRp5ku44BRZ/dyCuyxotD3gOG6KAsn62tNzCDvsLd6rjnmOqBNGQLyxwLmjvLeAGmZJHsUoE2cKqCUySrgo9dzDYC7TgRIl9ZjjO8VkdYM4IHYWdkZQ2WTgP+yI40bMb3TjA0Zlzv86/LY2Cu5p4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.160.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-43a2ad7bcc4so4076662fac.1 for ; Sun, 24 May 2026 09:12:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779639146; x=1780243946; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=25z3ic8/Pkx2AcYB/9aDrA71CiSAFUJRzNWM3+IEVSA=; b=SjQDMdL9VSk24D4Cr/ecNrcoMNUmbcWjdIxPKK9MdFEgJcbq3OkNEAKiOiioPAOHxM lGy1bZsH23mDXDQaxQYb2YeRseqTv0gG1hBNabFTez8ZyGOnhqXg+p3kFtH7vv7CLlWT FoM5PnjMySk65NjEctzG789FSqW28tuJqki0Wt609vmS/4iacOragMrLf6P/5YIqpumf hmFIvJc2DVnJXN6s7AmQkpVn/af4ghXuXNh+KjRfwI2wwyAKKTvejPRX4aEzLeOkHwaE UBVfKpXZ7PwbFl8LLaIsdmJnXHlC0jUbjaMlTLlviiJ0sG1Y6zKVEp+4jDH/XLkpkiNf BSAg== X-Forwarded-Encrypted: i=1; AFNElJ+lO3CwUVG/5BFpzL671J0FIhSgpYWaZMzTrApu3fCZwcTu5rBYj1TsWwCZ0Aguhkv1EksvvLwy3AvEVVo=@vger.kernel.org X-Gm-Message-State: AOJu0YybBpWaGwdcZJNI4jWKGtfTz/d4hOmilsY/aDGD/Bh9TbRMFySR bbk1jx6FQsyygGx0WteOcfNW1XVBDEM3IJVEgmlk8+VZMh86SPp64f9C0go5mNiu X-Gm-Gg: Acq92OEImJjpXdmuQizhELk9PtacuhZ/+imkLRRH0qk6qJTPKpJ5LRKst5RNr6TZG/5 vwPKdSYnmtwp+q5077jFv7OL/pO+9hsYX7HImSE7HXBV9ZrtzdFwdea9gI1quZOS3QevRG5jbbM Nd6+u/Zl5+De2fuc1WAhuJZuYuB3uMdxFB3kb+wg5/HlTq1dOmZO+ukHvsGRTYlQlo/KwUaGB1y i7+7HqBo9OYi4xkmyGrC+PIE4Ufs0IVN5O3jf1/4KsrFkCOxxa63vgSr3ABsLHAB4iOZh/gz3ve 8UN/PiGZT2k3XO90fdGeogpDy3THGrTL03FF/kJ5iTVGMSaPlzxVJPDo1QsLaA6phjzVNbF4ack o8/49po3MtTdczKekqclBYQ6sUXHrCet9wEQ3O1dT1mqkkfjTC4S2viEsn3NbmuwWq64Yn80jsR 9AoPeL1btJVyO0oVeo3TINdeAb X-Received: by 2002:a05:6870:d36e:b0:42c:1a8e:7f84 with SMTP id 586e51a60fabf-43b5aa16546mr6645847fac.4.1779639146237; Sun, 24 May 2026 09:12:26 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:40::]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-43b63512d63sm7646019fac.2.2026.05.24.09.12.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2026 09:12:25 -0700 (PDT) From: Breno Leitao Date: Sun, 24 May 2026 09:12:19 -0700 Subject: [PATCH 3/9] netconsole: move refill_skbs_work_handler() from netpoll 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: <20260524-netconsole_move_more-v1-3-909d1ab398b4@debian.org> References: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> In-Reply-To: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, gustavold@gmail.com, asantostc@gmail.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=2410; i=leitao@debian.org; h=from:subject:message-id; bh=GNE2yLcVmAnaMs7p03niEqNRSstWxlcBl/ztKs03sM0=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqEyNlGC2QPKnSBTStkOWy5dirRvVJvuTsmZ3pc YFnsdXAM4CJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCahMjZQAKCRA1o5Of/Hh3 bV3rD/4jNzFbGDNiwaiK+mjIptKK/m7rF/fDd/zwoeYN3L9Pi78WqnYyO1ze5Pgd3xjZUmiqm7m sz3wTAeiFAa56IBZIPby+VRSK6FaSd7N49zhpm/U+VJBilNJVxPSTrXKoe6SQ/WwpOM3xXH3FGS OhBR/367FVsyCfV/9LVRfHbFd5BHfPABM0hPsFoJaJc4E3V+UlItpGtSB9u74/7ylbU8cIKMphU yTETzpz+47z50B26TZUA4gptEXq+D6/Xizj8Igiach4sancEsnOEoguwn5hXRGgZ80VTyWPwl9d dCZI0SN7MwiKvZRTOaAm5wyx8/eQs+uWeIrna+xc6A62OV2/yamuHch6MJMCuFMmWA0Mn2Addlk UyJVrUN4RV9FqZuZcu5LQvUrNnj0Dgrnvt8F/yhYgsStghMaFLG9QbkhpFoi0YptXX7o7hAGQAq 5yR77IUzlydlWq65z0nihjauio2Jp5SZUPZ9V2ztUC74A/tzKduyHSSL5Mu014AG4hAV7TAYPNk fHMbZ19UmXE3ZdctppNiWNa7Xuuv9+y1omLv1uHkQ3Xteu20s/gV5ZJaylT6V6+SbhtwNPlTehM bbjgQ3uknaFyB8PHCs8DB9nWIoigz6w26pQKCqmzkXAutQtq9M8Q667S14EaRe4TFgOMatZgtbw wxfSQigWVDPxQpw== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D The work handler is wired via INIT_WORK() in netconsole_skb_pool_init() and has no other callers since the previous patch took the skb pool lifecycle out of __netpoll_setup(). Move the function body into drivers/net/netconsole.c as a file-static helper, drop EXPORT_SYMBOL_GPL() and remove the prototype from . Pure code motion: the body is unchanged and still calls the exported refill_skbs() in net/core/netpoll.c. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 8 ++++++++ include/linux/netpoll.h | 1 - net/core/netpoll.c | 9 --------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index b84de3ba44c3..3d7d17c59902 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -283,6 +283,14 @@ static bool bound_by_mac(struct netconsole_target *nt) return is_valid_ether_addr(nt->np.dev_mac); } =20 +static void refill_skbs_work_handler(struct work_struct *work) +{ + struct netpoll *np =3D + container_of(work, struct netpoll, refill_wq); + + refill_skbs(np); +} + /* Initialise the per-target skb pool that find_skb() falls back to and * seed it. Pair with netconsole_skb_pool_flush() at the matching * netpoll teardown. diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index 9fa4deed0bff..1a497d12f336 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h @@ -75,7 +75,6 @@ void do_netpoll_cleanup(struct netpoll *np); netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb); void netpoll_zap_completion_queue(void); void refill_skbs(struct netpoll *np); -void refill_skbs_work_handler(struct work_struct *work); void skb_pool_flush(struct netpoll *np); =20 #ifdef CONFIG_NETPOLL diff --git a/net/core/netpoll.c b/net/core/netpoll.c index a4d176ff9376..4111d6ee8d4b 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -367,15 +367,6 @@ void skb_pool_flush(struct netpoll *np) } EXPORT_SYMBOL_GPL(skb_pool_flush); =20 -void refill_skbs_work_handler(struct work_struct *work) -{ - struct netpoll *np =3D - container_of(work, struct netpoll, refill_wq); - - refill_skbs(np); -} -EXPORT_SYMBOL_GPL(refill_skbs_work_handler); - int __netpoll_setup(struct netpoll *np, struct net_device *ndev) { struct netpoll_info *npinfo; --=20 2.54.0 From nobody Sun May 24 18:44:41 2026 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (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 8EE873A874B for ; Sun, 24 May 2026 16:12:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639150; cv=none; b=lm07PY/z8huKGSFmrqQ7/z91BMILBIlCx79Hxt4kU4XGqHDwxJHHRDnAadSCYDVcvWFV4Wq/cvZ4fh07BWRYP1p1b3dsJSYEITOJqMiEAk1r7LEn4EH76pjRlU3DQhhtcY8bD5g9rTZCFqwFQippoM5h9+L15dx09UbnJt+oX98= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639150; c=relaxed/simple; bh=DfAMocgapgQ/LI/qEUqGA8jdlKm8WnUDdcQZ9Oss0SE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fMnPuMZfGQsoC10PZhdTqSh6WytygyKLXFbQLlFnXQ9QOHwCpXo4fDloRsIZ1gJK9EtY93XGtiXJmli6mUi38QBHmX2XXYOxjYDpdbpixVPYMsHcugbkmbQoir35BJ82Gxt37h/9r8Vibm6Wr6jxVxPA9PgF730bJ7tz1v3NVUA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.167.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-4856d563d4fso762768b6e.3 for ; Sun, 24 May 2026 09:12:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779639147; x=1780243947; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=LWDratKSJZdKmxRQRRe5Ewa5FMIG09hb/oexxLbLqXs=; b=cixb9NpzyJOkmm6euECYo8tFOowXt07MpNrANCsxHC5H2SijmWHdhbF7YIDhmC7Ewz TzdjjEBKVJBrrdBdO4PBV1cbUkQ7Mszolr2Vd8b4hMovH/NdBLFxIwIDHLXwuTeFMkc3 VcG0m+57OPvFcLIWCBBma3fVS4bPmeivNR06Y381SQkoSUHPNm0dBVATk/Lc3KSgWS3u bqnnw7Qy2oIN1RNS7FG4yrmdhKohRsLZgtAs1V9i+7pD70xDPC1JG51gtpgK13uPDry6 lgQLx/6Z4RuF876MuXLgfjm+WWj3CxtDUXdJybov4nBsJNChnFz6c+TGKcTFtb4T/nwo WZHw== X-Forwarded-Encrypted: i=1; AFNElJ8V4MFNGfKH3iUPPV5z/Nnpn+GKNC60EggfRFDsSRSXbEE42gUyvlDAAD14sKTs+XKJl5VxnXbXPzJAxTU=@vger.kernel.org X-Gm-Message-State: AOJu0YydWVgpsqy8HsyJ0LFk8Jf94bz0y/CtUFS9VYhyLWqv7kA7AhmG x1pRw0vFM4RVtBltVtVb0CWX+x58oCgTvAcITikn/sqjr+wsOZziEobA X-Gm-Gg: Acq92OEZKPM5++1nVp8p3D1KnpgBdA/02GfPQTIOFJahNvAfwzI278jxlwTtUTYvCyg pLcUAzE33oNoGNbeqp7bI15FRcp0hLhWSGCNyrKHhLdfUdGikHQOdFrh5ELC4w6lR/NoPMf8NAN 2SC7hSb8NaWSI/C+wZ8SW6WRfh3rGn/nrJsNmpNR9KqfRUwTqnXrXeBCRLMfk3NWTJDnAzg0/KF /8Dtg0zQnPNyCsZ/oQRBbEP+VvmzVijwpiAsATQRHZLOO2EplQPxhIkiQvvjsyk6KVsydZwCxv7 RZnIPZyTzDF3rWV1z1pUKAQsWAI7/lmxHpA6IbL03vA3p57m+TBA2k5gR64yT0UBUFofXupr97U wZHwgTRJtSZkprqDKiShHhMS/pzWANCrYTybButBWFUs4agYqDPRuYEhEQ/EjzK4pm02yfE44tE tNqvhM1ab6Bbz2zQ== X-Received: by 2002:a05:6808:448d:b0:482:7a59:47a with SMTP id 5614622812f47-4854a505287mr6934995b6e.46.1779639147456; Sun, 24 May 2026 09:12:27 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:70::]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7e606482b65sm5482001a34.10.2026.05.24.09.12.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2026 09:12:27 -0700 (PDT) From: Breno Leitao Date: Sun, 24 May 2026 09:12:20 -0700 Subject: [PATCH 4/9] netconsole: move refill_skbs() and skb-pool sizing macros from netpoll 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: <20260524-netconsole_move_more-v1-4-909d1ab398b4@debian.org> References: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> In-Reply-To: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, gustavold@gmail.com, asantostc@gmail.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=3932; i=leitao@debian.org; h=from:subject:message-id; bh=DfAMocgapgQ/LI/qEUqGA8jdlKm8WnUDdcQZ9Oss0SE=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqEyNlWNw3ugj9wFA7OW9WQeZKy2mrxbjA/GyBl trQ/M08IaeJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCahMjZQAKCRA1o5Of/Hh3 bd1IEACQFC685++1K0n3zuhL/63bxnY+H7TPcbfOIONCF9TvdoAISacN9gqyK8KCzPa6Lj4NBZz vaHNTRqDjDNGBzox3OGq9/Pv5/Bus5lO69TJhtTn5zKwX1uMdmNJpxj6tkhABg9p8BUZUZQVGrq gJ+148ge2a7ufXNFwvB+FUIjRaK+kJDu12wOr+JNcG9u5GRaC+yUFeKIXMYdfvLDCFmvGh3mE1s ja9GIPTdidlXhOKV1pa8/bKTC4P8b1ccdSiZqRBJ16RilpxBGsiNhxVHD9QYOIFC6qXbDTRFHaX WYVyaWU7sVeVFp7EOlsiYedroPK7/wqjaI5UaA/ykWoJksbqvWMlpLpNBh241pI4hQrp5LuGC1h 7/g/6iNLjSo8XE0G+ZHooimmgC2E+YWW5kM+ihiYvk2I1PifJO7jibQCxk/tl76Zl3OL+x2B31c CJBtSqOHRWvjoPpBLV8Q5/oi/kjtDwD+IK/WROAFeYtiE0JoRCkHPY1noD8KDe3wlC8gg7qhvyk xVnzDhEEgqzeH9HWT88EC3Y8A6AkU+DAbCi9lo9Mp7vbj4cpmKokBQhnUblVN1HnMdKNgKaXHDb 2vi4a2KTzWjruTL/5zHp9bV84Gc9rE9mXw/oixRinLzcTLEaBR13xQECxdDjLhkDYTp8gBXYy9e z4DLe6Ed2hPBuBw== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D refill_skbs() is now only called from netconsole (directly via netconsole_skb_pool_init() and indirectly via the just-moved refill_skbs_work_handler()), and the MAX_UDP_CHUNK / MAX_SKBS / MAX_SKB_SIZE macros are private to it. Move them all into drivers/net/netconsole.c. Drop EXPORT_SYMBOL_GPL(refill_skbs) and remove its prototype from ; the macros only ever lived as file-static defines in netpoll.c. Pure code motion: bodies and pool sizing semantics are unchanged. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 29 +++++++++++++++++++++++++++++ include/linux/netpoll.h | 1 - net/core/netpoll.c | 30 ------------------------------ 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 3d7d17c59902..76a569d487db 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -61,6 +61,19 @@ MODULE_IMPORT_NS("NETDEV_INTERNAL"); #define MAX_USERDATA_ITEMS 256 #define MAX_PRINT_CHUNK 1000 =20 +/* + * Sizing for the per-target fallback skb pool consulted by find_skb() + * when its GFP_ATOMIC allocation fails so messages still get out under + * memory pressure. + */ +#define MAX_UDP_CHUNK 1460 +#define MAX_SKBS 32 +#define MAX_SKB_SIZE \ + (sizeof(struct ethhdr) + \ + sizeof(struct iphdr) + \ + sizeof(struct udphdr) + \ + MAX_UDP_CHUNK) + static char config[MAX_PARAM_LENGTH]; module_param_string(netconsole, config, MAX_PARAM_LENGTH, 0); MODULE_PARM_DESC(netconsole, " netconsole=3D[src-port]@[src-ip]/[dev],[tgt= -port]@/[tgt-macaddr]"); @@ -283,6 +296,22 @@ static bool bound_by_mac(struct netconsole_target *nt) return is_valid_ether_addr(nt->np.dev_mac); } =20 +static void refill_skbs(struct netpoll *np) +{ + struct sk_buff_head *skb_pool; + struct sk_buff *skb; + + skb_pool =3D &np->skb_pool; + + while (READ_ONCE(skb_pool->qlen) < MAX_SKBS) { + skb =3D alloc_skb(MAX_SKB_SIZE, GFP_ATOMIC); + if (!skb) + break; + + skb_queue_tail(skb_pool, skb); + } +} + static void refill_skbs_work_handler(struct work_struct *work) { struct netpoll *np =3D diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index 1a497d12f336..bc491f600a71 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h @@ -74,7 +74,6 @@ void netpoll_cleanup(struct netpoll *np); void do_netpoll_cleanup(struct netpoll *np); netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb); void netpoll_zap_completion_queue(void); -void refill_skbs(struct netpoll *np); void skb_pool_flush(struct netpoll *np); =20 #ifdef CONFIG_NETPOLL diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 4111d6ee8d4b..2fca74b4ea75 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -36,21 +36,8 @@ #include #include =20 -/* - * We maintain a small pool of fully-sized skbs, to make sure the - * message gets out even in extreme OOM situations. - */ - -#define MAX_UDP_CHUNK 1460 -#define MAX_SKBS 32 #define USEC_PER_POLL 50 =20 -#define MAX_SKB_SIZE \ - (sizeof(struct ethhdr) + \ - sizeof(struct iphdr) + \ - sizeof(struct udphdr) + \ - MAX_UDP_CHUNK) - static unsigned int carrier_timeout =3D 4; module_param(carrier_timeout, uint, 0644); =20 @@ -220,23 +207,6 @@ void netpoll_poll_enable(struct net_device *dev) up(&ni->dev_lock); } =20 -void refill_skbs(struct netpoll *np) -{ - struct sk_buff_head *skb_pool; - struct sk_buff *skb; - - skb_pool =3D &np->skb_pool; - - while (READ_ONCE(skb_pool->qlen) < MAX_SKBS) { - skb =3D alloc_skb(MAX_SKB_SIZE, GFP_ATOMIC); - if (!skb) - break; - - skb_queue_tail(skb_pool, skb); - } -} -EXPORT_SYMBOL_GPL(refill_skbs); - void netpoll_zap_completion_queue(void) { unsigned long flags; --=20 2.54.0 From nobody Sun May 24 18:44:41 2026 Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.49]) (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 1ABDE3A7D74 for ; Sun, 24 May 2026 16:12:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639152; cv=none; b=YaqUhtfwLBVFXSNE44H2G6/BO8n6uW+UdppDMAp2ug8ltOaMFk4PAAiMzBPd2fugWKrhtLFEO63TMSLhCLE+9exAD3QpTgFT2bOqGbIE77EM32hw3QxHY99HsU3vR+7b+E8Upu1N/O9OypsygxYzWqg9JlNl75z8KPdiFobP5qw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639152; c=relaxed/simple; bh=2+kUJ9MLWgAjyqEnqV6PmrQCVE8DwsUu4Xz4X+NXL/8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=O3Jx4z1ALjVm/8onpu1nDneW+ayWW9hUDtD2NLrHY4K20lZZoqmdROli+sI4v+l+oaUu0ofqf2nh7ptQGioVAA2CPjfvQckUoXO3ABwXQQEyksdl2+yc4HJRMmXhJ+PlYh8CpMNUZukWwyEyurfi2h//Bg+h35RvBLou7Uy9ZR0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.160.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-43a2ad7bcc4so4076675fac.1 for ; Sun, 24 May 2026 09:12:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779639149; x=1780243949; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=xKgkaHoit0BwRCJTQUnz/viZDI3hhr4+HERagrPW2J0=; b=Qs3/uy9VDRI2mwxPcaFv01Sd3Y9shFa1R0SI3+zZI5KW4T0UbgagcxPxaZEU0pqI8d 0dXa5NpPMCL2RU2nHV9q8Q+IBBYGzufR+xrSUcmTwS3B+5yupkFtOUBXYWhtAVHLooRB wljmDYvMtPETDXpLwpgk9YfUWw+Gko3Y9f4TW0ATTHhDq5vQgdpofbrb3lNvuD5AEqhO yBe45SsN0JvMd/4UagyQd/zGZeYLyUPDxXoZoFYrqJN2qnBPtw4CFSVdkczbj7K8YWFO G57YYFTlhgXUbQ05tVFje2oj1rfYK8dKc5Ws/02JfulysrnojVqGHQeA5e1m2BiS2rTx H28Q== X-Forwarded-Encrypted: i=1; AFNElJ9YMZYlVlXt3wrFYQ9/SxpxwGwekQIbj3XaedsuY94dI6z23bItspSeTU2wQKek3izX4TjpNUy3O4jPR90=@vger.kernel.org X-Gm-Message-State: AOJu0Ywg6nrM8Bod/jc4V+ErUZaHAmIwfNaHT9W7jpAiHrTMycifG+2H +/Sx34XXRQ3XUcgaGIF0kNmf4Sdf9bVEKsqinfh5+Ur8YyCEWA1h2w7C X-Gm-Gg: Acq92OH0JOu5ZOdmWm1dLEOXbaGf+HKeaU7iNUuXeCcZ8CQbZkyEnETlwVRRWHHJeRK 9pB8Ha89n2taHBoYTK6aoasZB0+7xXKc+IiDC3UmchS2fwlrYOFmC+XXJo1ZzoMy+B1DomWYbkK DZQPM6a2zLOujupTxfKFUBbHczV68gcbFcNweUN0vIz7V1wbD+ABPO/4TAuJIcKBBtQucZZlSTv 36GUp1fTyXKJYD3Bd36eEdyk/S0A5fP2UR9Q1eRzE8KTy4Vb/LGC/0FA53BUJ8QAWHx6vxzDO1E +iU4SSWLP3GgKei4BbE9T0GkSIeMu+OoEDQAHwoSzN1NgfhkbHcMTqeoOaBKPlDS5qLSwsqDF5b xl7vF/BPKlg7aKWsvXCG33m+haHljxNs5+GpmzC0HZQHnTsYf9DVZI7FkShNsovWvIPs6v7Dbbk ypGdDehj0hxg4z54wBL0Kobqmm X-Received: by 2002:a05:6808:1455:b0:485:1173:f62a with SMTP id 5614622812f47-48549d8fb9fmr6366031b6e.1.1779639148953; Sun, 24 May 2026 09:12:28 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:71::]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-43b635d1551sm7990476fac.5.2026.05.24.09.12.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2026 09:12:28 -0700 (PDT) From: Breno Leitao Date: Sun, 24 May 2026 09:12:21 -0700 Subject: [PATCH 5/9] netconsole: move skb_pool_flush() from netpoll 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: <20260524-netconsole_move_more-v1-5-909d1ab398b4@debian.org> References: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> In-Reply-To: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, gustavold@gmail.com, asantostc@gmail.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=2321; i=leitao@debian.org; h=from:subject:message-id; bh=2+kUJ9MLWgAjyqEnqV6PmrQCVE8DwsUu4Xz4X+NXL/8=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqEyNlWZOrmYcQhvL8Zz9oK7ZJzlc8K4A2EKmR7 XyRlec+oAOJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCahMjZQAKCRA1o5Of/Hh3 bSV6D/4v+pU1rFx8RcKdVfCwz9IpWpp0qlv/6RwmeOCKfR9IsDj4acmmjA9DPOEiBwKtxQ+Z00c AxXZMUiKxOyu1T+w51IYFhedw5K+VJsG8H1JomrLTnWKhu1fZjanVYd6CihGP4RLzh7aCynnLwk CLqf16BeadcOr3LF456e8d/+FCi5USBT/Ix/cLCW6MQJNWeg2i9z9+zN+CQeDc7dBfJcSncoUh6 JXngMlJdGcLcd5N/Vv18SfGI/vVmrf3DlSZjMEZvH8k97vbbI+OaStWU5u3IeD4GQCA2D28FZtO R0p6BLzJT/MT9v4VYS9Q8FNd5o6Iy78MfbTESDIOCFoep/9fnXvbm7ZBXrqmxsYAybktSbQ90cf K1tN9ajtdbHd+8EpNTAJABnHKR6bwzAjbV2eryeBugrO1TKywOEMyfku36IzhY5aMqKmY0zFdOQ nwKBrbvk59TwxLV9BgQmuBdsYKQVamcqBdeHh6uQrGHByjJ4rWv48pUrnME2V6r3fWNsl15ScTa YWXhueqWTA0eG2Arcg4ttDxMvl7lrYR8ivJfjmWY4zC3v1HU91qeVv3LzSLtWnZb7OQzDdu7KJb XQ7WTm6690eYWfcNug4L9yPLHHZ6eIGAc3dXOMz0Ulb7NdjhPzpa7WSX1Fn7GZjR7qaK+eBAeC3 x6QUVyI/9hklzlg== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D skb_pool_flush() has no callers left in net/core/netpoll.c after netconsole took over the pool lifecycle. Inline its body into netconsole_skb_pool_flush() (the only caller) and drop the function and its export from netpoll. The prototype goes from . Pure code motion: cancel_work_sync() + skb_queue_purge_reason() semantics are unchanged. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 5 ++++- include/linux/netpoll.h | 1 - net/core/netpoll.c | 10 ---------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 76a569d487db..a8ced60bef7a 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -333,7 +333,10 @@ static void netconsole_skb_pool_init(struct netconsole= _target *nt) =20 static void netconsole_skb_pool_flush(struct netconsole_target *nt) { - skb_pool_flush(&nt->np); + struct netpoll *np =3D &nt->np; + + cancel_work_sync(&np->refill_wq); + skb_queue_purge_reason(&np->skb_pool, SKB_CONSUMED); } =20 /* Attempts to resume logging to a deactivated target. */ diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index bc491f600a71..e4b8f1f91e54 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h @@ -74,7 +74,6 @@ void netpoll_cleanup(struct netpoll *np); void do_netpoll_cleanup(struct netpoll *np); netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb); void netpoll_zap_completion_queue(void); -void skb_pool_flush(struct netpoll *np); =20 #ifdef CONFIG_NETPOLL static inline void *netpoll_poll_lock(struct napi_struct *napi) diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 2fca74b4ea75..796aab90e26e 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -327,16 +327,6 @@ netdev_tx_t netpoll_send_skb(struct netpoll *np, struc= t sk_buff *skb) } EXPORT_SYMBOL(netpoll_send_skb); =20 -void skb_pool_flush(struct netpoll *np) -{ - struct sk_buff_head *skb_pool; - - cancel_work_sync(&np->refill_wq); - skb_pool =3D &np->skb_pool; - skb_queue_purge_reason(skb_pool, SKB_CONSUMED); -} -EXPORT_SYMBOL_GPL(skb_pool_flush); - int __netpoll_setup(struct netpoll *np, struct net_device *ndev) { struct netpoll_info *npinfo; --=20 2.54.0 From nobody Sun May 24 18:44:41 2026 Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (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 640873A962E for ; Sun, 24 May 2026 16:12:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639155; cv=none; b=BEWeIT5fGCSMcuxQnySp5QQaetiG2Uc4U1aU7X2kvoBPPbjsoNqQAxChZr2Z1hcQboRpDAwVOjX0bwts1Rbl+FnxMcNBN1bRRCE1SjkRZMYHo4nwe6wXy7LX39jOXHeiDZ/mAICzneDRfIgG0nAqk/njfR87N/NYrsKKwhZCZaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639155; c=relaxed/simple; bh=9Io60ANRnBsmyAgRWfG1mFkAHxHn3SG2P8y1eiYREg0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HKm/LkSUTiT5c8nmZKs/gAho2iH8HlFYeC7HD0VBSywzZoCD8cDdlxs5FEPAtplyh3xNWAmxxxSN61kTw8kGBkzVAD00Eon/23GSEqCed8glx7DJ4EnThPeoFcQdW0ZMOr7HD23SHxNooe/VCjhcvZtR4lJ4ik8FeGotIHqYu2g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.167.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-4855e69a4c0so1757997b6e.1 for ; Sun, 24 May 2026 09:12:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779639150; x=1780243950; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=qOCvAbA4VDDlZEPxROsjDedDXmikIirSU/l9zKPktHc=; b=WBbkmjez2wmeF7LkJ6EHZ3u1znc3sZHxIfVfd9Nqgl6g2xxdoDBi/+NdA7EYPaGKJ+ b+2bRYJBLBj0NcP60I2oJ9eFEWIAB75vP4RtEUSIbF4oLRDbNi3vU51Gf9ryHH3ChtqH 22+YyCro1Vp3Fk7UNFoeOgY6iNGmchtBFBjSRAFLA+Ojv/Eq3FTKvaYtS9OsRy9/R8Zh hNZp9Taev0FV0hqdkJCzUI21jXfADICeGZqIkNlfrIlecGy9rtWIbTtKD3pOOe7YFGlW dUmYr3zkqq6ZyonPtHc1U6YCdqLTYUOF9asHEKwJ71DIkD5R4QV932toPw2F8mZ1o37A 0rCA== X-Forwarded-Encrypted: i=1; AFNElJ+g55TlAON/31vK/jYZJj6ZcfKelF72grTHOx5GOqt9O57ubPg76V46n37ccpKuD6i3WAIFp+PpqTEwKpY=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9gu1Nx8Peq/hutBcmVx8bzE+TjOs7u+kb362u00RAxqjQeYgi zYIXsOnD5f2Mo5VD+m4RkrAN9/RSianaQHS/PopXiPfLuxhgX8fNX0br X-Gm-Gg: Acq92OFBjZtDSkZ/9FS+gChonzBzpO9nnr5LjK5GBimQYc768X8CfVZIZZus5R4/4kM hiefDmg9nm64IrIl8TNs3RPwa3ezPFe+fmserfuB1bKGq5irSXrtnDTRMtSRNs7Q8aDkISv00P2 TCKIdiiec436Hfxp9aTCn0Fd6Vz4NZC9XpZIt1OscEdjdWkKXxRIIEC7A86yjBA/1gJk51ogInJ JUWY7EGWsG/aZckV7AR+Q7YxEXmaq9nOq3e/09WYmtRTNtTZA/fV2cMODKUAuXXXi5I7oYtpG5D wRuLd5SzFE1a3PY3hPNKLIp19Z5z7jRw5eqlmKJNFds6pwfyQfU8x1ekBxj2OQqSKoDmodo/niz kyT1qBUV8++PZEKsuw4b7iicP0xMssyNVYVl0c3GmLDrI8tVGcK0io3gIAKb3P3QV7iBmNzyBDK R/EO0LtQV8v6ityw== X-Received: by 2002:a05:6808:c1cb:b0:485:29ad:d19e with SMTP id 5614622812f47-4854a4101c8mr7027942b6e.47.1779639150174; Sun, 24 May 2026 09:12:30 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:40::]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4855476ab77sm3537709b6e.17.2026.05.24.09.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2026 09:12:29 -0700 (PDT) From: Breno Leitao Date: Sun, 24 May 2026 09:12:22 -0700 Subject: [PATCH 6/9] netconsole: move skb_pool / refill_wq from struct netpoll to netconsole_target 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: <20260524-netconsole_move_more-v1-6-909d1ab398b4@debian.org> References: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> In-Reply-To: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, gustavold@gmail.com, asantostc@gmail.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=5953; i=leitao@debian.org; h=from:subject:message-id; bh=9Io60ANRnBsmyAgRWfG1mFkAHxHn3SG2P8y1eiYREg0=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqEyNlUbp4nQefRCtC5/vbsMc4cAMNs/0r5BwbX /S8XQZfT06JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCahMjZQAKCRA1o5Of/Hh3 benfEACE+hT0Yf5LSCZ0h7++UVe8bzUB85RUWo4VvcPTtMprC/g0BIRnG7RDeSX4+pszi/lqSlt bB+5jquAksoVTFnCEOoQbJjYrFYaJcPxI8bN2G1lXWK3tUryhMSdLdTEfn3VhiymLj6beXZsFIR eS5TeR0jW64qj/lx9wrtsAuznGjbFUvlJCyyy89lHYx/frW2LORvkSP2yq+wkqc0pIc7sgfRXm2 CFDsNIJ/MQ/th5hwoNzFrzM5Lcmn1VFAlLVwyCti2PRDiqurGooGpQC/Fz5t5P+xeTcQIfDAsJV Ez5hC72zEon9+eNRit+c8PWCROVIYRwiR+HHLHg38QTlwYGn4Qz398PPzSKqQ79FZRADBI3seW1 F3sy63JV2u1zVEdPPtQuP5ZLajmv9jZXIwic3S3VBVtx4OaeeIZvc8JAoSQFU//fJjRFyBjJB3z gHqkixZWn9y3UPk5Y+knN5eSmWuMElOKmswD+ww9xAuNs2vwqagdqnQ902/zk8kT593Q0ITsBwO +VCCUQaSDrAgkLuzPhPeg3xYwCq5n2bDRREvLc80cneh5CSHF117sym4N/yf49W5frzYkt8Xnhq IyCIcvX6+MCFzmRZdRxSkVaoN2vpBzsP6wMNDzAUPmE/rUwdvloEUzpZ6Z7hFRbUnUWD2lhvg+G zef7+cvpofPhxLQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D These two fields back the fallback skb pool that find_skb() uses. Every helper that touches them lives in netconsole now (refill_skbs, refill_skbs_work_handler, netconsole_skb_pool_init, netconsole_skb_pool_flush, find_skb), so the data can move alongside its only consumer. Add skb_pool and refill_wq to struct netconsole_target, drop them from struct netpoll, and update the helpers and find_skb() to take a struct netconsole_target * and reach the pool through nt-> rather than np->. Thread nt through netpoll_send_udp() so its only caller in send_udp() can pass nt directly. struct netpoll shrinks by sizeof(sk_buff_head) + sizeof(work_struct) for every consumer, including bonding, bridge, team, vlan, macvlan and dsa, which carried the fields as dead weight. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 47 +++++++++++++++++++++++++++-----------------= --- include/linux/netpoll.h | 2 -- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index a8ced60bef7a..b8b1608d09e9 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -183,6 +183,11 @@ enum target_state { * remote_mac (read-write) * @buf: The buffer used to send the full msg to the network stack * @resume_wq: Workqueue to resume deactivated target + * @skb_pool: Per-target fallback skb pool consulted by find_skb() when + * its GFP_ATOMIC allocation fails. Lifetime brackets a + * successful netpoll_setup() / netpoll_cleanup() pair on @np. + * @refill_wq: Work item that asynchronously tops @skb_pool back up to + * MAX_SKBS after find_skb() drains an entry. */ struct netconsole_target { struct list_head list; @@ -206,6 +211,8 @@ struct netconsole_target { /* protected by target_list_lock */ char buf[MAX_PRINT_CHUNK]; struct work_struct resume_wq; + struct sk_buff_head skb_pool; + struct work_struct refill_wq; }; =20 #ifdef CONFIG_NETCONSOLE_DYNAMIC @@ -296,13 +303,11 @@ static bool bound_by_mac(struct netconsole_target *nt) return is_valid_ether_addr(nt->np.dev_mac); } =20 -static void refill_skbs(struct netpoll *np) +static void refill_skbs(struct netconsole_target *nt) { - struct sk_buff_head *skb_pool; + struct sk_buff_head *skb_pool =3D &nt->skb_pool; struct sk_buff *skb; =20 - skb_pool =3D &np->skb_pool; - while (READ_ONCE(skb_pool->qlen) < MAX_SKBS) { skb =3D alloc_skb(MAX_SKB_SIZE, GFP_ATOMIC); if (!skb) @@ -314,10 +319,10 @@ static void refill_skbs(struct netpoll *np) =20 static void refill_skbs_work_handler(struct work_struct *work) { - struct netpoll *np =3D - container_of(work, struct netpoll, refill_wq); + struct netconsole_target *nt =3D + container_of(work, struct netconsole_target, refill_wq); =20 - refill_skbs(np); + refill_skbs(nt); } =20 /* Initialise the per-target skb pool that find_skb() falls back to and @@ -326,17 +331,15 @@ static void refill_skbs_work_handler(struct work_stru= ct *work) */ static void netconsole_skb_pool_init(struct netconsole_target *nt) { - skb_queue_head_init(&nt->np.skb_pool); - INIT_WORK(&nt->np.refill_wq, refill_skbs_work_handler); - refill_skbs(&nt->np); + skb_queue_head_init(&nt->skb_pool); + INIT_WORK(&nt->refill_wq, refill_skbs_work_handler); + refill_skbs(nt); } =20 static void netconsole_skb_pool_flush(struct netconsole_target *nt) { - struct netpoll *np =3D &nt->np; - - cancel_work_sync(&np->refill_wq); - skb_queue_purge_reason(&np->skb_pool, SKB_CONSUMED); + cancel_work_sync(&nt->refill_wq); + skb_queue_purge_reason(&nt->skb_pool, SKB_CONSUMED); } =20 /* Attempts to resume logging to a deactivated target. */ @@ -1731,8 +1734,10 @@ static struct notifier_block netconsole_netdev_notif= ier =3D { .notifier_call =3D netconsole_netdev_event, }; =20 -static struct sk_buff *find_skb(struct netpoll *np, int len, int reserve) +static struct sk_buff *find_skb(struct netconsole_target *nt, int len, + int reserve) { + struct netpoll *np =3D &nt->np; int count =3D 0; struct sk_buff *skb; =20 @@ -1741,8 +1746,8 @@ static struct sk_buff *find_skb(struct netpoll *np, i= nt len, int reserve) =20 skb =3D alloc_skb(len, GFP_ATOMIC); if (!skb) { - skb =3D skb_dequeue(&np->skb_pool); - schedule_work(&np->refill_wq); + skb =3D skb_dequeue(&nt->skb_pool); + schedule_work(&nt->refill_wq); } =20 if (!skb) { @@ -1865,8 +1870,10 @@ static void push_ipv6(struct netpoll *np, struct sk_= buff *skb, int len) skb->protocol =3D htons(ETH_P_IPV6); } =20 -static int netpoll_send_udp(struct netpoll *np, const char *msg, int len) +static int netpoll_send_udp(struct netconsole_target *nt, const char *msg, + int len) { + struct netpoll *np =3D &nt->np; int total_len, ip_len, udp_len; struct sk_buff *skb; =20 @@ -1881,7 +1888,7 @@ static int netpoll_send_udp(struct netpoll *np, const= char *msg, int len) =20 total_len =3D ip_len + LL_RESERVED_SPACE(np->dev); =20 - skb =3D find_skb(np, total_len + np->dev->needed_tailroom, + skb =3D find_skb(nt, total_len + np->dev->needed_tailroom, total_len - len); if (!skb) return -ENOMEM; @@ -1912,7 +1919,7 @@ static int netpoll_send_udp(struct netpoll *np, const= char *msg, int len) */ static void send_udp(struct netconsole_target *nt, const char *msg, int le= n) { - int result =3D netpoll_send_udp(&nt->np, msg, len); + int result =3D netpoll_send_udp(nt, msg, len); =20 if (IS_ENABLED(CONFIG_NETCONSOLE_DYNAMIC)) { if (result =3D=3D NET_XMIT_DROP) { diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index e4b8f1f91e54..8344454df05d 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h @@ -35,8 +35,6 @@ struct netpoll { bool ipv6; u16 local_port, remote_port; u8 remote_mac[ETH_ALEN]; - struct sk_buff_head skb_pool; - struct work_struct refill_wq; }; =20 #define np_info(np, fmt, ...) \ --=20 2.54.0 From nobody Sun May 24 18:44:41 2026 Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) (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 B02903A9D9F for ; Sun, 24 May 2026 16:12:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639155; cv=none; b=TqZUC01JaToKtJi5Rljx7Bw5fjwd5AsNxVGZmlRl45srEJa0zMQXCuYYoBdyHvSikHcgqbCZ5nZ/U9TFTV7QhFsZJUqBmk1uYUZwzAPfPJNUfM8276OSjjWY+iaKDHZErFx4FBNN6earXKA5eHqaDjjudjC5kwL7yXfsHs/QwcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639155; c=relaxed/simple; bh=zPKT572Bg5B8ekJ3ya3g1bUmfBOQNpVNHzCjPrnHSPc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kweF/WTEsWRjLHicYIV2r8hLUzNJQkwRy9H839dKO45Ip9SPbUlTN5kCy8e7dM91yvbM1GHlWRBHuJ6T6jjh+x3+JBq9/supqTTZpKweh4NztbZ+pR1fsOmRSYvJ1fnwC8GgrlqtW2dd+hHOhnoDq3vgbf0sO/ek4kYaXsFq0/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.160.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-43a2ad7bcc4so4076700fac.1 for ; Sun, 24 May 2026 09:12:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779639151; x=1780243951; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=EuoL79h2+LzWuVOrTETIcdrYDXVMqx2rDNgDGKX/rTs=; b=M+eaMDwV9sufcC7uvrzkV0DujwrTISLpdmk8K6LiJqzqnrupvjNIZbPmgSWlnaTJO/ sNOxgJmZj3ZdTiIqrbdS4MRzGt4VGbFxgFb5XGnxU1xxgwW93FvIsK7UPgfSWzsX9Cwq g3Y257Rqgv9u58tv2ZYO+L+lNSF/fLRqDOKZQDm02zmHsTPJsi+v82t9FN6/Gqs7XTK+ ns2tMvSx+CjZxNWNlK91Jp/+JccqAICx9zAMuM0uerTNjBLVGqhriBnpIi610zF9XN0z 56ujePom8frktjEI063ZAg26rzWl2rAICkwF2vr9o9jdAc/tX+8tivOEg/Tqo3X9lbD/ b67Q== X-Forwarded-Encrypted: i=1; AFNElJ+TrZYPebi5NN3tct5jizzfJ5zwvbd1RayIAHEjiA+lS51WcbipwvTE4tUO074i3UAgH2Aiwex/daKcrn8=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0z7j9ksvBvyc2RB/IW8TEMkTVf3uahQGld86xOasigQpF8xnG 9h14aQxiG44HrN4WlCaty2shk9KfB0XW79Cbx/KFUKyikaNjfVNDPZdG X-Gm-Gg: Acq92OEgsnYCvfokeDbhFVRR3JEhGZQj5lKP7N9AM9wQe+XJATUFZuegtJ6CAmv8nQT VBdE2BlrcS/KJw59Yi7b6AJAA9+eBelmnXt20LpIOUA5wFW3p8Uv14hyMt1GFPOm8/nnZWoa92I iV0EqPn37qG5/j/9WyYdBO+MQ2vFpznakjeFJBaLrOot8A1HFtOFfNpOZfqjs6/dEy12cJNxDf6 W4eN/Vb7audct+pHKh51xsF2lzDvTKMZ6YCytza+3fdoqpJgSdwWK5VX457ZuWv//OWq95iTqcu B8vxHnJSbvXoDgVYuP/ZWm9A8iUO5AzfGt8PYkbXKY6AUUR6kouAN+WuZaS0RTlAmfDUCASo5fQ tG8uaf8qJfNWmPUU+9x725vsDlEgPdw2QqBv4ia8uzRTwlbD7OoHdIPHVXoVA+KKx+zUL2rMulH MmNKwUepNTZ3VQ X-Received: by 2002:a05:6808:13c9:b0:482:c2f2:7bde with SMTP id 5614622812f47-48549d906demr7016668b6e.4.1779639151118; Sun, 24 May 2026 09:12:31 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:2::]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-43b635e373fsm7697975fac.8.2026.05.24.09.12.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2026 09:12:30 -0700 (PDT) From: Breno Leitao Date: Sun, 24 May 2026 09:12:23 -0700 Subject: [PATCH 7/9] netconsole: move local_port from struct netpoll to netconsole_target 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: <20260524-netconsole_move_more-v1-7-909d1ab398b4@debian.org> References: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> In-Reply-To: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, gustavold@gmail.com, asantostc@gmail.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=6708; i=leitao@debian.org; h=from:subject:message-id; bh=zPKT572Bg5B8ekJ3ya3g1bUmfBOQNpVNHzCjPrnHSPc=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqEyNlEVGQaBxfbvha3NelN2OLsuODN17jS00q1 jhZEfxB526JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCahMjZQAKCRA1o5Of/Hh3 bQAqEACdMw+R2fweJxfJzJy07RAqLYMtv/6X5FU7FueWxUawwoh+mcIi+ypXls4lMp5OMW8AhTS 80CxDKBJRxWvzL3Iam5w/NC97Ebg4xwWObtxvVd8a9E6PD5w0BdjAqkqw42Ndn6xOGDHyilope1 +pPhudrUaZH+y+jhG2wXWYfz/gRQ0q0pN1WKVoB1SCO1JV+crPmSG83EPTktvNYBkJsc0GaQjKw WtFjYhgl3tg3rP03aAY/CN79ae9Sywuot1Rv+Mx+DPty4KxKuZLIuVk2c3JYUKZg+mQJ8ny7G1Q uZiQekIjq492iv+8J5GU8Xf2ybPfyPUY0Ds4MyQu4E97Nfgq+Sc34PfHakaMTIELkK6G8pY00vu Z/G76zP7DonNJtj0BEM9rRH7oGF1+kvJd3DqtQXaLNgsuOvF8MtctEgj60mYyVN5am0J6iwUW32 muR8pHzW6nVLprynrJKKrsnkj4OHaf+P0dIVcPgno5+v/OkZzep706fjnZqxYGY1R9XFEs4zN8O 8CcYO/HsTaHadJC4vibCkchWlqxmGr0nrH8B/SG8NN/FG+ehg/TtGI2BZ+F4Od/Z+r4j6DuhdD+ /+ZoEv9hxbOJYL8d3Oy9Vvpgcl5UK2vi3seB4GIa5GUUv0j40tZNAcsA3JXpr/omRtLUsuDxVI5 Bfws/zJYfvGErgw== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D The UDP source port used to build outgoing log packets is pure netconsole configuration. net/core/netpoll.c never reads it, and no other struct netpoll consumer (bonding, bridge, team, vlan, macvlan, dsa) touches it either. Add local_port to struct netconsole_target, drop it from struct netpoll, and update alloc_and_init(), the local_port_show / local_port_store configfs handlers, push_udp(), netconsole_print_banner() and netconsole_parser_cmdline() to read it from nt-> rather than np->. netconsole_print_banner(), push_udp() and netconsole_parser_cmdline() gain a struct netconsole_target * parameter so they can reach the new home; subsequent patches that move remote_port and remote_mac reuse the same plumbing. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 45 +++++++++++++++++++++++---------------------- include/linux/netpoll.h | 2 +- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index b8b1608d09e9..a4f34560cee5 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -172,15 +172,11 @@ enum target_state { * @extended: Denotes whether console is extended or not. * @release: Denotes whether kernel release version should be prepended * to the message. Depends on extended console. - * @np: The netpoll structure for this target. - * Contains the other userspace visible parameters: - * dev_name (read-write) - * local_port (read-write) - * remote_port (read-write) - * local_ip (read-write) - * remote_ip (read-write) - * local_mac (read-only) - * remote_mac (read-write) + * @np: The netpoll structure for this target. Holds the + * underlying net_device handle and the addressing fields + * that netpoll core still reads (local_ip, remote_ip, ipv6, + * dev_name, dev_mac). + * @local_port: UDP source port used to build outgoing log packets. * @buf: The buffer used to send the full msg to the network stack * @resume_wq: Workqueue to resume deactivated target * @skb_pool: Per-target fallback skb pool consulted by find_skb() when @@ -208,6 +204,7 @@ struct netconsole_target { bool extended; bool release; struct netpoll np; + u16 local_port; /* protected by target_list_lock */ char buf[MAX_PRINT_CHUNK]; struct work_struct resume_wq; @@ -432,7 +429,7 @@ static struct netconsole_target *alloc_and_init(void) =20 nt->np.name =3D "netconsole"; strscpy(nt->np.dev_name, "eth0", IFNAMSIZ); - nt->np.local_port =3D 6665; + nt->local_port =3D 6665; nt->np.remote_port =3D 6666; eth_broadcast_addr(nt->np.remote_mac); nt->state =3D STATE_DISABLED; @@ -471,9 +468,11 @@ static void netconsole_process_cleanups_core(void) mutex_unlock(&target_cleanup_list_lock); } =20 -static void netconsole_print_banner(struct netpoll *np) +static void netconsole_print_banner(struct netconsole_target *nt) { - np_info(np, "local port %d\n", np->local_port); + struct netpoll *np =3D &nt->np; + + np_info(np, "local port %d\n", nt->local_port); if (np->ipv6) np_info(np, "local IPv6 address %pI6c\n", &np->local_ip.in6); else @@ -603,7 +602,7 @@ static ssize_t dev_name_show(struct config_item *item, = char *buf) =20 static ssize_t local_port_show(struct config_item *item, char *buf) { - return sysfs_emit(buf, "%d\n", to_target(item)->np.local_port); + return sysfs_emit(buf, "%d\n", to_target(item)->local_port); } =20 static ssize_t remote_port_show(struct config_item *item, char *buf) @@ -798,7 +797,7 @@ static ssize_t enabled_store(struct config_item *item, * Skip netconsole_parser_cmdline() -- all the attributes are * already configured via configfs. Just print them out. */ - netconsole_print_banner(&nt->np); + netconsole_print_banner(nt); =20 /* Initialise the skb pool before netpoll_setup() so the pool * is valid as soon as nt->np.dev becomes visible to @@ -937,7 +936,7 @@ static ssize_t local_port_store(struct config_item *ite= m, const char *buf, goto out_unlock; } =20 - ret =3D kstrtou16(buf, 10, &nt->np.local_port); + ret =3D kstrtou16(buf, 10, &nt->local_port); if (ret < 0) goto out_unlock; ret =3D count; @@ -1788,8 +1787,9 @@ static void netpoll_udp_checksum(struct netpoll *np, = struct sk_buff *skb, udph->check =3D CSUM_MANGLED_0; } =20 -static void push_udp(struct netpoll *np, struct sk_buff *skb, int len) +static void push_udp(struct netconsole_target *nt, struct sk_buff *skb, in= t len) { + struct netpoll *np =3D &nt->np; struct udphdr *udph; int udp_len; =20 @@ -1799,7 +1799,7 @@ static void push_udp(struct netpoll *np, struct sk_bu= ff *skb, int len) skb_reset_transport_header(skb); =20 udph =3D udp_hdr(skb); - udph->source =3D htons(np->local_port); + udph->source =3D htons(nt->local_port); udph->dest =3D htons(np->remote_port); udph->len =3D htons(udp_len); =20 @@ -1896,7 +1896,7 @@ static int netpoll_send_udp(struct netconsole_target = *nt, const char *msg, skb_copy_to_linear_data(skb, msg, len); skb_put(skb, len); =20 - push_udp(np, skb, len); + push_udp(nt, skb, len); if (np->ipv6) push_ipv6(np, skb, len); else @@ -2214,8 +2214,9 @@ __releases(&target_list_lock) spin_unlock_irqrestore(&target_list_lock, flags); } =20 -static int netconsole_parser_cmdline(struct netpoll *np, char *opt) +static int netconsole_parser_cmdline(struct netconsole_target *nt, char *o= pt) { + struct netpoll *np =3D &nt->np; bool ipversion_set =3D false; char *cur =3D opt; char *delim; @@ -2226,7 +2227,7 @@ static int netconsole_parser_cmdline(struct netpoll *= np, char *opt) if (!delim) goto parse_failed; *delim =3D 0; - if (kstrtou16(cur, 10, &np->local_port)) + if (kstrtou16(cur, 10, &nt->local_port)) goto parse_failed; cur =3D delim; } @@ -2299,7 +2300,7 @@ static int netconsole_parser_cmdline(struct netpoll *= np, char *opt) goto parse_failed; } =20 - netconsole_print_banner(np); + netconsole_print_banner(nt); =20 return 0; =20 @@ -2337,7 +2338,7 @@ static struct netconsole_target *alloc_param_target(c= har *target_config, } =20 /* Parse parameters and setup netpoll */ - err =3D netconsole_parser_cmdline(&nt->np, target_config); + err =3D netconsole_parser_cmdline(nt, target_config); if (err) goto fail; =20 diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index 8344454df05d..dcea36713720 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h @@ -33,7 +33,7 @@ struct netpoll { =20 union inet_addr local_ip, remote_ip; bool ipv6; - u16 local_port, remote_port; + u16 remote_port; u8 remote_mac[ETH_ALEN]; }; =20 --=20 2.54.0 From nobody Sun May 24 18:44:41 2026 Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (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 C36EB3A8747 for ; Sun, 24 May 2026 16:12:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639156; cv=none; b=O/dseCKYRJASAN9m/tPLspmc8+A+I+ITJmNau1EkI0Ra5PBY1qRUhonji/KQvhWdwzEcQ+STw7RS+kBafIxydrulKcP0l+kRkDzIi3As1LSlgXApN13VEDf9vDpxj5keerp7PX5P262M1RwxiQSd4wqoFAGf8V/dWsXnZT9RnfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639156; c=relaxed/simple; bh=Yoy7b4IX7Q3gIK8QWyqTSh51xiLDR24883Jvqpd8ZGI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MRH3HjqRpBJ9PbhEaI0gJMs32pt0xJCPj/hsx1u5durUH2GKfHk+dtMtxaOAkCBudf5b8aTsuTNYWIk0oVHfH3NQ6/8U7NM+iMkEjxB38ivaQ3HwtjHhbe0TjqWD06CCF/GnIND+IYdtlOTTRvu/rMwZHBQu629VaRNIbvpvupk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.167.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-4824b15c19eso7371521b6e.2 for ; Sun, 24 May 2026 09:12:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779639152; x=1780243952; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=SQ5ZFv4zqTjU+YraDC0YfxKk0Y8XgFqrJVhkuiFQ0YE=; b=f/RKjfSFk3U3pmXX/73v+o4iKPym3HEw93TMvzsnaQxh+StefYeGq902osR7efAZt+ YY0IBIbXEQfws5S6oCmKLwpM93ympzgr8/8/szN4zzYxVsOMiHrG0IOFAPcqCr/q6qyH 0P1eVavjTu0pGNEVsCXSZc7f+YJF08GEjmTbeSw/aJ+y6fpQeXrQq1gwl3z/JjWytWRZ ZMa3RKB9HyrBQtF0Leyf4I4bzL2zFAa2a50YezXknhLBQLb38au6PgqSimwl3siFjbmi IcEICFiKW5juvV/NXgJAeP+ajaY03RXyaizZwzXcfUtCAVa5EhaMSMUv/T57NDfqDozE lFlw== X-Forwarded-Encrypted: i=1; AFNElJ+35bKREApq463A3F8wxS8onN+6tTYpylsb6iUEXMWuQtAoZzJLaX0C/SrTgytiT1ewYwKbcGSXSY4fe4I=@vger.kernel.org X-Gm-Message-State: AOJu0YyddaT/QydZsXfuMLk3gKOnB/fuh8a/sPV70UpRZ69h70Knf4Se rQK1SY3k3q8/rF1PuxHz0XXYjkqTeTrAdwT+efntFrpZFZewpuG141ge X-Gm-Gg: Acq92OFjIL4FVz74FxS1tViLg/I2r34z9z3XuWcZXX3ZnEp8Brsn8iZFmh+WXoH5Frv CvwjHT9EnHpASzjbydLmRLY9IAph6lzf83kvjOZK66ZZi2BDXylZIf6H2iooMX8eMiEx2Js0Jlq n4GltxFXjdzaiTDoe/ZjnH0a24ZVaGvfn8Ltm0501hiVWaVCzl1t+Wb8xMKGqWDl0fa60HAowYp vdMvTqbn9I6d6VHpYU89CuKD1Q0AMDMeBaU3+/EjieD+yuiSj5wCYf4eg81+V0NrE6rPChNewU6 Me0aUiDEjyeOSSk0xYTMtLechIis05mJhBxY2uUY6AD/oh1RAG21/l1eZs8i/vnSlmDZWzWtm+b 0Tbl1fCIdU73Rkg6JIsGEsi2yaJR1fJAEfSjy/IpyHiPVGJe4UDldpkxuvtFD0IjTyCb3ApTzzI g2mXuX2LvBF9czA/N/HhlkVNNtj+LIPzFSEIc= X-Received: by 2002:a05:6808:1521:b0:485:1174:4582 with SMTP id 5614622812f47-4854a0eb6ebmr7684343b6e.13.1779639152191; Sun, 24 May 2026 09:12:32 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:5f::]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7e6065e6aabsm5589238a34.13.2026.05.24.09.12.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2026 09:12:31 -0700 (PDT) From: Breno Leitao Date: Sun, 24 May 2026 09:12:24 -0700 Subject: [PATCH 8/9] netconsole: move remote_port from struct netpoll to netconsole_target 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: <20260524-netconsole_move_more-v1-8-909d1ab398b4@debian.org> References: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> In-Reply-To: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, gustavold@gmail.com, asantostc@gmail.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=4143; i=leitao@debian.org; h=from:subject:message-id; bh=Yoy7b4IX7Q3gIK8QWyqTSh51xiLDR24883Jvqpd8ZGI=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqEyNlcbGdUtW03jM9/bec0QsfkwZSiZIKAhBU2 pGLl7xndXOJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCahMjZQAKCRA1o5Of/Hh3 baxlEACEGNJcQ/LVw0+2GDdZfjS97JnL4p6NPMZGcDYosrotkT8Eo55iHERFzbG1v95f1O2zkJ8 RFdTq2zkoei+XxiyKypt3W3015Uk76iad7IbB7xq1MZn3uSqVPMyVFNTMmBnwWGxH16hSM2h3kQ i05KQhc6alXuzkBJd0hNr1fY8cGNjfYoGnw0Fd+P5YgCqt+7DYUZIFKOzPeeG1KXf0t72USvho+ N3cp0/0VxITppI4nHYYePli8T+uXEa5rzxl3ujl9gfi4s68vXv4ShHqthDDD1R9DhDitx3J55R3 8mKakGgZcRfv1fMwVKgP8x0dtEVXWDshzYobywYAp2HI/aX3SLKTWFvT5zdE+Fo6/uR1I55KL1Z yFNED+0AJ6oBk6fxvyEaIEgthP1ORpTRZc0e7NZTCneOjzJmUtNFzIPozZeguf03K5WGd1hY05x GtPFa22YphyUuHU+4pJYgCTueJ+KPOSDkmATyT6sJ+HbRK9spNJExdwLanNbwtwMMhm4tkdyXuS nvGMFkg470UW5UFw8fYltGDZGlyd1ur+sKcn1AmjffjBv/9Zy45f5tS7ihAKduHSYubDYrNmtca OE5r4I1uAAM7Ex8eyL2nwnnzfJrjcgfOO84L2AcVbiaxNOwlyvnxabszELPeJkFsIvssRXetwpC /HpCD3J3S6BcWZQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D The UDP destination port used to build outgoing log packets is pure netconsole configuration. net/core/netpoll.c never reads it, and no other struct netpoll consumer touches it. Add remote_port to struct netconsole_target, drop it from struct netpoll, and update alloc_and_init(), the remote_port_show / remote_port_store configfs handlers, push_udp(), netconsole_print_banner() and netconsole_parser_cmdline() to read it from nt-> rather than np->. The struct netconsole_target * parameter threaded through these helpers by the previous patch already gives them access to the new home. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 14 ++++++++------ include/linux/netpoll.h | 1 - 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index a4f34560cee5..32e2a925f915 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -177,6 +177,7 @@ enum target_state { * that netpoll core still reads (local_ip, remote_ip, ipv6, * dev_name, dev_mac). * @local_port: UDP source port used to build outgoing log packets. + * @remote_port: UDP destination port used to build outgoing log packets. * @buf: The buffer used to send the full msg to the network stack * @resume_wq: Workqueue to resume deactivated target * @skb_pool: Per-target fallback skb pool consulted by find_skb() when @@ -205,6 +206,7 @@ struct netconsole_target { bool release; struct netpoll np; u16 local_port; + u16 remote_port; /* protected by target_list_lock */ char buf[MAX_PRINT_CHUNK]; struct work_struct resume_wq; @@ -430,7 +432,7 @@ static struct netconsole_target *alloc_and_init(void) nt->np.name =3D "netconsole"; strscpy(nt->np.dev_name, "eth0", IFNAMSIZ); nt->local_port =3D 6665; - nt->np.remote_port =3D 6666; + nt->remote_port =3D 6666; eth_broadcast_addr(nt->np.remote_mac); nt->state =3D STATE_DISABLED; INIT_WORK(&nt->resume_wq, process_resume_target); @@ -479,7 +481,7 @@ static void netconsole_print_banner(struct netconsole_t= arget *nt) np_info(np, "local IPv4 address %pI4\n", &np->local_ip.ip); np_info(np, "interface name '%s'\n", np->dev_name); np_info(np, "local ethernet address '%pM'\n", np->dev_mac); - np_info(np, "remote port %d\n", np->remote_port); + np_info(np, "remote port %d\n", nt->remote_port); if (np->ipv6) np_info(np, "remote IPv6 address %pI6c\n", &np->remote_ip.in6); else @@ -607,7 +609,7 @@ static ssize_t local_port_show(struct config_item *item= , char *buf) =20 static ssize_t remote_port_show(struct config_item *item, char *buf) { - return sysfs_emit(buf, "%d\n", to_target(item)->np.remote_port); + return sysfs_emit(buf, "%d\n", to_target(item)->remote_port); } =20 static ssize_t local_ip_show(struct config_item *item, char *buf) @@ -958,7 +960,7 @@ static ssize_t remote_port_store(struct config_item *it= em, goto out_unlock; } =20 - ret =3D kstrtou16(buf, 10, &nt->np.remote_port); + ret =3D kstrtou16(buf, 10, &nt->remote_port); if (ret < 0) goto out_unlock; ret =3D count; @@ -1800,7 +1802,7 @@ static void push_udp(struct netconsole_target *nt, st= ruct sk_buff *skb, int len) =20 udph =3D udp_hdr(skb); udph->source =3D htons(nt->local_port); - udph->dest =3D htons(np->remote_port); + udph->dest =3D htons(nt->remote_port); udph->len =3D htons(udp_len); =20 netpoll_udp_checksum(np, skb, len); @@ -2274,7 +2276,7 @@ static int netconsole_parser_cmdline(struct netconsol= e_target *nt, char *opt) *delim =3D 0; if (*cur =3D=3D ' ' || *cur =3D=3D '\t') np_info(np, "warning: whitespace is not allowed\n"); - if (kstrtou16(cur, 10, &np->remote_port)) + if (kstrtou16(cur, 10, &nt->remote_port)) goto parse_failed; cur =3D delim; } diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index dcea36713720..12467a45929e 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h @@ -33,7 +33,6 @@ struct netpoll { =20 union inet_addr local_ip, remote_ip; bool ipv6; - u16 remote_port; u8 remote_mac[ETH_ALEN]; }; =20 --=20 2.54.0 From nobody Sun May 24 18:44:41 2026 Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) (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 ECC0E3A7F57 for ; Sun, 24 May 2026 16:12:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639157; cv=none; b=YGOEP10zLRK2T073bAR/F5XtCvzh2tGD7CnW/E9jSmF9PqLk103SMJY4jEaNoEZAKohs2145kNSUGtjQpbe+f35pfsyce4Zi0Pp1zTNVWf4i4f7Wumg08yu0B3XIGsdedIZjkcQpeFQuWWsF9PRM4RryBZey8B1N4OBCHV0dvlg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779639157; c=relaxed/simple; bh=9Sqs1TK1Ksxaf+/Hq1IN8xHVOCo2tM1wmJ3tA/Tq28g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZfNa+fWWNckiy624ukknQtdK/6c9kBXGMOwT0+HHGqFVyF1y40CkXcmQfGFGQ/FEB4ufKBsBgKFfQUJU6W9CgZJARK5QEbYFN/DHd7TteM3gsX/4dCenmdQ6nkkB7NH3XiiI7/1YdcDYdccVZaZ+MOVEkUSkP0JTJUS5dGvy9Cw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.160.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-43b7987a9d1so1594922fac.1 for ; Sun, 24 May 2026 09:12:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779639153; x=1780243953; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=jWUyH1vJgjwR/lyt/ttGR7R2TxtiIcscs9RO38w3oMY=; b=D2r9BRfW+WL6gUR/LSmfjinqcd9aDzVff+55Yq0tGoXX32PxIhQkhhIl3p8RvhqEou rpF+jQr35nkRl63z6MMBh2wqsFXBvE4RBvGNBNRFE4Yk8UIdpzyYnjBiM9hR0/APkwYO 2H+IayKNBnd9JO2JxhuxHODz/ug2YgzFJxY1IUlEZbfP1Vjrzlesk63nCD9RTUHDVpbr Gf4dyvcW9JNaTyY779sRSJCXZOk9cO6biVIquON+wq2CjsP8en1Uw/qw55D7v7DWwPqR ObYTLWDB07leyMCH7Clpfvv3Iug80bbZIta5+WZR8bMnugAPK7XeEntMLtB86WNbzGGS 5wxw== X-Forwarded-Encrypted: i=1; AFNElJ+/TWqY64I7a0Td2w+kD28Iz2aS/n7+HiRZGuuPKzNuOnNjL3p7wrJZDEwQq92euD3hjxW6N1RQz1vUPGY=@vger.kernel.org X-Gm-Message-State: AOJu0YxYezviCbRINwtyPFzdPmA2ef6ExBEMsajpO1y3QX35FVbls33A Qx5Ycyyq8sLrjXUnl2NFKABLesDH56tGJCpopKbyffvMWRMdV1JuWRLt X-Gm-Gg: Acq92OHRpffxqjBE3zp8SsB6+KFqyrhMyqwebNfnffp0BEyRi5tr+0axR7dRFT45TuO /ySH5R5m/KpPycxjQEErilIxNUtD02/m4bydi+Xz9KGs2CSqDCwJ4l4qb6USdXKesX0eTVGv049 0J5qWLzIy/oLKD2XAtTyuZ8EkfBwdVnrziXuU9rt0+43JCs2YnxpAF/t3UhEY097ZohWF94wAMO z0pmVRQDasbN4/ba5287Ip7muCVci/855mxdP+qRjJrlK7YEgS9omiQW7GqjiGtHAseS3c12U/0 cBO+KRHC4OShhe1y9obo9Zp5zZ1A73oHirHxb+0YQ0sWa2wC+rdCvZeSeVYhkDwSixU1rp+SPTh ubCQyeSF11YlI2WB0GEUoQU322WEpurqorzspE+1JICEPNMP5Q7YaWGP1HKjEkEbdrE8KVW437g aiXHNnF2Acb6iZ6g== X-Received: by 2002:a05:6871:c3c1:b0:41c:6bf0:677c with SMTP id 586e51a60fabf-43b5abcf07emr6678996fac.2.1779639153283; Sun, 24 May 2026 09:12:33 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:4f::]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-43b635e4f8bsm7855506fac.7.2026.05.24.09.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2026 09:12:33 -0700 (PDT) From: Breno Leitao Date: Sun, 24 May 2026 09:12:25 -0700 Subject: [PATCH 9/9] netconsole: move remote_mac from struct netpoll to netconsole_target 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: <20260524-netconsole_move_more-v1-9-909d1ab398b4@debian.org> References: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> In-Reply-To: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, gustavold@gmail.com, asantostc@gmail.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=5022; i=leitao@debian.org; h=from:subject:message-id; bh=9Sqs1TK1Ksxaf+/Hq1IN8xHVOCo2tM1wmJ3tA/Tq28g=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqEyNlTE/yd2VYLMfSLEN43Tx0EAsOC208ck36X exGS+lSfB+JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCahMjZQAKCRA1o5Of/Hh3 bQx1D/9NeadADcrmO21T0J7fjWBLaVM1LM+kejoae6Up5lNnywFC8cQJwSZOtjfcp4s9q2HEH+Q EU5WdEX5oRs52t+eqZe9vD7hnJmzsWOmEx4axIM4OHEMomdYLaNYnjEyIvbczRUyrFXwgTCri7k 43S6L2GCd1ESG2hKdYP9SLQBJ2A6zoaEUwv07IF+0L6YPdqmlCaoiYju793somD4kG3cleyTWGz CU7Azw3acCj6V6UvOr+Wwltr7YOgn7zyO5gTu2c6KUYsU09kByrZn7eRiZvI9H16nqy9RAxJ4If yi+kms2zXi6nWTH5IUtA2FP1nUVrfvTcewqVNVQZNo64qVqzivltvdtRwEHbLfBl7j8g9Rwh3Zd tX3KtD6jq+AR6OlHTxQSwcKRZA1TOHZllhhjmR0kT/NuSUFL5SMB1yUd3nl6vXBpAfE2jJFt9jz kBjJ0gClNeUaJzU/UTkTNEslfsN3RdhZFsRdRflPKE8jXEFgMRkcn1xeuskCiUIOs0x7Yw6yi2E cyXBM+rg7sppTSDyzrnq4X54DKU8Z2SQ+n3ArUouQTFI13/NpOcgkZ4HhgcihaUeEoLNkFr6Qna 34OifeydfhdbNQ2yiZsz/YUl2PLILA/ovvhsecjCDyyb2v4wRXu8W34OKfY0/ILjocUQHEH+za0 zqMXaYzzvI7EgQQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D The destination ethernet address used to build outgoing log packets is pure netconsole configuration. net/core/netpoll.c never reads it, and no other struct netpoll consumer touches it. Add remote_mac to struct netconsole_target, drop it from struct netpoll, and update alloc_and_init(), the remote_mac_show / remote_mac_store configfs handlers, push_eth(), netconsole_print_banner() and netconsole_parser_cmdline() to read it from nt-> rather than np->. push_eth() gains a struct netconsole_target * parameter to reach the new home; its only caller in netpoll_send_udp() already has nt available. After this patch struct netpoll keeps only what genuinely belongs to the generic poll/transmit abstraction (dev, dev_tracker, dev_name, dev_mac, name) plus the IP addressing fields that netpoll_setup() and netpoll_take_ipv6() still read themselves (local_ip, remote_ip, ipv6). Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 19 +++++++++++-------- include/linux/netpoll.h | 1 - 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 32e2a925f915..29a6c13e9cfd 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -178,6 +178,7 @@ enum target_state { * dev_name, dev_mac). * @local_port: UDP source port used to build outgoing log packets. * @remote_port: UDP destination port used to build outgoing log packets. + * @remote_mac: Destination ethernet address used to build outgoing log pa= ckets. * @buf: The buffer used to send the full msg to the network stack * @resume_wq: Workqueue to resume deactivated target * @skb_pool: Per-target fallback skb pool consulted by find_skb() when @@ -207,6 +208,7 @@ struct netconsole_target { struct netpoll np; u16 local_port; u16 remote_port; + u8 remote_mac[ETH_ALEN]; /* protected by target_list_lock */ char buf[MAX_PRINT_CHUNK]; struct work_struct resume_wq; @@ -433,7 +435,7 @@ static struct netconsole_target *alloc_and_init(void) strscpy(nt->np.dev_name, "eth0", IFNAMSIZ); nt->local_port =3D 6665; nt->remote_port =3D 6666; - eth_broadcast_addr(nt->np.remote_mac); + eth_broadcast_addr(nt->remote_mac); nt->state =3D STATE_DISABLED; INIT_WORK(&nt->resume_wq, process_resume_target); =20 @@ -486,7 +488,7 @@ static void netconsole_print_banner(struct netconsole_t= arget *nt) np_info(np, "remote IPv6 address %pI6c\n", &np->remote_ip.in6); else np_info(np, "remote IPv4 address %pI4\n", &np->remote_ip.ip); - np_info(np, "remote ethernet address %pM\n", np->remote_mac); + np_info(np, "remote ethernet address %pM\n", nt->remote_mac); } =20 /* Parse the string and populate the `inet_addr` union. Return 0 if IPv4 is @@ -642,7 +644,7 @@ static ssize_t local_mac_show(struct config_item *item,= char *buf) =20 static ssize_t remote_mac_show(struct config_item *item, char *buf) { - return sysfs_emit(buf, "%pM\n", to_target(item)->np.remote_mac); + return sysfs_emit(buf, "%pM\n", to_target(item)->remote_mac); } =20 static ssize_t transmit_errors_show(struct config_item *item, char *buf) @@ -1047,7 +1049,7 @@ static ssize_t remote_mac_store(struct config_item *i= tem, const char *buf, goto out_unlock; if (buf[MAC_ADDR_STR_LEN] && buf[MAC_ADDR_STR_LEN] !=3D '\n') goto out_unlock; - memcpy(nt->np.remote_mac, remote_mac, ETH_ALEN); + memcpy(nt->remote_mac, remote_mac, ETH_ALEN); =20 ret =3D count; out_unlock: @@ -1808,14 +1810,15 @@ static void push_udp(struct netconsole_target *nt, = struct sk_buff *skb, int len) netpoll_udp_checksum(np, skb, len); } =20 -static void push_eth(struct netpoll *np, struct sk_buff *skb) +static void push_eth(struct netconsole_target *nt, struct sk_buff *skb) { + struct netpoll *np =3D &nt->np; struct ethhdr *eth; =20 eth =3D skb_push(skb, ETH_HLEN); skb_reset_mac_header(skb); ether_addr_copy(eth->h_source, np->dev->dev_addr); - ether_addr_copy(eth->h_dest, np->remote_mac); + ether_addr_copy(eth->h_dest, nt->remote_mac); if (np->ipv6) eth->h_proto =3D htons(ETH_P_IPV6); else @@ -1903,7 +1906,7 @@ static int netpoll_send_udp(struct netconsole_target = *nt, const char *msg, push_ipv6(np, skb, len); else push_ipv4(np, skb, len); - push_eth(np, skb); + push_eth(nt, skb); skb->dev =3D np->dev; =20 return (int)netpoll_send_skb(np, skb); @@ -2298,7 +2301,7 @@ static int netconsole_parser_cmdline(struct netconsol= e_target *nt, char *opt) =20 if (*cur !=3D 0) { /* MAC address */ - if (!mac_pton(cur, np->remote_mac)) + if (!mac_pton(cur, nt->remote_mac)) goto parse_failed; } =20 diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index 12467a45929e..9f4236557ffe 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h @@ -33,7 +33,6 @@ struct netpoll { =20 union inet_addr local_ip, remote_ip; bool ipv6; - u8 remote_mac[ETH_ALEN]; }; =20 #define np_info(np, fmt, ...) \ --=20 2.54.0