Bridge Device Setup Routine
Details about how device drivers use the setup routines when initializing their
devices can be found in the section "Device
Type Initialization: xxx_setup Functions" in Chapter 8. Bridge devices use the br_dev_setup setup routine. The following snapshot shows the interesting part:
void br_dev_setup(struct net_device *dev)
{
memset(dev->dev_addr, 0 , ETH_ALEN);
ether_setup(dev);
...
dev->do_ioctl = br_dev_ioctl;
dev->hard_start_xmit = br_dev_xmit;
dev->open = br_dev_open;
dev->change_mtu = br_change_mtu;
dev->stop = br_dev_stop;
dev->tx_queue_len = 0 ;
dev->set_mac_addr = NULL ;
dev->priv_flags = IFF_EBRIDGE;
}Bridge devices do not implement queuing by default. They let their enslaved devices
take care of it, which explains why tx_queue_len is
initialized to 0. However, the administrator can configure tx_queue_len with ifconfig or ip link.
When the Maximum Transmission Unit (MTU) on a bridge device is changed, the kernel
must ensure that the new value is no bigger than the smallest MTU value among the enslaved
devices. This is ensured by br_change_mtu.
The bridge MAC address dev_addr is cleared because
it will be derived by the MAC addresses configured on its enslaved devices with br_stp_recalculate_bridge_id (see the section "Bridge IDs and Port IDs"). For the same
reason, the driver does not provide a set_mac_addr
function.
The IFF_EBRIDGE flag is set so that kernel code can
distinguish bridge devices from other types of devices when needed.
The br_dev_ioctl ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access