From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <40D1E993.3060801@siennax.com> Date: Thu, 17 Jun 2004 20:57:23 +0200 From: Mark Ruijter MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030504030106050001010708" Subject: [Bridge] Bridge code enhancement (link state detection) and bug fix. (patches included). List-Id: Linux Ethernet Bridging List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: bridge@lists.osdl.org This is a multi-part message in MIME format. --------------030504030106050001010708 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 1. Link state monitoring added. We discovered the following problem with the existing bridge code. The code doesn't monitor the link state of the interfaces. When using two cisco switches with two Linux bridging firewalls the following problem exists. When the Cisco switch that has the blocking (stp) Linux bridge attached dies, the Linux bridge no longer receives stp packets and changes it's state from blocking to forwarding. As soon as the Cisco switch comes back alive a loop is created in the network for a short but long enough period of time. :-( To fix this I added link state monitoring to the code. This is only active when stp is turned on. When a link fails the bridge port goes to blocked and then to the new 'nolink' status. The bridge-utils patch makes it possible to see the status with brctl showstp. I did encounter a second problem when writing the link monitoring code. When you add a vlan interface like eth0.10 then it's not possible to obtain link state information from this interface. The fix I wrote is that brctl now allows you to specify the interface that contains the link state. Example : brctl addif NUM1 eth0.10 eth0 The old syntax: "brctl addif NUM1 eth0.10" still works but the link will always appear to be up. "brctl addif NUM1 eth0" works with link detection since this is a valid 'link state providing' device. If anyone is wants to know how to use the linux bridges with Cisco switches running rstp feel free to ask. It involves a few tricks to get it running..... I also discovered a small bug in de bridge code shipped in 2.6.6. 2. Bug fix... Creating a bridge like this is no longer possible: vconfig add eth0 10 vconfig add eth0 20 ifconfig eth0.10 0.0.0.0 up ifconfig eth0.20 0.0.0.0 up brctl addbr NUM1 brctl addif NUM1 eth0.10 brctl addif NUM1 eth0.20 The last command produces the following error: br_add_interface: File exists Older bridge code did accept this although it would log a warning. I hope the code can make it to mainstream. Please let me know how you feel about it. Mark Ruijter. --------------030504030106050001010708 Content-Type: text/x-patch; name="bridge-utils-1.0.4.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="bridge-utils-1.0.4.patch" diff -urN ./bridge-utils-1.0.4-old/brctl/brctl.c ./bridge-utils-1.0.4/brctl/brctl.c --- ./bridge-utils-1.0.4-old/brctl/brctl.c 2004-05-21 19:41:49.000000000 +0200 +++ ./bridge-utils-1.0.4/brctl/brctl.c 2004-06-16 12:10:10.000000000 +0200 @@ -54,7 +54,7 @@ goto help; } - if (argc < cmd->nargs + 2) { + if (argc < cmd->nargs + 2 ) { fprintf(stderr, "incorrect number of arguments for command\n"); goto help; } diff -urN ./bridge-utils-1.0.4-old/brctl/brctl_cmd.c ./bridge-utils-1.0.4/brctl/brctl_cmd.c --- ./bridge-utils-1.0.4-old/brctl/brctl_cmd.c 2004-06-04 20:03:40.000000000 +0200 +++ ./bridge-utils-1.0.4/brctl/brctl_cmd.c 2004-06-16 00:17:21.000000000 +0200 @@ -83,7 +83,7 @@ { int err; - switch (err = br_add_interface(argv[1], argv[2])) { + switch (err = br_add_interface(argv[1], argv[2], argv[3])) { case 0: return 0; case ENODEV: @@ -369,33 +369,33 @@ } static const struct command commands[] = { - { 1, "addbr", br_cmd_addbr, "\t\tadd bridge" }, - { 1, "delbr", br_cmd_delbr, "\t\tdelete bridge" }, + { 1, "addbr", br_cmd_addbr, "\t\t\tadd bridge" }, + { 1, "delbr", br_cmd_delbr, "\t\t\tdelete bridge" }, { 2, "addif", br_cmd_addif, - " \tadd interface to bridge" }, + " []\tadd interface to bridge, is the bridge device,\n\t\t\t\t\t\t\trealdev (optional) is the device with link information\n\t\t\t\t\t\t\tExample : brctl addif eth0.10 eth0" }, { 2, "delif", br_cmd_delif, - " \tdelete interface from bridge" }, + " \t\tdelete interface from bridge" }, { 2, "setageing", br_cmd_setageing, - "