[Bridge] Help Needed On Bridge Module in Linux Kernel 2.6.23

Stephen Hemminger shemminger at vyatta.com
Fri May 29 10:23:44 PDT 2009


On Fri, 29 May 2009 22:07:32 +0530
Vijay Kumar N <vn0030410 at TechMahindra.com> wrote:

> 
> Hi Stephen,
>             I would kindly request you to give your comments and please do let me know if I’m going wrong anywhere.
> 
> I’m using Linux Kernel 2.6.23 bridge module. I have 3 Linux Machines with 2 NIC’s each and would create a Bridge and add the two interfaces(eth0 & eth1) on all the 3 machines to form a ring as shown in the below diagram.
> [cid:image001.gif at 01C9E08E.0AED6E00]
> I don’t need STP to be running and I would be using only the BR_STATE_FORWARDING and BR_STATE_BLOCKING only. Even when the cable is Plugged Out or Plugged In I have to prevent the port state changes. I would be running my program in user space and would be controlling the port states from here. I also do send control packets often on the interfaces on all the nodes. I would be receiving these control packets in the kernel and writing it to a file ( Have 2 files separate for both interfaces ). After writing to a file I would be sending a SIGNAL to my user space program to inform that a control packet was received. I use SIGUSR1 for eth0 & SIGUSR2 for eth1. I have SIGUSR1 and SIGUSR2 handlers written in user space program which would be running. I use API kill_proc(PID of my process, SIGNAL_NO, &siginfo)  to send signals to User Space From Kernel Space. When I get signal to my User Space Program I read from that appropriate file the control packet and do my processing in my program. In Kernel Space I use sys_open to create/Open a file and sys_write to write to the file with O_CREAT | O_WRONLY | O_TRUNC and 0777 mode.
> I set the file system to KERNEL_DS before writing to the file and after writing I revert back to earlier file system state.
> 
> Things I have changed in Linux kernel 2.6.23 bridge module to stop STP and prevent the port state changes.
> 
> 
>  1.  Have written IOCTL to set the port states on the interface I specify.
>  2.  Have written IOCTL to send my control packets.
>  3.  Have written IOCTL to store PID of my User Space Program in Kernel.
>  4.  For sending control packets I’m using the same LLC API’s and NF_HOOK which STP uses.
>  5.  For receiving control packets I use the stp_bpdu_rcv(). LLC_SAP_BSPAN which STP uses.
>  6.  I have set the stp_state to 1 (BR_KERNEL_STP) so that I can receive my control packets on and stp_bpdu_rcv() via netif_recieve_skb() via LLC_SAP_BSPAN.
>  7.  I have commented out contents of STP bpdu sending functions, so that even if it gets called no stp bpdu’s would flow out. When I set the IP for the bridge the STP enable functions on both the interfaces [br_stp_enable_port() ] and the bridge [br_stp_enable_bridge() ] are called as in case of STP. I have commented out the code for the disable functions on both ports and bridge. So that even If I plug out or plug in the cable no state change will happen. When I add interfaces to bridge I have made changes so that they would be in BR_STATE_FORWARDING.
>  8.  When a cable is plugged out I detect it using the state available in /sys/class/net/ethXX/operstate and set that port to BR_STATE_BLOCKING. I would be continuously polling on this file.
> 

It looks like you are doing same thing as user mode STP, so why not turn that on and do it all in userspace.
See the rstpd program to see how that could be done.

It is too hard to debug a detailed problem. You have changed so much and are asking questions
equivalent to "I changed the wheels on my bicycle with truck tires but now it won't turn, please help?"


More information about the Bridge mailing list