Enabling and Disabling a Network Device
Once a device has been registered it is available for
use, but it will not transmit and receive traffic until it is explicitly enabled by the
user (or a user-space application). Requests to enable a device are taken care of by
dev_open, defined in net/core/dev.c. Enabling a device consists of the following tasks:
Call
dev->openif it is defined. Not all device drivers initialize this function.Set the
_ _LINK_STATE_STARTflag indev->stateto mark the device as up and running.
Figure 8-6. Function netdev_wait_allrefs
Set the
IFF_UPflag indev->flagsto mark the device as up.Call
dev_activateto initialize the egress queuing discipline used by Traffic Control, and start the watchdog timer.[*] If there is no user configuration for Traffic Control, assign a default First In, First Out (FIFO) queue.Send a
NETDEV_UPnotification to thenetdev_chainnotification chain to notify interested kernel components that the device is now enabled.
While a device needs to be explicitly enabled, it can be disabled either explicitly by
a user command or implicitly by other events. For example, before a device is
unregistered, it is first disabled (see the section "Device Unregistration"). Network devices
are disabled with dev_close. Disabling a device
consists of the following tasks:
Send a
NETDEV_GOING_DOWNnotification to thenetdev_chainnotification chain to notify ...
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