diff mbox series

[-next] af_packet: display drop field in packet_seq_show

Message ID 20240826092625.2637632-1-liumingrui@huawei.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [-next] af_packet: display drop field in packet_seq_show | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 18 this patch: 18
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 25 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-26--03-00 (tests: 714)

Commit Message

Liu Mingrui Aug. 26, 2024, 9:26 a.m. UTC
Display the dropped count of the packet, which could provide more
information for debugging.

Signed-off-by: Liu Mingrui <liumingrui@huawei.com>
---
 net/packet/af_packet.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Eric Dumazet Aug. 26, 2024, 7:10 a.m. UTC | #1
On Mon, Aug 26, 2024 at 3:26 AM Liu Mingrui <liumingrui@huawei.com> wrote:
>
> Display the dropped count of the packet, which could provide more
> information for debugging.
>
> Signed-off-by: Liu Mingrui <liumingrui@huawei.com>

Old /proc interface is legacy, we do not accept changes in it.

Instead, change net/packet/diag.c , iproute2/ss and use "ss -0".

Also, your patch is not correct, because of getsockopt( ...
PACKET_STATISTICS ... )
Stephen Hemminger Aug. 27, 2024, 12:19 a.m. UTC | #2
On Mon, 26 Aug 2024 09:26:25 +0000
Liu Mingrui <liumingrui@huawei.com> wrote:

> Display the dropped count of the packet, which could provide more
> information for debugging.
> 
> Signed-off-by: Liu Mingrui <liumingrui@huawei.com>
> ---

At this point /proc/net/packet is a poor choice for extension.
For example, ss command ignores it if PACKET_DIAG_MEMINFO is available.

Better to add new netlink field see net/packet/diag.c.

Maybe time for PACKET_DIAG_STATS with name/value like ethtool.
diff mbox series

Patch

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 4a364cdd445e..22c59ee61888 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -4771,14 +4771,14 @@  static int packet_seq_show(struct seq_file *seq, void *v)
 {
 	if (v == SEQ_START_TOKEN)
 		seq_printf(seq,
-			   "%*sRefCnt Type Proto  Iface R Rmem   User   Inode\n",
+			   "%*sRefCnt Type Proto  Iface R Rmem   User   Inode   Drops\n",
 			   IS_ENABLED(CONFIG_64BIT) ? -17 : -9, "sk");
 	else {
 		struct sock *s = sk_entry(v);
 		const struct packet_sock *po = pkt_sk(s);
 
 		seq_printf(seq,
-			   "%pK %-6d %-4d %04x   %-5d %1d %-6u %-6u %-6lu\n",
+			   "%pK %-6d %-4d %04x   %-5d %1d %-6u %-6u %-6lu %u\n",
 			   s,
 			   refcount_read(&s->sk_refcnt),
 			   s->sk_type,
@@ -4787,7 +4787,8 @@  static int packet_seq_show(struct seq_file *seq, void *v)
 			   packet_sock_flag(po, PACKET_SOCK_RUNNING),
 			   atomic_read(&s->sk_rmem_alloc),
 			   from_kuid_munged(seq_user_ns(seq), sock_i_uid(s)),
-			   sock_i_ino(s));
+			   sock_i_ino(s),
+			   atomic_read(&po->tp_drops));
 	}
 
 	return 0;