Directory: http://www.cnblogs.com/WuCountry/archive/2008/11/15/1333960.html
[Do not provide illustrations. You are advised to download the source book from the Internet]
5.9. Virtual Devices Virtual Device
A virtual device is an internal action built on top of one or more real devices. the association between virtual devices and real devices can be used-to-consume, as shown by the three models in Figure 5-4. it is also possible to build virtual devices on top of other virtual devices. however, not all combinations are meaningful or are supported by the kernel.
A virtual device is an abstract device built on one or more real devices. The associations between virtual devices and real devices can be many to many, as shown in Figure 5-4. It may also be built on other virtual devices. However, not all combinations are meaningful, and not all are supported by the kernel.
Figure 5-4. Possible Relationship between virtual and real devices
5.9.1. Example of examples of Virtual Devices Virtual Device
Linux allows you to define different kinds of Virtual Devices. Here are a few examples:
The kernel allows you to define different types of Virtual Devices. There are several examples:
Bonding binding
With this feature, a virtual device bundles a group of physical devices and makes them behave as one.
Together with this feature, a virtual device processes a group of physical devices and allows them to act like a device.
802.1Q
This is an IEEE Standard that extends the 802.3/Ethernet header with the so-called VLAN header, allowing for the creation of virtual LANs.
This is a packet in the IEEE 802.3/Ethernet header, also known as the VLAN header. You can create a virtual LAN.
Bridging bridging
A bridge interface is a virtual representation of a bridge. Details are in part IV.
A bridge interface represents a virtual bridge. The details are discussed in Part 5.
Aliasing interfaces alias Interface
Originally, the main purpose for this feature was to allow a single real Ethernet interface to span several virtual interfaces (eth0: 0, eth0: 1, etc .), each with its own IP configuration. now, thanks to improvements to the networking Code, there is no need to define a new Virtual Interface to configure multiple IP addresses on the same Nic. however, there may be cases (notably Routing) where having different virtual hosts on the same Nic wocould make life easier, perhaps allowing simpler configuration. details are in chapter 30.
In the beginning, the main purpose of this feature is to allow a single Ethernet interface to distinguish virtual interfaces (eth0: 0, eth0: 1, etc.), each with its own IP configuration. Now, thanks toCodeNow, you do not have to define a new virtual configuration for configuring multiple IP addresses on the same Nic. However, in some cases (probably Routing), different virtual NICs in the same Nic may make life easier and perhaps more simple. For more details, see Chapter 1.
True equalizer (teql) real balancing
This is a queuing discipline that can be used with traffic control. Its implementation requires the creation of a special device. The idea behind teql is a bit similar to bonding.
Here is a queue principle that can be used to control traffic. In this implementation, you need to create a feature device. This idea is hidden behind teql, which is a little different from bonding.
Tunnel interfaces tunnel Interface
The implementation of IP-over-IP tunneling (ipip) and the generalized Routing Encapsulation (GRE) protocol is based on the creation of a virtual device.
The implementation of ipip and General Routing Encapsulation Protocol are based on the creation of a virtual device.
This list is not complete. Also, given the speed with which new features are encoded into the Linux kernel, you can perform CT to see new virtual devices being added to the kernel.
This is an incomplete list. Similarly, it shows the speed of adding a new feature to the Linux kernel. You can see that a new virtual device has been added to the kernel.
Bonding, bridging, and 802.1Q devices are examples of the model in Figure 5-4 (c ). aliasing interfaces are examples of the model in Figure 5-4 (B ). the model in Figure 5-4 (a) can be seen as a special case of the other two.
Binding, bridging, and 802.1Q devices are examples of the model in Figure 5-4 (c. Another interface is an example in Figure 5-4 (B), and the situation in Figure 5-4 (a) can be seen as a special case except the two.
5.9.2. Interaction with the interaction between the kernel network stack and the kernel network stack
Virtual Devices and real devices interact with the kernel in slightly different ways. For example, they differ with regard to the following points:
Virtual Devices and real device interfaces interact in slightly different ways through the kernel. For example, for the following details:
Initialization
Most virtual devices are assigned a net_device data structure, as real devices are. often, most of the virtual device's net_device's function pointers are initialized to routines implemented as wrappers, more or less complex, around the function pointers used by the associated real devices.
Many virtual devices are associated with the data structure of a net_device, which is like a real device. Generally, net_device function pointers of most virtual devices use implemented functions for initialization, which is more or less complex. These function pointers are used by relevant real devices.
However, not all virtual devices are assigned a net_device instance. aliasing devices are an example; they are implemented as simple labels on the associated real device (see the section "old-generation configuration: aliasing interfaces" in Chapter 30 ).
However, not all Virtual Devices specify a net_device instance. The associated devices are an example. They are implemented by associating a simple tag to a real device (see "old-style configuration: alias interface" in Chapter 30th ).
Configuration
It is common to provide ad hoc user-space tools to configure virtual devices, especially for the high-level fields that apply only to those devices and which cocould not be configured using standard tools such as ifconfig.
There is a common method to provide tools for configuring virtual devices for the hoc user space, especially for configuring upper-layer application fields. These fields cannot be configured using common tools such as ifconfig.
External Interface
Each Virtual Device usually exports a file, or a directory with a few files, to the/proc filesystem. how complex and detailed the information exported with those files is depends on the kind of virtual device and on the design. you will see the ones used by each virtual device listed in the section "Virtual Devices" in their associated chapters (for those devices covered in this book ). files associated with virtual devices are extra files; they do not replace the ones associated with the physical devices. aliasing devices, which do not have their own net_device instances, are again an exception.
Each Virtual Device usually exposes a file or a directory with a few files to the/proc file system. The details of these exposed information depend on the complexity of different virtual devices and their design. In the relevant section of the virtual device section, you can see that each virtual device uses an example. Virtual Device-related files are additional files that do not replace files related to real devices. Alias devices, which do not have their own net_device instances, are also a special case.
Transmission
When the relationship of virtual device to real device is not one-to-one, the routine used to transmit may need to include, among other tasks, the selection of the real device to use. [*] Because QoS is enforced on a per-device basis, the multiple relationships between virtual devices and associated real devices have implications for the traffic control configuration.
When the relationship between a virtual device and a real device is not one-to-oneProgramMust be included. Because QoS is mandatory for each device, the configuration of traffic control is implicitly configured for multiple associations between real devices of a virtual device.
[*] See Chapter 11 for more details on packet transmission in general, and dev_queue_xmit in particle.
Token reception
Because Virtual Devices are software objects, they do not need to engage in interactions with real resources on the system, such as registering an IRQ handler or allocating I/O Ports and I/O memory. their traffic comes secondhand from the physical devices that perform those tasks. packet termination tion happens differently for different types of Virtual Devices. for instance, 802.1Q interfaces register an ethertype and are passed only those packets encoded ed by the associated real devices that carry the right protocol id. [] In contrast, bridge interfaces receive any packet that arrives from the associated devices (see chapter 16 ).
Because Virtual Devices are software objects, they do not need to interact with the real resources of the system, such as registering IRQ handles or allocating I/O Ports and I/O memory. Their traffic is indirectly from physical devices that actually provide these features. Packet Receipt varies with virtual devices. For example, the 802.1Q interface registers an ethereum type, and only requests from physical devices with correct protocol packets pass. Correspondingly, the bridge interface receives all packets from the relevant devices.
[] Chapter 13 discusses the demultiplexing of ingress traffic based on the protocol identifier.
External notifications
Events from other kernel components about specific events taking place in the kernel [] are of interest as much to virtual devices as to real ones. because Virtual Devices 'logic is implemented on top of real devices, the latter have no knowledge about that logic and therefore are not able to pass on those notifications. for this reason, replications need to go directly to the virtual devices. let's use bonding as an example: if one device in the bundle goes down, the algorithms used to distribute traffic among the bundle's members have to be made aware of that so that they do not select the devices that are no longer available.
Notifications about special events in the kernel reported by other kernel components are more interesting for real devices. Because the device logic is implemented by the top-layer device, the latter does not know the logic and therefore cannot send these notifications. For this reason, you need to directly notify the virtual device. Let's take the binding type as an example. If the traffic of a device in a queue begins to decreaseAlgorithmSo that they do not need to select invalid devices.
[] Chapter 4 defines notification chains and explains what kind of notifications they can be used.
Unlike these software-triggered communications, hardware-triggered communications (e.g., PCI Power Management) cannot reach Virtual Devices directly because there is no hardware associated with virtual devices.
Notifications that are triggered by software, such as PCI power management, cannot directly reach the virtual device because no hardware is associated with the virtual device.