Introduction to openvswitch (ovs) Source Code Analysis

Source: Internet
Author: User
Tags openvswitch

Cloud computing is now popular in the IT industry, but there is no uniform definition of what the cloud computing industry really is (many companies define cloud computing according to their own narrow interests ), let alone standard specifications. So now, many people say that cloud computing is just a fake. It's a big bang, and it's not practical. I just want to talk about it. Although I don't know what it is called cloud computing, what is the definition of cloud computing, but I still know something about cloud computing services based on the cloud computing products that my company is currently using. I don't think it's a good joke, but if this cloud computing technology is not very mature, I barely agree. If I compare cloud computing to a person, I personally think that it is now 20 years old. When I was in my thirds, it was quite mature, so I can probably imagine the current situation of cloud computing. Next I will introduce some technologies that implement cloud computing. I have no research on cloud computing and have not been able to analyze cloud computing technologies from a global perspective, let alone analyze problems from a higher position. All I can introduce is the computing-related technologies that a small programmer has encountered during his work, we hope to become a cloud computing leader one day ".

Cloud computing is a topic around the world, so there are talented people from all over the world to fight for this cloud computing. The cloud computing technologies I have met at this stage are openvswitch and docker. Let's start with the introduction of openvswitch. I will use a series of blogs to analyze the data structure and workflow of openvswitch, as well as the analysis of each important module. All the introductions are based on source code analysis and hope to be useful for beginners.

Openvswitch is an open virtual switch based on its name. It is the basis for realizing network virtualization Sdn, it is a multi-layer virtual exchange standard for product-level quality under the open-source apache2.0 license. The purpose of the openvswitch design is to solve some limitations of the physical switch: The openvswitch has lower costs and higher work efficiency than the physical switch; A vswitch can have dozens of ports to connect to the virtual machine, while openvswitch itself occupies a very small amount of resources. You can flexibly configure it to receive and analyze data packets; standard management interfaces and protocols are also supported, such as NetFlow, sFlow, span, and rspan.

Introduction to the open vswtich Module
The latest code package mainly includes the following modules and features:
The main ovs-vswitchd module implements switch daemon, including a Linux kernel module that supports stream exchange;
Ovsdb-server lightweight database server, which provides ovs-vswitchd for configuration information;
Ovs-brcompatd replace ovs-vswitch with Linux bridge, including obtaining the Linux kernel module of bridge IOCTLs;
Ovs-dpctl is used to configure the switch kernel module;
Some scripts and specs auxiliary ovs are installed on Citrix xenserver as the default switch;
Ovs-vsctl query and update the configuration of ovs-vswitchd;
Ovs-appctl sends command messages and runs related daemon;
The ovsdbmonitor GUI tool can remotely obtain the stream tables of ovs databases and openflow.
Ovs-openflowd: A simple openflow switch;
Ovs-Controller: A simple openflow controller;
Ovs-ofctl queries and controls openflow switches and controllers;
Ovs-PKI: Creates and manages a public key framework for an openflow switch;
Ovs-tcpundump: tcpdump patch to parse openflow messages;

The above are some of the main modules of openvswitch mentioned on the Internet. In fact, some files in the datapath directory are the most important in openvswitch. There are port modules such as vport, key logic processing modules such as datapath, flow and other flow table modules, and finally the action response module and channel module.

The following describes the workflow:

The General Data Packet Flow Direction in the Linux network protocol stack is Black Arrow direction: After receiving the data packet from the network adapter, it analyzes it layer by layer, and finally leaves the kernel state to transmit the data to the user State. Of course, some data packets are only operated in the kernel network protocol stack, and then sent from a certain Nic.

However, when openvswitch exists, the data packet flow is different. First, create a bridge: ovs-vsctl add-Br br0; then bind a NIC: bind NIC: ovs-vsctl add-port br0 eth0; The eth0 Nic is bound by default. The data packet flows from the network adapter eth0 to the port vport of openvswitch and enters openvswitch. Then, the stream table is matched based on the key value. If the matching is successful, find the corresponding operation method based on the corresponding action in the stream table to complete the corresponding action (this action may be to convert a request into a response, it may also be discarded directly, or you can design your own action). If the matching fails, the default action is executed, it may be to put it back into the kernel network protocol stack for processing (a port will be created to connect to the kernel protocol stack when a bridge is created ).

The general workflow is like this. In the work, we usually modify the kernel code in these areas to achieve our goal: the first one is in datapath. in C, the ovs_dp_process_received_packet (struct vport * P, struct sk_buff * SKB) function adds the corresponding code to achieve its own purpose, because this function is necessary for each data packet; the second is to design your own stream table. The third is associated with the second, which is to design your own action based on the stream table to complete the desired function.


If there are any errors, please correct them! Thank you !!



Introduction to openvswitch (ovs) Source Code Analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.