diff mbox series

[net-next] net: display more skb fields in skb_dump()

Message ID 20240406160825.1587913-1-edumazet@google.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: display more skb fields in skb_dump() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for 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: 944 this patch: 944
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 954 this patch: 954
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: 955 this patch: 955
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 29 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 54 this patch: 54
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-07--00-00 (tests: 956)

Commit Message

Eric Dumazet April 6, 2024, 4:08 p.m. UTC
Print these additional fields in skb_dump()

- mac_len
- priority
- mark
- alloc_cpu
- vlan_all
- encapsulation
- inner_protocol
- inner_mac_header
- inner_network_header
- inner_transport_header

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/core/skbuff.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Willem de Bruijn April 6, 2024, 5:48 p.m. UTC | #1
Eric Dumazet wrote:
> Print these additional fields in skb_dump()
> 
> - mac_len
> - priority
> - mark
> - alloc_cpu
> - vlan_all
> - encapsulation
> - inner_protocol
> - inner_mac_header
> - inner_network_header
> - inner_transport_header
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Reviewed-by: Willem de Bruijn <willemb@google.com>

> ---
>  net/core/skbuff.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 2a5ce6667bbb9bb70e89d47abda5daca5d16aae2..fa0d1364657e001c6668aafaf2c2a3d434980798 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -1304,13 +1304,16 @@ void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt)
>  	has_trans = skb_transport_header_was_set(skb);
>  
>  	printk("%sskb len=%u headroom=%u headlen=%u tailroom=%u\n"
> -	       "mac=(%d,%d) net=(%d,%d) trans=%d\n"
> +	       "mac=(%d,%d) mac_len=%u net=(%d,%d) trans=%d\n"
>  	       "shinfo(txflags=%u nr_frags=%u gso(size=%hu type=%u segs=%hu))\n"
>  	       "csum(0x%x ip_summed=%u complete_sw=%u valid=%u level=%u)\n"

If touching this function, also add csum_start and csum_offset?
These are technically already present in csum, as it's a union:

        union {
                __wsum          csum;
                struct {        
                        __u16   csum_start;
                        __u16   csum_offset;
                };              
        };

But it is a bit annoying to have to do the conversion manually.
And this is a regular playground for syzbot.

> -	       "hash(0x%x sw=%u l4=%u) proto=0x%04x pkttype=%u iif=%d\n",
> +	       "hash(0x%x sw=%u l4=%u) proto=0x%04x pkttype=%u iif=%d\n"
> +	       "priority=0x%x mark=0x%x alloc_cpu=%u vlan_all=0x%x\n"
> +	       "encapsulation=%d inner(proto=0x%04x, mac=%u, net=%u, trans=%u)\n",
>  	       level, skb->len, headroom, skb_headlen(skb), tailroom,
>  	       has_mac ? skb->mac_header : -1,
>  	       has_mac ? skb_mac_header_len(skb) : -1,
> +	       skb->mac_len,
>  	       skb->network_header,
>  	       has_trans ? skb_network_header_len(skb) : -1,
>  	       has_trans ? skb->transport_header : -1,
> @@ -1319,7 +1322,10 @@ void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt)
>  	       skb->csum, skb->ip_summed, skb->csum_complete_sw,
>  	       skb->csum_valid, skb->csum_level,
>  	       skb->hash, skb->sw_hash, skb->l4_hash,
> -	       ntohs(skb->protocol), skb->pkt_type, skb->skb_iif);
> +	       ntohs(skb->protocol), skb->pkt_type, skb->skb_iif,
> +	       skb->priority, skb->mark, skb->alloc_cpu, skb->vlan_all,
> +	       skb->encapsulation, skb->inner_protocol, skb->inner_mac_header,
> +	       skb->inner_network_header, skb->inner_transport_header);
>  
>  	if (dev)
>  		printk("%sdev name=%s feat=%pNF\n",
> -- 
> 2.44.0.478.gd926399ef9-goog
>
Eric Dumazet April 7, 2024, 8:03 a.m. UTC | #2
On Sat, Apr 6, 2024 at 7:48 PM Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
>
> Eric Dumazet wrote:
> > Print these additional fields in skb_dump()
> >
> > - mac_len
> > - priority
> > - mark
> > - alloc_cpu
> > - vlan_all
> > - encapsulation
> > - inner_protocol
> > - inner_mac_header
> > - inner_network_header
> > - inner_transport_header
> >
> > Signed-off-by: Eric Dumazet <edumazet@google.com>
>
> Reviewed-by: Willem de Bruijn <willemb@google.com>
>
> > ---
> >  net/core/skbuff.c | 12 +++++++++---
> >  1 file changed, 9 insertions(+), 3 deletions(-)
> >
> > diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> > index 2a5ce6667bbb9bb70e89d47abda5daca5d16aae2..fa0d1364657e001c6668aafaf2c2a3d434980798 100644
> > --- a/net/core/skbuff.c
> > +++ b/net/core/skbuff.c
> > @@ -1304,13 +1304,16 @@ void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt)
> >       has_trans = skb_transport_header_was_set(skb);
> >
> >       printk("%sskb len=%u headroom=%u headlen=%u tailroom=%u\n"
> > -            "mac=(%d,%d) net=(%d,%d) trans=%d\n"
> > +            "mac=(%d,%d) mac_len=%u net=(%d,%d) trans=%d\n"
> >              "shinfo(txflags=%u nr_frags=%u gso(size=%hu type=%u segs=%hu))\n"
> >              "csum(0x%x ip_summed=%u complete_sw=%u valid=%u level=%u)\n"
>
> If touching this function, also add csum_start and csum_offset?
> These are technically already present in csum, as it's a union:
>
>         union {
>                 __wsum          csum;
>                 struct {
>                         __u16   csum_start;
>                         __u16   csum_offset;
>                 };
>         };
>
> But it is a bit annoying to have to do the conversion manually.
> And this is a regular playground for syzbot.

I agree, I am adding them in V2, thanks !
diff mbox series

Patch

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 2a5ce6667bbb9bb70e89d47abda5daca5d16aae2..fa0d1364657e001c6668aafaf2c2a3d434980798 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1304,13 +1304,16 @@  void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt)
 	has_trans = skb_transport_header_was_set(skb);
 
 	printk("%sskb len=%u headroom=%u headlen=%u tailroom=%u\n"
-	       "mac=(%d,%d) net=(%d,%d) trans=%d\n"
+	       "mac=(%d,%d) mac_len=%u net=(%d,%d) trans=%d\n"
 	       "shinfo(txflags=%u nr_frags=%u gso(size=%hu type=%u segs=%hu))\n"
 	       "csum(0x%x ip_summed=%u complete_sw=%u valid=%u level=%u)\n"
-	       "hash(0x%x sw=%u l4=%u) proto=0x%04x pkttype=%u iif=%d\n",
+	       "hash(0x%x sw=%u l4=%u) proto=0x%04x pkttype=%u iif=%d\n"
+	       "priority=0x%x mark=0x%x alloc_cpu=%u vlan_all=0x%x\n"
+	       "encapsulation=%d inner(proto=0x%04x, mac=%u, net=%u, trans=%u)\n",
 	       level, skb->len, headroom, skb_headlen(skb), tailroom,
 	       has_mac ? skb->mac_header : -1,
 	       has_mac ? skb_mac_header_len(skb) : -1,
+	       skb->mac_len,
 	       skb->network_header,
 	       has_trans ? skb_network_header_len(skb) : -1,
 	       has_trans ? skb->transport_header : -1,
@@ -1319,7 +1322,10 @@  void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt)
 	       skb->csum, skb->ip_summed, skb->csum_complete_sw,
 	       skb->csum_valid, skb->csum_level,
 	       skb->hash, skb->sw_hash, skb->l4_hash,
-	       ntohs(skb->protocol), skb->pkt_type, skb->skb_iif);
+	       ntohs(skb->protocol), skb->pkt_type, skb->skb_iif,
+	       skb->priority, skb->mark, skb->alloc_cpu, skb->vlan_all,
+	       skb->encapsulation, skb->inner_protocol, skb->inner_mac_header,
+	       skb->inner_network_header, skb->inner_transport_header);
 
 	if (dev)
 		printk("%sdev name=%s feat=%pNF\n",