From nobody Wed Dec 4 18:51:00 2024 Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (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 2D4F11DE8AF for ; Mon, 2 Dec 2024 19:55:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733169314; cv=none; b=goMiLLqfmor6B+YkL3PS6NmFhXXLLYO+BTXGS/8aC6ggCSQjkJEjo6lNWch0K0YAPcbYX1CoGK0aroBTyxCIY/t1pGgYBUVoCATnEshdayMl99yCeml1efkQ76WeMW1R+xpiS35B5W936sDEJYmpvsCKqkBFkhOPJeY8G9rfO8U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733169314; c=relaxed/simple; bh=pxh8grUMvqJBGylhMPYpSUfz6LOHGp0+0GbZkYU8Sto=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ekWvs1KutneMrerJfvp8uDDxgwaJ27UBYm0FqMqKqWt/eIH5EuyzP8TQPQB7WheLphSVKXwvz3HYkyRL7uLSKEbeKdfU7DXHFHr0l9jpM8C+LGnD1r7VMr7jyNSZVC3qvM3iwl8ywjIIGVAWvsgSgYN9bm0IcXRRNXEbo2vD8Pc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kutsevol.com; spf=none smtp.mailfrom=kutsevol.com; dkim=pass (2048-bit key) header.d=kutsevol-com.20230601.gappssmtp.com header.i=@kutsevol-com.20230601.gappssmtp.com header.b=x8OEk/c4; arc=none smtp.client-ip=209.85.222.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kutsevol.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=kutsevol.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kutsevol-com.20230601.gappssmtp.com header.i=@kutsevol-com.20230601.gappssmtp.com header.b="x8OEk/c4" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-7b666215645so205676485a.0 for ; Mon, 02 Dec 2024 11:55:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kutsevol-com.20230601.gappssmtp.com; s=20230601; t=1733169311; x=1733774111; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yXntLZOBYToAE4e1z/0kMPS4CzoGHC4HyiF9Kuy9Nlg=; b=x8OEk/c48nCRvKmXUfA79UqY+qqWzDCbDya23kdzb4WLONyfEweo04BNh7ll23eZDj 7hCPFjGRAN+dPsCkvkhdMW7cL/eu1BjD3FPkmB+euEeBDehoVxAHna7w0gHstyAo4zId Xhe23QiLcK0IYl3tjXYoJfe31fwbPIUbaTYLCt3p4fngLKmbRPEXIzjy7yvHa61Os3ya yNkQD6LPr8l5imc2Pjg1Ioexg336eI9BNGUid68Idkxiu6zbjnuYEeoztjWyroYxxK+T MgCzghMvNbmQB5hzTxK7HQ8PByYYr/Qw8WHhiRhVyOdeXO80yOTLZ31tpmrUzE9a42NZ 9Fug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733169311; x=1733774111; 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=yXntLZOBYToAE4e1z/0kMPS4CzoGHC4HyiF9Kuy9Nlg=; b=H0jDjGHZdMWLZAQhCZA/INWiJUeqb69WOTFYiaT9N3A9RZO4QtPfyHcOiu9cDvGSlt j6qB+7MzzrYo2mmx5lc/rTfOjKwnipkDrD+aEMDtGYaxmoQL9VP3cyU4VZ/JIaXqFU5k gT1GzWvf2cH1HnKG+ti2Jvsi5w+/ZMqiI1MJ8JoJm+ePzthWK9PHsmXkyL2C3iNZ9yhr VKDYxARJBxK0BCvNOO2+KgX5od8QzLkNSSdE/WwDvdSkyhMLhOq0rTO75yoWxfHEcRsg YvOFlJVo6nl9KUAwgQkX5aKZ4jvFlxDDikCPOZxsq8o4j5JZLSaS1QEfuFcchwoij74m GItA== X-Forwarded-Encrypted: i=1; AJvYcCVND28c8EGRLMzHhn2MJJpFyE7NM3GZ8Qax7YFtZ4smE5I6biCPmzBMknQ8Jxx9N/rlEbqdTOcJF7zj7wE=@vger.kernel.org X-Gm-Message-State: AOJu0Yxgfr9mVeRF+TUZ6uPcHRQ52fygvyK8UTXIcPxdnilDhtEW/8y5 5g9ne9NRFbzI3djLGhNTb9AuMLGU92isv7veXmPdqhktozv/XXsgOgom5NkgoSA= X-Gm-Gg: ASbGncu5icvo+dEXph0vRUZIhuLUFDMJit5bAZh05wtY1PQAHRupvwyaKMpeubGxnuA Te+LzA87mmgEVvGvia/ChTN08gzOBCmhdt8xjK+2Dwh2fGytVPMKbKcmSSOrPWroVM6tkcmLq+x 0ZErIg3T/sCQNxz5JSG2Zus8UGK8nzr0S5zSvdvfyYnxkMj+gx9sMMCBWpuCa6Ncd//+3ix1rKo 0JzlkQ8ELnjdDy2tbHqzyqjoKaKcVOLp3qKTGj9EEjfItC8DKBcZu4YsuES8e53euhu3ly7wMTr FtJNSQDe2x5H7Dyniw== X-Google-Smtp-Source: AGHT+IH7jMHZuSZZo2PI/NEGFUcGD0IVLK+ivsRBO2IP+SpUjaEZ9qlKTaaCydeh+UEE77QGG32ckQ== X-Received: by 2002:a05:620a:290a:b0:7b6:6b34:879f with SMTP id af79cd13be357-7b67c28383cmr3468499785a.22.1733169311004; Mon, 02 Dec 2024 11:55:11 -0800 (PST) Received: from localhost.localdomain (fwdproxy-ash-112.fbsv.net. [2a03:2880:20ff:70::face:b00c]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b6849aac8dsm439338585a.77.2024.12.02.11.55.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 11:55:10 -0800 (PST) From: Maksym Kutsevol Date: Mon, 02 Dec 2024 11:55:07 -0800 Subject: [PATCH net-next v5 1/2] netpoll: Make netpoll_send_udp return status instead of void 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: <20241202-netcons-add-udp-send-fail-statistics-to-netconsole-v5-1-70e82239f922@kutsevol.com> References: <20241202-netcons-add-udp-send-fail-statistics-to-netconsole-v5-0-70e82239f922@kutsevol.com> In-Reply-To: <20241202-netcons-add-udp-send-fail-statistics-to-netconsole-v5-0-70e82239f922@kutsevol.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Andrew Lunn , Breno Leitao Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maksym Kutsevol X-Mailer: b4 0.13.0 netpoll_send_udp can return if send was successful. It will allow client code to be aware of the send status. Possible return values are the result of __netpoll_send_skb (cast to int) and -ENOMEM. This doesn't cover the case when TX was not successful instantaneously and was scheduled for later, __netpoll__send_skb returns success in that case. Signed-off-by: Maksym Kutsevol Reported-by: Breno Leitao --- include/linux/netpoll.h | 2 +- net/core/netpoll.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index b34301650c47..f91e50a76efd 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h @@ -57,7 +57,7 @@ static inline void netpoll_poll_disable(struct net_device= *dev) { return; } static inline void netpoll_poll_enable(struct net_device *dev) { return; } #endif =20 -void netpoll_send_udp(struct netpoll *np, const char *msg, int len); +int netpoll_send_udp(struct netpoll *np, const char *msg, int len); void netpoll_print_options(struct netpoll *np); int netpoll_parse_options(struct netpoll *np, char *opt); int __netpoll_setup(struct netpoll *np, struct net_device *ndev); diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 2e459b9d88eb..8ae10306c1a4 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -390,7 +390,7 @@ netdev_tx_t netpoll_send_skb(struct netpoll *np, struct= sk_buff *skb) } EXPORT_SYMBOL(netpoll_send_skb); =20 -void netpoll_send_udp(struct netpoll *np, const char *msg, int len) +int netpoll_send_udp(struct netpoll *np, const char *msg, int len) { int total_len, ip_len, udp_len; struct sk_buff *skb; @@ -414,7 +414,7 @@ void netpoll_send_udp(struct netpoll *np, const char *m= sg, int len) skb =3D find_skb(np, total_len + np->dev->needed_tailroom, total_len - len); if (!skb) - return; + return -ENOMEM; =20 skb_copy_to_linear_data(skb, msg, len); skb_put(skb, len); @@ -490,7 +490,7 @@ void netpoll_send_udp(struct netpoll *np, const char *m= sg, int len) =20 skb->dev =3D np->dev; =20 - netpoll_send_skb(np, skb); + return (int)netpoll_send_skb(np, skb); } EXPORT_SYMBOL(netpoll_send_udp); =20 --=20 2.43.5 From nobody Wed Dec 4 18:51:00 2024 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (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 0D7931DE8A8 for ; Mon, 2 Dec 2024 19:55:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733169315; cv=none; b=HYUcDPQ86qprhZc+MZ6RP/7l7IWnngv0t0Umj5CJ5ppOCKsYlCuSYhD2utXkQELpRYgDXY0NLpke8TI6Rjx8eObu6Csa4pesSIlT+7H35LHmAHP5Olup9qXCzOJV+36OctHixS9p7VdooCcXED9EzLlqgIsGf17Y9j5WR2+vX9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733169315; c=relaxed/simple; bh=eUA71z1hIjKNOvxnXQEls9LTBPEc6g6iX+lcrcPdObc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RuCEDo1vNq75YAJwJGo/sO21mwvvc7GO+mGI7JK56TTSI4TSZXFeHaCC8xqG3YT0vgAT+gI5/bgn8UhfCWAFYII+6AeecXdlDuvUZQJ7Zb3rY14RtIrq92IS/1ELL8U9gjnvPM3Rbe3mH/ROHfZjq3xypvno8BSr91XXSwvfajI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kutsevol.com; spf=none smtp.mailfrom=kutsevol.com; dkim=pass (2048-bit key) header.d=kutsevol-com.20230601.gappssmtp.com header.i=@kutsevol-com.20230601.gappssmtp.com header.b=YUOlAv+K; arc=none smtp.client-ip=209.85.222.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kutsevol.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=kutsevol.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kutsevol-com.20230601.gappssmtp.com header.i=@kutsevol-com.20230601.gappssmtp.com header.b="YUOlAv+K" Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-7b66b64a381so321697285a.2 for ; Mon, 02 Dec 2024 11:55:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kutsevol-com.20230601.gappssmtp.com; s=20230601; t=1733169312; x=1733774112; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wRZpDuxb0fnCTNdiv+eYSWo0c2+YedGDoD8nLAb9AxE=; b=YUOlAv+KEF/YXmGMmjgNOEE/+xPznslcztZeDTWWPn+gb6PEa5rakdCv8ROHJzSQj1 MDkNabUGqTykvfGqqtpHZdIMVFZj7lKAd6j1jD0g/sIfxx984e/hMlMuqgUlONCrV/EX LDTgedYClwgKT0Km4h2yl3QEiHf8gVlHjb+LMJ7rkhzvCXx+QRff9tu+cQ7yQa43ajJb mIk/1DGOjFRp8JZze83KkyGQw82M8EiJ8KO8oZRWrZQhjQYQSfPzBTTB8F8OAqKK+7ln xJ2XBkWm5oTiEnPTpzVw3UPsPasG6Q1gN6GvkIeraWUycMgQR0pjAsYLVjBfSr3Dym4n SAvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733169312; x=1733774112; 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=wRZpDuxb0fnCTNdiv+eYSWo0c2+YedGDoD8nLAb9AxE=; b=alZ4wFkUIURXsvS00O1CmWicUF0nNtp0BuHV79IeRyjybG/0XGvQA0eU2Ru3vJ+34d DK941xTpAEb+fF6nXQJkgC3oWZMHLcU9rR3nbvj1gtWmB4agPnkAIhAo5F+pyAyJlxqq ccM0rVmsowa8kghCxpkvzjlFI1GQXXOaGBcPXsEWiq9mIi4GdxADhWVOEj9VIT46WG8W ddTgcp9AmdcqeJ5/jUuCAVsgG6VVpPEVgdiUrvhy9I7OKVnwOPrcE8aP8Kc8GZL4FKvj JBzIRi81S3z6VgdldLnDCfoocD5Z1piCTyE08HmKj+wzisL7zi+UcLuzxbbin0CM6XFt pf1w== X-Forwarded-Encrypted: i=1; AJvYcCVYEddU34xteg4tRVdhRbhYiJsT9wMZwu5ntk8eNsUgEvhFr60Gy8hDnSsZId6s7zX+jkbgDft2MCRK4To=@vger.kernel.org X-Gm-Message-State: AOJu0YzNsOBFC01td2vLD2Ejxs4kJTBJKxnKjqOYgSbq8Z4NHXvhJBfn 6BrafWfybDJOZaZ58jLyUqG2hfomHJX6JfHqmqgEPIDiQ/4zTLsi323or3ib1Ic= X-Gm-Gg: ASbGnct8x6g5D/TSeRvm1gCXUz/5qNTb8Ub03hiNsKh4NSx0jHzoah6wA1z2QSgCYXE Sutc8XdosKSsF4JQDdsRXVLreJdXS267MBKRNrvndC3zDtT/3L5GAAFkNBTVop1IUbTDfGjeDDQ EF2ptaeC3HWRJuHEPvfvMemjRZDkg/Tt0lwno1Tw29b5B8n/Zyfq+jfdHYmxJ730hyjHQiCHBMe Z6IKxWQGAGVjTru2n9WZnd63j883k6LDajFhFIkln0Bag1gIITIPP4pXkxNFEBvTK2rf5Vj/KDi CuF+PAgioO/f9j7A0Q== X-Google-Smtp-Source: AGHT+IER+aopHzq3Qub8r1H+QKI7Szm1e1dlYhCaPMPGeY07rn7YaUg8NfWRAz5rccCycX4qtdKCmA== X-Received: by 2002:a05:620a:4049:b0:7b6:6ee8:6c06 with SMTP id af79cd13be357-7b67c45e1b6mr4044295085a.30.1733169311894; Mon, 02 Dec 2024 11:55:11 -0800 (PST) Received: from localhost.localdomain (fwdproxy-ash-112.fbsv.net. [2a03:2880:20ff:70::face:b00c]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b6849aac8dsm439338585a.77.2024.12.02.11.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 11:55:11 -0800 (PST) From: Maksym Kutsevol Date: Mon, 02 Dec 2024 11:55:08 -0800 Subject: [PATCH net-next v5 2/2] netcons: Add udp send fail statistics to netconsole 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: <20241202-netcons-add-udp-send-fail-statistics-to-netconsole-v5-2-70e82239f922@kutsevol.com> References: <20241202-netcons-add-udp-send-fail-statistics-to-netconsole-v5-0-70e82239f922@kutsevol.com> In-Reply-To: <20241202-netcons-add-udp-send-fail-statistics-to-netconsole-v5-0-70e82239f922@kutsevol.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Andrew Lunn , Breno Leitao Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maksym Kutsevol X-Mailer: b4 0.13.0 Enhance observability of netconsole. Packet sends can fail. Start tracking at least two failure possibilities: ENOMEM and NET_XMIT_DROP for every target. Stats are exposed via an additional attribute in CONFIGFS. The exposed statistics allows easier debugging of cases when netconsole messages were not seen by receivers, eliminating the guesswork if the sender thinks that messages in question were sent out. Stats are not reset on enable/disable/change remote ip/etc, they belong to the netcons target itself. Reported-by: Breno Leitao Closes: https://lore.kernel.org/all/ZsWoUzyK5du9Ffl+@gmail.com/ Signed-off-by: Maksym Kutsevol --- Documentation/networking/netconsole.rst | 5 +-- drivers/net/netconsole.c | 61 +++++++++++++++++++++++++++++= ++-- 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/Documentation/networking/netconsole.rst b/Documentation/networ= king/netconsole.rst index d55c2a22ec7a..94c4680fdf3e 100644 --- a/Documentation/networking/netconsole.rst +++ b/Documentation/networking/netconsole.rst @@ -124,7 +124,7 @@ To remove a target:: =20 The interface exposes these parameters of a netconsole target to userspace: =20 - =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D enabled Is this target currently enabled? (read-write) extended Extended mode enabled (read-write) release Prepend kernel release to message (read-write) @@ -135,7 +135,8 @@ The interface exposes these parameters of a netconsole = target to userspace: remote_ip Remote agent's IP address (read-write) local_mac Local interface's MAC address (read-only) remote_mac Remote agent's MAC address (read-write) - =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + transmit_errors Number of packet send errors (read-only) + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 The "enabled" attribute is also used to control whether the parameters of a target can be updated or not -- you can modify the parameters of only diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 4ea44a2f48f7..636a56bb04cd 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include =20 @@ -90,6 +91,12 @@ static DEFINE_MUTEX(target_cleanup_list_lock); */ static struct console netconsole_ext; =20 +struct netconsole_target_stats { + u64_stats_t xmit_drop_count; + u64_stats_t enomem_count; + struct u64_stats_sync syncp; +}; + /** * struct netconsole_target - Represents a configured netconsole target. * @list: Links this target into the target_list. @@ -97,6 +104,7 @@ static struct console netconsole_ext; * @userdata_group: Links to the userdata configfs hierarchy * @userdata_complete: Cached, formatted string of append * @userdata_length: String length of userdata_complete + * @stats: Packet send stats for the target. Used for debugging. * @enabled: On / off knob to enable / disable target. * Visible from userspace (read-write). * We maintain a strict 1:1 correspondence between this and @@ -124,6 +132,7 @@ struct netconsole_target { char userdata_complete[MAX_USERDATA_ENTRY_LENGTH * MAX_USERDATA_ITEMS]; size_t userdata_length; #endif + struct netconsole_target_stats stats; bool enabled; bool extended; bool release; @@ -262,6 +271,7 @@ static void netconsole_process_cleanups_core(void) * | remote_ip * | local_mac * | remote_mac + * | transmit_errors * | userdata/ * | / * | value @@ -371,6 +381,21 @@ static ssize_t remote_mac_show(struct config_item *ite= m, char *buf) return sysfs_emit(buf, "%pM\n", to_target(item)->np.remote_mac); } =20 +static ssize_t transmit_errors_show(struct config_item *item, char *buf) +{ + struct netconsole_target *nt =3D to_target(item); + u64 xmit_drop_count, enomem_count; + unsigned int start; + + do { + start =3D u64_stats_fetch_begin(&nt->stats.syncp); + xmit_drop_count =3D u64_stats_read(&nt->stats.xmit_drop_count); + enomem_count =3D u64_stats_read(&nt->stats.enomem_count); + } while (u64_stats_fetch_retry(&nt->stats.syncp, start)); + + return sysfs_emit(buf, "%llu\n", xmit_drop_count + enomem_count); +} + /* * This one is special -- targets created through the configfs interface * are not enabled (and the corresponding netpoll activated) by default. @@ -842,6 +867,7 @@ CONFIGFS_ATTR(, remote_ip); CONFIGFS_ATTR_RO(, local_mac); CONFIGFS_ATTR(, remote_mac); CONFIGFS_ATTR(, release); +CONFIGFS_ATTR_RO(, transmit_errors); =20 static struct configfs_attribute *netconsole_target_attrs[] =3D { &attr_enabled, @@ -854,6 +880,7 @@ static struct configfs_attribute *netconsole_target_att= rs[] =3D { &attr_remote_ip, &attr_local_mac, &attr_remote_mac, + &attr_transmit_errors, NULL, }; =20 @@ -1058,6 +1085,34 @@ static struct notifier_block netconsole_netdev_notif= ier =3D { .notifier_call =3D netconsole_netdev_event, }; =20 +/** + * send_udp - Wrapper for netpoll_send_udp that counts errors + * @nt: target to send message to + * @msg: message to send + * @len: length of message + * + * Calls netpoll_send_udp and classifies the return value. If an error + * occurred it increments statistics in nt->stats accordingly. + * Only calls netpoll_send_udp if CONFIG_NETCONSOLE_DYNAMIC is disabled. + */ +static void send_udp(struct netconsole_target *nt, + const char *msg, int len) +{ + int result =3D netpoll_send_udp(&nt->np, msg, len); + + if (IS_ENABLED(CONFIG_NETCONSOLE_DYNAMIC)) { + if (result =3D=3D NET_XMIT_DROP) { + u64_stats_update_begin(&nt->stats.syncp); + u64_stats_inc(&nt->stats.xmit_drop_count); + u64_stats_update_end(&nt->stats.syncp); + } else if (result =3D=3D -ENOMEM) { + u64_stats_update_begin(&nt->stats.syncp); + u64_stats_inc(&nt->stats.enomem_count); + u64_stats_update_end(&nt->stats.syncp); + } + } +} + static void send_msg_no_fragmentation(struct netconsole_target *nt, const char *msg, int msg_len, @@ -1085,7 +1140,7 @@ static void send_msg_no_fragmentation(struct netconso= le_target *nt, MAX_PRINT_CHUNK - msg_len, "%s", userdata); =20 - netpoll_send_udp(&nt->np, buf, msg_len); + send_udp(nt, buf, msg_len); } =20 static void append_release(char *buf) @@ -1178,7 +1233,7 @@ static void send_fragmented_body(struct netconsole_ta= rget *nt, char *buf, this_offset +=3D this_chunk; } =20 - netpoll_send_udp(&nt->np, buf, this_header + this_offset); + send_udp(nt, buf, this_header + this_offset); offset +=3D this_offset; } } @@ -1288,7 +1343,7 @@ static void write_msg(struct console *con, const char= *msg, unsigned int len) tmp =3D msg; for (left =3D len; left;) { frag =3D min(left, MAX_PRINT_CHUNK); - netpoll_send_udp(&nt->np, tmp, frag); + send_udp(nt, tmp, frag); tmp +=3D frag; left -=3D frag; } --=20 2.43.5