Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to analyze Open vSwitch OvS source code

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to carry out Open vSwitch OvS source code analysis, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Cloud computing is now quite popular in the IT industry, but there is no unified definition of what is really in the cloud computing industry (many companies define cloud computing narrowly according to their own interests), let alone standards and specifications. So now there are a lot of people saying that cloud computing is just a cover, it's a boo, it's not practical, it's just talk about it, although I'm not quite sure what cloud computing is and what the definition of cloud computing is, but according to the cloud computing products my company is doing now, I still know something about cloud computing services. I don't think it's a cover or boo, but if this cloud computing technology is not very mature, I reluctantly agree. If you compare cloud computing to a person, I personally think it is exactly what it looks like in its twenties, and it is more mature in its thirties, so I can probably imagine the current situation of cloud computing. The following is a brief introduction to some technologies to achieve cloud computing. I have no research on cloud computing, and I have not been able to analyze cloud computing technology from a global perspective, let alone analyze problems from a higher position. all I can introduce is some of the technologies related to cloud computing that I have encountered in my work. Over time, I hope to become a cloud computing "expert" one day.

Cloud computing is a topic all over the world, so there are talented people all over the world to strive for the realization of cloud computing. The technologies I encounter about cloud computing at this stage are Open vSwitch, OpenStack technology, and docker technology. Let's start with the introduction of Open vSwitch. I will use a series of blog to analyze the relevant data structure and workflow of Open vSwitch, as well as the analysis of each important module. All the introductions are based on the analysis of the source code, hoping to be useful for beginners.

Open vSwitch, by its name, is an open virtual switch (open virtual switch); it is the basis for implementing network virtualization SDN, and it is a multi-layer virtual switching standard of production quality under the open source Apache2.0 license. The Open vSwitch is designed to solve some limitations of the physical switch: Open vSwitch has lower cost and higher efficiency than the physical switch; a virtual switch can have dozens of ports to connect to the virtual machine, and the Open vSwitch itself takes up very small resources; you can receive, analyze and process data packets according to your own flexible configuration. It also supports standard management interfaces and protocols, such as NetFlow, sFlow, SPAN, RSPAN and so on.

Introduction of Open vSwtich module

The current latest code package mainly includes the following modules and features:

Ovs-vswitchd: the main module that implements the daemon of switch, including a Linux kernel module that supports stream switching

Ovsdb-server: lightweight database server that provides ovs-vswitchd to obtain configuration information

Ovs-brcompatd: let ovs-vswitch replace Linux bridge, including the Linux kernel module that gets bridge ioctls

Ovs-dpctl: used to configure the switch kernel module

Some Scripts and specs: secondary OvS is installed on Citrix XenServer as the default switch

Ovs-vsctl: query and update the configuration of ovs-vswitchd

Ovs-appctl: send a command message and run the relevant daemon

Ovsdbmonitor: the GUI tool that remotely fetches the OvS database and the flow table of OpenFlow.

Ovs-openflowd: a simple OpenFlow switch

Ovs-controller: a simple OpenFlow controller

Ovs-ofctl: query and control OpenFlow switches and controllers

Ovs-pki: OpenFlow switch creates and manages a public key framework

Patch for ovs-tcpundump:tcpdump to parse OpenFlow messages

Above are some of the main modules of Open vSwitch mentioned on the Internet. In fact, the most important thing in Open vSwitch is some files in the datapath directory. There are port module vport, key logic processing module datapath, flow table module such as flow, action action response module, channel module and so on.

Open vSwtich workflow

The general flow direction of the data packet in the linux network protocol stack is the black arrow flow: after receiving the data packet from the network card, it is analyzed layer by layer, and finally leaves the kernel state and transmits the data to the user state. Of course, some packets just operate in the kernel network protocol stack and then send out from a network card.

But when there is an openVswitch in it, the flow of the packet is different. First, create a bridge: ovs-vsctl add-br br0; and then bind a network card: bind the network card: ovs-vsctl add-port br0 eth0;. Here, the eth0 network card is bound by default. The flow direction of the data packet is from the network card eth0 and then to the port vport of the openVswitch into the openVswitch, and then match the flow table according to the key value. If the match is successful, find the corresponding operation method according to the corresponding action in the flow table and complete the corresponding action (this action may turn a request into a reply, or it may be discarded directly, or you can design your own action) If the match is not successful, the default action is performed, which may be put back into the kernel network protocol stack for processing (a port connection kernel protocol stack is created accordingly when the bridge is created).

This is probably the work flow. In general, the kernel code is modified in these places in order to achieve its own purpose: the first is to add the corresponding code to the ovs_dp_process_received_packet (struct vport * p, struct sk_buff * skb) function in datapath.c to achieve its own purpose, because this function is necessary for each packet; the second is to design your own flow table. The third and the second are related, that is, they design their own action according to the flow table to complete the functions they want.

The above is how to carry out Open vSwitch OvS source code analysis, the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report