Tuesday, October 27, 2009

Section 16.5.  Creating a New Bridge Device










16.5. Creating a New Bridge Device







Even though bridge devices are virtual, the discussion about how a device is enabled, disabled, registered, and unregistered in Chapter 8 still applies. You are encouraged to use that chapter as a reference when reading this section.


The creation and registration of a bridge device follows the model described in Chapter 8. The only difference is that because it is a virtual device, a bridge needs extra initializations in its private area (i.e., the net_bridge data structure at the bottom of Figure 16-6). This last task is taken care of by new_bridge_dev, which:


  • Allocates and initializes a net_device data structure using br_dev_setup as the setup routine. See the section "Bridge Device Setup Routine."

  • Initializes the private structure, as shown in Figure 16-6.

  • Initializes the bridge priority to the default value, 32,768 (0x8000).

  • Initializes the designated bridge ID with its identifier, the root path cost to 0, and the root port to 0 (i.e., no root port). This is because when a bridge is first enabled, it believes itself to be the root bridge. See the section "Root Bridge Selection" in Chapter 15.

  • Initializes the aging time to the default of 5 minutes.

  • Initializes the per-bridge timers with br_stp_timer_init.


Note that the initialization of spanning tree parameters is done regardless of whether the STP is enabled for the bridge.


Bridge devices can be assigned any name. Common ones are brN and stpN, when the Spanning Tree Protocol is disabled and enabled, respectively. For example, if you define two bridges that don't use STP, you would conventionally call them br1 and br2. However, your dog's name would be accepted, too.


As with any other network device, bridges are assigned a directory in /sys/class/net/. See the section "Tuning via /sys Filesystem" in Chapter 17.












No comments: