Hello!
> Is it necessary to do a dev_hold() when placing the outgoing dev in an
> sk_buff?
It is not only not necessary, it would be wrong.
skb->dev is randomly rewritten and used only as a scratch variable.
Devices are held by different logic in output direction.
When a part of code uses device, it is already referenced
and skb finishes its life either inside device or in device
queue, which also holds it and destroys skbs before device
is destroyed.
You may hold device only if it is recorded in skb->rx_dev,
but it is almost never necessary, and it is not recommended.
rx_dev is for core only.
> but skb->rx_dev
> is held (in netif_rx).
It is one case when holding is required, packet waits in backlog
without any other references to device.
Alexey
|