Analysis of kernel reading Linux2.6.34 kernel bridging data Forwarding (iii) __linux

Source: Internet
Author: User

If there is any mistake, please correct the study.

Handle_bridge () function, which is in the LINUX2.6.34\NET\CORE\DEV.C


Here's a callback to the Br_handle_frame_hook () function, which is a hook function. The Br_handle_frame_hook () function is br_handle_frame_hook=br_handle_frame in linux2.6.34\net\bridge\br_input.c, so the actual function is Br_ Handle_frame.


function to raise the destination address in the packet, if the destination address is the local MAC address will call the Br_handle_local_finish () function to let the bridge Learning update correction cam table, and then let the function return SKB, so NETIF_RECEIVE_SKB () The function will continue to execute, and the packet is passed to L3 when traversing the second linked list.

If the destination address is not native, the network Bridge chooses to forward it, calling the Br_handle_frame_finish () function for packet forwarding, which is in the linux2.6.34\net\bridge\br_input.c

The strategy that the function uses to forward packets is: If the Network Bridge maintains the cam table to find the packet target address Mac corresponding to the Ethernet port, the bridge will be the packet from the Ethernet port forward, if not found, then the flood in the way, the packet forward to each Ethernet port. Of course, both of these strategies may cause problems, such as: output Ethernet port can not be the same as the input Ethernet port, and so on, these are Should_deliver () function (LINUX2.6.34\NET\BRIDGE\BR_FORWARD.C) to check. Detailed analysis as follows:

The function is just beginning to let the bridge learn to update and correct cam table. The next step is to determine whether the destination address is a multicast address, then call Br_multicast_forword () to forward it, which finally calls the _br_forword () function, which is analyzed later. If the destination address is not a multicast address, check the cam table to see if the destination address of the packet is registered on the Cam table, if there is a call Br_forword () function for forwarding packets, if not then call the Br_flood_forword () function for flood.

Br_forword () function in LINUX2.6.34\NET\BRIDGE\BR_FORWORD.C

This is mainly called the _br_forward () function, which is analyzed later.

Br_flood_forword () function in LINUX2.6.34\NET\BRIDGE\BR_FORWARD.C

This function also calls the _br_forword () function.

_br_forword () function in LINUX2.6.34\NET\BRIDGE\FORWARD.C


The _br_forword () function also did nothing, or called the Br_forward_finish () function.

Br_forward_finish () function in LINUX2.6.34\NET\BRIDGE\BR_FORWARD.C


The Br_forward_finish () function calls the Br_dev_queue_push_xmit () function.

Br_dev_queue_push_xmit () function in LINUX2.6.34\NET\BRIDGE\BR_FORWARD.C


The function has just begun to detect the length of the data, if the data length is greater than the MTU, discard the data frame, otherwise, from the data frame queue to remove the data frame to the Dev_queue_xmit () function, Dev_queue_xmit () function is responsible for the data frame forward to the NIC driver outgoing. So the whole bridge data forwarding is over.

Oh, almost a drop. Br_handle_frame_finish () function to find Cam, it will again determine whether the target address is not a native address, if the native address, Br_forward () and Br_flood_forward () function will not be able to execute, will be directed to execute the BR_PASS_FRAME_UP () function to pass the data frame to the native L3. Br_pass_frame_up () function in linux2.6.34\net\bridge\br_input.c

The BR_PASS_FRAME_UP () function is a callback to the NETIF_RECEIVE_SKB () function to implement a L3 that uploads the data frame to the local computer.

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.