因为ipftrace2是根据skb包中的mark进行跟踪,所以使用iptables设定需要跟踪的目标IP的数据包的mark标志:
root@# iptables -t raw -A OUTPUT -d 8.8.8.8 -j MARK --set-mark 0xdeadbeef
root@# iptables -t raw -A PREROUTING -s 8.8.8.8 -j MARK --set-mark 0xdeadbeef
准备开始跟踪:
root@######### ipft -m 0xdeadbeef
Attaching program (total 1406, succeeded 1406, failed 0, filtered: 0)
Trace ready!
ping一个数据包:
ping 192.168.1.1 -c 1
执行完ping动作后可以看到有抓到traces点,按ctrl+C,等待一会就会打印出调用堆栈:
Got 63 traces^C
Timestamp CPU Function
===
12181977825902 006 ping_queue_rcv_skb
12181977828122 006 sock_queue_rcv_skb
12181977830952 006 sk_filter_trim_cap
12181977836242 006 __cgroup_bpf_run_filter_skb
12181977840272 006 security_sock_rcv_skb
12181977843362 006 apparmor_socket_sock_rcv_skb
12181977846642 006 __sock_queue_rcv_skb
12181977859872 001 __sock_recv_timestamp
12181977863822 001 ip_cmsg_recv_offset
12181977866632 001 skb_free_datagram
12181977868922 001 consume_skb
12181977871433 001 skb_release_all
12181977873803 001 skb_release_head_state
12181977877713 001 sock_rfree
12181977879843 001 skb_release_data
12181977881683 001 skb_free_head
12181977883933 001 kfree_skbmem
===
12181977782191 006 ip_route_input_noref
12181977790312 006 ip_local_deliver
12181977793142 006 ip_local_deliver_finish
12181977795902 006 ip_protocol_deliver_rcu
12181977800342 006 raw_local_deliver
12181977803952 006 icmp_rcv
12181977807882 006 ping_rcv
12181977812192 006 skb_push
12181977818182 006 ping_lookup
12181977820912 006 skb_clone
12181977851172 006 consume_skb
12181977853872 006 skb_release_all
12181977856572 006 skb_release_head_state
12181977859092 006 skb_release_data
12181977862052 006 kfree_skbmem
===
12181977438637 001 ip_output
12181977449408 001 nf_hook_slow
12181977452808 001 apparmor_ipv4_postroute
12181977456028 001 ip_finish_output
12181977462088 001 __cgroup_bpf_run_filter_skb
12181977466658 001 __ip_finish_output
12181977469648 001 ip_finish_output2
12181977474628 001 neigh_resolve_output
12181977476898 001 __neigh_event_send
12181977483178 001 skb_push
12181977485408 001 dev_queue_xmit
12181977487738 001 __dev_queue_xmit
12181977490288 001 netdev_core_pick_tx
12181977493218 001 mlx5e_select_queue
12181977496418 001 netdev_pick_tx
12181977498498 001 __get_xps_queue_idx
12181977503438 001 validate_xmit_skb_list
12181977507318 001 validate_xmit_skb
12181977511768 001 netif_skb_features
12181977515358 001 mlx5e_features_check
12181977517908 001 mlx5e_ipsec_feature_check
12181977521028 001 skb_network_protocol
12181977523778 001 validate_xmit_xfrm
12181977528708 001 dev_hard_start_xmit
12181977531688 001 mlx5e_xmit
12181977535409 001 mlx5e_sq_xmit_prepare
12181977567299 006 napi_consume_skb
12181977576659 006 skb_release_all
12181977580469 006 skb_release_head_state
12181977583029 006 sock_wfree
12181977587779 006 skb_release_data
12181977590309 006 skb_free_head
下边我们在抓一个数据包调用堆栈:
ipft -m 0xdeadbeef
iperf -s
?在另外一台PC上发送50 Bytes,抓到一个包的调用堆栈:
Got 249 traces^C
Timestamp CPU Function
===
14254958067261 001 tcp_v4_early_demux
14254958080461 001 ip_local_deliver
14254958084171 001 ip_local_deliver_finish
14254958087521 001 ip_protocol_deliver_rcu
14254958093801 001 raw_local_deliver
14254958096961 001 tcp_v4_rcv
14254958100111 001 sk_filter_trim_cap
14254958107901 001 __cgroup_bpf_run_filter_skb
14254958113761 001 security_sock_rcv_skb
14254958118571 001 apparmor_socket_sock_rcv_skb
14254958122011 001 tcp_v4_fill_cb
14254958126771 001 tcp_v4_do_rcv
14254958130371 001 tcp_rcv_established
14254958133291 001 tcp_validate_incoming
14254958137241 001 tcp_urg
14254958139511 001 tcp_data_queue
14254958142991 001 tcp_queue_rcv
14254958172532 002 __kfree_skb
14254958186132 002 skb_release_all
14254958196642 002 skb_release_head_state
14254958201822 002 sock_rfree
14254958208472 002 skb_release_data
14254958211512 002 skb_free_head
14254958219032 002 kfree_skbmem
===
14292853221008 000 ip_output
14292853231578 000 nf_hook_slow
14292853234628 000 apparmor_ipv4_postroute
14292853237208 000 ip_finish_output
14292853241818 000 __ip_finish_output
14292853243908 000 ip_finish_output2
14292853247438 000 neigh_resolve_output
14292853249668 000 __neigh_event_send
14292853253198 000 skb_push
14292853254928 000 dev_queue_xmit
14292853256348 000 __dev_queue_xmit
14292853257978 000 netdev_core_pick_tx
14292853260808 000 mlx5e_select_queue
14292853264759 000 netdev_pick_tx
14292853267049 000 __get_xps_queue_idx
14292853273159 000 validate_xmit_skb_list
14292853274679 000 validate_xmit_skb
14292853276309 000 netif_skb_features
14292853280849 000 mlx5e_features_check
14292853283259 000 mlx5e_ipsec_feature_check
14292853285989 000 skb_network_protocol
14292853287659 000 skb_csum_hwoffload_help
14292853289219 000 validate_xmit_xfrm
14292853290999 000 dev_hard_start_xmit
14292853293279 000 mlx5e_xmit
14292853297839 000 mlx5e_sq_xmit_prepare
14292853332529 004 napi_consume_skb
14292853339799 004 skb_release_all
14292853343239 004 skb_release_head_state
14292853345749 004 sock_wfree
14292853348290 004 skb_release_data
14292853350370 004 skb_free_head
===
14254947672680 001 ip_output
14254947674680 001 nf_hook_slow
14254947676310 001 apparmor_ipv4_postroute
14254947677800 001 ip_finish_output
14254947680280 001 __cgroup_bpf_run_filter_skb
14254947682200 001 __ip_finish_output
14254947683850 001 ip_finish_output2
14254947685720 001 neigh_resolve_output
14254947687300 001 skb_push
14254947689240 001 dev_queue_xmit
14254947690650 001 __dev_queue_xmit
14254947692160 001 netdev_core_pick_tx
14254947693680 001 mlx5e_select_queue
14254947695780 001 netdev_pick_tx
14254947697250 001 __get_xps_queue_idx
14254947699950 001 validate_xmit_skb_list
14254947701970 001 validate_xmit_skb
14254947704330 001 netif_skb_features
14254947706240 001 mlx5e_features_check
14254947708250 001 mlx5e_ipsec_feature_check
14254947709930 001 skb_network_protocol
14254947712110 001 skb_csum_hwoffload_help
14254947714250 001 validate_xmit_xfrm
14254947716800 001 dev_hard_start_xmit
14254947718490 001 mlx5e_xmit
14254947720660 001 mlx5e_sq_xmit_prepare
14254947748051 003 napi_consume_skb
14254947756531 003 skb_release_all
14254947758901 003 skb_release_head_state
14254947763401 003 __sock_wfree
14254947765281 003 skb_release_data
14254947767131 003 skb_free_head
===
14254946596867 001 tcp_v4_early_demux
14254946616127 001 ip_route_input_noref
14254946624067 001 ip_local_deliver
14254946627598 001 ip_local_deliver_finish
14254946630598 001 ip_protocol_deliver_rcu
14254946637118 001 raw_local_deliver
14254946639958 001 tcp_v4_rcv
14254946643808 001 sk_filter_trim_cap
14254946650448 001 __cgroup_bpf_run_filter_skb
14254946655588 001 security_sock_rcv_skb
14254946658748 001 apparmor_socket_sock_rcv_skb
14254946661398 001 tcp_v4_fill_cb
14254946665208 001 tcp_v4_do_rcv
14254946667838 001 tcp_rcv_state_process
14254946672578 001 tcp_v4_conn_request
14254946676418 001 tcp_conn_request
14254946692758 001 tcp_v4_route_req
14254946696038 001 security_inet_conn_request
14254946698638 001 apparmor_inet_conn_request
14254946710868 001 tcp_try_fastopen
14254946973422 001 consume_skb
14254946976942 001 skb_release_all
14254946978902 001 skb_release_head_state
14254946981732 001 skb_release_data
14254946983592 001 skb_free_head
14254946988842 001 kfree_skbmem
14254947112773 001 tcp_v4_early_demux
14254947116413 001 ip_route_input_noref
14254947118523 001 ip_local_deliver
14254947120053 001 ip_local_deliver_finish
14254947121753 001 ip_protocol_deliver_rcu
14254947123503 001 raw_local_deliver
14254947124913 001 tcp_v4_rcv
14254947126483 001 sk_filter_trim_cap
14254947128253 001 __cgroup_bpf_run_filter_skb
14254947129923 001 security_sock_rcv_skb
14254947131463 001 apparmor_socket_sock_rcv_skb
14254947132953 001 tcp_v4_fill_cb
14254947135013 001 tcp_check_req
14254947137423 001 tcp_create_openreq_child
14254947148064 001 tcp_child_process
14254947151984 001 tcp_rcv_state_process
14254947153804 001 tcp_validate_incoming
14254947156254 001 tcp_init_transfer
14254947161174 001 tcp_urg
14254947162794 001 tcp_data_queue
14254947166304 001 __kfree_skb
14254947167834 001 skb_release_all
14254947170084 001 skb_release_head_state
14254947171714 001 skb_release_data
14254947173054 001 skb_free_head
14254947174814 001 kfree_skbmem
14254947620299 001 tcp_v4_early_demux
14254947626209 001 ip_local_deliver
14254947628059 001 ip_local_deliver_finish
14254947629679 001 ip_protocol_deliver_rcu
14254947631789 001 raw_local_deliver
14254947633359 001 tcp_v4_rcv
14254947635119 001 sk_filter_trim_cap
14254947637409 001 __cgroup_bpf_run_filter_skb
14254947639319 001 security_sock_rcv_skb
14254947640839 001 apparmor_socket_sock_rcv_skb
14254947642329 001 tcp_v4_fill_cb
14254947644209 001 tcp_v4_do_rcv
14254947647009 001 tcp_rcv_established
14254947648879 001 tcp_urg
14254947650969 001 tcp_data_queue
14254947653089 001 tcp_queue_rcv
14254947654899 001 tcp_event_data_recv
14254948402868 002 __kfree_skb
14254948411898 002 skb_release_all
14254948414348 002 skb_release_head_state
14254948416528 002 sock_rfree
14254948418648 002 skb_release_data
14254948420398 002 skb_free_head
14254948422598 002 kfree_skbmem
===
14254958573127 002 ip_output
14254958577077 002 nf_hook_slow
14254958579887 002 apparmor_ipv4_postroute
14254958583497 002 ip_finish_output
14254958591077 002 __cgroup_bpf_run_filter_skb
14254958597097 002 __ip_finish_output
14254958600347 002 ip_finish_output2
14254958606377 002 neigh_resolve_output
14254958608587 002 skb_push
14254958611377 002 dev_queue_xmit
14254958613617 002 __dev_queue_xmit
14254958615817 002 netdev_core_pick_tx
14254958619797 002 mlx5e_select_queue
14254958623767 002 netdev_pick_tx
14254958626357 002 __get_xps_queue_idx
14254958753469 002 validate_xmit_skb_list
14254958758039 002 validate_xmit_skb
14254958762219 002 netif_skb_features
14254958765489 002 mlx5e_features_check
14254958767759 002 mlx5e_ipsec_feature_check
14254958770539 002 skb_network_protocol
14254958774049 002 skb_csum_hwoffload_help
14254958778179 002 validate_xmit_xfrm
14254958782519 002 dev_hard_start_xmit
14254958785099 002 mlx5e_xmit
14254958788409 002 mlx5e_sq_xmit_prepare
14254958816309 007 napi_consume_skb
14254958824769 007 skb_release_all
14254958827589 007 skb_release_head_state
14254958831270 007 tcp_wfree
14254958833950 007 skb_release_data
14254958836910 007 kfree_skbmem
===
14254958851690 001 tcp_v4_early_demux
14254958858160 001 ip_local_deliver
14254958860500 001 ip_local_deliver_finish
14254958862650 001 ip_protocol_deliver_rcu
14254958865980 001 raw_local_deliver
14254958867890 001 tcp_v4_rcv
14254958870060 001 sk_filter_trim_cap
14254958873120 001 __cgroup_bpf_run_filter_skb
14254958875780 001 security_sock_rcv_skb
14254958878350 001 apparmor_socket_sock_rcv_skb
14254958880570 001 tcp_v4_fill_cb
14254958883680 001 tcp_v4_do_rcv
14254958887320 001 tcp_rcv_state_process
14254958890460 001 tcp_validate_incoming
14254958909760 001 tcp_drop
14254958912920 001 __kfree_skb
14254958914690 001 skb_release_all
14254958916170 001 skb_release_head_state
14254958917631 001 skb_release_data
14254958918961 001 skb_free_head
14254958921161 001 kfree_skbmem
===
14254946734599 001 ip_output
14254946737429 001 nf_hook_slow
14254946741159 001 apparmor_ipv4_postroute
14254946745659 001 ip_finish_output
14254946748919 001 __cgroup_bpf_run_filter_skb
14254946752709 001 __ip_finish_output
14254946757879 001 ip_finish_output2
14254946766419 001 neigh_resolve_output
14254946770019 001 __neigh_event_send
14254946774159 001 skb_push
14254946777669 001 dev_queue_xmit
14254946783399 001 __dev_queue_xmit
14254946787539 001 netdev_core_pick_tx
14254946791609 001 mlx5e_select_queue
14254946797159 001 netdev_pick_tx
14254946802960 001 __get_xps_queue_idx
14254946928521 001 validate_xmit_skb_list
14254946931581 001 validate_xmit_skb
14254946936171 001 netif_skb_features
14254946940481 001 mlx5e_features_check
14254946942851 001 mlx5e_ipsec_feature_check
14254946945841 001 skb_network_protocol
14254946948671 001 skb_csum_hwoffload_help
14254946951041 001 validate_xmit_xfrm
14254946955921 001 dev_hard_start_xmit
14254946959341 001 mlx5e_xmit
14254946964501 001 mlx5e_sq_xmit_prepare
14254947017682 003 napi_consume_skb
14254947033822 003 skb_release_all
14254947039832 003 skb_release_head_state
14254947045172 003 sock_edemux
14254947051332 003 skb_release_data
14254947053952 003 skb_free_head
发送数据的堆栈:
iperf -c 8.8.8.8 -n 50
查看堆栈:
Got 232 traces^C
Timestamp CPU Function
===
14562342633157 007 tcp_v4_early_demux
14562342639207 007 ip_route_input_noref
14562342643617 007 ip_local_deliver
14562342645977 007 ip_local_deliver_finish
14562342648258 007 ip_protocol_deliver_rcu
14562342650508 007 raw_local_deliver
14562342652198 007 tcp_v4_rcv
14562342654388 007 sk_filter_trim_cap
14562342656268 007 __cgroup_bpf_run_filter_skb
14562342658188 007 security_sock_rcv_skb
14562342659718 007 apparmor_socket_sock_rcv_skb
14562342661458 007 tcp_v4_fill_cb
14562342664688 007 tcp_v4_do_rcv
14562342666638 007 tcp_rcv_state_process
14562342668498 007 tcp_rcv_synsent_state_process
14562342682598 007 tcp_finish_connect
14562342684768 007 security_inet_conn_established
14562342686398 007 tcp_init_transfer
14562342751528 007 tcp_urg
14562342753368 007 __kfree_skb
14562342755058 007 skb_release_all
14562342756808 007 skb_release_head_state
14562342758508 007 skb_release_data
14562342759988 007 skb_free_head
14562342762188 007 kfree_skbmem
14562343338663 007 tcp_v4_early_demux
14562343341373 007 ip_local_deliver
14562343343493 007 ip_local_deliver_finish
14562343345443 007 ip_protocol_deliver_rcu
14562343347663 007 raw_local_deliver
14562343349833 007 tcp_v4_rcv
14562343351983 007 sk_filter_trim_cap
14562343354403 007 __cgroup_bpf_run_filter_skb
14562343356613 007 security_sock_rcv_skb
14562343358603 007 apparmor_socket_sock_rcv_skb
14562343360623 007 tcp_v4_fill_cb
14562343362943 007 tcp_v4_do_rcv
14562343365343 007 tcp_rcv_established
14562343367603 007 tcp_validate_incoming
14562343375363 007 tcp_urg
14562343377613 007 tcp_data_queue
14562343379663 007 __kfree_skb
14562343381543 007 skb_release_all
14562343383413 007 skb_release_head_state
14562343385223 007 skb_release_data
14562343386833 007 skb_free_head
14562343388593 007 kfree_skbmem
14562354785649 007 tcp_v4_early_demux
14562354790859 007 ip_local_deliver
14562354792659 007 ip_local_deliver_finish
14562354794219 007 ip_protocol_deliver_rcu
14562354796459 007 raw_local_deliver
14562354798469 007 tcp_v4_rcv
14562354800269 007 sk_filter_trim_cap
14562354802339 007 __cgroup_bpf_run_filter_skb
14562354804099 007 security_sock_rcv_skb
14562354805639 007 apparmor_socket_sock_rcv_skb
14562354807129 007 tcp_v4_fill_cb
14562354809299 007 tcp_v4_do_rcv
14562354811379 007 tcp_rcv_state_process
14562354813059 007 tcp_validate_incoming
14562354821359 007 tcp_urg
14562354823599 007 tcp_data_queue
14562354826569 007 tcp_queue_rcv
14562354896860 007 kfree_skb
14562354899010 007 skb_release_all
14562354900930 007 skb_release_head_state
14562354903050 007 sock_rfree
14562354905130 007 skb_release_data
14562354906850 007 skb_free_head
14562354909010 007 kfree_skbmem
===
14562354835879 007 ip_output
14562354837849 007 nf_hook_slow
14562354840139 007 apparmor_ipv4_postroute
14562354842129 007 ip_finish_output
14562354844339 007 __cgroup_bpf_run_filter_skb
14562354846819 007 __ip_finish_output
14562354848829 007 ip_finish_output2
14562354851049 007 neigh_resolve_output
14562354853050 007 skb_push
14562354855750 007 dev_queue_xmit
14562354857620 007 __dev_queue_xmit
14562354859560 007 netdev_core_pick_tx
14562354861420 007 mlx5e_select_queue
14562354863480 007 netdev_pick_tx
14562354865260 007 __get_xps_queue_idx
14562354867550 007 validate_xmit_skb_list
14562354869780 007 validate_xmit_skb
14562354872700 007 netif_skb_features
14562354874600 007 mlx5e_features_check
14562354876290 007 mlx5e_ipsec_feature_check
14562354878090 007 skb_network_protocol
14562354880120 007 skb_csum_hwoffload_help
14562354882030 007 validate_xmit_xfrm
14562354884340 007 dev_hard_start_xmit
14562354886190 007 mlx5e_xmit
14562354888320 007 mlx5e_sq_xmit_prepare
14562354915040 004 napi_consume_skb
14562354919860 004 skb_release_all
14562354921980 004 skb_release_head_state
14562354924010 004 __sock_wfree
14562354930020 004 skb_release_data
14562354931530 004 skb_free_head
===
14562342697708 007 ip_output
14562342699628 007 nf_hook_slow
14562342701878 007 apparmor_ipv4_postroute
14562342704008 007 ip_finish_output
14562342706478 007 __cgroup_bpf_run_filter_skb
14562342708598 007 __ip_finish_output
14562342710488 007 ip_finish_output2
14562342712718 007 neigh_resolve_output
14562342714668 007 skb_push
14562342716398 007 dev_queue_xmit
14562342718328 007 __dev_queue_xmit
14562342720348 007 netdev_core_pick_tx
14562342722378 007 mlx5e_select_queue
14562342724318 007 netdev_pick_tx
14562342726138 007 __get_xps_queue_idx
14562342728388 007 validate_xmit_skb_list
14562342730688 007 validate_xmit_skb
14562342732758 007 netif_skb_features
14562342734698 007 mlx5e_features_check
14562342736488 007 mlx5e_ipsec_feature_check
14562342738228 007 skb_network_protocol
14562342740228 007 skb_csum_hwoffload_help
14562342742128 007 validate_xmit_xfrm
14562342744378 007 dev_hard_start_xmit
14562342745988 007 mlx5e_xmit
14562342747868 007 mlx5e_sq_xmit_prepare
14562342773858 004 napi_consume_skb
14562342778678 004 skb_release_all
14562342780879 004 skb_release_head_state
14562342784249 004 __sock_wfree
14562342786209 004 skb_release_data
14562342787669 004 skb_free_head
===
14562342310375 007 ip_output
14562342320415 007 nf_hook_slow
14562342322605 007 apparmor_ipv4_postroute
14562342325125 007 ip_finish_output
14562342326945 007 __cgroup_bpf_run_filter_skb
14562342330165 007 __ip_finish_output
14562342332345 007 ip_finish_output2
14562342334845 007 neigh_resolve_output
14562342336515 007 __neigh_event_send
14562342338725 007 skb_push
14562342340565 007 dev_queue_xmit
14562342342105 007 __dev_queue_xmit
14562342343925 007 netdev_core_pick_tx
14562342346775 007 mlx5e_select_queue
14562342349675 007 netdev_pick_tx
14562342351585 007 __get_xps_queue_idx
14562342355775 007 validate_xmit_skb_list
14562342357825 007 validate_xmit_skb
14562342361205 007 netif_skb_features
14562342363195 007 mlx5e_features_check
14562342365235 007 mlx5e_ipsec_feature_check
14562342367395 007 skb_network_protocol
14562342370425 007 skb_csum_hwoffload_help
14562342372165 007 validate_xmit_xfrm
14562342376125 007 dev_hard_start_xmit
14562342378655 007 mlx5e_xmit
14562342381825 007 mlx5e_sq_xmit_prepare
14562342424616 004 napi_consume_skb
14562342431256 004 skb_release_all
14562342433386 004 skb_release_head_state
14562342435816 004 tcp_wfree
14562342437996 004 skb_release_data
14562342440126 004 kfree_skbmem
14562343225952 007 ip_output
14562343230492 007 nf_hook_slow
14562343232312 007 apparmor_ipv4_postroute
14562343233892 007 ip_finish_output
14562343235822 007 __cgroup_bpf_run_filter_skb
14562343237582 007 __ip_finish_output
14562343238992 007 ip_finish_output2
14562343240682 007 neigh_resolve_output
14562343242292 007 skb_push
14562343243712 007 dev_queue_xmit
14562343244962 007 __dev_queue_xmit
14562343246412 007 netdev_core_pick_tx
14562343247882 007 mlx5e_select_queue
14562343249312 007 netdev_pick_tx
14562343250932 007 __get_xps_queue_idx
14562343252742 007 validate_xmit_skb_list
14562343254492 007 validate_xmit_skb
14562343256192 007 netif_skb_features
14562343257652 007 mlx5e_features_check
14562343259632 007 mlx5e_ipsec_feature_check
14562343261452 007 skb_network_protocol
14562343263872 007 skb_csum_hwoffload_help
14562343265712 007 validate_xmit_xfrm
14562343267992 007 dev_hard_start_xmit
14562343269882 007 mlx5e_xmit
14562343271902 007 mlx5e_sq_xmit_prepare
14562343274162 007 mlx5e_sq_calc_wqe_attr
14562343289022 004 napi_consume_skb
14562343293742 004 skb_release_all
14562343295882 004 skb_release_head_state
14562343297942 004 tcp_wfree
14562343300032 004 skb_release_data
14562343302192 004 kfree_skbmem
14562353401939 007 ip_output
14562353409439 007 nf_hook_slow
14562353411429 007 apparmor_ipv4_postroute
14562353413269 007 ip_finish_output
14562353415579 007 __cgroup_bpf_run_filter_skb
14562353417599 007 __ip_finish_output
14562353419179 007 ip_finish_output2
14562353421349 007 neigh_resolve_output
14562353423029 007 skb_push
14562353424649 007 dev_queue_xmit
14562353426289 007 __dev_queue_xmit
14562353427819 007 netdev_core_pick_tx
14562353429399 007 mlx5e_select_queue
14562353431019 007 netdev_pick_tx
14562353432799 007 __get_xps_queue_idx
14562353435429 007 validate_xmit_skb_list
14562353438299 007 validate_xmit_skb
14562353440929 007 netif_skb_features
14562353443149 007 mlx5e_features_check
14562353444929 007 mlx5e_ipsec_feature_check
14562353446979 007 skb_network_protocol
14562353449409 007 skb_csum_hwoffload_help
14562353451339 007 validate_xmit_xfrm
14562353454059 007 dev_hard_start_xmit
14562353456179 007 mlx5e_xmit
14562353458399 007 mlx5e_sq_xmit_prepare
14562353489899 004 napi_consume_skb
14562353494689 004 skb_release_all
14562353496739 004 skb_release_head_state
14562353498710 004 tcp_wfree
14562353500720 004 skb_release_data
14562353502780 004 kfree_skbmem
在抓一下UDP接收数据的堆栈:
ipft -m 0xdeadbeef
Attaching program (total 1406, succeeded 1406, failed 0, filtered: 0)
Trace ready!
iperf -s -u
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size: 208 KByte (default)
------------------------------------------------------------
在远端PC发送数据50 Bytes后,抓到堆栈:
Got 78 traces^C
Timestamp CPU Function
===
15332510205976 004 udp_v4_early_demux
15332510223886 004 ip_route_input_noref
15332510230956 004 ip_local_deliver
15332510233916 004 ip_local_deliver_finish
15332510236766 004 ip_protocol_deliver_rcu
15332510241456 004 raw_local_deliver
15332510244236 004 udp_rcv
15332510247066 004 __udp4_lib_rcv
15332510251536 004 udp_queue_rcv_skb
15332510253316 004 udp_queue_rcv_one_skb
15332510255096 004 sk_filter_trim_cap
15332510260066 004 __cgroup_bpf_run_filter_skb
15332510264506 004 security_sock_rcv_skb
15332510274236 004 apparmor_socket_sock_rcv_skb
15332510276337 004 skb_pull_rcsum
15332510280957 004 ipv4_pktinfo_prepare
15332510285347 004 __udp_enqueue_schedule_skb
15332510329207 001 __sock_recv_ts_and_drops
15332510337267 001 __sock_recv_timestamp
15332510342757 001 skb_consume_udp
15332510347567 001 __consume_stateless_skb
15332510351227 001 skb_release_data
15332510353667 001 skb_free_head
15332510358507 001 kfree_skbmem
===
15332525097147 001 ip_output
15332525103327 001 nf_hook_slow
15332525105857 001 apparmor_ipv4_postroute
15332525108587 001 ip_finish_output
15332525113857 001 __cgroup_bpf_run_filter_skb
15332525117827 001 __ip_finish_output
15332525120007 001 ip_finish_output2
15332525123747 001 neigh_resolve_output
15332525126307 001 __neigh_event_send
15332525131037 001 skb_push
15332525134237 001 dev_queue_xmit
15332525136107 001 __dev_queue_xmit
15332525138787 001 netdev_core_pick_tx
15332525141427 001 mlx5e_select_queue
15332525145057 001 netdev_pick_tx
15332525147427 001 __get_xps_queue_idx
15332525152157 001 validate_xmit_skb_list
15332525157097 001 validate_xmit_skb
15332525160687 001 netif_skb_features
15332525163737 001 mlx5e_features_check
15332525166087 001 mlx5e_ipsec_feature_check
15332525168227 001 skb_network_protocol
15332525171487 001 skb_csum_hwoffload_help
15332525173367 001 validate_xmit_xfrm
15332525177698 001 dev_hard_start_xmit
15332525181018 001 mlx5e_xmit
15332525183778 001 mlx5e_sq_xmit_prepare
15332525211628 003 napi_consume_skb
15332525221938 003 skb_release_all
15332525226948 003 skb_release_head_state
15332525228528 003 sock_wfree
15332525233428 003 skb_release_data
15332525235478 003 skb_free_head
===
15332499076333 004 udp_v4_early_demux
15332499094243 004 ip_route_input_noref
15332499102033 004 ip_local_deliver
15332499105633 004 ip_local_deliver_finish
15332499108343 004 ip_protocol_deliver_rcu
15332499114053 004 raw_local_deliver
15332499117433 004 udp_rcv
15332499120703 004 __udp4_lib_rcv
15332499125334 004 udp_queue_rcv_skb
15332499127354 004 udp_queue_rcv_one_skb
15332499129524 004 sk_filter_trim_cap
15332499135904 004 __cgroup_bpf_run_filter_skb
15332499141494 004 security_sock_rcv_skb
15332499144944 004 apparmor_socket_sock_rcv_skb
15332499147214 004 skb_pull_rcsum
15332499152714 004 ipv4_pktinfo_prepare
15332499158564 004 __udp_enqueue_schedule_skb
15332499217284 001 skb_consume_udp
15332499225425 001 __consume_stateless_skb
15332499229945 001 skb_release_data
15332499232835 001 skb_free_head
15332499238705 001 kfree_skbmem
抓UDP发送数据包,远端PC做为server,本地PC 发送数据50 Bytes:
root@ZX:/home/henry# iperf -c 8.8.8.8 -u -n 50
------------------------------------------------------------
Client connecting to 8.8.8.8, UDP port 5001
Sending 1470 byte datagrams, IPG target: 11215.21 us (kalman adjust)
UDP buffer size: 208 KByte (default)
------------------------------------------------------------
[ 3] local 8.8.8.9 port 51949 connected with 8.8.8.8 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 0.0 sec 50.0 Bytes 35.1 Kbits/sec
[ 3] Sent 1 datagrams
[ 3] Server Report:
[ 3] 0.0- 0.0 sec 1.44 KBytes 1.13 Mbits/sec 0.000 ms 0/ 1 (0%)
Got 85 traces^C
Timestamp CPU Function
===
15471566821934 006 ip_output
15471566833054 006 nf_hook_slow
15471566835244 006 apparmor_ipv4_postroute
15471566837744 006 ip_finish_output
15471566840284 006 __cgroup_bpf_run_filter_skb
15471566844894 006 __ip_finish_output
15471566847394 006 ip_finish_output2
15471566849844 006 neigh_resolve_output
15471566851524 006 __neigh_event_send
15471566855864 006 skb_push
15471566857594 006 dev_queue_xmit
15471566859174 006 __dev_queue_xmit
15471566861234 006 netdev_core_pick_tx
15471566863534 006 mlx5e_select_queue
15471566866434 006 netdev_pick_tx
15471566868135 006 __get_xps_queue_idx
15471566872235 006 validate_xmit_skb_list
15471566874695 006 validate_xmit_skb
15471566878625 006 netif_skb_features
15471566880435 006 mlx5e_features_check
15471566882255 006 mlx5e_ipsec_feature_check
15471566884125 006 skb_network_protocol
15471566887105 006 skb_csum_hwoffload_help
15471566889035 006 validate_xmit_xfrm
15471566892895 006 dev_hard_start_xmit
15471566895415 006 mlx5e_xmit
15471566898605 006 mlx5e_sq_xmit_prepare
15471566928445 001 napi_consume_skb
15471566936565 001 skb_release_all
15471566938855 001 skb_release_head_state
15471566940305 001 sock_wfree
15471566943255 001 skb_release_data
15471566945215 001 skb_free_head
===
15471578208752 006 ip_output
15471578214952 006 nf_hook_slow
15471578217132 006 apparmor_ipv4_postroute
15471578218872 006 ip_finish_output
15471578221262 006 __cgroup_bpf_run_filter_skb
15471578223082 006 __ip_finish_output
15471578224652 006 ip_finish_output2
15471578226582 006 neigh_resolve_output
15471578228612 006 skb_push
15471578230052 006 dev_queue_xmit
15471578231482 006 __dev_queue_xmit
15471578233122 006 netdev_core_pick_tx
15471578234752 006 mlx5e_select_queue
15471578236402 006 netdev_pick_tx
15471578238302 006 validate_xmit_skb_list
15471578240152 006 validate_xmit_skb
15471578242102 006 netif_skb_features
15471578243752 006 mlx5e_features_check
15471578245272 006 mlx5e_ipsec_feature_check
15471578246932 006 skb_network_protocol
15471578248682 006 skb_csum_hwoffload_help
15471578250222 006 validate_xmit_xfrm
15471578252212 006 dev_hard_start_xmit
15471578253842 006 mlx5e_xmit
15471578255692 006 mlx5e_sq_xmit_prepare
15471578283773 001 napi_consume_skb
15471578293793 001 skb_release_all
15471578296953 001 skb_release_head_state
15471578299453 001 sock_wfree
15471578302843 001 skb_release_data
15471578305593 001 skb_free_head
===
15471598854084 004 udp_v4_early_demux
15471598867814 004 ip_route_input_noref
15471598874355 004 ip_local_deliver
15471598877155 004 ip_local_deliver_finish
15471598879495 004 ip_protocol_deliver_rcu
15471598883905 004 raw_local_deliver
15471598886905 004 udp_rcv
15471598889665 004 __udp4_lib_rcv
15471598894305 004 udp_queue_rcv_skb
15471598896195 004 udp_queue_rcv_one_skb
15471598898105 004 sk_filter_trim_cap
15471598903925 004 __cgroup_bpf_run_filter_skb
15471598908125 004 security_sock_rcv_skb
15471598911825 004 apparmor_socket_sock_rcv_skb
15471598913605 004 skb_pull_rcsum
15471598918315 004 ipv4_pktinfo_prepare
15471598922525 004 __udp_enqueue_schedule_skb
15471598958915 006 skb_consume_udp
15471598969926 006 __consume_stateless_skb
15471598975236 006 skb_release_data
15471598977506 006 skb_free_head
15471598984116 006 kfree_skbmem
本来ipftrace2可以打印出函数的包含关系,但是本地测试会报错,没有解决:
ipft -m 0xdeadbeef -t function_graph
libbpf: load bpf program failed: Invalid argument
libbpf: -- BEGIN DUMP LOG ---
libbpf:
arg#0 type is not a struct
Unrecognized arg#0 type PTR
; SEC("fentry/ipft_main1") int ipft_main1(void **ctx)
0: (bf) r6 = r1
; struct sk_buff *skb = (struct sk_buff *)ctx[0];
1: (79) r7 = *(u64 *)(r6 +0)
func 'audit_receive' arg0 has btf_id 3385 type STRUCT 'sk_buff'
|