Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support dumping skb hash #502

Open
borkmann opened this issue Feb 7, 2025 · 2 comments
Open

Support dumping skb hash #502

borkmann opened this issue Feb 7, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@borkmann
Copy link
Member

borkmann commented Feb 7, 2025

Extend pwru to support duming:

  • skb hash
  • whether the skb hash is L4 hash (vs L3 or lower)
  • whether the skb hash is SW hash (vs HW)

It would be useful to see this meta data at each traced function.

For example, packet comes in from HW/NIC, gets into Cilium, is rewritten (K8s services) and pushed via tunnel device to a backend. It would be useful to analyze the skb hash at each of these stages.

@borkmann borkmann added the enhancement New feature or request label Feb 7, 2025
@Asphaltt
Copy link
Contributor

Asphaltt commented Feb 9, 2025

Hi Daniel,

I don't think we should add more output options to pwru in order to output skb meta data.

With the PR #499, we're able to filter skb/xdp meta data by --filter-skb-expr/--filter-xdp-expr.

Then, like this PR, it's better to output skb meta data by --output-skb-meta skb->hash, --output-skb-meta skb->l4_hash and --output-skb-meta skb->sw_hash.

The expected result would be skb->hash=0xXX skb->l4_hash=0xXX skb->sw_hash=0xXX.

After the PR #499 getting merged, I'll try to implement --output-skb-meta and --output-xdp-meta options.

@jschwinger233
Copy link
Member

I just checked, --output-skb already gives the .hash fields:

0xffff88fb4a98c8e8 3   ~in/curl:1517270 4026534376 0            eth0:70      0x0800 65536 146   172.18.0.5:57858->172.18.0.2:8472(udp)     __iptunnel_pull_header       vxlan_rcv[vxlan]
(struct sk_buff){
 (union){
  (struct){
   (union){
    .dev = (struct net_device *)0x0000000054c482f3,
    .dev_scratch = (long unsigned int)18446613216915714048,
   },
  },
  .rbnode = (struct rb_node){
   .rb_left = (struct rb_node *)0x0000000054c482f3,
  },
 },
 .cb = (char[])[
  'F',
 ],
 (union){
  (struct){
   ._skb_refdst = (long unsigned int)18446613228463974465,
  },
  .tcp_tsorted_anchor = (struct list_head){
   .next = (struct list_head *)0x0000000066cd7982,
  },
  ._sk_redir = (long unsigned int)18446613228463974465,
 },
 .len = (unsigned int)146,
 .data_len = (unsigned int)20,
 .mac_len = (__u16)14,
 .fclone = (__u8)0x2,
 (union){
  (struct){
   .ooo_okay = (__u8)0x1,
   .tc_at_ingress = (__u8)0x1,
   .l4_hash = (__u8)0x1,
   .csum_valid = (__u8)0x1,
   .slow_gro = (__u8)0x1,
   .alloc_cpu = (u16)3,
   (union){
    .csum = (__wsum)1048856,
    (struct){
     .csum_start = (__u16)280,
     .csum_offset = (__u16)16,
    },
   },
   .skb_iif = (int)70,
   .hash = (__u32)2372300512,
   (union){
    .napi_id = (unsigned int)4,
    .sender_cpu = (unsigned int)4,
   },
   (union){
    .inner_protocol = (__be16)22629,
    .inner_ipproto = (__u8)101,
   },
   .inner_transport_header = (__u16)244,
   .inner_network_header = (__u16)224,
   .inner_mac_header = (__u16)210,
   .protocol = (__be16)8,
   .transport_header = (__u16)194,
   .network_header = (__u16)174,
   .mac_header = (__u16)160,
  },
  .headers = (struct){
   .ooo_okay = (__u8)0x1,
   .tc_at_ingress = (__u8)0x1,
   .l4_hash = (__u8)0x1,
   .csum_valid = (__u8)0x1,
   .slow_gro = (__u8)0x1,
   .alloc_cpu = (u16)3,
   (union){
    .csum = (__wsum)1048856,
    (struct){
     .csum_start = (__u16)280,
     .csum_offset = (__u16)16,
    },
   },
   .skb_iif = (int)70,
   .hash = (__u32)2372300512,
   (union){
    .napi_id = (unsigned int)4,
    .sender_cpu = (unsigned int)4,
   },
   (union){
    .inner_protocol = (__be16)22629,
    .inner_ipproto = (__u8)101,
   },
   .inner_transport_header = (__u16)244,
   .inner_network_header = (__u16)224,
   .in

There are two issues:

  1. Incorrect global variables usage for outputting skb and shinfo #491
  2. buff size is still too small, we can see from above the output has been truncated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants