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 |
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 ... )
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 --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;
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(-)