systemstap调试ovs

可以通过stap工具打印和调试ovs的代码:

准备工作

安装kernel-debuginfo-common, kernel-debuginfo,kernel-devel,一定要匹配内核版本

uname -r
3.10.0-1160.83.1.el7.x86_64

stap工具可以通过指定stap脚本来实现对代码的打印或调试。

ovs内核datapath代码栈信息打印

stap脚本

probe begin {
            printf("=== begin ===\n");
}

probe module("openvswitch").function("*").call {
            printf("%s -> %s\n", thread_indent(4), ppfunc());
}

probe module("openvswitch").function("*").return {
            printf("%s <- %s\n", thread_indent(-4), ppfunc());
}

probe end {
            printf("=== end ===\n");
}

运行stap脚本:

stap datapath.stp -d kernel

结果展示:

     0 ping(26244):    -> internal_dev_xmit
     2 ping(26244):        -> ovs_flow_key_extract
     3 ping(26244):            -> key_extract
     5 ping(26244):                -> parse_vlan_tag
     6 ping(26244):                <- parse_vlan_tag
     8 ping(26244):                -> key_extract_l3l4
     9 ping(26244):                    -> check_header
    11 ping(26244):                    <- check_header
    12 ping(26244):                <- key_extract_l3l4
    13 ping(26244):            <- key_extract
    15 ping(26244):            -> ovs_ct_fill_key
    16 ping(26244):                -> ovs_ct_update_key
    18 ping(26244):                    -> __ovs_ct_update_key
    19 ping(26244):                    <- __ovs_ct_update_key
    21 ping(26244):                <- ovs_ct_update_key
    22 ping(26244):            <- ovs_ct_fill_key
    24 ping(26244):        <- ovs_flow_key_extract
    26 ping(26244):        -> ovs_dp_process_packet
    28 ping(26244):            -> ovs_flow_tbl_lookup_stats
    30 ping(26244):                -> flow_lookup
    31 ping(26244):                    -> masked_flow_lookup
    33 ping(26244):                        -> ovs_flow_mask_key
    34 ping(26244):                        <- ovs_flow_mask_key
    36 ping(26244):                    <- masked_flow_lookup
    37 ping(26244):                <- flow_lookup
    38 ping(26244):            <- ovs_flow_tbl_lookup_stats
    39 ping(26244):            -> ovs_flow_stats_update
    40 ping(26244):            <- ovs_flow_stats_update
    41 ping(26244):            -> ovs_execute_actions
    42 ping(26244):                -> do_execute_actions
    43 ping(26244):                    -> do_output
    44 ping(26244):                        -> ovs_lookup_vport
    45 ping(26244):                        <- ovs_lookup_vport
    46 ping(26244):                        -> ovs_vport_send
    48 ping(26244):                            -> internal_dev_recv
    49 ping(26244):                            <- internal_dev_recv
    50 ping(26244):                        <- ovs_vport_send
    51 ping(26244):                    <- do_output
    52 ping(26244):                <- do_execute_actions
    52 ping(26244):            <- ovs_execute_actions
    53 ping(26244):        <- ovs_dp_process_packet
    54 ping(26244):    <- internal_dev_xmit

ovs用户空间代码打印

stap脚本

probe begin {
    printf("=== begin ===\n");
}

probe process("ovs-vswitchd").function("*").call {
    printf("%s -> %s\n", thread_indent(4), ppfunc());
}

probe process("ovs-vswitchd").function("*").return {
    printf("%s <- %s\n", thread_indent(-4), ppfunc());
}

probe end {
    printf("=== end ===\n");
}

运行stap脚本

stap user.stp

stap脚本还有很多其它语法,可玩性很高

你可能感兴趣的:(systemstap调试ovs)