OpenvSwitch 代码笔记

此处主要记录OpenvSwitch 功能实现的调用过程:bash

 

注册用户态接收包时回调函数:
                                          construct
                                              |
                                              |
                                     open_dpif_backer
                                     /               \
                      (dpif-netdev) /                  \(dpif-net-link)
                                   /                    \
                            udpif_create                  udpif_set_threads
                                 |                                |
                       dpif_register_upcall_cb            udpif_start_threads
                                 |                                |
                   dpif_netdev_register_upcall_cb         ovs_thread_create
                                                                   |
                                                          udpif_upcall_handler (* 接收到内核态的请求)
                                                                   |
                                                               recv_upcalls
                                                                /          \
                                                          (2)  /             \ (1)
                                                              /                \
                                                     upcall_receive          dpif_recv
                                                             |                    |
                                                       flow_extract         dpif_netlink_recv
                                                             |
                                                       process_upcall
                                                             |
                                                       upcall_xlate
                                                             |
                                                       xlate_actions

  

处理controller发送的packetout数据包:
                                      ofconn_run
                                           |
                                     handle_openflow
                                           |
                                     handle_packet_out
                                       /               \
                                 (2) /                   \(1)
                                   /                       \
                 ofproto_packet_out_finish              ofproto_packet_out_start
                               |                                           |
                       packet_execute                                  packet_xlate
                               |                                           |
                         dpif_execute                                  xlate_actions
                               |                                           |
                        dpif_operate                              rule_dpif_lookup_from_table
           (dpif-netdev) /          \(dpif-netlink)                        |
                       /              \                              rule_dpif_lookup_in_table
           dpif_netdev_operate    dpif_netlink_operate                  /              \
                    |                        |                    (2) /                  \(1)
           dpif_netdev_execute  dpif_netlink_encode_execute         /                      \
                    |                        |                do_xlate_actions            classifier_lookup
     dp_netdev_execute_actions         nl_msg_put_genlmsghdr         |                           |
                    |                                         xlate_output_action         find_match_wc
           odp_execute_actions                                       |
                    |                                           compose_output_action
             dp_execute_cb                                            |
                    |                                           nl_msg_put_odp_port
                netdev_send

   

内核态Datapath处理packet流程:
            netdev_frame_hook
                     |
            netdev_port_receive
                     |
            ovs_vport_receive
                     |
           ovs_dp_process_packet
               /              \
 (Normal Match)/                \ (Non-normal Match)
             /                   \
   ovs_execute_actions         ovs_dp_upcall
                                   |
                            queue_userspace_packet
                                   |
                           genlmsg_unicast

  

用户态Datapath处理packet流程:
        pmd_thread_main           dpif_netdev_run
                 \                      /
                   \                  /
                dp_netdev_process_rxq_port
                           |
                      dp_netdev_input
                           |
                     fast_path_processing
                           |
                    handle_packet_upcall
                       /             \
                 (2) /                 \(1)
                   /                     \
  dp_netdev_execute_actions       dp_netdev_upcall
                  |                         |
         odp_execute_actions             upcall_cb(调用注册的回调函数)
                  |
            dp_execute_cb
                  |
             netdev_send