Hi,

I have a question about dev_hold() and dev_put():
When we start to use a device, we call dev_hold(). call dev_put(), when we finish. sk_buff has a field of dev, but the operation for this field (I mean dev_hold() and dev_put()) seems a little different. If it is the outgoing sk_buff, the dev of sk_buff is from dst_entry. I read the code of the kernel, I don't see dev_hold() is called when dst->dev is assigned to skb->dev. If the incoming skb_buff, the dev of sk_buf is set by the driver of the network device. I see dev_hold() is called for skb->dev in netif_rx() and dev_put() is called in process_backlog(). So my conclusion is that we don't need to call dev_hold() and dev_put() for the dev of the outgoing skb_buff, dst_entry structure will take care of it. For incoming skb_buff, we have to handle it manually. So, for example, if the dev of sk_buff is changed in the network stack, we have to call dev_put() for the old device, and call dev_hold() for the new one.
Is it right?
I'm writing a kernel module which needs to handle this stuff, so I want to make sure my understanding is right.

Best,
Zheng Da

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [EMAIL PROTECTED]
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to